sch-all-debug.js 266 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080
  1. // eval
  2. Ext.define("Sch.util.Patch", {
  3. target : null,
  4. minVersion : null,
  5. maxVersion : null,
  6. reportUrl : null,
  7. description : null,
  8. applyFn : null,
  9. ieOnly : false,
  10. onClassExtended : function(a, b) {
  11. if (Sch.disableOverrides) {
  12. return
  13. }
  14. if (b.ieOnly && !Ext.isIE) {
  15. return
  16. }
  17. if ((!b.minVersion || Ext.versions.extjs.equals(b.minVersion) || Ext.versions.extjs
  18. .isGreaterThan(b.minVersion))
  19. && (!b.maxVersion || Ext.versions.extjs.equals(b.maxVersion) || Ext.versions.extjs
  20. .isLessThan(b.maxVersion))) {
  21. if (b.applyFn) {
  22. b.applyFn()
  23. } else {
  24. b.requires[0].override(b.overrides)
  25. }
  26. }
  27. }
  28. });
  29. Ext.define("Sch.patches.LoadMask", {
  30. extend : "Sch.util.Patch",
  31. requires : ["Ext.view.AbstractView"],
  32. minVersion : "4.1.0b3",
  33. //reportURL : "http://www.sencha.com/forum/showthread.php?187700-4.1.0-B3-Ext.AbstractView-no-longer-binds-its-store-to-load-mask",
  34. //description : "In Ext4.1 loadmask no longer bind the store",
  35. overrides : {}
  36. });
  37. Ext.define("Sch.patches.Table", {
  38. extend : "Sch.util.Patch",
  39. requires : ["Ext.view.Table"],
  40. minVersion : "4.1.1",
  41. maxVersion : "4.1.1",
  42. //reportURL : "http://www.sencha.com/forum/showthread.php?238026-4.1.1-Alt-row-styling-lost-after-record-update&p=874190#post874190",
  43. //description : "In Ext4.1.1 when record is updated, the alternate row styling is lost",
  44. overrides : {
  45. onUpdate : function(c, a, b, e) {
  46. var d = this.store.indexOf(a);
  47. this.callParent(arguments);
  48. this.doStripeRows(d, d)
  49. }
  50. }
  51. });
  52. Ext.define("Sch.patches.TreeView", {
  53. extend : "Sch.util.Patch",
  54. requires : ["Ext.tree.View"],
  55. maxVersion : "4.1.3",
  56. applyFn : function() {
  57. Ext.tree.View.addMembers({
  58. providedStore : null,
  59. initComponent : function() {
  60. var a = this, b = a.panel.getStore();
  61. if (a.initialConfig.animate === undefined) {
  62. a.animate = Ext.enableFx
  63. }
  64. a.store = a.providedStore
  65. || new Ext.data.NodeStore({
  66. treeStore : b,
  67. recursive : true,
  68. rootVisible : a.rootVisible
  69. });
  70. a.store.on({
  71. beforeexpand : a.onBeforeExpand,
  72. expand : a.onExpand,
  73. beforecollapse : a.onBeforeCollapse,
  74. collapse : a.onCollapse,
  75. write : a.onStoreWrite,
  76. datachanged : a.onStoreDataChanged,
  77. collapsestart : a.beginBulkUpdate,
  78. collapsecomplete : a.endBulkUpdate,
  79. scope : a
  80. });
  81. if (Ext.versions.extjs
  82. .isGreaterThanOrEqual("4.1.2")) {
  83. a.mon(b, {
  84. scope : a,
  85. beforefill : a.onBeforeFill,
  86. fillcomplete : a.onFillComplete,
  87. beforebulkremove : a.beginBulkUpdate,
  88. bulkremovecomplete : a.endBulkUpdate
  89. });
  90. if (!b.remoteSort) {
  91. a.mon(b, {
  92. scope : a,
  93. beforesort : a.onBeforeSort,
  94. sort : a.onSort
  95. })
  96. }
  97. }
  98. if (a.node && !a.store.node) {
  99. a.setRootNode(a.node)
  100. }
  101. a.animQueue = {};
  102. a.animWraps = {};
  103. a.addEvents("afteritemexpand",
  104. "afteritemcollapse");
  105. a.callParent(arguments);
  106. a.on({
  107. element : "el",
  108. scope : a,
  109. delegate : a.expanderSelector,
  110. mouseover : a.onExpanderMouseOver,
  111. mouseout : a.onExpanderMouseOut
  112. });
  113. a.on({
  114. element : "el",
  115. scope : a,
  116. delegate : a.checkboxSelector,
  117. click : a.onCheckboxChange
  118. })
  119. }
  120. })
  121. }
  122. });
  123. Ext.define("Sch.patches.DataOperation", {
  124. extend : "Sch.util.Patch",
  125. requires : ["Ext.data.Operation"],
  126. //reportURL : "http://www.sencha.com/forum/showthread.php?198894-4.1-Ext.data.TreeStore-CRUD-regression.",
  127. //description : "In Ext 4.1.0 newly created records do not get the Id returned by server applied",
  128. maxVersion : "4.1.0",
  129. overrides : {
  130. commitRecords : function(j) {
  131. var g = this, h, f, a, c, b, d, e;
  132. if (!g.actionSkipSyncRe.test(g.action)) {
  133. a = g.records;
  134. if (a && a.length) {
  135. if (a.length > 1) {
  136. if (g.action == "update" || a[0].clientIdProperty) {
  137. h = new Ext.util.MixedCollection();
  138. h.addAll(j);
  139. for (f = a.length; f--;) {
  140. b = a[f];
  141. c = h.findBy(g.matchClientRec, b);
  142. b.copyFrom(c)
  143. }
  144. } else {
  145. for (d = 0, e = a.length; d < e; ++d) {
  146. b = a[d];
  147. c = j[d];
  148. if (b && c) {
  149. g.updateRecord(b, c)
  150. }
  151. }
  152. }
  153. } else {
  154. this.updateRecord(a[0], j[0])
  155. }
  156. if (g.actionCommitRecordsRe.test(g.action)) {
  157. for (f = a.length; f--;) {
  158. a[f].commit()
  159. }
  160. }
  161. }
  162. }
  163. },
  164. updateRecord : function(a, b) {
  165. if (b && (a.phantom || a.getId() === b.getId())) {
  166. a.copyFrom(b)
  167. }
  168. }
  169. }
  170. });
  171. Ext.define("Sch.patches.TreeStore", {
  172. extend : "Sch.util.Patch",
  173. requires : ["Ext.data.TreeStore"],
  174. //description : "http://www.sencha.com/forum/showthread.php?208602-Model-s-Id-field-not-defined-after-sync-in-TreeStore-%28CRUD%29",
  175. maxVersion : "4.1.0",
  176. overrides : {
  177. onCreateRecords : function(c) {
  178. this.callParent(arguments);
  179. var d = 0, b = c.length, a = this.tree, e;
  180. for (; d < b; ++d) {
  181. e = c[d];
  182. a.onNodeIdChanged(e, null, e.getId())
  183. }
  184. },
  185. setRootNode : function(a, e) {
  186. var d = this, c = d.model, b = c.prototype.idProperty;
  187. a = a || {};
  188. if (!a.isModel) {
  189. Ext.applyIf(a, {
  190. text : "Root",
  191. allowDrag : false
  192. });
  193. if (a[b] === undefined) {
  194. a[b] = d.defaultRootId
  195. }
  196. Ext.data.NodeInterface.decorate(c);
  197. a = Ext.ModelManager.create(a, c)
  198. } else {
  199. if (a.isModel && !a.isNode) {
  200. Ext.data.NodeInterface.decorate(c)
  201. }
  202. }
  203. d.getProxy().getReader().buildExtractors(true);
  204. d.tree.setRootNode(a);
  205. if (e !== true && !a.isLoaded()
  206. && (d.autoLoad === true || a.isExpanded())) {
  207. d.load({
  208. node : a
  209. })
  210. }
  211. return a
  212. }
  213. }
  214. });
  215. Ext.define("Sch.view.Locking", {
  216. extend : "Ext.grid.LockingView",
  217. scheduleEventRelayRe : /^(schedule|event|beforeevent|afterevent|dragcreate|beforedragcreate|afterdragcreate|beforetooltipshow)/,
  218. constructor : function(b) {
  219. this.callParent(arguments);
  220. var e = this, g = [], a = e.scheduleEventRelayRe, f = b.normal
  221. .getView(), c = f.events, d;
  222. for (d in c) {
  223. if (c.hasOwnProperty(d) && a.test(d)) {
  224. g.push(d)
  225. }
  226. }
  227. e.relayEvents(f, g)
  228. },
  229. getElementFromEventRecord : function(a) {
  230. return this.normal.getView().getElementFromEventRecord(a)
  231. },
  232. onClear : function() {
  233. this.relayFn("onClear", arguments)
  234. },
  235. beginBulkUpdate : function() {
  236. this.relayFn("beginBulkUpdate", arguments)
  237. },
  238. endBulkUpdate : function() {
  239. this.relayFn("endBulkUpdate", arguments)
  240. },
  241. refreshKeepingScroll : function() {
  242. this.locked.getView().refresh();
  243. this.normal.getView().refreshKeepingScroll()
  244. }
  245. });
  246. Ext.define("Sch.tooltip.ClockTemplate", {
  247. constructor : function() {
  248. var h = Math.PI / 180, k = Math.cos, i = Math.sin, l = 7, c = 2, d = 10, j = 6, e = 3, a = 10;
  249. function b(m) {
  250. var p = m * h, n = k(p), s = i(p), q = j * i((90 - m) * h), r = j
  251. * k((90 - m) * h), t = Math.min(j, j - q), o = m > 180
  252. ? r
  253. : 0, u = "progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', M11 = "
  254. + n
  255. + ", M12 = "
  256. + (-s)
  257. + ", M21 = "
  258. + s
  259. + ", M22 = "
  260. + n
  261. + ")";
  262. return Ext.String.format(
  263. "filter:{0};-ms-filter:{0};top:{1}px;left:{2}px;", u,
  264. t + e, o + a)
  265. }
  266. function g(m) {
  267. var p = m * h, n = k(p), s = i(p), q = l * i((90 - m) * h), r = l
  268. * k((90 - m) * h), t = Math.min(l, l - q), o = m > 180
  269. ? r
  270. : 0, u = "progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', M11 = "
  271. + n
  272. + ", M12 = "
  273. + (-s)
  274. + ", M21 = "
  275. + s
  276. + ", M22 = "
  277. + n
  278. + ")";
  279. return Ext.String.format(
  280. "filter:{0};-ms-filter:{0};top:{1}px;left:{2}px;", u,
  281. t + c, o + d)
  282. }
  283. function f(m) {
  284. return Ext.String
  285. .format(
  286. "transform:rotate({0}deg);-moz-transform: rotate({0}deg);-webkit-transform: rotate({0}deg);-o-transform:rotate({0}deg);",
  287. m)
  288. }
  289. return new Ext.XTemplate(
  290. '<div class="sch-clockwrap {cls}"><div class="sch-clock"><div class="sch-hourIndicator" style="{[this.getHourStyle((values.date.getHours()%12) * 30)]}">{[Ext.Date.monthNames[values.date.getMonth()].substr(0,3)]}</div><div class="sch-minuteIndicator" style="{[this.getMinuteStyle(values.date.getMinutes() * 6)]}">{[values.date.getDate()]}</div></div><span class="sch-clock-text">{text}</span></div>',
  291. {
  292. compiled : true,
  293. disableFormats : true,
  294. getMinuteStyle : Ext.isIE ? g : f,
  295. getHourStyle : Ext.isIE ? b : f
  296. })
  297. }
  298. });
  299. Ext.define("Sch.tooltip.Tooltip", {
  300. extend : "Ext.tip.ToolTip",
  301. requires : ["Sch.tooltip.ClockTemplate"],
  302. autoHide : false,
  303. anchor : "b",
  304. padding : "0 3 0 0",
  305. showDelay : 0,
  306. hideDelay : 0,
  307. quickShowInterval : 0,
  308. dismissDelay : 0,
  309. trackMouse : false,
  310. valid : true,
  311. anchorOffset : 5,
  312. shadow : false,
  313. frame : false,
  314. constructor : function(b) {
  315. var a = Ext.create("Sch.tooltip.ClockTemplate");
  316. this.renderTo = document.body;
  317. this.startDate = this.endDate = new Date();
  318. if (!this.template) {
  319. this.template = Ext
  320. .create(
  321. "Ext.XTemplate",
  322. '<div class="{[values.valid ? "sch-tip-ok" : "sch-tip-notok"]}">',
  323. '{[this.renderClock(values.startDate, values.startText, "sch-tooltip-startdate")]}',
  324. '{[this.renderClock(values.endDate, values.endText, "sch-tooltip-enddate")]}',
  325. "</div>", {
  326. compiled : true,
  327. disableFormats : true,
  328. renderClock : function(d, e, c) {
  329. return a.apply({
  330. date : d,
  331. text : e,
  332. cls : c
  333. })
  334. }
  335. })
  336. }
  337. this.callParent(arguments)
  338. },
  339. update : function(a, e, d) {
  340. if (this.startDate - a !== 0 || this.endDate - e !== 0
  341. || this.valid !== d) {
  342. this.startDate = a;
  343. this.endDate = e;
  344. this.valid = d;
  345. var c = this.schedulerView.getFormattedDate(a), b = this.schedulerView
  346. .getFormattedEndDate(e, a);
  347. if (this.mode === "calendar"
  348. && e.getHours() === 0
  349. && e.getMinutes() === 0
  350. && !(e.getYear() === a.getYear()
  351. && e.getMonth() === a.getMonth() && e.getDate() === a
  352. .getDate())) {
  353. e = Sch.util.Date.add(e, Sch.util.Date.DAY, -1)
  354. }
  355. this.callParent([this.template.apply({
  356. valid : d,
  357. startDate : a,
  358. startText : c,
  359. endText : b,
  360. endDate : e
  361. })])
  362. }
  363. },
  364. show : function(b, a) {
  365. if (!b) {
  366. return
  367. }
  368. if (Sch.util.Date.compareUnits(
  369. this.schedulerView.getTimeResolution().unit, Sch.util.Date.DAY) >= 0) {
  370. this.mode = "calendar";
  371. this.addCls("sch-day-resolution")
  372. } else {
  373. this.mode = "clock";
  374. this.removeCls("sch-day-resolution")
  375. }
  376. this.mouseOffsets = [a - 18, -7];
  377. this.setTarget(b);
  378. this.callParent();
  379. this.alignTo(b, "bl-tl", this.mouseOffsets);
  380. this.mon(Ext.getBody(), "mousemove", this.onMyMouseMove, this);
  381. this.mon(Ext.getBody(), "mouseup", this.onMyMouseUp, this, {
  382. single : true
  383. })
  384. },
  385. onMyMouseMove : function() {
  386. this.el.alignTo(this.target, "bl-tl", this.mouseOffsets)
  387. },
  388. onMyMouseUp : function() {
  389. this.mun(Ext.getBody(), "mousemove", this.onMyMouseMove, this)
  390. },
  391. afterRender : function() {
  392. this.callParent(arguments);
  393. this.el.on("mouseenter", this.onElMouseEnter, this)
  394. },
  395. onElMouseEnter : function() {
  396. this.alignTo(this.target, "bl-tl", this.mouseOffsets)
  397. }
  398. });
  399. Ext.define("Sch.util.Date", {
  400. requires : "Ext.Date",
  401. singleton : true,
  402. unitHash : null,
  403. unitsByName : {},
  404. unitNames : {
  405. YEAR : {
  406. single : "year",
  407. plural : "years",
  408. abbrev : "yr"
  409. },
  410. QUARTER : {
  411. single : "quarter",
  412. plural : "quarters",
  413. abbrev : "q"
  414. },
  415. MONTH : {
  416. single : "month",
  417. plural : "months",
  418. abbrev : "mon"
  419. },
  420. WEEK : {
  421. single : "week",
  422. plural : "weeks",
  423. abbrev : "w"
  424. },
  425. DAY : {
  426. single : "day",
  427. plural : "days",
  428. abbrev : "d"
  429. },
  430. HOUR : {
  431. single : "hour",
  432. plural : "hours",
  433. abbrev : "h"
  434. },
  435. MINUTE : {
  436. single : "minute",
  437. plural : "minutes",
  438. abbrev : "min"
  439. },
  440. SECOND : {
  441. single : "second",
  442. plural : "seconds",
  443. abbrev : "s"
  444. },
  445. MILLI : {
  446. single : "ms",
  447. plural : "ms",
  448. abbrev : "ms"
  449. }
  450. },
  451. constructor : function() {
  452. var a = Ext.Date;
  453. var c = this.unitHash = {
  454. MILLI : a.MILLI,
  455. SECOND : a.SECOND,
  456. MINUTE : a.MINUTE,
  457. HOUR : a.HOUR,
  458. DAY : a.DAY,
  459. WEEK : "w",
  460. MONTH : a.MONTH,
  461. QUARTER : "q",
  462. YEAR : a.YEAR
  463. };
  464. Ext.apply(this, c);
  465. var b = this;
  466. this.units = [b.MILLI, b.SECOND, b.MINUTE, b.HOUR, b.DAY,
  467. b.WEEK, b.MONTH, b.QUARTER, b.YEAR];
  468. this.setUnitNames(this.unitNames)
  469. },
  470. setUnitNames : function(e) {
  471. var d = this.unitsByName = {};
  472. this.unitNames = e;
  473. var b = this.unitHash;
  474. for (var a in b) {
  475. if (b.hasOwnProperty(a)) {
  476. var c = b[a];
  477. e[c] = e[a];
  478. d[a] = c;
  479. d[c] = c
  480. }
  481. }
  482. },
  483. betweenLesser : function(b, d, a) {
  484. var c = b.getTime();
  485. return d.getTime() <= c && c < a.getTime()
  486. },
  487. constrain : function(b, c, a) {
  488. return this.min(this.max(b, c), a)
  489. },
  490. compareUnits : function(c, b) {
  491. var a = Ext.Array.indexOf(this.units, c), d = Ext.Array
  492. .indexOf(this.units, b);
  493. return a > d ? 1 : (a < d ? -1 : 0)
  494. },
  495. isUnitGreater : function(b, a) {
  496. return this.compareUnits(b, a) > 0
  497. },
  498. copyTimeValues : function(b, a) {
  499. b.setHours(a.getHours());
  500. b.setMinutes(a.getMinutes());
  501. b.setSeconds(a.getSeconds());
  502. b.setMilliseconds(a.getMilliseconds())
  503. },
  504. add : function(b, c, e) {
  505. var f = Ext.Date.clone(b);
  506. if (!c || e === 0) {
  507. return f
  508. }
  509. switch (c.toLowerCase()) {
  510. case this.MILLI :
  511. f = new Date(b.getTime() + e);
  512. break;
  513. case this.SECOND :
  514. f = new Date(b.getTime() + (e * 1000));
  515. break;
  516. case this.MINUTE :
  517. f = new Date(b.getTime() + (e * 60000));
  518. break;
  519. case this.HOUR :
  520. f = new Date(b.getTime() + (e * 3600000));
  521. break;
  522. case this.DAY :
  523. f.setDate(b.getDate() + e);
  524. break;
  525. case this.WEEK :
  526. f.setDate(b.getDate() + e * 7);
  527. break;
  528. case this.MONTH :
  529. var a = b.getDate();
  530. if (a > 28) {
  531. a = Math.min(a,
  532. Ext.Date.getLastDateOfMonth(this.add(
  533. Ext.Date.getFirstDateOfMonth(b),
  534. this.MONTH, e)).getDate())
  535. }
  536. f.setDate(a);
  537. f.setMonth(f.getMonth() + e);
  538. break;
  539. case this.QUARTER :
  540. f = this.add(b, this.MONTH, e * 3);
  541. break;
  542. case this.YEAR :
  543. f.setFullYear(b.getFullYear() + e);
  544. break
  545. }
  546. return f
  547. },
  548. getMeasuringUnit : function(a) {
  549. if (a === this.WEEK) {
  550. return this.DAY
  551. }
  552. return a
  553. },
  554. getDurationInUnit : function(d, a, c) {
  555. var b;
  556. switch (c) {
  557. case this.YEAR :
  558. b = Math.round(this.getDurationInYears(d, a));
  559. break;
  560. case this.QUARTER :
  561. b = Math.round(this.getDurationInMonths(d, a) / 3);
  562. break;
  563. case this.MONTH :
  564. b = Math.round(this.getDurationInMonths(d, a));
  565. break;
  566. case this.WEEK :
  567. b = Math.round(this.getDurationInDays(d, a)) / 7;
  568. break;
  569. case this.DAY :
  570. b = Math.round(this.getDurationInDays(d, a));
  571. break;
  572. case this.HOUR :
  573. b = Math.round(this.getDurationInHours(d, a));
  574. break;
  575. case this.MINUTE :
  576. b = Math.round(this.getDurationInMinutes(d, a));
  577. break;
  578. case this.SECOND :
  579. b = Math.round(this.getDurationInSeconds(d, a));
  580. break;
  581. case this.MILLI :
  582. b = Math.round(this.getDurationInMilliseconds(d, a));
  583. break
  584. }
  585. return b
  586. },
  587. getUnitToBaseUnitRatio : function(b, a) {
  588. if (b === a) {
  589. return 1
  590. }
  591. switch (b) {
  592. case this.YEAR :
  593. switch (a) {
  594. case this.QUARTER :
  595. return 1 / 4;
  596. case this.MONTH :
  597. return 1 / 12
  598. }
  599. break;
  600. case this.QUARTER :
  601. switch (a) {
  602. case this.YEAR :
  603. return 4;
  604. case this.MONTH :
  605. return 1 / 3
  606. }
  607. break;
  608. case this.MONTH :
  609. switch (a) {
  610. case this.YEAR :
  611. return 12;
  612. case this.QUARTER :
  613. return 3
  614. }
  615. break;
  616. case this.WEEK :
  617. switch (a) {
  618. case this.DAY :
  619. return 1 / 7;
  620. case this.HOUR :
  621. return 1 / 168
  622. }
  623. break;
  624. case this.DAY :
  625. switch (a) {
  626. case this.WEEK :
  627. return 7;
  628. case this.HOUR :
  629. return 1 / 24;
  630. case this.MINUTE :
  631. return 1 / 1440
  632. }
  633. break;
  634. case this.HOUR :
  635. switch (a) {
  636. case this.DAY :
  637. return 24;
  638. case this.MINUTE :
  639. return 1 / 60
  640. }
  641. break;
  642. case this.MINUTE :
  643. switch (a) {
  644. case this.HOUR :
  645. return 60;
  646. case this.SECOND :
  647. return 1 / 60;
  648. case this.MILLI :
  649. return 1 / 60000
  650. }
  651. break;
  652. case this.SECOND :
  653. switch (a) {
  654. case this.MILLI :
  655. return 1 / 1000
  656. }
  657. break;
  658. case this.MILLI :
  659. switch (a) {
  660. case this.SECOND :
  661. return 1000
  662. }
  663. break
  664. }
  665. return -1
  666. },
  667. getDurationInMilliseconds : function(b, a) {
  668. return (a - b)
  669. },
  670. getDurationInSeconds : function(b, a) {
  671. return (a - b) / 1000
  672. },
  673. getDurationInMinutes : function(b, a) {
  674. return (a - b) / 60000
  675. },
  676. getDurationInHours : function(b, a) {
  677. return (a - b) / 3600000
  678. },
  679. getDurationInDays : function(b, a) {
  680. return (a - b) / 86400000
  681. },
  682. getDurationInBusinessDays : function(g, b) {
  683. var c = Math.round((b - g) / 86400000), a = 0, f;
  684. for (var e = 0; e < c; e++) {
  685. f = this.add(g, this.DAY, e).getDay();
  686. if (f !== 6 && f !== 0) {
  687. a++
  688. }
  689. }
  690. return a
  691. },
  692. getDurationInMonths : function(b, a) {
  693. return ((a.getFullYear() - b.getFullYear()) * 12)
  694. + (a.getMonth() - b.getMonth())
  695. },
  696. getDurationInYears : function(b, a) {
  697. return this.getDurationInMonths(b, a) / 12
  698. },
  699. min : function(b, a) {
  700. return b < a ? b : a
  701. },
  702. max : function(b, a) {
  703. return b > a ? b : a
  704. },
  705. intersectSpans : function(c, d, b, a) {
  706. return this.betweenLesser(c, b, a)
  707. || this.betweenLesser(b, c, d)
  708. },
  709. getNameOfUnit : function(a) {
  710. a = this.getUnitByName(a);
  711. switch (a.toLowerCase()) {
  712. case this.YEAR :
  713. return "YEAR";
  714. case this.QUARTER :
  715. return "QUARTER";
  716. case this.MONTH :
  717. return "MONTH";
  718. case this.WEEK :
  719. return "WEEK";
  720. case this.DAY :
  721. return "DAY";
  722. case this.HOUR :
  723. return "HOUR";
  724. case this.MINUTE :
  725. return "MINUTE";
  726. case this.SECOND :
  727. return "SECOND";
  728. case this.MILLI :
  729. return "MILLI"
  730. }
  731. throw "Incorrect UnitName"
  732. },
  733. getReadableNameOfUnit : function(b, a) {
  734. return this.unitNames[b][a ? "plural" : "single"]
  735. },
  736. getShortNameOfUnit : function(a) {
  737. return this.unitNames[a].abbrev
  738. },
  739. getUnitByName : function(a) {
  740. if (!this.unitsByName[a]) {
  741. Ext.Error.raise("Unknown unit name: " + a)
  742. }
  743. return this.unitsByName[a]
  744. },
  745. getNext : function(c, g, a, f) {
  746. var e = Ext.Date.clone(c);
  747. f = arguments.length < 4 ? 1 : f;
  748. a = a || 1;
  749. switch (g) {
  750. case this.MILLI :
  751. e = this.add(c, g, a);
  752. break;
  753. case this.SECOND :
  754. e = this.add(c, g, a);
  755. e.setMilliseconds(0);
  756. break;
  757. case this.MINUTE :
  758. e = this.add(c, g, a);
  759. e.setSeconds(0);
  760. e.setMilliseconds(0);
  761. break;
  762. case this.HOUR :
  763. e = this.add(c, g, a);
  764. e.setMinutes(0);
  765. e.setSeconds(0);
  766. e.setMilliseconds(0);
  767. break;
  768. case this.DAY :
  769. var d = c.getHours() === 23
  770. && this.add(e, this.HOUR, 1).getHours() === 1;
  771. if (d) {
  772. e = this.add(e, this.DAY, 2);
  773. Ext.Date.clearTime(e);
  774. return e
  775. }
  776. Ext.Date.clearTime(e);
  777. e = this.add(e, this.DAY, a);
  778. break;
  779. case this.WEEK :
  780. Ext.Date.clearTime(e);
  781. var b = e.getDay();
  782. e = this.add(e, this.DAY, f - b + 7
  783. * (a - (f <= b ? 0 : 1)));
  784. if (e.getDay() !== f) {
  785. e = this.add(e, this.HOUR, 1)
  786. } else {
  787. Ext.Date.clearTime(e)
  788. }
  789. break;
  790. case this.MONTH :
  791. e = this.add(e, this.MONTH, a);
  792. e.setDate(1);
  793. Ext.Date.clearTime(e);
  794. break;
  795. case this.QUARTER :
  796. e = this.add(e, this.MONTH, ((a - 1) * 3)
  797. + (3 - (e.getMonth() % 3)));
  798. Ext.Date.clearTime(e);
  799. e.setDate(1);
  800. break;
  801. case this.YEAR :
  802. e = new Date(e.getFullYear() + a, 0, 1);
  803. break;
  804. default :
  805. throw "Invalid date unit"
  806. }
  807. return e
  808. },
  809. getNumberOfMsFromTheStartOfDay : function(a) {
  810. return a - Ext.Date.clearTime(a, true) || 86400000
  811. },
  812. getNumberOfMsTillTheEndOfDay : function(a) {
  813. return this.getStartOfNextDay(a, true) - a
  814. },
  815. getStartOfNextDay : function(b, e) {
  816. var d = this.add(Ext.Date.clearTime(b, e), this.DAY, 1);
  817. if (d.getDate() == b.getDate()) {
  818. var c = this.add(Ext.Date.clearTime(b, e), this.DAY, 2)
  819. .getTimezoneOffset();
  820. var a = b.getTimezoneOffset();
  821. d = this.add(d, this.MINUTE, a - c)
  822. }
  823. return d
  824. },
  825. getEndOfPreviousDay : function(b) {
  826. var a = Ext.Date.clearTime(b, true);
  827. if (a - b) {
  828. return a
  829. } else {
  830. return this.add(a, this.DAY, -1)
  831. }
  832. },
  833. timeSpanContains : function(c, b, d, a) {
  834. return (d - c) >= 0 && (b - a) >= 0
  835. }
  836. });
  837. Ext.define("Sch.util.Debug", {
  838. singleton : true,
  839. runDiagnostics : function() {
  840. var d;
  841. var a = console;
  842. if (a && a.log) {
  843. d = function() {
  844. a.log.apply(console, arguments)
  845. }
  846. } else {
  847. if (!window.schedulerDebugWin) {
  848. window.schedulerDebugWin = new Ext.Window({
  849. height : 400,
  850. width : 500,
  851. bodyStyle : "padding:10px",
  852. closeAction : "hide",
  853. autoScroll : true
  854. })
  855. }
  856. window.schedulerDebugWin.show();
  857. schedulerDebugWin.update("");
  858. d = function(l) {
  859. schedulerDebugWin
  860. .update((schedulerDebugWin.body.dom.innerHTML || "")
  861. + l + "<br/>")
  862. }
  863. }
  864. var e = Ext.select(".sch-schedulerpanel");
  865. if (e.getCount() === 0) {
  866. d("No scheduler component found")
  867. }
  868. var k = Ext.getCmp(e.elements[0].id), i = k.getResourceStore(), c = k
  869. .getEventStore();
  870. if (!(c instanceof Sch.data.EventStore)) {
  871. d("Your event store must be or extend Sch.data.EventStore")
  872. }
  873. d("Scheduler view start: " + k.getStart() + ", end: " + k.getEnd());
  874. if (!i) {
  875. d("No store configured");
  876. return
  877. }
  878. if (!c) {
  879. d("No event store configured");
  880. return
  881. }
  882. d(i.getCount() + " records in the resource store");
  883. d(c.getCount() + " records in the eventStore");
  884. var j = c.model.prototype.idProperty;
  885. var b = i.model.prototype.idProperty;
  886. var h = c.model.prototype.fields.getByKey(j);
  887. var f = i.model.prototype.fields.getByKey(b);
  888. if (!(c.model.prototype instanceof Sch.model.Event)) {
  889. d("Your event model must extend Sch.model.Event")
  890. }
  891. if (!(i.model.prototype instanceof Sch.model.Resource)) {
  892. d("Your event model must extend Sch.model.Resource")
  893. }
  894. if (!h) {
  895. d("idProperty on the event model is incorrectly setup, value: " + j)
  896. }
  897. if (!f) {
  898. d("idProperty on the resource model is incorrectly setup, value: "
  899. + b)
  900. }
  901. var g = k.getSchedulingView();
  902. d(g.el.select(g.eventSelector).getCount()
  903. + " events present in the DOM");
  904. if (c.getCount() > 0) {
  905. if (!c.first().getStartDate()
  906. || !(c.first().getStartDate() instanceof Date)) {
  907. d("The eventStore reader is misconfigured - The StartDate field is not setup correctly, please investigate");
  908. d("StartDate is configured with dateFormat: "
  909. + c.model.prototype.fields.getByKey("StartDate").dateFormat);
  910. d("See Ext JS docs for information about different date formats: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Date")
  911. }
  912. if (!c.first().getEndDate()
  913. || !(c.first().getEndDate() instanceof Date)) {
  914. d("The eventStore reader is misconfigured - The EndDate field is not setup correctly, please investigate");
  915. d("EndDate is configured with dateFormat: "
  916. + c.model.prototype.fields.getByKey("EndDate").dateFormat);
  917. d("See Ext JS docs for information about different date formats: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Date")
  918. }
  919. if (c.proxy && c.proxy.reader && c.proxy.reader.jsonData) {
  920. d("Dumping jsonData to console");
  921. console.dir(c.proxy.reader.jsonData)
  922. }
  923. d("Records in the event store:");
  924. c.each(function(m, l) {
  925. d((l + 1) + ". " + m.startDateField + ":"
  926. + m.getStartDate() + ", " + m.endDateField
  927. + ":" + m.getEndDate() + ", "
  928. + m.resourceIdField + ":" + m.getResourceId());
  929. if (!m.getStartDate()) {
  930. d(m.getStartDate())
  931. }
  932. })
  933. } else {
  934. d("Event store has no data. Has it been loaded properly?")
  935. }
  936. if (i.getCount() > 0) {
  937. d("Records in the resource store:");
  938. i.each(function(m, l) {
  939. d((l + 1) + ". " + m.idProperty + ":" + m.getId());
  940. return
  941. })
  942. } else {
  943. d("Resource store has no data.");
  944. return
  945. }
  946. d("Everything seems to be setup ok!")
  947. }
  948. });
  949. Ext.define("Sch.util.HeaderRenderers", {
  950. singleton : true,
  951. requires : ["Sch.util.Date", "Ext.XTemplate"],
  952. constructor : function() {
  953. var b = Ext
  954. .create(
  955. "Ext.XTemplate",
  956. '<table class="sch-nested-hdr-tbl '
  957. + Ext.baseCSSPrefix
  958. + 'column-header-text" cellpadding="0" cellspacing="0"><tr><tpl for="."><td style="width:{[100/xcount]}%" class="{cls} sch-dayheadercell-{dayOfWeek}">{text}</td></tpl></tr></table>')
  959. .compile();
  960. var a = Ext
  961. .create(
  962. "Ext.XTemplate",
  963. '<table class="sch-nested-hdr-tbl" cellpadding="0" cellspacing="0"><tr><tpl for="."><td style="width:{[100/xcount]}%" class="{cls}">{text}</td></tpl></tr></table>')
  964. .compile();
  965. return {
  966. quarterMinute : function(f, d, c, e) {
  967. c.headerCls = "sch-nested-hdr-pad";
  968. return '<table class="sch-nested-hdr-tbl" cellpadding="0" cellspacing="0"><tr><td>00</td><td>15</td><td>30</td><td>45</td></tr></table>'
  969. },
  970. dateCells : function(d, c, e) {
  971. return function(j, g, f) {
  972. f.headerCls = "sch-nested-hdr-nopad";
  973. var i = [], h = Ext.Date.clone(j);
  974. while (h < g) {
  975. i.push({
  976. text : Ext.Date.format(h, e)
  977. });
  978. h = Sch.util.Date.add(h, d, c)
  979. }
  980. i[0].cls = "sch-nested-hdr-cell-first";
  981. i[i.length - 1].cls = "sch-nested-hdr-cell-last";
  982. return a.apply(i)
  983. }
  984. },
  985. dateNumber : function(g, d, c) {
  986. c.headerCls = "sch-nested-hdr-nopad";
  987. var f = [], e = Ext.Date.clone(g);
  988. while (e < d) {
  989. f.push({
  990. dayOfWeek : e.getDay(),
  991. text : e.getDate()
  992. });
  993. e = Sch.util.Date.add(e, Sch.util.Date.DAY, 1)
  994. }
  995. return b.apply(f)
  996. },
  997. dayLetter : function(g, d, c) {
  998. c.headerCls = "sch-nested-hdr-nopad";
  999. var f = [], e = g;
  1000. while (e < d) {
  1001. f.push({
  1002. dayOfWeek : e.getDay(),
  1003. text : Ext.Date.dayNames[e.getDay()].substr(0,
  1004. 1)
  1005. });
  1006. e = Sch.util.Date.add(e, Sch.util.Date.DAY, 1)
  1007. }
  1008. f[0].cls = "sch-nested-hdr-cell-first";
  1009. f[f.length - 1].cls = "sch-nested-hdr-cell-last";
  1010. return b.apply(f)
  1011. },
  1012. dayStartEndHours : function(e, d, c) {
  1013. c.headerCls = "sch-hdr-startend";
  1014. return Ext.String
  1015. .format(
  1016. '<span class="sch-hdr-start">{0}</span><span class="sch-hdr-end">{1}</span>',
  1017. Ext.Date.format(e, "G"), Ext.Date
  1018. .format(d, "G"))
  1019. }
  1020. }
  1021. }
  1022. });
  1023. Ext.define("Sch.util.DragTracker", {
  1024. extend : "Ext.dd.DragTracker",
  1025. xStep : 1,
  1026. yStep : 1,
  1027. setXStep : function(a) {
  1028. this.xStep = a
  1029. },
  1030. setYStep : function(a) {
  1031. this.yStep = a
  1032. },
  1033. getRegion : function() {
  1034. var e = this.startXY, d = this.getXY(), b = Math.min(e[0], d[0]), f = Math
  1035. .min(e[1], d[1]), c = Math.abs(e[0] - d[0]), a = Math.abs(e[1]
  1036. - d[1]);
  1037. return new Ext.util.Region(f, b + c, f + a, b)
  1038. },
  1039. onMouseDown : function(f, d) {
  1040. if (this.disabled || f.dragTracked) {
  1041. return
  1042. }
  1043. var c = f.getXY(), g, b, a = c[0], h = c[1];
  1044. if (this.xStep > 1) {
  1045. g = this.el.getX();
  1046. a -= g;
  1047. a = Math.round(a / this.xStep) * this.xStep;
  1048. a += g
  1049. }
  1050. if (this.yStep > 1) {
  1051. b = this.el.getY();
  1052. h -= b;
  1053. h = Math.round(h / this.yStep) * this.yStep;
  1054. h += b
  1055. }
  1056. this.dragTarget = this.delegate ? d : this.handle.dom;
  1057. this.startXY = this.lastXY = [a, h];
  1058. this.startRegion = Ext.fly(this.dragTarget).getRegion();
  1059. if (this.fireEvent("mousedown", this, f) === false
  1060. || this.fireEvent("beforedragstart", this, f) === false
  1061. || this.onBeforeStart(f) === false) {
  1062. return
  1063. }
  1064. this.mouseIsDown = true;
  1065. f.dragTracked = true;
  1066. if (this.preventDefault !== false) {
  1067. f.preventDefault()
  1068. }
  1069. Ext.getDoc().on({
  1070. scope : this,
  1071. mouseup : this.onMouseUp,
  1072. mousemove : this.onMouseMove,
  1073. selectstart : this.stopSelect
  1074. });
  1075. if (this.autoStart) {
  1076. this.timer = Ext.defer(this.triggerStart, this.autoStart === true
  1077. ? 1000
  1078. : this.autoStart, this, [f])
  1079. }
  1080. },
  1081. onMouseMove : function(g, f) {
  1082. if (this.active && Ext.isIE && !g.browserEvent.button) {
  1083. g.preventDefault();
  1084. this.onMouseUp(g);
  1085. return
  1086. }
  1087. g.preventDefault();
  1088. var d = g.getXY(), b = this.startXY;
  1089. if (!this.active) {
  1090. if (Math.max(Math.abs(b[0] - d[0]), Math.abs(b[1] - d[1])) > this.tolerance) {
  1091. this.triggerStart(g)
  1092. } else {
  1093. return
  1094. }
  1095. }
  1096. var a = d[0], h = d[1];
  1097. if (this.xStep > 1) {
  1098. a -= this.startXY[0];
  1099. a = Math.round(a / this.xStep) * this.xStep;
  1100. a += this.startXY[0]
  1101. }
  1102. if (this.yStep > 1) {
  1103. h -= this.startXY[1];
  1104. h = Math.round(h / this.yStep) * this.yStep;
  1105. h += this.startXY[1]
  1106. }
  1107. var c = this.xStep > 1 || this.yStep > 1;
  1108. if (!c || a !== d[0] || h !== d[1]) {
  1109. this.lastXY = [a, h];
  1110. if (this.fireEvent("mousemove", this, g) === false) {
  1111. this.onMouseUp(g)
  1112. } else {
  1113. this.onDrag(g);
  1114. this.fireEvent("drag", this, g)
  1115. }
  1116. }
  1117. }
  1118. });
  1119. Ext.define("Sch.preset.Manager", {
  1120. extend : "Ext.util.MixedCollection",
  1121. requires : ["Sch.util.Date", "Sch.util.HeaderRenderers"],
  1122. singleton : true,
  1123. constructor : function() {
  1124. this.callParent(arguments);
  1125. this.registerDefaults()
  1126. },
  1127. registerPreset : function(b, a) {
  1128. if (a) {
  1129. var c = a.headerConfig;
  1130. var d = Sch.util.Date;
  1131. for (var e in c) {
  1132. if (c.hasOwnProperty(e)) {
  1133. if (d[c[e].unit]) {
  1134. c[e].unit = d[c[e].unit.toUpperCase()]
  1135. }
  1136. }
  1137. }
  1138. if (!a.timeColumnWidth) {
  1139. a.timeColumnWidth = 50
  1140. }
  1141. if (a.timeResolution && d[a.timeResolution.unit]) {
  1142. a.timeResolution.unit = d[a.timeResolution.unit
  1143. .toUpperCase()]
  1144. }
  1145. if (a.shiftUnit && d[a.shiftUnit]) {
  1146. a.shiftUnit = d[a.shiftUnit.toUpperCase()]
  1147. }
  1148. }
  1149. if (this.isValidPreset(a)) {
  1150. if (this.containsKey(b)) {
  1151. this.removeAtKey(b)
  1152. }
  1153. this.add(b, a)
  1154. } else {
  1155. throw "Invalid preset, please check your configuration"
  1156. }
  1157. },
  1158. isValidPreset : function(a) {
  1159. var d = Sch.util.Date, b = true, c = Sch.util.Date.units;
  1160. for (var e in a.headerConfig) {
  1161. if (a.headerConfig.hasOwnProperty(e)) {
  1162. b = b
  1163. && Ext.Array.indexOf(c, a.headerConfig[e].unit) >= 0
  1164. }
  1165. }
  1166. if (a.timeResolution) {
  1167. b = b && Ext.Array.indexOf(c, a.timeResolution.unit) >= 0
  1168. }
  1169. if (a.shiftUnit) {
  1170. b = b && Ext.Array.indexOf(c, a.shiftUnit) >= 0
  1171. }
  1172. return b
  1173. },
  1174. getPreset : function(a) {
  1175. return this.get(a)
  1176. },
  1177. deletePreset : function(a) {
  1178. this.removeAtKey(a)
  1179. },
  1180. registerDefaults : function() {
  1181. var b = this, a = this.defaultPresets;
  1182. for (var c in a) {
  1183. b.registerPreset(c, a[c])
  1184. }
  1185. },
  1186. defaultPresets : {
  1187. minuteAndHour : {
  1188. timeColumnWidth : 100,
  1189. rowHeight : 24,
  1190. resourceColumnWidth : 100,
  1191. displayDateFormat : "G:i",
  1192. shiftIncrement : 1,
  1193. shiftUnit : "HOUR",
  1194. defaultSpan : 24,
  1195. timeResolution : {
  1196. unit : "MINUTE",
  1197. increment : 30
  1198. },
  1199. headerConfig : {
  1200. middle : {
  1201. unit : "MINUTE",
  1202. increment : "30",
  1203. dateFormat : "i"
  1204. },
  1205. top : {
  1206. unit : "HOUR",
  1207. dateFormat : "D, GA/m"
  1208. }
  1209. }
  1210. },
  1211. hourAndDay : {
  1212. timeColumnWidth : 60,
  1213. rowHeight : 24,
  1214. resourceColumnWidth : 100,
  1215. displayDateFormat : "G:i",
  1216. shiftIncrement : 1,
  1217. shiftUnit : "DAY",
  1218. defaultSpan : 24,
  1219. timeResolution : {
  1220. unit : "MINUTE",
  1221. increment : 30
  1222. },
  1223. headerConfig : {
  1224. middle : {
  1225. unit : "HOUR",
  1226. dateFormat : "G:i"
  1227. },
  1228. top : {
  1229. unit : "DAY",
  1230. dateFormat : "D d/m"
  1231. }
  1232. }
  1233. },
  1234. dayAndWeek : {
  1235. timeColumnWidth : 100,
  1236. rowHeight : 24,
  1237. resourceColumnWidth : 100,
  1238. displayDateFormat : "Y-m-d G:i",
  1239. shiftUnit : "DAY",
  1240. shiftIncrement : 1,
  1241. defaultSpan : 5,
  1242. timeResolution : {
  1243. unit : "HOUR",
  1244. increment : 1
  1245. },
  1246. headerConfig : {
  1247. middle : {
  1248. unit : "DAY",
  1249. dateFormat : "D d M"
  1250. },
  1251. top : {
  1252. unit : "WEEK",
  1253. dateFormat : "W M Y",
  1254. renderer : function(c, b, a) {
  1255. return Sch.util.Date.getShortNameOfUnit("WEEK")
  1256. + "." + Ext.Date.format(c, "W M Y")
  1257. }
  1258. }
  1259. }
  1260. },
  1261. weekAndDay : {
  1262. timeColumnWidth : 100,
  1263. rowHeight : 24,
  1264. resourceColumnWidth : 100,
  1265. displayDateFormat : "Y-m-d",
  1266. shiftUnit : "WEEK",
  1267. shiftIncrement : 1,
  1268. defaultSpan : 1,
  1269. timeResolution : {
  1270. unit : "DAY",
  1271. increment : 1
  1272. },
  1273. headerConfig : {
  1274. bottom : {
  1275. unit : "DAY",
  1276. increment : 1,
  1277. dateFormat : "d/m"
  1278. },
  1279. middle : {
  1280. unit : "WEEK",
  1281. dateFormat : "D d M",
  1282. align : "left"
  1283. }
  1284. }
  1285. },
  1286. weekAndMonth : {
  1287. timeColumnWidth : 100,
  1288. rowHeight : 24,
  1289. resourceColumnWidth : 100,
  1290. displayDateFormat : "Y-m-d",
  1291. shiftUnit : "WEEK",
  1292. shiftIncrement : 5,
  1293. defaultSpan : 6,
  1294. timeResolution : {
  1295. unit : "DAY",
  1296. increment : 1
  1297. },
  1298. headerConfig : {
  1299. middle : {
  1300. unit : "WEEK",
  1301. renderer : function(c, b, a) {
  1302. a.align = "left";
  1303. return Ext.Date.format(c, "d M")
  1304. }
  1305. },
  1306. top : {
  1307. unit : "MONTH",
  1308. dateFormat : "M Y"
  1309. }
  1310. }
  1311. },
  1312. monthAndYear : {
  1313. timeColumnWidth : 110,
  1314. rowHeight : 24,
  1315. resourceColumnWidth : 100,
  1316. displayDateFormat : "Y-m-d",
  1317. shiftIncrement : 3,
  1318. shiftUnit : "MONTH",
  1319. defaultSpan : 12,
  1320. timeResolution : {
  1321. unit : "DAY",
  1322. increment : 1
  1323. },
  1324. headerConfig : {
  1325. middle : {
  1326. unit : "MONTH",
  1327. dateFormat : "M Y"
  1328. },
  1329. top : {
  1330. unit : "YEAR",
  1331. dateFormat : "Y"
  1332. }
  1333. }
  1334. },
  1335. year : {
  1336. timeColumnWidth : 100,
  1337. rowHeight : 24,
  1338. resourceColumnWidth : 100,
  1339. displayDateFormat : "Y-m-d",
  1340. shiftUnit : "YEAR",
  1341. shiftIncrement : 1,
  1342. defaultSpan : 1,
  1343. timeResolution : {
  1344. unit : "MONTH",
  1345. increment : 1
  1346. },
  1347. headerConfig : {
  1348. bottom : {
  1349. unit : "QUARTER",
  1350. renderer : function(c, b, a) {
  1351. return Ext.String.format(Sch.util.Date
  1352. .getShortNameOfUnit("QUARTER")
  1353. .toUpperCase()
  1354. + "{0}", Math.floor(c
  1355. .getMonth()
  1356. / 3)
  1357. + 1)
  1358. }
  1359. },
  1360. middle : {
  1361. unit : "YEAR",
  1362. dateFormat : "Y"
  1363. }
  1364. }
  1365. },
  1366. weekAndDayLetter : {
  1367. timeColumnWidth : 20,
  1368. rowHeight : 24,
  1369. resourceColumnWidth : 100,
  1370. displayDateFormat : "Y-m-d",
  1371. shiftUnit : "WEEK",
  1372. shiftIncrement : 1,
  1373. defaultSpan : 10,
  1374. timeResolution : {
  1375. unit : "DAY",
  1376. increment : 1
  1377. },
  1378. headerConfig : {
  1379. bottom : {
  1380. unit : "DAY",
  1381. increment : 1,
  1382. renderer : function(a) {
  1383. return Ext.Date.dayNames[a.getDay()].substring(
  1384. 0, 1)
  1385. }
  1386. },
  1387. middle : {
  1388. unit : "WEEK",
  1389. dateFormat : "D d M Y",
  1390. align : "left"
  1391. }
  1392. }
  1393. },
  1394. weekDateAndMonth : {
  1395. timeColumnWidth : 30,
  1396. rowHeight : 24,
  1397. resourceColumnWidth : 100,
  1398. displayDateFormat : "Y-m-d",
  1399. shiftUnit : "WEEK",
  1400. shiftIncrement : 1,
  1401. defaultSpan : 10,
  1402. timeResolution : {
  1403. unit : "DAY",
  1404. increment : 1
  1405. },
  1406. headerConfig : {
  1407. middle : {
  1408. unit : "WEEK",
  1409. dateFormat : "d"
  1410. },
  1411. top : {
  1412. unit : "MONTH",
  1413. dateFormat : "Y F",
  1414. align : "left"
  1415. }
  1416. }
  1417. }
  1418. }
  1419. });
  1420. Ext.define("Sch.preset.ViewPreset", {});
  1421. Ext.define("Sch.preset.ViewPresetHeaderRow", {});
  1422. Ext.define("Sch.feature.AbstractTimeSpan", {
  1423. extend : "Ext.AbstractPlugin",
  1424. lockableScope : "normal",
  1425. schedulerView : null,
  1426. timeAxis : null,
  1427. containerEl : null,
  1428. expandToFitView : false,
  1429. disabled : false,
  1430. cls : null,
  1431. template : null,
  1432. store : null,
  1433. renderElementsBuffered : false,
  1434. renderDelay : 15,
  1435. constructor : function(a) {
  1436. this.uniqueCls = this.uniqueCls || ("sch-timespangroup-" + Ext.id());
  1437. Ext.apply(this, a)
  1438. },
  1439. setDisabled : function(a) {
  1440. if (a) {
  1441. this.removeElements()
  1442. }
  1443. this.disabled = a
  1444. },
  1445. getElements : function() {
  1446. if (this.containerEl) {
  1447. return this.containerEl.select("." + this.uniqueCls)
  1448. }
  1449. return null
  1450. },
  1451. removeElements : function() {
  1452. var a = this.getElements();
  1453. if (a) {
  1454. a.remove()
  1455. }
  1456. },
  1457. init : function(a) {
  1458. this.timeAxis = a.getTimeAxis();
  1459. this.schedulerView = a.getSchedulingView();
  1460. if (!this.store) {
  1461. Ext.Error.raise("Error: You must define a store for this plugin")
  1462. }
  1463. this.schedulerView.on({
  1464. afterrender : this.onAfterRender,
  1465. destroy : this.onDestroy,
  1466. scope : this
  1467. })
  1468. },
  1469. onAfterRender : function(b) {
  1470. var a = this.schedulerView;
  1471. this.containerEl = a.el;
  1472. a.mon(this.store, {
  1473. load : this.renderElements,
  1474. datachanged : this.renderElements,
  1475. clear : this.renderElements,
  1476. add : this.renderElements,
  1477. remove : this.renderElements,
  1478. update : this.refreshSingle,
  1479. scope : this
  1480. });
  1481. if (Ext.data.NodeStore && a.store instanceof Ext.data.NodeStore) {
  1482. if (a.animate) {
  1483. } else {
  1484. a.mon(a.store, {
  1485. expand : this.renderElements,
  1486. collapse : this.renderElements,
  1487. scope : this
  1488. })
  1489. }
  1490. }
  1491. a.on({
  1492. refresh : this.renderElements,
  1493. itemadd : this.renderElements,
  1494. itemremove : this.renderElements,
  1495. itemupdate : this.renderElements,
  1496. groupexpand : this.renderElements,
  1497. groupcollapse : this.renderElements,
  1498. columnwidthchange : this.renderElements,
  1499. resize : this.renderElements,
  1500. scope : this
  1501. });
  1502. a.headerCt.on({
  1503. add : this.renderElements,
  1504. remove : this.renderElements,
  1505. scope : this
  1506. });
  1507. a.ownerCt.up("panel").on({
  1508. viewchange : this.renderElements,
  1509. orientationchange : this.renderElements,
  1510. scope : this
  1511. });
  1512. this.renderElements()
  1513. },
  1514. renderElements : function() {
  1515. if (this.renderElementsBuffered || this.disabled
  1516. || this.schedulerView.headerCt.getColumnCount() === 0) {
  1517. return
  1518. }
  1519. this.renderElementsBuffered = true;
  1520. Ext.Function.defer(this.renderElementsInternal, this.renderDelay, this)
  1521. },
  1522. renderElementsInternal : function() {
  1523. this.renderElementsBuffered = false;
  1524. if (this.disabled || this.schedulerView.isDestroyed
  1525. || this.schedulerView.headerCt.getColumnCount() === 0) {
  1526. return
  1527. }
  1528. this.removeElements();
  1529. Ext.core.DomHelper.insertHtml("afterBegin", this.containerEl.dom, this
  1530. .generateMarkup())
  1531. },
  1532. generateMarkup : function(b) {
  1533. var d = this.timeAxis.getStart(), a = this.timeAxis.getEnd(), c = this
  1534. .getElementData(d, a, null, b);
  1535. return this.template.apply(c)
  1536. },
  1537. getElementData : function(b, a) {
  1538. throw "Abstract method call"
  1539. },
  1540. onDestroy : function() {
  1541. if (this.store.autoDestroy) {
  1542. this.store.destroy()
  1543. }
  1544. },
  1545. refreshSingle : function(c, b) {
  1546. var e = Ext.get(this.uniqueCls + "-" + b.internalId);
  1547. if (e) {
  1548. var g = this.timeAxis.getStart(), a = this.timeAxis.getEnd(), f = this
  1549. .getElementData(g, a, [b])[0], d = b.clsField || "Cls";
  1550. if (f) {
  1551. e.dom.className = this.cls + " " + this.uniqueCls + " "
  1552. + (f[d] || "");
  1553. e.setTop(f.top);
  1554. e.setLeft(f.left);
  1555. e.setSize(f.width, f.height)
  1556. } else {
  1557. Ext.destroy(e)
  1558. }
  1559. } else {
  1560. this.renderElements()
  1561. }
  1562. }
  1563. });
  1564. Ext.define("Sch.feature.DragCreator", {
  1565. requires : ["Ext.XTemplate", "Sch.util.Date", "Sch.util.DragTracker",
  1566. "Sch.tooltip.Tooltip", "Sch.tooltip.ClockTemplate"],
  1567. disabled : false,
  1568. showHoverTip : true,
  1569. showDragTip : true,
  1570. dragTolerance : 2,
  1571. validatorFn : Ext.emptyFn,
  1572. validatorFnScope : null,
  1573. constructor : function(a) {
  1574. Ext.apply(this, a || {});
  1575. this.lastTime = new Date();
  1576. this.template = this.template
  1577. || Ext
  1578. .create(
  1579. "Ext.Template",
  1580. '<div class="sch-dragcreator-proxy sch-event"><div class="sch-event-inner">&#160;</div></div>',
  1581. {
  1582. compiled : true,
  1583. disableFormats : true
  1584. });
  1585. this.schedulerView.on("destroy", this.onSchedulerDestroy, this);
  1586. this.schedulerView.el.on("mousemove", this.setupTooltips, this, {
  1587. single : true
  1588. });
  1589. this.callParent([a])
  1590. },
  1591. setDisabled : function(a) {
  1592. this.disabled = a;
  1593. if (this.hoverTip) {
  1594. this.hoverTip.setDisabled(a)
  1595. }
  1596. if (this.dragTip) {
  1597. this.dragTip.setDisabled(a)
  1598. }
  1599. },
  1600. getProxy : function() {
  1601. if (!this.proxy) {
  1602. this.proxy = this.template.append(this.schedulerView.panel.el, {},
  1603. true)
  1604. }
  1605. return this.proxy
  1606. },
  1607. onMouseMove : function(c) {
  1608. var a = this.hoverTip;
  1609. if (a.disabled || this.dragging) {
  1610. return
  1611. }
  1612. if (c.getTarget("." + this.schedulerView.timeCellCls, 2)) {
  1613. var b = this.schedulerView.getDateFromDomEvent(c, "floor");
  1614. if (b) {
  1615. if (b - this.lastTime !== 0) {
  1616. this.updateHoverTip(b);
  1617. if (a.hidden) {
  1618. a[Sch.util.Date.compareUnits(this.schedulerView
  1619. .getTimeResolution().unit,
  1620. Sch.util.Date.DAY) >= 0
  1621. ? "addCls"
  1622. : "removeCls"]("sch-day-resolution");
  1623. a.show()
  1624. }
  1625. }
  1626. } else {
  1627. a.hide();
  1628. this.lastTime = null
  1629. }
  1630. } else {
  1631. a.hide();
  1632. this.lastTime = null
  1633. }
  1634. },
  1635. updateHoverTip : function(a) {
  1636. if (a) {
  1637. var b = this.schedulerView.getFormattedDate(a);
  1638. this.hoverTip.update(this.hoverTipTemplate.apply({
  1639. date : a,
  1640. text : b
  1641. }));
  1642. this.lastTime = a
  1643. }
  1644. },
  1645. onBeforeDragStart : function(d, g) {
  1646. var b = this.schedulerView, a = g.getTarget("." + b.timeCellCls, 2);
  1647. if (a) {
  1648. var c = b.resolveResource(a);
  1649. var f = b.getDateFromDomEvent(g);
  1650. if (!this.disabled && a
  1651. && b.fireEvent("beforedragcreate", b, c, f, g) !== false) {
  1652. this.resourceRecord = c;
  1653. this.originalStart = f;
  1654. this.resourceRegion = b.getScheduleRegion(this.resourceRecord,
  1655. this.originalStart);
  1656. this.dateConstraints = b.getDateConstraints(
  1657. this.resourceRecord, this.originalStart);
  1658. return true
  1659. }
  1660. }
  1661. return false
  1662. },
  1663. onDragStart : function() {
  1664. var d = this, b = d.schedulerView, c = d.getProxy(), a = d.schedulerView.snapToIncrement;
  1665. this.dragging = true;
  1666. if (this.hoverTip) {
  1667. this.hoverTip.disable()
  1668. }
  1669. d.start = d.originalStart;
  1670. d.end = d.start;
  1671. if (b.getOrientation() === "horizontal") {
  1672. d.rowBoundaries = {
  1673. top : d.resourceRegion.top,
  1674. bottom : d.resourceRegion.bottom
  1675. };
  1676. c.setRegion({
  1677. top : d.rowBoundaries.top,
  1678. right : d.tracker.startXY[0],
  1679. bottom : d.rowBoundaries.bottom,
  1680. left : d.tracker.startXY[0]
  1681. })
  1682. } else {
  1683. d.rowBoundaries = {
  1684. left : d.resourceRegion.left,
  1685. right : d.resourceRegion.right
  1686. };
  1687. c.setRegion({
  1688. top : d.tracker.startXY[1],
  1689. right : d.resourceRegion.right,
  1690. bottom : d.tracker.startXY[1],
  1691. left : d.resourceRegion.left
  1692. })
  1693. }
  1694. c.show();
  1695. d.schedulerView.fireEvent("dragcreatestart", d.schedulerView);
  1696. if (d.showDragTip) {
  1697. d.dragTip.enable();
  1698. d.dragTip.update(d.start, d.end, true);
  1699. d.dragTip.show(c);
  1700. d.dragTip.el.setStyle("visibility", "visible")
  1701. }
  1702. },
  1703. onDrag : function(f, h) {
  1704. var d = this, c = d.schedulerView, b = d.tracker.getRegion()
  1705. .constrainTo(d.resourceRegion), g = c
  1706. .getStartEndDatesFromRegion(b, "round");
  1707. if (!g) {
  1708. return
  1709. }
  1710. d.start = g.start || d.start;
  1711. d.end = g.end || d.end;
  1712. var a = d.dateConstraints;
  1713. if (a) {
  1714. d.end = Sch.util.Date.constrain(d.end, a.start, a.end);
  1715. d.start = Sch.util.Date.constrain(d.start, a.start, a.end)
  1716. }
  1717. d.valid = this.validatorFn.call(d.validatorFnScope || d,
  1718. d.resourceRecord, d.start, d.end) !== false;
  1719. if (d.showDragTip) {
  1720. d.dragTip.update(d.start, d.end, d.valid)
  1721. }
  1722. Ext.apply(b, d.rowBoundaries);
  1723. this.getProxy().setRegion(b)
  1724. },
  1725. onDragEnd : function(c, d) {
  1726. this.dragging = false;
  1727. var a = this.schedulerView;
  1728. if (this.showDragTip) {
  1729. this.dragTip.disable()
  1730. }
  1731. if (!this.start || !this.end || (this.end - this.start <= 0)) {
  1732. this.valid = false
  1733. }
  1734. if (this.valid) {
  1735. var b = Ext.create(this.schedulerView.eventStore.model);
  1736. b.assign(this.resourceRecord);
  1737. b.setStartEndDate(this.start, this.end);
  1738. a.fireEvent("dragcreateend", a, b, this.resourceRecord, d)
  1739. } else {
  1740. this.proxy.hide()
  1741. }
  1742. this.schedulerView.fireEvent("afterdragcreate", a);
  1743. if (this.hoverTip) {
  1744. this.hoverTip.enable()
  1745. }
  1746. },
  1747. tipCfg : {
  1748. trackMouse : true,
  1749. bodyCssClass : "sch-hovertip",
  1750. autoHide : false,
  1751. dismissDelay : 1000,
  1752. showDelay : 300
  1753. },
  1754. dragging : false,
  1755. setupTooltips : function() {
  1756. var b = this, a = b.schedulerView;
  1757. b.tracker = new Sch.util.DragTracker({
  1758. el : a.el,
  1759. tolerance : b.dragTolerance,
  1760. listeners : {
  1761. beforedragstart : b.onBeforeDragStart,
  1762. dragstart : b.onDragStart,
  1763. drag : b.onDrag,
  1764. dragend : b.onDragEnd,
  1765. scope : b
  1766. }
  1767. });
  1768. if (this.showDragTip) {
  1769. this.dragTip = Ext.create("Sch.tooltip.Tooltip", {
  1770. cls : "sch-dragcreate-tip",
  1771. schedulerView : a,
  1772. listeners : {
  1773. beforeshow : function() {
  1774. return b.dragging
  1775. }
  1776. }
  1777. })
  1778. }
  1779. if (b.showHoverTip) {
  1780. var c = a.el;
  1781. b.hoverTipTemplate = b.hoverTipTemplate
  1782. || Ext.create("Sch.tooltip.ClockTemplate");
  1783. b.hoverTip = new Ext.ToolTip(Ext.applyIf({
  1784. renderTo : document.body,
  1785. target : c,
  1786. disabled : b.disabled
  1787. }, b.tipCfg));
  1788. b.hoverTip.on("beforeshow", b.tipOnBeforeShow, b);
  1789. a.mon(c, {
  1790. mouseleave : function() {
  1791. b.hoverTip.hide()
  1792. },
  1793. mousemove : b.onMouseMove,
  1794. scope : b
  1795. })
  1796. }
  1797. },
  1798. onSchedulerDestroy : function() {
  1799. if (this.hoverTip) {
  1800. this.hoverTip.destroy()
  1801. }
  1802. if (this.dragTip) {
  1803. this.dragTip.destroy()
  1804. }
  1805. if (this.tracker) {
  1806. this.tracker.destroy()
  1807. }
  1808. if (this.proxy) {
  1809. Ext.destroy(this.proxy);
  1810. this.proxy = null
  1811. }
  1812. },
  1813. tipOnBeforeShow : function(a) {
  1814. return !this.disabled && !this.dragging && this.lastTime !== null
  1815. }
  1816. });
  1817. Ext.define("Sch.feature.DragZone", {
  1818. extend : "Ext.dd.DragZone",
  1819. containerScroll : true,
  1820. onStartDrag : function() {
  1821. var a = this.schedulerView;
  1822. a.fireEvent("eventdragstart", a, this.dragData.records)
  1823. },
  1824. getDragData : function(n) {
  1825. var p = this.schedulerView, h = n.getTarget(p.eventSelector);
  1826. if (h) {
  1827. var g = p.getSelectionModel(), m = Ext.get(h), c = m
  1828. .is(p.eventSelector) ? h : m.up(p.eventSelector).dom, o = p
  1829. .getEventRecordFromDomId(c.id);
  1830. if (p.fireEvent("beforeeventdrag", p, o, n) === false) {
  1831. return null
  1832. }
  1833. var b, f = o.getStartDate(), l = [o], a, d = Ext
  1834. .get(Ext.core.DomHelper.createDom({
  1835. cls : "sch-dd-wrap",
  1836. children : [{
  1837. cls : "sch-dd-proxy-hd",
  1838. html : "&nbsp"
  1839. }]
  1840. }));
  1841. for (var j = 0, k = l.length; j < k; j++) {
  1842. a = p.getElementFromEventRecord(l[j]).dom.cloneNode(true);
  1843. a.id = Ext.id();
  1844. d.appendChild(a)
  1845. }
  1846. return {
  1847. repairXY : Ext.fly(h).getXY(),
  1848. ddel : d.dom,
  1849. sourceEventRecord : o,
  1850. records : l,
  1851. duration : o.getEndDate() - f
  1852. }
  1853. }
  1854. return null
  1855. },
  1856. afterRepair : function() {
  1857. this.dragging = false;
  1858. var a = this.schedulerView;
  1859. a.fireEvent("aftereventdrop", a)
  1860. },
  1861. getRepairXY : function() {
  1862. return this.dragData.repairXY
  1863. },
  1864. onDragKeyDown : function(b) {
  1865. var a = this.getProxy();
  1866. if (b.ctrlKey
  1867. && (a.dropStatus === a.dropAllowed || a.dropStatus === (a.dropAllowed + " add"))) {
  1868. a.setStatus(a.dropAllowed + " add")
  1869. }
  1870. },
  1871. onDragKeyUp : function(b) {
  1872. if (!b.ctrlKey) {
  1873. var a = this.getProxy();
  1874. a.setStatus(a.dropStatus.replace(" add", ""))
  1875. }
  1876. },
  1877. onMouseDown : function() {
  1878. if (this.enableCopy) {
  1879. Ext.getBody().on({
  1880. keydown : this.onDragKeyDown,
  1881. keyup : this.onDragKeyUp,
  1882. scope : this
  1883. })
  1884. }
  1885. },
  1886. onMouseUp : function() {
  1887. var a = Ext.getBody();
  1888. a.un("keydown", this.onDragKeyDown, this);
  1889. a.un("keyup", this.onDragKeyUp, this)
  1890. }
  1891. });
  1892. Ext.define("Sch.feature.DropZone", {
  1893. extend : "Ext.dd.DropZone",
  1894. constructor : function() {
  1895. this.callParent(arguments);
  1896. var a = this.schedulerView;
  1897. this.proxyTpl = this.proxyTpl
  1898. || new Ext.XTemplate(
  1899. '<span class="sch-dd-newtime">{[ this.getText(values) ]}</span>',
  1900. {
  1901. getText : function(b) {
  1902. var c = a.getFormattedDate(b.StartDate);
  1903. if (b.Duration) {
  1904. c += " - "
  1905. + a
  1906. .getFormattedEndDate(
  1907. Sch.util.Date
  1908. .add(
  1909. b.StartDate,
  1910. Sch.util.Date.MILLI,
  1911. b.Duration),
  1912. b.StartDate)
  1913. }
  1914. return c
  1915. }
  1916. })
  1917. },
  1918. validatorFn : Ext.emptyFn,
  1919. getTargetFromEvent : function(a) {
  1920. return a.getTarget("." + this.schedulerView.timeCellCls)
  1921. },
  1922. onNodeEnter : function(d, a, c, b) {
  1923. Ext.fly(d).addCls("sch-dd-cellover")
  1924. },
  1925. onNodeOut : function(d, a, c, b) {
  1926. Ext.fly(d).removeCls("sch-dd-cellover")
  1927. },
  1928. onNodeOver : function(i, a, h, g) {
  1929. var d = this.schedulerView, c = d.getDateFromDomEvent(h, "round"), f;
  1930. if (!c) {
  1931. return this.dropNotAllowed
  1932. }
  1933. this.proxyTpl.overwrite(a.proxy.el.down(".sch-dd-proxy-hd"), {
  1934. StartDate : c,
  1935. Duration : g.duration
  1936. });
  1937. var b = d.resolveResource(h.getTarget("." + d.timeCellCls));
  1938. if (this.validatorFn.call(this.validatorFnScope || this, g.records, b,
  1939. c, g.duration, h) !== false) {
  1940. return this.dropAllowed
  1941. + ((this.enableCopy && h.ctrlKey) ? " add" : "")
  1942. } else {
  1943. return this.dropNotAllowed
  1944. }
  1945. },
  1946. onNodeDrop : function(i, c, j, g) {
  1947. var l = this.schedulerView, b = l.resolveResource(i), f = l
  1948. .getDateFromDomEvent(j, "round"), a = false, k = this.enableCopy
  1949. && j.ctrlKey;
  1950. if (f
  1951. && this.validatorFn.call(this.validatorFnScope || this,
  1952. g.records, b, f, g.duration, j) !== false) {
  1953. var d, h = l.resourceStore.indexOf(b);
  1954. if (k) {
  1955. d = this.copyRecords(g.records, f, b, g.sourceEventRecord, h);
  1956. a = true
  1957. } else {
  1958. a = this.updateRecords(g.records, f, b, g.sourceEventRecord, h,
  1959. g)
  1960. }
  1961. if (a) {
  1962. l.getSelectionModel().deselectAll()
  1963. }
  1964. l.fireEvent("eventdrop", l, k ? d : g.records, k)
  1965. }
  1966. l.fireEvent("aftereventdrop", l);
  1967. return a
  1968. },
  1969. updateRecords : function(e, c, s, l, d, h) {
  1970. if (e.length === 1) {
  1971. l.beginEdit();
  1972. l.assign(s);
  1973. l.setStartDate(c);
  1974. l.setEndDate(Sch.util.Date.add(c, Sch.util.Date.MILLI, h.duration));
  1975. l.endEdit();
  1976. return true
  1977. }
  1978. var j = l.getStartDate(), o = this.schedulerView.resourceStore, q = c
  1979. - j, k = o.indexOf(l.getResource()), n, m, f, a, p, b = o
  1980. .getCount(), g;
  1981. for (g = 0; g < e.length; g++) {
  1982. a = e[g];
  1983. m = o.indexOf(a.getResource());
  1984. p = m - k + d;
  1985. if (p < 0 || p > b) {
  1986. return false
  1987. }
  1988. }
  1989. for (g = 0; g < e.length; g++) {
  1990. a = e[g];
  1991. m = o.indexOf(a.getResource());
  1992. n = m - k;
  1993. f = o.getAt(d + n);
  1994. a.beginEdit();
  1995. a.assign(f);
  1996. a.setStartDate(Sch.util.Date.add(a.getStartDate(),
  1997. Sch.util.Date.MILLI, q));
  1998. a.setEndDate(Sch.util.Date.add(a.getEndDate(), Sch.util.Date.MILLI,
  1999. q));
  2000. a.endEdit()
  2001. }
  2002. return true
  2003. },
  2004. copyRecords : function(d, g, b, f, c) {
  2005. var a = d[0], e = a.copy(), h = f.getEndDate() - f.getStartDate();
  2006. e.assign(b);
  2007. e.setStartDate(g);
  2008. e.setEndDate(Sch.util.Date.add(g, Sch.util.Date.MILLI, h));
  2009. return [e]
  2010. }
  2011. });
  2012. Ext.define("Sch.feature.PointDragZone", {
  2013. extend : "Ext.dd.DragZone",
  2014. requires : ["Sch.tooltip.Tooltip"],
  2015. repairHighlight : false,
  2016. containerScroll : true,
  2017. dropAllowed : "sch-dragproxy",
  2018. dropNotAllowed : "sch-dragproxy",
  2019. constructor : function(b, a) {
  2020. this.proxy = this.proxy || Ext.create("Ext.dd.StatusProxy", {
  2021. shadow : false,
  2022. dropAllowed : "sch-dragproxy",
  2023. dropNotAllowed : "sch-dragproxy"
  2024. });
  2025. this.callParent(arguments);
  2026. this.isTarget = true;
  2027. this.scroll = false;
  2028. this.ignoreSelf = false;
  2029. Ext.dd.ScrollManager.register(this.el)
  2030. },
  2031. destroy : function() {
  2032. this.callParent(arguments);
  2033. Ext.dd.ScrollManager.unregister(this.el)
  2034. },
  2035. autoOffset : function(a, e) {
  2036. var d = this.dragData.repairXY, c = a - d[0], b = e - d[1];
  2037. this.setDelta(c, b)
  2038. },
  2039. constrainTo : function(a, b) {
  2040. this.resetConstraints();
  2041. this.initPageX = a.left;
  2042. this.initPageY = a.top;
  2043. this.setXConstraint(a.left, a.right - (b.right - b.left),
  2044. this.xTickSize);
  2045. this.setYConstraint(a.top, a.bottom - (b.bottom - b.top),
  2046. this.yTickSize)
  2047. },
  2048. constrainToResource : function(b, c, a) {
  2049. this.resetConstraints();
  2050. this.initPageX = b.left;
  2051. this.initPageY = b.top;
  2052. if (a === "horizontal") {
  2053. this.setXConstraint(b.left, b.right - (c.right - c.left),
  2054. this.xTickSize);
  2055. this.setYConstraint(c.top, c.top, this.yTickSize)
  2056. } else {
  2057. this.setXConstraint(c.left, c.left, this.xTickSize);
  2058. this.setYConstraint(b.top, b.bottom - (c.bottom - c.top),
  2059. this.yTickSize)
  2060. }
  2061. },
  2062. setXConstraint : function(c, b, a) {
  2063. this.leftConstraint = c;
  2064. this.rightConstraint = b;
  2065. this.minX = c;
  2066. this.maxX = b;
  2067. if (a) {
  2068. this.setXTicks(this.initPageX, a)
  2069. }
  2070. this.constrainX = true
  2071. },
  2072. setYConstraint : function(a, c, b) {
  2073. this.topConstraint = a;
  2074. this.bottomConstraint = c;
  2075. this.minY = a;
  2076. this.maxY = c;
  2077. if (b) {
  2078. this.setYTicks(this.initPageY, b)
  2079. }
  2080. this.constrainY = true
  2081. },
  2082. onDragEnter : Ext.emptyFn,
  2083. onDragOut : Ext.emptyFn,
  2084. resolveStartEndDates : function(e) {
  2085. var a = this.dragData, c, d = a.origStart, b = a.origEnd;
  2086. if (!a.startsOutsideView) {
  2087. c = this.schedulerView.getStartEndDatesFromRegion(e, "round");
  2088. if (c) {
  2089. d = c.start || a.start;
  2090. b = Sch.util.Date.add(d, Sch.util.Date.MILLI, a.duration)
  2091. }
  2092. } else {
  2093. if (!a.endsOutsideView) {
  2094. c = this.schedulerView.getStartEndDatesFromRegion(e, "round");
  2095. if (c) {
  2096. b = c.end || a.end;
  2097. d = Sch.util.Date.add(b, Sch.util.Date.MILLI, -a.duration)
  2098. }
  2099. }
  2100. }
  2101. return {
  2102. startDate : d,
  2103. endDate : b
  2104. }
  2105. },
  2106. onDragOver : function(c, d) {
  2107. var a = this.dragData;
  2108. if (!a.originalHidden) {
  2109. Ext.each(a.eventEls, function(e) {
  2110. e.hide()
  2111. });
  2112. a.originalHidden = true
  2113. }
  2114. if (this.showTooltip) {
  2115. var b = this.getDragContext(c);
  2116. if (b) {
  2117. this.tip.update(b.startDate, b.endDate, b.valid)
  2118. }
  2119. }
  2120. },
  2121. getDragContext : function(d) {
  2122. var a = this.dragData;
  2123. if (!a.refElement) {
  2124. return
  2125. }
  2126. var c = this.schedulerView, f = a.refElement.getRegion();
  2127. var b = this.resolveStartEndDates(f);
  2128. b.resource = c.constrainDragToResource ? a.resourceRecord : this
  2129. .resolveResource([f.left + a.offsets[0], f.top + a.offsets[1]],
  2130. d);
  2131. if (b.resource) {
  2132. b.valid = this.validatorFn.call(this.validatorFnScope || this,
  2133. a.eventRecords, b.resource, b.startDate, a.duration, d)
  2134. } else {
  2135. b.valid = false
  2136. }
  2137. return b
  2138. },
  2139. onStartDrag : function(b, d) {
  2140. var c = this.schedulerView, a = this.dragData;
  2141. this.start = a.origStart;
  2142. this.end = a.origEnd;
  2143. c.fireEvent("eventdragstart", c, a.eventRecords)
  2144. },
  2145. startDrag : function() {
  2146. var b = this.callParent(arguments);
  2147. this.dragData.refElement = this.proxy.el.down("#sch-id-dd-ref");
  2148. if (this.showTooltip) {
  2149. var a = this.schedulerView;
  2150. if (!this.tip) {
  2151. this.tip = Ext.create("Sch.tooltip.Tooltip", {
  2152. schedulerView : a,
  2153. cls : "sch-dragdrop-tip"
  2154. })
  2155. }
  2156. this.tip.update(this.start, this.end, true);
  2157. this.tip.el.setStyle("visibility");
  2158. this.tip.show(this.dragData.refElement, this.dragData.offsets[0])
  2159. }
  2160. return b
  2161. },
  2162. getDragData : function(x) {
  2163. var q = this.schedulerView, p = x.getTarget(q.eventSelector);
  2164. if (!p) {
  2165. return
  2166. }
  2167. var l = q.resolveEventRecord(p);
  2168. if (l.isDraggable() === false
  2169. || q.fireEvent("beforeeventdrag", q, l, x) === false) {
  2170. return null
  2171. }
  2172. var i = x.getXY(), a = Ext.get(p), y = a.getXY(), k = [i[0] - y[0],
  2173. i[1] - y[1]], b = q.resolveResource(p), m = a.getRegion(), u = q
  2174. .getSnapPixelAmount();
  2175. if (!b) {
  2176. throw "Resource could not be resolved for event: " + l.getId()
  2177. }
  2178. this.clearTicks();
  2179. if (q.constrainDragToResource) {
  2180. this.constrainToResource(q.getScheduleRegion(b, l), m, q
  2181. .getOrientation())
  2182. } else {
  2183. this.constrainTo(q.getScheduleRegion(null, l), m)
  2184. }
  2185. if (u >= 1) {
  2186. if (q.getOrientation() === "horizontal") {
  2187. this.setXConstraint(this.leftConstraint, this.rightConstraint,
  2188. u)
  2189. } else {
  2190. this.setYConstraint(this.topConstraint, this.bottomConstraint,
  2191. u)
  2192. }
  2193. }
  2194. var d = l.getStartDate(), n = q.timeAxis, j = n.getStart(), h = n
  2195. .getEnd(), o = l.getEndDate(), v = d < j, r = o > h, c = Ext
  2196. .getBody().getScroll(), g = this.getRelatedRecords(l), w = [a];
  2197. Ext.Array.each(g, function(s) {
  2198. var e = q.getElementFromEventRecord(s);
  2199. if (e) {
  2200. w.push(e)
  2201. }
  2202. });
  2203. var f = {
  2204. offsets : k,
  2205. eventEls : w,
  2206. repairXY : y,
  2207. eventRecords : [l].concat(g),
  2208. relatedEventRecords : g,
  2209. resourceRecord : b,
  2210. origStart : d,
  2211. origEnd : o,
  2212. duration : o - d,
  2213. startsOutsideView : v,
  2214. endsOutsideView : r,
  2215. bodyScroll : c,
  2216. eventObj : x
  2217. };
  2218. f.ddel = this.getDragElement(a, f);
  2219. return f
  2220. },
  2221. getRelatedRecords : function(c) {
  2222. var b = this.schedulerView;
  2223. var d = b.panel.up("tablepanel").getEventSelectionModel();
  2224. var a = [];
  2225. if (d.selected.getCount() > 1) {
  2226. d.selected.each(function(e) {
  2227. if (e !== c && e.isDraggable() !== false) {
  2228. a.push(e)
  2229. }
  2230. })
  2231. }
  2232. return a
  2233. },
  2234. getDragElement : function(a, e) {
  2235. var c = this.schedulerView;
  2236. var d = e.eventEls;
  2237. var f;
  2238. if (d.length > 1) {
  2239. var b = Ext.get(Ext.core.DomHelper.createDom({
  2240. tag : "div",
  2241. cls : "sch-dd-wrap",
  2242. style : {
  2243. overflow : "visible"
  2244. }
  2245. }));
  2246. Ext.Array.each(d, function(h) {
  2247. f = h.dom.cloneNode(true);
  2248. if (h.dom === a.dom) {
  2249. f.id = "sch-id-dd-ref"
  2250. } else {
  2251. f.id = Ext.id()
  2252. }
  2253. b.appendChild(f);
  2254. var g = h.getOffsetsTo(a);
  2255. Ext.fly(f).setStyle({
  2256. left : g[0] + "px",
  2257. top : g[1] + "px"
  2258. })
  2259. });
  2260. return b.dom
  2261. } else {
  2262. f = a.dom.cloneNode(true);
  2263. f.id = "sch-id-dd-ref";
  2264. f.style.left = 0;
  2265. f.style.top = 0;
  2266. return f
  2267. }
  2268. },
  2269. onDragDrop : function(k, c) {
  2270. var m = this, q = m.schedulerView, n = q.resourceStore, l = m.cachedTarget
  2271. || Ext.dd.DragDropMgr.getDDById(c), i = m.dragData, d = m
  2272. .getDragContext(k), o = false;
  2273. if (d
  2274. && d.valid
  2275. && d.startDate
  2276. && d.endDate
  2277. && this.isValidDrop(i.resourceRecord, d.resource,
  2278. i.relatedEventRecords)) {
  2279. var h = i.eventRecords[0], b = d.startDate, f = i.relatedEventRecords, a = b
  2280. - i.origStart, g = d.resource;
  2281. o = (d.startDate - i.origStart) !== 0 || g !== i.resourceRecord;
  2282. h.beginEdit();
  2283. if (g !== i.resourceRecord) {
  2284. h.unassign(i.resourceRecord);
  2285. h.assign(g)
  2286. }
  2287. h.setStartDate(d.startDate, true,
  2288. q.eventStore.skipWeekendsDuringDragDrop);
  2289. h.endEdit();
  2290. var j;
  2291. var p = Ext.data.TreeStore && n instanceof Ext.data.TreeStore;
  2292. if (p) {
  2293. j = q.indexOf(i.resourceRecord) - q.indexOf(g)
  2294. } else {
  2295. j = n.indexOf(i.resourceRecord) - n.indexOf(g)
  2296. }
  2297. Ext.each(f, function(r) {
  2298. r.shift(Ext.Date.MILLI, a);
  2299. if (p) {
  2300. var e = q.store.indexOf(r.getResource()) - j;
  2301. r.setResource(q.store.getAt(e))
  2302. } else {
  2303. r.setResource(n.getAt(n.indexOf(r.getResource())
  2304. - j))
  2305. }
  2306. });
  2307. q.fireEvent("eventdrop", q, [h].concat(f), false)
  2308. }
  2309. if (m.tip) {
  2310. m.tip.hide()
  2311. }
  2312. if (d && d.valid && o) {
  2313. if (Ext.isIE9) {
  2314. m.proxy.el.setStyle("visibility", "hidden");
  2315. Ext.Function.defer(m.onValidDrop, 10, m, [l, k, c])
  2316. } else {
  2317. m.onValidDrop(l, k, c)
  2318. }
  2319. q.fireEvent("aftereventdrop", q)
  2320. } else {
  2321. this.onInvalidDrop(l, k, c)
  2322. }
  2323. },
  2324. isValidDrop : function(e, b, c) {
  2325. if (e === b || c.length === 0) {
  2326. return true
  2327. }
  2328. var f = this, j = f.schedulerView, a = true, d, g = j.resourceStore, h, i = Ext.data.TreeStore
  2329. && g instanceof Ext.data.TreeStore;
  2330. if (i) {
  2331. d = j.indexOf(e) - j.indexOf(b)
  2332. } else {
  2333. d = g.indexOf(e) - g.indexOf(b)
  2334. }
  2335. Ext.each(c, function(k) {
  2336. if (i) {
  2337. h = j.store.indexOf(e) - d;
  2338. if (h < 0 || h >= j.store.getCount()) {
  2339. a = false;
  2340. return false
  2341. }
  2342. } else {
  2343. h = g.indexOf(e) - d;
  2344. if (h < 0 || h >= g.getCount()) {
  2345. a = false;
  2346. return false
  2347. }
  2348. }
  2349. });
  2350. return a
  2351. },
  2352. onInvalidDrop : function() {
  2353. var a = this.schedulerView;
  2354. if (this.tip) {
  2355. this.tip.hide()
  2356. }
  2357. Ext.each(this.dragData.eventEls, function(b) {
  2358. b.show()
  2359. });
  2360. this.callParent(arguments);
  2361. a.fireEvent("aftereventdrop", a)
  2362. },
  2363. resolveResource : function(f, d) {
  2364. var b = this.proxy.el.dom;
  2365. b.style.display = "none";
  2366. var c = document.elementFromPoint(f[0] - this.dragData.bodyScroll.left,
  2367. f[1] - this.dragData.bodyScroll.top);
  2368. if (Ext.isIE8 && d && d.browserEvent.synthetic) {
  2369. c = document.elementFromPoint(f[0] - this.dragData.bodyScroll.left,
  2370. f[1] - this.dragData.bodyScroll.top)
  2371. }
  2372. b.style.display = "block";
  2373. if (!c) {
  2374. return null
  2375. }
  2376. if (!c.className.match(this.schedulerView.timeCellCls)) {
  2377. var a = Ext.fly(c).up("." + this.schedulerView.timeCellCls);
  2378. if (a) {
  2379. c = a.dom;
  2380. return this.schedulerView.resolveResource(c)
  2381. }
  2382. return null
  2383. }
  2384. return this.schedulerView.resolveResource(c)
  2385. }
  2386. });
  2387. Ext.define("Sch.feature.DragDrop", {
  2388. requires : ["Ext.XTemplate", "Sch.feature.PointDragZone",
  2389. "Sch.feature.DragZone", "Sch.feature.DropZone"],
  2390. validatorFn : function(b, a, c, f, d) {
  2391. return true
  2392. },
  2393. enableCopy : false,
  2394. useDragProxy : false,
  2395. showTooltip : true,
  2396. constructor : function(c, a) {
  2397. Ext.apply(this, a);
  2398. this.schedulerView = c;
  2399. var b = !!document.elementFromPoint;
  2400. if (!this.useDragProxy && !this.dragConfig.useDragProxy && b) {
  2401. this.initProxyLessDD()
  2402. } else {
  2403. this.initProxyDD()
  2404. }
  2405. this.schedulerView.on("destroy", this.cleanUp, this);
  2406. this.callParent([a])
  2407. },
  2408. cleanUp : function() {
  2409. if (this.schedulerView.dragZone) {
  2410. this.schedulerView.dragZone.destroy()
  2411. }
  2412. if (this.schedulerView.dropZone) {
  2413. this.schedulerView.dropZone.destroy()
  2414. }
  2415. if (this.tip) {
  2416. this.tip.destroy()
  2417. }
  2418. },
  2419. initProxyLessDD : function() {
  2420. var a = this.schedulerView;
  2421. a.dragZone = Ext.create("Sch.feature.PointDragZone", a.el, Ext
  2422. .apply({
  2423. ddGroup : a.id,
  2424. schedulerView : a,
  2425. enableCopy : this.enableCopy,
  2426. validatorFn : this.validatorFn,
  2427. validatorFnScope : this.validatorFnScope,
  2428. showTooltip : this.showTooltip
  2429. }, this.dragConfig))
  2430. },
  2431. initProxyDD : function() {
  2432. var b = this.schedulerView, a = b.el;
  2433. b.dragZone = Ext.create("Sch.feature.DragZone", a, Ext.apply({
  2434. ddGroup : b.id,
  2435. schedulerView : b,
  2436. enableCopy : this.enableCopy
  2437. }, this.dragConfig));
  2438. b.dropZone = Ext.create("Sch.feature.DropZone", a, Ext.apply({
  2439. ddGroup : b.id,
  2440. schedulerView : b,
  2441. enableCopy : this.enableCopy,
  2442. validatorFn : this.validatorFn,
  2443. validatorFnScope : this.validatorFnScope
  2444. }, this.dropConfig))
  2445. }
  2446. });
  2447. Ext.define("Sch.feature.ResizeZone", {
  2448. extend : "Ext.util.Observable",
  2449. requires : ["Ext.resizer.Resizer", "Sch.tooltip.Tooltip"],
  2450. showTooltip : true,
  2451. validatorFn : Ext.emptyFn,
  2452. validatorFnScope : null,
  2453. origEl : null,
  2454. constructor : function(a) {
  2455. Ext.apply(this, a);
  2456. var b = this.schedulerView;
  2457. b.on({
  2458. destroy : this.cleanUp,
  2459. scope : this
  2460. });
  2461. b.mon(b.el, {
  2462. mousedown : this.onMouseDown,
  2463. mouseup : this.onMouseUp,
  2464. scope : this,
  2465. delegate : ".sch-resizable-handle"
  2466. });
  2467. this.callParent(arguments)
  2468. },
  2469. onMouseDown : function(g, a) {
  2470. var b = this.schedulerView;
  2471. var f = this.eventRec = b.resolveEventRecord(a);
  2472. var c = this.getHandlePosition(a);
  2473. var d = f.isResizable();
  2474. if (d === false || typeof d === "string" && !a.className.match(d)) {
  2475. return
  2476. }
  2477. this.eventRec = f;
  2478. this.handlePos = c;
  2479. this.origEl = Ext.get(g.getTarget(".sch-event"));
  2480. b.el.on({
  2481. mousemove : this.onMouseMove,
  2482. scope : this,
  2483. single : true
  2484. })
  2485. },
  2486. onMouseUp : function(c, a) {
  2487. var b = this.schedulerView;
  2488. b.el.un({
  2489. mousemove : this.onMouseMove,
  2490. scope : this,
  2491. single : true
  2492. })
  2493. },
  2494. onMouseMove : function(f, a) {
  2495. var b = this.schedulerView;
  2496. var d = this.eventRec;
  2497. if (!d || b.fireEvent("beforeeventresize", b, d, f) === false) {
  2498. return
  2499. }
  2500. delete this.eventRec;
  2501. f.stopEvent();
  2502. var c = this.handlePos;
  2503. this.resizer = this.createResizer(this.origEl, d, c, f, a);
  2504. this.resizer.resizeTracker.onMouseDown(f, this.resizer[c].dom);
  2505. if (this.showTooltip) {
  2506. if (!this.tip) {
  2507. this.tip = Ext.create("Sch.tooltip.Tooltip", {
  2508. schedulerView : b,
  2509. cls : "sch-resize-tip"
  2510. })
  2511. }
  2512. this.tip.update(d.getStartDate(), d.getEndDate(), true);
  2513. this.tip.show(this.origEl)
  2514. }
  2515. b.fireEvent("eventresizestart", b, d)
  2516. },
  2517. getHandlePosition : function(a) {
  2518. if (this.schedulerView.getOrientation() === "horizontal") {
  2519. return a.className.match("start") ? "west" : "east"
  2520. } else {
  2521. return a.className.match("start") ? "north" : "south"
  2522. }
  2523. },
  2524. createResizer : function(c, f, b) {
  2525. var j = this.schedulerView, e = j.resolveResource(c), g = j
  2526. .getSnapPixelAmount(), i = j.getScheduleRegion(e, f), a = j
  2527. .getDateConstraints(e, f), d = {
  2528. target : c,
  2529. dateConstraints : a,
  2530. resourceRecord : e,
  2531. eventRecord : f,
  2532. handles : b.substring(0, 1),
  2533. minHeight : c.getHeight(),
  2534. constrainTo : i,
  2535. listeners : {
  2536. resizedrag : this.partialResize,
  2537. resize : this.afterResize,
  2538. scope : this
  2539. }
  2540. };
  2541. if (j.getOrientation() === "vertical") {
  2542. if (g > 0) {
  2543. Ext.apply(d, {
  2544. minHeight : g,
  2545. heightIncrement : g
  2546. })
  2547. }
  2548. } else {
  2549. if (g > 0) {
  2550. Ext.apply(d, {
  2551. minWidth : g,
  2552. widthIncrement : g
  2553. })
  2554. }
  2555. }
  2556. var h = Ext.create("Ext.resizer.Resizer", d);
  2557. c.setStyle("z-index", parseInt(c.getStyle("z-index"), 10) + 1);
  2558. return h
  2559. },
  2560. getStartEndDates : function(f) {
  2561. var e = this.resizer, c = e.el, d = this.schedulerView, b = e.handles[0] === "w"
  2562. || e.handles[0] === "n", g, a;
  2563. if (b) {
  2564. a = e.eventRecord.getEndDate();
  2565. g = d.getDateFromXY([c.getLeft(), c.getTop()], "round")
  2566. } else {
  2567. g = e.eventRecord.getStartDate();
  2568. a = d.getDateFromXY([c.getRight(), c.getBottom()], "round")
  2569. }
  2570. if (e.dateConstraints) {
  2571. g = Sch.util.Date.constrain(g, e.dateConstraints.start,
  2572. e.dateConstraints.end);
  2573. a = Sch.util.Date.constrain(a, e.dateConstraints.start,
  2574. e.dateConstraints.end)
  2575. }
  2576. return {
  2577. start : g,
  2578. end : a
  2579. }
  2580. },
  2581. partialResize : function(b, d, h, g) {
  2582. var j = this.schedulerView, i = this.getStartEndDates(g.getXY()), c = i.start, f = i.end;
  2583. if (!c || !f || ((b.start - c === 0) && (b.end - f === 0))) {
  2584. return
  2585. }
  2586. var a = this.validatorFn.call(this.validatorFnScope || this,
  2587. b.resourceRecord, b.eventRecord, c, f) !== false;
  2588. b.end = f;
  2589. b.start = c;
  2590. j.fireEvent("eventpartialresize", j, b.eventRecord, c, f, b.el);
  2591. if (this.showTooltip) {
  2592. this.tip.update(c, f, a)
  2593. }
  2594. },
  2595. afterResize : function(a, k, f, g) {
  2596. if (this.showTooltip) {
  2597. this.tip.hide()
  2598. }
  2599. var i = a.resourceRecord, j = a.eventRecord, d = j.getStartDate(), m = j
  2600. .getEndDate(), b = a.start || d, c = a.end || m, l = this.schedulerView;
  2601. if (b
  2602. && c
  2603. && (c - b > 0)
  2604. && ((b - d !== 0) || (c - m !== 0))
  2605. && this.validatorFn.call(this.validatorFnScope || this, i, j,
  2606. b, c, g) !== false) {
  2607. j.setStartEndDate(b, c, l.eventStore.skipWeekendsDuringDragDrop)
  2608. } else {
  2609. l.refreshKeepingScroll()
  2610. }
  2611. this.resizer.destroy();
  2612. l.fireEvent("eventresizeend", l, j)
  2613. },
  2614. cleanUp : function() {
  2615. if (this.tip) {
  2616. this.tip.destroy()
  2617. }
  2618. }
  2619. });
  2620. Ext.define("Sch.feature.Scheduling", {
  2621. extend : "Ext.grid.feature.Feature",
  2622. alias : "feature.scheduling",
  2623. getMetaRowTplFragments : function() {
  2624. return {
  2625. embedRowAttr : function() {
  2626. return 'style="height:{rowHeight}px"'
  2627. }
  2628. }
  2629. }
  2630. });
  2631. Ext.define("Sch.column.Time", {
  2632. extend : "Ext.grid.column.Column",
  2633. alias : "timecolumn",
  2634. draggable : false,
  2635. groupable : false,
  2636. hideable : false,
  2637. sortable : false,
  2638. fixed : true,
  2639. align : "center",
  2640. tdCls : "sch-timetd",
  2641. menuDisabled : true,
  2642. initComponent : function() {
  2643. this.addEvents("timeheaderdblclick");
  2644. this.enableBubble("timeheaderdblclick");
  2645. this.callParent()
  2646. },
  2647. initRenderData : function() {
  2648. var a = this;
  2649. a.renderData.headerCls = a.renderData.headerCls || a.headerCls;
  2650. return a.callParent(arguments)
  2651. },
  2652. onElDblClick : function(b, a) {
  2653. this.callParent(arguments);
  2654. this.fireEvent("timeheaderdblclick", this, this.startDate,
  2655. this.endDate, b)
  2656. }
  2657. }, function() {
  2658. Sch.column.Time.prototype.renderTpl = Sch.column.Time.prototype.renderTpl
  2659. .replace("column-header-inner",
  2660. "column-header-inner sch-timeheader {headerCls}")
  2661. });
  2662. Ext.define("Sch.column.Resource", {
  2663. extend : "Ext.grid.Column",
  2664. alias : "widget.resourcecolumn",
  2665. cls : "sch-resourcecolumn-header",
  2666. align : "center",
  2667. menuDisabled : true,
  2668. hideable : false,
  2669. sortable : false,
  2670. initComponent : function() {
  2671. this.callParent(arguments);
  2672. this.minWidth = undefined
  2673. }
  2674. });
  2675. Ext.define("Sch.column.timeAxis.Horizontal", {
  2676. extend : "Ext.grid.column.Column",
  2677. alias : "widget.timeaxiscolumn",
  2678. requires : ["Ext.Date", "Ext.XTemplate", "Sch.column.Time",
  2679. "Sch.preset.Manager"],
  2680. cls : "sch-timeaxiscolumn",
  2681. timeAxis : null,
  2682. renderTpl : '<div id="{id}-titleEl" class="'
  2683. + Ext.baseCSSPrefix
  2684. + 'column-header-inner"><span id="{id}-textEl" style="display:none" class="'
  2685. + Ext.baseCSSPrefix
  2686. + 'column-header-text"></span><tpl if="topHeaderCells">{topHeaderCells}</tpl><tpl if="middleHeaderCells">{middleHeaderCells}</tpl></div>{%this.renderContainer(out,values)%}',
  2687. headerRowTpl : '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle}" class="sch-header-row sch-header-row-{position}"><thead><tr>{cells}</tr></thead></table>',
  2688. headerCellTpl : '<tpl for="."><td class="sch-column-header x-column-header {headerCls}" style="position : static; text-align: {align}; {style}" tabIndex="0" id="{headerId}" headerPosition="{position}" headerIndex="{index}"><div class="x-column-header-inner">{header}</div></td></tpl>',
  2689. columnConfig : {},
  2690. timeCellRenderer : null,
  2691. timeCellRendererScope : null,
  2692. columnWidth : null,
  2693. previousWidth : null,
  2694. previousHeight : null,
  2695. initComponent : function() {
  2696. if (!(this.headerRowTpl instanceof Ext.Template)) {
  2697. this.headerRowTpl = Ext.create("Ext.XTemplate", this.headerRowTpl)
  2698. }
  2699. if (!(this.headerCellTpl instanceof Ext.Template)) {
  2700. this.headerCellTpl = Ext
  2701. .create("Ext.XTemplate", this.headerCellTpl)
  2702. }
  2703. this.columns = [{}];
  2704. this.addEvents("timeheaderdblclick", "timeaxiscolumnreconfigured");
  2705. this.enableBubble("timeheaderdblclick");
  2706. this.stubForResizer = new Ext.Component({
  2707. isOnLeftEdge : function() {
  2708. return false
  2709. },
  2710. isOnRightEdge : function() {
  2711. return false
  2712. },
  2713. el : {
  2714. dom : {
  2715. style : {}
  2716. }
  2717. }
  2718. });
  2719. this.callParent(arguments);
  2720. this.onTimeAxisReconfigure();
  2721. this
  2722. .mon(this.timeAxis, "reconfigure", this.onTimeAxisReconfigure,
  2723. this)
  2724. },
  2725. getSchedulingView : function() {
  2726. return this.getOwnerHeaderCt().view
  2727. },
  2728. onTimeAxisReconfigure : function() {
  2729. var e = this.timeAxis, d = e.preset.timeColumnWidth, f = this.rendered
  2730. && this.getSchedulingView(), g = e.headerConfig, b = e
  2731. .getStart(), c = e.getEnd(), h = {
  2732. renderer : this.timeColumnRenderer,
  2733. scope : this,
  2734. width : this.rendered ? f.calculateTimeColumnWidth(d) : d
  2735. };
  2736. delete this.previousWidth;
  2737. delete this.previousHeight;
  2738. var j = this.columnConfig = this.createColumns(this.timeAxis, g, h);
  2739. Ext.suspendLayouts();
  2740. this.removeAll();
  2741. if (this.rendered) {
  2742. var a = this.el.child(".x-column-header-inner");
  2743. a.select("table").remove();
  2744. var i = this.initRenderData();
  2745. if (j.top) {
  2746. Ext.core.DomHelper.append(a, i.topHeaderCells)
  2747. }
  2748. if (j.middle) {
  2749. Ext.core.DomHelper.append(a, i.middleHeaderCells)
  2750. }
  2751. if (!j.top && !j.middle) {
  2752. this.addCls("sch-header-single-row")
  2753. } else {
  2754. this.removeCls("sch-header-single-row")
  2755. }
  2756. }
  2757. Ext.resumeLayouts();
  2758. this.add(j.bottom);
  2759. if (this.rendered) {
  2760. if (this.fireEvent("timeaxiscolumnreconfigured", this) !== false) {
  2761. f.refresh()
  2762. }
  2763. }
  2764. },
  2765. beforeRender : function() {
  2766. var a = this.columnConfig;
  2767. if (!a.middle && !a.top) {
  2768. this.addCls("sch-header-single-row")
  2769. }
  2770. this.callParent(arguments)
  2771. },
  2772. timeColumnRenderer : function(i, e, f, l, d, c, k) {
  2773. var a = "";
  2774. if (Ext.isIE) {
  2775. e.style += ";z-index:" + (this.items.getCount() - d)
  2776. }
  2777. if (this.timeCellRenderer) {
  2778. var h = this.timeAxis, b = h.getAt(d), g = b.start, j = b.end;
  2779. a = this.timeCellRenderer.call(this.timeCellRendererScope || this,
  2780. e, f, l, d, c, g, j)
  2781. }
  2782. return a
  2783. },
  2784. initRenderData : function() {
  2785. var a = this.columnConfig;
  2786. var c = a.top ? this.headerRowTpl.apply({
  2787. cells : this.headerCellTpl.apply(a.top),
  2788. position : "top",
  2789. tstyle : "border-top : 0; width : 100px"
  2790. }) : "";
  2791. var b = a.middle ? this.headerRowTpl.apply({
  2792. cells : this.headerCellTpl.apply(a.middle),
  2793. position : "middle",
  2794. tstyle : a.top
  2795. ? "width : 100px"
  2796. : "border-top : 0; width : 100px"
  2797. }) : "";
  2798. return Ext.apply(this.callParent(arguments), {
  2799. topHeaderCells : c,
  2800. middleHeaderCells : b
  2801. })
  2802. },
  2803. defaultRenderer : function(c, b, a) {
  2804. return Ext.Date.format(c, a)
  2805. },
  2806. createColumns : function(f, d, g) {
  2807. if (!f || !d) {
  2808. throw "Invalid parameters passed to createColumns"
  2809. }
  2810. var c = [], a = d.bottom || d.middle, h, e = this;
  2811. f.forEachInterval(d.bottom ? "bottom" : "middle", function(l, j, k) {
  2812. h = {
  2813. align : a.align || "center",
  2814. headerCls : "",
  2815. startDate : l,
  2816. endDate : j
  2817. };
  2818. if (a.renderer) {
  2819. h.header = a.renderer.call(a.scope || e, l, j, h, k)
  2820. } else {
  2821. h.header = e.defaultRenderer(l, j, a.dateFormat)
  2822. }
  2823. c[c.length] = Ext
  2824. .create("Sch.column.Time", Ext.apply(h, g))
  2825. });
  2826. var b = this.createHeaderRows(f, d);
  2827. return {
  2828. bottom : c,
  2829. middle : b.middle,
  2830. top : b.top
  2831. }
  2832. },
  2833. createHeaderRows : function(e, c) {
  2834. var d = {};
  2835. if (c.top) {
  2836. var a;
  2837. if (c.top.cellGenerator) {
  2838. a = c.top.cellGenerator.call(this, e.getStart(), e.getEnd())
  2839. } else {
  2840. a = this.createHeaderRow(e, c.top)
  2841. }
  2842. d.top = this.processHeaderRow(a, "top")
  2843. }
  2844. if (c.bottom) {
  2845. var b;
  2846. if (c.middle.cellGenerator) {
  2847. b = c.middle.cellGenerator.call(this, e.getStart(), e.getEnd())
  2848. } else {
  2849. b = this.createHeaderRow(e, c.middle)
  2850. }
  2851. d.middle = this.processHeaderRow(b, "middle")
  2852. }
  2853. return d
  2854. },
  2855. processHeaderRow : function(c, a) {
  2856. var b = this;
  2857. Ext.each(c, function(d, e) {
  2858. d.index = e;
  2859. d.position = a;
  2860. d.headerId = b.stubForResizer.id
  2861. });
  2862. return c
  2863. },
  2864. createHeaderRow : function(e, k) {
  2865. var n = [], l, a = e.getStart(), c = e.getEnd(), m = c - a, j = [], b = a, d = 0, f, g = k.align
  2866. || "center", h;
  2867. while (b < c) {
  2868. h = Sch.util.Date.min(e.getNext(b, k.unit, k.increment || 1), c);
  2869. l = {
  2870. align : g,
  2871. start : b,
  2872. end : h,
  2873. headerCls : ""
  2874. };
  2875. if (k.renderer) {
  2876. l.header = k.renderer.call(k.scope || this, b, h, l, d)
  2877. } else {
  2878. l.header = this.defaultRenderer(b, h, k.dateFormat, l, d)
  2879. }
  2880. n.push(l);
  2881. b = h;
  2882. d++
  2883. }
  2884. return n
  2885. },
  2886. afterLayout : function() {
  2887. delete this.columnWidth;
  2888. this.callParent(arguments);
  2889. var b = this.getWidth();
  2890. var g = this.getHeight();
  2891. if (b === this.previousWidth && g === this.previousHeight) {
  2892. return
  2893. }
  2894. this.previousWidth = b;
  2895. this.previousHeight = g;
  2896. var i = this.columnConfig;
  2897. var e = this;
  2898. var c = this.el;
  2899. var f = i.top;
  2900. var d = 0;
  2901. var a = 0;
  2902. if (f) {
  2903. c.select(".sch-header-row-top").setWidth(this.lastBox.width);
  2904. c.select(".sch-header-row-top td").each(function(l, m, j) {
  2905. var k = e.getHeaderGroupCellWidth(f[j].start, f[j].end);
  2906. l.setVisibilityMode(Ext.Element.DISPLAY);
  2907. if (k) {
  2908. d += k;
  2909. l.show();
  2910. l.setWidth(k)
  2911. } else {
  2912. l.hide()
  2913. }
  2914. })
  2915. }
  2916. var h = i.middle;
  2917. if (h) {
  2918. c.select(".sch-header-row-middle").setWidth(this.lastBox.width);
  2919. c.select(".sch-header-row-middle td").each(function(l, m, j) {
  2920. var k = e.getHeaderGroupCellWidth(h[j].start, h[j].end);
  2921. l.setVisibilityMode(Ext.Element.DISPLAY);
  2922. if (k) {
  2923. a += k;
  2924. l.show();
  2925. l.setWidth(k)
  2926. } else {
  2927. l.hide()
  2928. }
  2929. })
  2930. }
  2931. },
  2932. getHeaderGroupCellWidth : function(h, b) {
  2933. var e = this.timeAxis.unit, d = this.timeAxis.increment, c, g = Sch.util.Date
  2934. .getMeasuringUnit(e), a = Sch.util.Date.getDurationInUnit(h, b,
  2935. g), f = this.getSchedulingView();
  2936. if (this.timeAxis.isContinuous()) {
  2937. c = a * f.getSingleUnitInPixels(g)
  2938. } else {
  2939. c = f.getXYFromDate(b)[0] - f.getXYFromDate(h)[0]
  2940. }
  2941. return c
  2942. },
  2943. onElDblClick : function(d, f) {
  2944. this.callParent(arguments);
  2945. var e = d.getTarget(".sch-column-header");
  2946. if (e) {
  2947. var a = Ext.fly(e).getAttribute("headerPosition"), b = Ext.fly(e)
  2948. .getAttribute("headerIndex"), c = this.columnConfig[a][b];
  2949. this.fireEvent("timeheaderdblclick", this, c.start, c.end, d)
  2950. }
  2951. },
  2952. getTimeColumnWidth : function() {
  2953. if (this.columnWidth === null) {
  2954. this.columnWidth = this.items.get(0).getWidth()
  2955. }
  2956. return this.columnWidth
  2957. },
  2958. setTimeColumnWidth : function(a) {
  2959. this.suspendEvents();
  2960. this.items.each(function(b) {
  2961. b.setWidth(a)
  2962. });
  2963. this.resumeEvents()
  2964. }
  2965. });
  2966. Ext.define("Sch.column.timeAxis.HorizontalSingle", {
  2967. extend : "Sch.column.Time",
  2968. alias : "widget.singletimeaxiscolumn",
  2969. requires : ["Ext.Date", "Ext.XTemplate", "Sch.preset.Manager"],
  2970. cls : "sch-simple-timeaxis",
  2971. timeAxis : null,
  2972. trackHeaderOver : true,
  2973. compactCellWidthThreshold : 16,
  2974. renderTpl : '<div id="{id}-titleEl" class="'
  2975. + Ext.baseCSSPrefix
  2976. + 'column-header-inner"><span id="{id}-textEl" style="display:none" class="'
  2977. + Ext.baseCSSPrefix
  2978. + 'column-header-text"></span><tpl if="topHeaderCells">{topHeaderCells}</tpl><tpl if="middleHeaderCells">{middleHeaderCells}</tpl><tpl if="bottomHeaderCells">{bottomHeaderCells}</tpl></div>{%this.renderContainer(out,values)%}',
  2979. headerRowTpl : '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle}" class="sch-header-row sch-header-row-{position}"><thead><tr><tpl for="cells"><td class="sch-column-header x-column-header {headerCls}" style="position : static; text-align: {align}; {style}" tabIndex="0" id="{headerId}" headerPosition="{parent.position}" headerIndex="{[xindex-1]}"><div class="sch-simple-timeheader">{header}</div></td></tpl></tr></thead></table>',
  2980. columnConfig : {},
  2981. columnWidth : null,
  2982. nbrTimeColumns : null,
  2983. initComponent : function() {
  2984. this.tdCls += " sch-singletimetd";
  2985. if (!(this.headerRowTpl instanceof Ext.Template)) {
  2986. this.headerRowTpl = Ext.create("Ext.XTemplate", this.headerRowTpl)
  2987. }
  2988. this.addEvents("timeheaderdblclick", "timeaxiscolumnreconfigured");
  2989. this.enableBubble("timeheaderdblclick");
  2990. this.callParent(arguments);
  2991. this.onTimeAxisReconfigure();
  2992. this
  2993. .mon(this.timeAxis, "reconfigure", this.onTimeAxisReconfigure,
  2994. this);
  2995. this.on("resize", this.refreshHeaderSizes, this);
  2996. this.ownHoverCls = this.hoverCls;
  2997. this.hoverCls = ""
  2998. },
  2999. getSchedulingView : function() {
  3000. return this.getOwnerHeaderCt().view
  3001. },
  3002. onTimeAxisReconfigure : function() {
  3003. var h = this.timeAxis, g = h.preset.timeColumnWidth, j = this.rendered
  3004. && this.getSchedulingView(), l = h.headerConfig, c = h
  3005. .getStart(), f = h.getEnd(), d = this.rendered ? j
  3006. .calculateTimeColumnWidth(g) : g;
  3007. var o = this.columnConfig = this.createHeaderRows(l);
  3008. var a = o.bottom || o.middle;
  3009. if (this.rendered) {
  3010. var e;
  3011. var b = this.el.child(".x-column-header-inner");
  3012. var i = b.dom;
  3013. var k = i.style.display;
  3014. var m = i.parentNode;
  3015. i.style.display = "none";
  3016. m.removeChild(i);
  3017. i.innerHTML = "";
  3018. var n = this.initRenderData();
  3019. if (o.top) {
  3020. e = Ext.core.DomHelper.append(b, n.topHeaderCells);
  3021. this.refreshHeaderRow("top", e)
  3022. }
  3023. if (o.middle) {
  3024. e = Ext.core.DomHelper.append(b, n.middleHeaderCells);
  3025. this.refreshHeaderRow("middle", e)
  3026. }
  3027. if (o.bottom) {
  3028. e = Ext.core.DomHelper.append(b, n.bottomHeaderCells);
  3029. this.refreshHeaderRow("bottom", e)
  3030. }
  3031. if (!o.top && !o.middle) {
  3032. this.addCls("sch-header-single-row")
  3033. } else {
  3034. this.removeCls("sch-header-single-row")
  3035. }
  3036. m.appendChild(i);
  3037. i.style.display = k;
  3038. if (d !== this.columnWidth || this.nbrTimeColumns !== a.length) {
  3039. this.nbrTimeColumns = a.length;
  3040. this.setTimeColumnWidth(d)
  3041. }
  3042. if (this.fireEvent("timeaxiscolumnreconfigured", this) !== false) {
  3043. j.refreshKeepingResourceScroll(true)
  3044. }
  3045. } else {
  3046. if (d !== this.columnWidth || this.nbrTimeColumns !== a.length) {
  3047. this.nbrTimeColumns = a.length;
  3048. this.setTimeColumnWidth(d)
  3049. }
  3050. }
  3051. },
  3052. beforeRender : function() {
  3053. var b = this, a = this.columnConfig;
  3054. if (!a.middle && !a.top) {
  3055. b.addCls("sch-header-single-row")
  3056. }
  3057. b.callParent(arguments)
  3058. },
  3059. afterRender : function() {
  3060. var a = this;
  3061. if (this.trackHeaderOver) {
  3062. a.el.on({
  3063. mousemove : a.highlightCell,
  3064. delegate : "div.sch-simple-timeheader",
  3065. scope : a
  3066. });
  3067. a.el.on({
  3068. mouseleave : a.clearHighlight,
  3069. scope : a
  3070. })
  3071. }
  3072. a.callParent(arguments)
  3073. },
  3074. initRenderData : function() {
  3075. var a = this.columnConfig;
  3076. var c = a.top ? this.headerRowTpl.apply({
  3077. cells : a.top,
  3078. position : "top",
  3079. tstyle : "border-top : 0; width : 100px"
  3080. }) : "";
  3081. var b = a.middle ? this.headerRowTpl.apply({
  3082. cells : a.middle,
  3083. position : "middle",
  3084. tstyle : a.top
  3085. ? "width : 100px"
  3086. : "border-top : 0; width : 100px"
  3087. }) : "";
  3088. var d = a.bottom ? this.headerRowTpl.apply({
  3089. cells : a.bottom,
  3090. position : "bottom",
  3091. tstyle : "width : 100px"
  3092. }) : "";
  3093. return Ext.apply(this.callParent(arguments), {
  3094. topHeaderCells : c,
  3095. middleHeaderCells : b,
  3096. bottomHeaderCells : d
  3097. })
  3098. },
  3099. defaultRenderer : function(c, b, a) {
  3100. return Ext.Date.format(c, a)
  3101. },
  3102. createHeaderRows : function(a) {
  3103. var b = {};
  3104. for (var c in a) {
  3105. if (a[c].cellGenerator) {
  3106. b[c] = a[c].cellGenerator.call(this, this.timeAxis.getStart(),
  3107. this.timeAxis.getEnd())
  3108. } else {
  3109. b[c] = this.createHeaderRow(c, a[c])
  3110. }
  3111. }
  3112. return b
  3113. },
  3114. createHeaderRow : function(a, c) {
  3115. var b = [], d = this, f, e = c.align || "center";
  3116. this.timeAxis.forEachInterval(a, function(j, g, h) {
  3117. f = {
  3118. align : e,
  3119. start : j,
  3120. end : g,
  3121. headerCls : ""
  3122. };
  3123. if (c.renderer) {
  3124. f.header = c.renderer.call(c.scope || d, j, g, f, h)
  3125. } else {
  3126. f.header = d.defaultRenderer(j, g, c.dateFormat, f, h)
  3127. }
  3128. if (c.unit === Sch.util.Date.DAY
  3129. && (!c.increment || c.increment === 1)) {
  3130. f.headerCls += " sch-dayheadercell-" + j.getDay()
  3131. }
  3132. b.push(f)
  3133. });
  3134. return b
  3135. },
  3136. afterLayout : function() {
  3137. this.callParent(arguments);
  3138. this.refreshHeaderSizes()
  3139. },
  3140. refreshHeaderSizes : function() {
  3141. var a = this.columnConfig;
  3142. if (a.top) {
  3143. this.refreshHeaderRow("top")
  3144. }
  3145. if (a.middle) {
  3146. this.refreshHeaderRow("middle")
  3147. }
  3148. if (a.bottom) {
  3149. this.refreshHeaderRow("bottom")
  3150. }
  3151. },
  3152. refreshHeaderRow : function(a, b) {
  3153. var e = this.el;
  3154. var f = this.columnConfig[a];
  3155. var d = this;
  3156. var c;
  3157. var g = a === "bottom" || (a === "middle" && !this.columnConfig.bottom);
  3158. b = b || e.down(".sch-header-row-" + a, true);
  3159. Ext.fly(b).setWidth(d.getTotalWidth());
  3160. Ext.fly(b).select(" thead > tr > td").each(function(i, j, h) {
  3161. c = g ? d.columnWidth : d.getHeaderGroupCellWidth(f[h].start,
  3162. f[h].end);
  3163. i.setVisibilityMode(Ext.Element.DISPLAY);
  3164. if (c) {
  3165. if (Ext.isSafari && Ext.isMac) {
  3166. c -= 2
  3167. }
  3168. i.show();
  3169. i.setWidth(c - (Ext.chromeVersion === 19 ? (h ? 1 : 0) : 0))
  3170. } else {
  3171. i.hide()
  3172. }
  3173. });
  3174. if (a === "bottom") {
  3175. if (c < this.compactCellWidthThreshold) {
  3176. Ext.fly(b).addCls("sch-header-row-compact")
  3177. } else {
  3178. Ext.fly(b).removeCls("sch-header-row-compact")
  3179. }
  3180. }
  3181. },
  3182. getHeaderGroupCellWidth : function(c, a) {
  3183. var b = this.getSchedulingView();
  3184. return b.getXYFromDate(a)[0] - b.getXYFromDate(c)[0]
  3185. },
  3186. onElDblClick : function(d, f) {
  3187. var e = d.getTarget(".sch-column-header");
  3188. if (e) {
  3189. var a = Ext.fly(e).getAttribute("headerPosition"), b = Ext.fly(e)
  3190. .getAttribute("headerIndex"), c = this.columnConfig[a][b];
  3191. this.fireEvent("timeheaderdblclick", this, c.start, c.end, d)
  3192. }
  3193. },
  3194. getTimeColumnWidth : function() {
  3195. if (this.columnWidth === null) {
  3196. this.columnWidth = this.getWidth() / this.nbrTimeColumns
  3197. }
  3198. return this.columnWidth
  3199. },
  3200. setTimeColumnWidth : function(a) {
  3201. this.columnWidth = a;
  3202. if (this.rendered) {
  3203. Ext.suspendLayouts();
  3204. this.setWidth(a * this.nbrTimeColumns);
  3205. Ext.resumeLayouts();
  3206. this.refreshHeaderSizes();
  3207. this.ownerCt.updateLayout()
  3208. } else {
  3209. this.setWidth(a * this.nbrTimeColumns)
  3210. }
  3211. },
  3212. getTotalWidth : function() {
  3213. return this.columnWidth * this.nbrTimeColumns
  3214. },
  3215. highlightCell : function(c, a) {
  3216. var b = this;
  3217. if (a !== b.highlightedCell) {
  3218. b.clearHighlight();
  3219. b.highlightedCell = a;
  3220. Ext.fly(a).addCls(b.ownHoverCls)
  3221. }
  3222. },
  3223. clearHighlight : function() {
  3224. var b = this, a = b.highlightedCell;
  3225. if (a) {
  3226. Ext.fly(a).removeCls(b.ownHoverCls);
  3227. delete b.highlightedCell
  3228. }
  3229. }
  3230. });
  3231. Ext.define("Sch.column.timeAxis.Vertical", {
  3232. extend : "Ext.grid.column.Column",
  3233. alias : "widget.verticaltimeaxis",
  3234. align : "right",
  3235. draggable : false,
  3236. groupable : false,
  3237. hideable : false,
  3238. sortable : false,
  3239. menuDisabled : true,
  3240. dataIndex : "start",
  3241. timeAxis : null,
  3242. initComponent : function() {
  3243. this.callParent(arguments);
  3244. this.tdCls = (this.tdCls || "") + " sch-verticaltimeaxis-cell";
  3245. this.scope = this
  3246. },
  3247. renderer : function(b, a, c) {
  3248. var d = this.timeAxis.headerConfig, e = d.bottom || d.middle;
  3249. if (e.renderer) {
  3250. return e.renderer
  3251. .call(e.scope || this, b, c.data.end, a, 0)
  3252. } else {
  3253. return Ext.Date.format(b, e.dateFormat)
  3254. }
  3255. }
  3256. });
  3257. Ext.define("Sch.mixin.Lockable", {
  3258. extend : "Ext.grid.Lockable",
  3259. requires : ["Sch.column.timeAxis.Horizontal",
  3260. "Sch.column.timeAxis.HorizontalSingle"],
  3261. findEditingPlugin : function() {
  3262. var b = this.plugins || [];
  3263. var c = this;
  3264. var a;
  3265. Ext.each(b, function(e, d) {
  3266. if (Ext.grid.plugin && Ext.grid.plugin.CellEditing
  3267. && e instanceof Ext.grid.plugin.CellEditing) {
  3268. a = e;
  3269. Ext.Array.remove(b, e);
  3270. return false
  3271. }
  3272. });
  3273. return a
  3274. },
  3275. processSchedulerPlugins : function() {
  3276. var e = [];
  3277. var d = [];
  3278. var g = [];
  3279. var a = this.plugins || [];
  3280. var c = this;
  3281. for (var b = a.length - 1; b >= 0; b--) {
  3282. var f = a[b];
  3283. if (f.lockableScope) {
  3284. switch (f.lockableScope) {
  3285. case "top" :
  3286. g.push(f);
  3287. break;
  3288. case "locked" :
  3289. e.push(f);
  3290. break;
  3291. case "normal" :
  3292. d.push(f);
  3293. break
  3294. }
  3295. Ext.Array.remove(a, f)
  3296. }
  3297. }
  3298. if (e.length > 0) {
  3299. c.lockedGridConfig.plugins = (c.lockedGridConfig.plugins || [])
  3300. .concat(e)
  3301. }
  3302. if (d.length > 0) {
  3303. c.normalGridConfig.plugins = (c.normalGridConfig.plugins || [])
  3304. .concat(d)
  3305. }
  3306. c.topPlugins = g
  3307. },
  3308. injectLockable : function() {
  3309. var d = this.findEditingPlugin();
  3310. var k = this;
  3311. var g = Ext.data.TreeStore && k.store instanceof Ext.data.TreeStore;
  3312. var m = k.store.buffered;
  3313. var c = k.getEventSelectionModel ? k.getEventSelectionModel() : k
  3314. .getSelectionModel();
  3315. k.lockedGridConfig = Ext.apply({}, k.lockedGridConfig || {});
  3316. k.normalGridConfig = Ext.apply({}, k.schedulerConfig
  3317. || k.normalGridConfig || {});
  3318. var a = k.lockedGridConfig, j = k.normalGridConfig;
  3319. Ext.applyIf(k.lockedGridConfig, {
  3320. xtype : k.lockedXType,
  3321. id : k.id + "_locked",
  3322. enableLocking : false,
  3323. lockable : false,
  3324. useArrows : true,
  3325. columnLines : k.columnLines,
  3326. rowLines : k.rowLines,
  3327. stateful : k.stateful,
  3328. delayScroll : function() {
  3329. if (this.rendered) {
  3330. return this.self.prototype.delayScroll.apply(this,
  3331. arguments)
  3332. }
  3333. },
  3334. split : true,
  3335. animCollapse : false,
  3336. collapseDirection : "left",
  3337. region : "west"
  3338. });
  3339. if (d) {
  3340. k.lockedGridConfig.plugins = (k.lockedGridConfig.plugins || [])
  3341. .concat(d)
  3342. }
  3343. k.processSchedulerPlugins();
  3344. Ext.applyIf(k.normalGridConfig, {
  3345. xtype : k.normalXType,
  3346. enableLocking : false,
  3347. lockable : false,
  3348. viewType : k.viewType,
  3349. layout : "fit",
  3350. sortableColumns : false,
  3351. enableColumnMove : false,
  3352. enableColumnResize : false,
  3353. enableColumnHide : false,
  3354. selModel : c,
  3355. eventSelModel : c,
  3356. _top : k,
  3357. orientation : k.orientation,
  3358. viewPreset : k.viewPreset,
  3359. timeAxis : k.timeAxis,
  3360. columnLines : k.columnLines,
  3361. rowLines : k.rowLines,
  3362. collapseDirection : "right",
  3363. animCollapse : false,
  3364. region : "center"
  3365. });
  3366. k.bothCfgCopy = k.bothCfgCopy
  3367. || (Ext.grid.Panel && Ext.grid.Panel.prototype.bothCfgCopy)
  3368. || ["invalidateScrollerOnRefresh", "hideHeaders",
  3369. "enableColumnHide", "enableColumnMove",
  3370. "enableColumnResize", "sortableColumns"];
  3371. if (k.orientation === "vertical") {
  3372. a.store = j.store = k.timeAxis.tickStore;
  3373. k.mon(k.resourceStore, {
  3374. clear : k.refreshResourceColumns,
  3375. datachanged : k.refreshResourceColumns,
  3376. update : k.refreshResourceColumns,
  3377. load : k.refreshResourceColumns,
  3378. scope : k
  3379. })
  3380. }
  3381. if (a.width) {
  3382. k.syncLockedWidth = Ext.emptyFn;
  3383. a.scroll = "horizontal";
  3384. a.scrollerOwner = true
  3385. }
  3386. if (k.resourceStore) {
  3387. j.resourceStore = k.resourceStore
  3388. }
  3389. if (k.eventStore) {
  3390. j.eventStore = k.eventStore
  3391. }
  3392. if (k.dependencyStore) {
  3393. j.dependencyStore = k.dependencyStore
  3394. }
  3395. var e = k.lockedViewConfig = k.lockedViewConfig || {};
  3396. var l = k.normalViewConfig = k.normalViewConfig || {};
  3397. if (g && m && Ext.getScrollbarSize().width === 0) {
  3398. k.lockedGridConfig.scroll = "horizontal"
  3399. }
  3400. if (m) {
  3401. e.preserveScrollOnRefresh = true
  3402. }
  3403. e.enableAnimations = k.normalViewConfig.enableAnimations = false;
  3404. if (g) {
  3405. if (Ext.versions.extjs.isLessThan("4.1.3")) {
  3406. k.normalViewConfig.providedStore = e.providedStore = k.store.nodeStore
  3407. } else {
  3408. k.normalViewConfig.store = e.store = k.store.nodeStore
  3409. }
  3410. k.overrideNodeStore(k.store.nodeStore)
  3411. }
  3412. var f = k.layout;
  3413. this.callParent(arguments);
  3414. if (k.topPlugins) {
  3415. k.plugins = k.topPlugins
  3416. }
  3417. if (a.width) {
  3418. k.lockedGrid.setWidth(a.width);
  3419. k.normalGrid.getView().addCls("sch-timeline-horizontal-scroll");
  3420. k.lockedGrid.getView().addCls("sch-locked-horizontal-scroll")
  3421. } else {
  3422. if (k.normalGrid.collapsed) {
  3423. k.normalGrid.collapsed = false;
  3424. k.normalGrid.view.on("boxready", function() {
  3425. k.normalGrid.collapse()
  3426. }, k, {
  3427. delay : 10
  3428. })
  3429. }
  3430. }
  3431. var n = k.lockedGrid.getView();
  3432. var b = k.normalGrid.getView();
  3433. var h;
  3434. if (m) {
  3435. h = k.normalGrid.verticalScroller;
  3436. n.on("render", this.onLockedViewRender, this);
  3437. this.fixPagingScroller(h);
  3438. if (Ext.getVersion("extjs").isLessThan("4.1.1")) {
  3439. if (Ext.getScrollbarSize().width > 0) {
  3440. n.on({
  3441. scroll : {
  3442. fn : k.onLockedViewScroll,
  3443. element : "el",
  3444. scope : k
  3445. }
  3446. })
  3447. }
  3448. }
  3449. }
  3450. if (Ext.getScrollbarSize().width === 0) {
  3451. n.addCls("sch-ganttpanel-force-locked-scroll")
  3452. }
  3453. if (g) {
  3454. this.setupLockableTree()
  3455. }
  3456. if (!b.deferInitialRefresh) {
  3457. var i = b.onRender;
  3458. b.onRender = function() {
  3459. this.doFirstRefresh = function() {
  3460. };
  3461. i.apply(this, arguments);
  3462. delete this.doFirstRefresh
  3463. }
  3464. }
  3465. if (m) {
  3466. b.el = {
  3467. un : function() {
  3468. }
  3469. };
  3470. h.bindView(b);
  3471. b.un("refresh", h.self.prototype.onViewRefresh, h);
  3472. delete b.el
  3473. }
  3474. k.view.clearListeners();
  3475. n.on({
  3476. refresh : k.updateSpacer,
  3477. scope : k
  3478. });
  3479. if (!Ext.grid.Lockable.prototype.updateSpacer) {
  3480. b.on({
  3481. refresh : k.updateSpacer,
  3482. scope : k
  3483. })
  3484. }
  3485. k.view = Ext.create("Sch.view.Locking", {
  3486. locked : k.lockedGrid,
  3487. normal : k.normalGrid,
  3488. panel : k
  3489. });
  3490. if (k.syncRowHeight) {
  3491. n.on("refresh", this.onLockedViewRefresh, this);
  3492. if (g) {
  3493. k.mon(k.store, {
  3494. beforeload : function() {
  3495. n.un({
  3496. itemadd : k.onViewItemAdd,
  3497. scope : k
  3498. });
  3499. b.un({
  3500. itemadd : k.onViewItemAdd,
  3501. scope : k
  3502. })
  3503. },
  3504. load : function() {
  3505. n.un({
  3506. itemadd : k.onViewItemAdd,
  3507. scope : k
  3508. });
  3509. b.un({
  3510. itemadd : k.onViewItemAdd,
  3511. scope : k
  3512. });
  3513. k.prepareFullRowHeightSync();
  3514. k.syncRowHeights()
  3515. }
  3516. });
  3517. k.normalGrid.on("afteritemexpand", k.afterNormalGridItemExpand,
  3518. k)
  3519. }
  3520. n.on({
  3521. itemadd : k.onViewItemAdd,
  3522. scope : k
  3523. });
  3524. b.on({
  3525. itemadd : k.onViewItemAdd,
  3526. itemupdate : k.onNormalViewItemUpdate,
  3527. groupexpand : k.onNormalViewGroupExpand,
  3528. scope : k
  3529. });
  3530. if (Ext.isIE9 && Ext.isStrict) {
  3531. k.onNormalViewItemUpdate = function(o, p, r) {
  3532. r = r.dom ? r.dom : r;
  3533. if (k.lockedGridDependsOnSchedule) {
  3534. var q = k.lockedGrid.getView();
  3535. q.suspendEvents();
  3536. q.onUpdate(k.lockedGrid.store, o);
  3537. q.resumeEvents()
  3538. }
  3539. var s = k.normalGrid.getView().getNode(p);
  3540. s.style.height = r.style.height;
  3541. k.normalHeights[p] = r.style.height;
  3542. k.syncRowHeights()
  3543. }
  3544. }
  3545. }
  3546. if (f !== "fit") {
  3547. k.layout = f
  3548. }
  3549. k.normalGrid.on({
  3550. collapse : k.onNormalGridCollapse,
  3551. expand : k.onNormalGridExpand,
  3552. scope : k
  3553. });
  3554. k.lockedGrid.on({
  3555. collapse : k.onLockedGridCollapse,
  3556. scope : k
  3557. });
  3558. if (this.lockedGrid.view.store !== this.normalGrid.view.store) {
  3559. Ext.Error
  3560. .raise("Sch.mixin.Lockable setup failed, not sharing store between the two views")
  3561. }
  3562. },
  3563. onLockedGridCollapse : function() {
  3564. if (this.normalGrid.collapsed) {
  3565. this.normalGrid.expand()
  3566. }
  3567. },
  3568. onNormalGridCollapse : function() {
  3569. var a = this;
  3570. if (!a.normalGrid.reExpander) {
  3571. a.normalGrid.reExpander = a.normalGrid.placeholder
  3572. }
  3573. if (!a.lockedGrid.rendered) {
  3574. a.lockedGrid.on("render", a.onNormalGridCollapse, a, {
  3575. delay : 1
  3576. })
  3577. } else {
  3578. a.lastLockedWidth = a.lockedGrid.getWidth();
  3579. a.lockedGrid.setWidth(a.getWidth() - 35);
  3580. if (a.lockedGrid.collapsed) {
  3581. a.lockedGrid.expand()
  3582. }
  3583. a.addCls("sch-normalgrid-collapsed")
  3584. }
  3585. },
  3586. onNormalGridExpand : function() {
  3587. this.removeCls("sch-normalgrid-collapsed");
  3588. this.lockedGrid.setWidth(this.lastLockedWidth)
  3589. },
  3590. fixPagingScroller : function(a) {
  3591. var b = a.onViewRefresh;
  3592. a.onViewRefresh = function() {
  3593. var j = this, l = j.store, i, k = j.view, o = k.el, p = o.dom, r, n, h, q = k.table.dom, m, g;
  3594. if (j.focusOnRefresh) {
  3595. o.focus();
  3596. j.focusOnRefresh = false
  3597. }
  3598. j.disabled = true;
  3599. var f = l.getCount() === l.getTotalCount();
  3600. j.stretcher.setHeight(i = j.getScrollHeight());
  3601. g = p.scrollTop;
  3602. j.isScrollRefresh = (g > 0);
  3603. if (j.scrollProportion !== undefined) {
  3604. j.setTablePosition("absolute");
  3605. j.setTableTop((j.scrollProportion && j.tableStart > 0
  3606. ? (i * j.scrollProportion)
  3607. - (q.offsetHeight * j.scrollProportion)
  3608. : 0)
  3609. + "px")
  3610. } else {
  3611. j.setTablePosition("absolute");
  3612. j.setTableTop((m = (j.tableStart || 0) * j.rowHeight) + "px");
  3613. if (j.scrollOffset) {
  3614. r = k.getNodes();
  3615. n = -o.getOffsetsTo(r[j.commonRecordIndex])[1];
  3616. h = n - j.scrollOffset;
  3617. j.position = (p.scrollTop += h)
  3618. } else {
  3619. if ((m > g) || ((m + q.offsetHeight) < g + p.clientHeight)) {
  3620. if (!(f && !m)) {
  3621. j.lastScrollDirection = -1;
  3622. j.position = p.scrollTop = m
  3623. }
  3624. }
  3625. }
  3626. }
  3627. j.disabled = false
  3628. };
  3629. a.setViewTableStyle = function(f, h, g) {
  3630. if (f.table.dom) {
  3631. f.table.dom.style[h] = g
  3632. }
  3633. f = f.lockingPartner;
  3634. if (f) {
  3635. if (f.table.dom) {
  3636. f.table.dom.style[h] = g
  3637. }
  3638. }
  3639. };
  3640. var d = a.view.lockingPartner;
  3641. if (d) {
  3642. var e = a.onLockRefresh;
  3643. var c = function(f) {
  3644. if (f.table.dom) {
  3645. e.apply(this, arguments)
  3646. }
  3647. };
  3648. d.un("refresh", e, a);
  3649. d.on("refresh", c, a);
  3650. a.onLockRefresh = c
  3651. }
  3652. a.view.un("render", a.onViewRender, a);
  3653. a.onViewRender = function() {
  3654. var g = this, f = g.view.el;
  3655. f.setStyle("position", "relative");
  3656. g.stretcher = f.createChild({
  3657. style : {
  3658. position : "absolute",
  3659. width : "1px",
  3660. height : 0,
  3661. top : 0,
  3662. left : 0
  3663. }
  3664. }, f.dom.firstChild)
  3665. };
  3666. a.view.on("render", a.onViewRender, a);
  3667. if (Ext.getVersion("extjs").isLessThan("4.1.3")) {
  3668. a.scrollTo = function(m, g, p, r) {
  3669. var j = this, l = j.view, q = l.el.dom, n = j.store, k = n
  3670. .getTotalCount(), i, f, h, o;
  3671. m = Math.min(Math.max(m, 0), k - 1);
  3672. i = Math
  3673. .max(
  3674. Math
  3675. .min(
  3676. m
  3677. - ((j.leadingBufferZone + j.trailingBufferZone) / 2),
  3678. k - j.viewSize + 1), 0);
  3679. o = i * j.rowHeight;
  3680. f = i + j.viewSize - 1;
  3681. j.lastScrollDirection = undefined;
  3682. j.disabled = true;
  3683. n.guaranteeRange(i, f, function() {
  3684. h = n.pageMap.getRange(m, m)[0];
  3685. l.table.dom.style.top = o + "px";
  3686. q.scrollTop = o = Math.min(Math.max(0,
  3687. o
  3688. - l.table.getOffsetsTo(l
  3689. .getNode(h))[1]),
  3690. q.scrollHeight - q.clientHeight);
  3691. if (Ext.isIE) {
  3692. q.scrollTop = o
  3693. }
  3694. j.disabled = false;
  3695. if (g) {
  3696. j.grid.selModel.select(h)
  3697. }
  3698. if (p) {
  3699. p.call(r || j, m, h)
  3700. }
  3701. })
  3702. }
  3703. }
  3704. },
  3705. onLockedViewScroll : function() {
  3706. if (this.store.buffered) {
  3707. var a = this.normalGrid.getView().el;
  3708. if (!a || !a.child("table", true)) {
  3709. return
  3710. }
  3711. }
  3712. return this.callParent(arguments)
  3713. },
  3714. onNormalViewScroll : function() {
  3715. if (this.store.buffered) {
  3716. var a = this.lockedGrid.getView().el;
  3717. if (!a || !a.child("table", true)) {
  3718. return
  3719. }
  3720. }
  3721. return this.callParent(arguments)
  3722. },
  3723. setupLockableTree : function() {
  3724. var h = this;
  3725. var i = h.store.buffered;
  3726. var c = h.getView();
  3727. var l = h.lockedGrid.getView();
  3728. var d = h.normalGrid.getView();
  3729. var j = d.store;
  3730. var b = h.store;
  3731. var e = Sch.mixin.FilterableTreeView.prototype;
  3732. l.initTreeFiltering = e.initTreeFiltering;
  3733. l.onFilterChangeStart = e.onFilterChangeStart;
  3734. l.onFilterChangeEnd = e.onFilterChangeEnd;
  3735. l.onFilterCleared = e.onFilterCleared;
  3736. l.onFilterSet = e.onFilterSet;
  3737. l.initTreeFiltering();
  3738. if (i) {
  3739. b.on("nodestore-datachange-end", function() {
  3740. if (d.rendered) {
  3741. h.onNormalViewScroll()
  3742. }
  3743. })
  3744. } else {
  3745. this.mon(b, {
  3746. "root-fill-start" : function() {
  3747. j.suspendEvents()
  3748. },
  3749. "root-fill-end" : function() {
  3750. j.resumeEvents();
  3751. c.refresh()
  3752. }
  3753. })
  3754. }
  3755. this.mon(b, "filter", function(n, m) {
  3756. j.filter.apply(j, m);
  3757. c.refresh()
  3758. });
  3759. this.mon(b, "clearfilter", function(m) {
  3760. j.clearFilter();
  3761. c.refresh()
  3762. });
  3763. var g = h.normalGrid.verticalScroller;
  3764. if (i && g) {
  3765. var a = g.onGuaranteedRange;
  3766. g.onGuaranteedRange = function() {
  3767. a.apply(this, arguments);
  3768. Ext.suspendLayouts();
  3769. c.refresh();
  3770. Ext.resumeLayouts()
  3771. }
  3772. }
  3773. var k = l.onAdd;
  3774. var f = l.onRemove;
  3775. l.onAdd = function() {
  3776. Ext.suspendLayouts();
  3777. k.apply(this, arguments);
  3778. Ext.resumeLayouts()
  3779. };
  3780. l.onRemove = function() {
  3781. Ext.suspendLayouts();
  3782. f.apply(this, arguments);
  3783. Ext.resumeLayouts()
  3784. }
  3785. },
  3786. onNormalViewItemUpdate : function(a, b, d) {
  3787. d = d.dom ? d.dom : d;
  3788. if (this.lockedGridDependsOnSchedule) {
  3789. var c = this.lockedGrid.getView();
  3790. c.suspendEvents();
  3791. c.onUpdate(this.lockedGrid.store, a);
  3792. c.resumeEvents()
  3793. }
  3794. var f = this.normalGrid.getView().getNode(b);
  3795. var e = f.style.height !== d.style.height;
  3796. f.style.height = d.style.height;
  3797. this.normalHeights[b] = d.style.height;
  3798. this.syncRowHeights(e)
  3799. },
  3800. afterNormalGridItemExpand : function(a) {
  3801. var c = this;
  3802. var b = c.getSchedulingView();
  3803. a.cascadeBy(function(f) {
  3804. if (f !== a) {
  3805. var e = b.getNode(f);
  3806. if (e) {
  3807. var d = b.indexOf(e);
  3808. c.normalHeights[d] = e.style.height
  3809. }
  3810. }
  3811. });
  3812. c.syncRowHeights(true)
  3813. },
  3814. onViewItemAdd : function(c, d, b) {
  3815. var e = this.normalGrid.getView();
  3816. var f = this.lockedGrid.getView();
  3817. if (e.getNodes().length !== f.getNodes().length) {
  3818. return
  3819. }
  3820. var a = this.normalHeights;
  3821. Ext.each(c, function(h, g) {
  3822. var i = e.getNode(h);
  3823. if (i) {
  3824. a[i.viewIndex] = i.style.height
  3825. }
  3826. });
  3827. this.syncRowHeights()
  3828. },
  3829. processColumns : function(b) {
  3830. var a = this.callParent(arguments);
  3831. var c = [];
  3832. Ext.each(b, function(d) {
  3833. if (d.position == "right") {
  3834. d.processed = true;
  3835. if (!Ext.isNumber(d.width)) {
  3836. Ext.Error
  3837. .raise('"Right" columns must have a fixed width')
  3838. }
  3839. c.push(d);
  3840. Ext.Array.remove(a.locked.items, d);
  3841. a.lockedWidth -= d.width
  3842. }
  3843. });
  3844. if (this.orientation === "horizontal") {
  3845. a.normal.items = [{
  3846. xtype : this.lightWeight
  3847. ? "singletimeaxiscolumn"
  3848. : "timeaxiscolumn",
  3849. timeAxis : this.timeAxis,
  3850. timeCellRenderer : this.timeCellRenderer,
  3851. timeCellRendererScope : this.timeCellRendererScope,
  3852. trackHeaderOver : this.trackHeaderOver
  3853. }].concat(c)
  3854. } else {
  3855. a.locked.items = [Ext.apply({
  3856. xtype : "verticaltimeaxis",
  3857. width : 100,
  3858. timeAxis : this.timeAxis
  3859. }, this.timeAxisColumnCfg || {})];
  3860. a.lockedWidth = a.locked.items[0].width
  3861. }
  3862. return a
  3863. },
  3864. prepareFullRowHeightSync : function() {
  3865. var g = this, h = g.normalGrid.getView(), j = g.lockedGrid.getView();
  3866. if (!h.rendered || !j.rendered) {
  3867. return
  3868. }
  3869. var a = h.el, d = j.el, f = a.query(h.getItemSelector()), b = d.query(j
  3870. .getItemSelector()), e = f.length, c = 0;
  3871. g.lockedHeights = [];
  3872. g.normalHeights = [];
  3873. if (b.length !== e) {
  3874. return
  3875. }
  3876. for (; c < e; c++) {
  3877. g.normalHeights[c] = f[c].style.height
  3878. }
  3879. },
  3880. onLockedViewRefresh : function() {
  3881. this.prepareFullRowHeightSync();
  3882. this.syncRowHeights()
  3883. },
  3884. onNormalViewRefresh : function() {
  3885. var a = this.lockedGrid.getView();
  3886. if (this.lockedGridDependsOnSchedule) {
  3887. a.un("refresh", this.onLockedViewRefresh, this);
  3888. this.lockedGrid.getView().refresh();
  3889. a.on("refresh", this.onLockedViewRefresh, this)
  3890. }
  3891. this.prepareFullRowHeightSync();
  3892. this.syncRowHeights()
  3893. },
  3894. syncRowHeights : function(b) {
  3895. if (!this.lockedGrid.getView().rendered
  3896. || !this.normalGrid.getView().rendered) {
  3897. return
  3898. }
  3899. var j = this, c = j.lockedHeights, k = j.normalHeights, a = [], h = c.length
  3900. || k.length, f = 0, l, d, e, g;
  3901. if (c.length || k.length) {
  3902. l = j.lockedGrid.getView();
  3903. d = j.normalGrid.getView();
  3904. e = l.el.query(l.getItemSelector());
  3905. g = d.el.query(d.getItemSelector());
  3906. if (g.length !== e.length) {
  3907. return
  3908. }
  3909. for (; f < h; f++) {
  3910. if (e[f] && k[f]) {
  3911. e[f].style.height = k[f]
  3912. }
  3913. }
  3914. j.lockedHeights = [];
  3915. j.normalHeights = []
  3916. }
  3917. if (b !== false) {
  3918. j.updateSpacer()
  3919. }
  3920. },
  3921. getMenuItems : function() {
  3922. if (Ext.versions.extjs.isGreaterThanOrEqual("4.1.2")) {
  3923. return this.callParent(arguments)
  3924. }
  3925. return function() {
  3926. return Ext.grid.header.Container.prototype.getMenuItems.apply(this,
  3927. arguments)
  3928. }
  3929. },
  3930. applyColumnsState : Ext.emptyFn,
  3931. updateSpacer : function() {
  3932. var g = this.lockedGrid.getView();
  3933. var e = this.normalGrid.getView();
  3934. if (g.rendered && e.rendered && g.el.child("table")
  3935. && !this.getSchedulingView().__lightRefresh) {
  3936. var f = this, c = g.el, d = e.el.dom, b = c.dom.id + "-spacer", h = (d.offsetHeight - d.clientHeight)
  3937. + "px";
  3938. f.spacerEl = Ext.getDom(b);
  3939. if (Ext.isIE6 || Ext.isIE7 || (Ext.isIEQuirks && Ext.isIE8)
  3940. && f.spacerEl) {
  3941. Ext.removeNode(f.spacerEl);
  3942. f.spacerEl = null
  3943. }
  3944. if (f.spacerEl) {
  3945. f.spacerEl.style.height = h
  3946. } else {
  3947. var a;
  3948. if (this.store.buffered) {
  3949. a = f.normalGrid.verticalScroller.stretcher.item(0).dom.parentNode === c.dom
  3950. ? f.normalGrid.verticalScroller.stretcher.item(0)
  3951. : f.normalGrid.verticalScroller.stretcher.item(1)
  3952. } else {
  3953. a = c
  3954. }
  3955. Ext.core.DomHelper.append(a, {
  3956. id : b,
  3957. cls : this.store.buffered
  3958. ? "sch-locked-buffered-spacer"
  3959. : "",
  3960. style : "height: " + h
  3961. })
  3962. }
  3963. }
  3964. },
  3965. onLockedViewRender : function() {
  3966. var e = this.normalGrid;
  3967. if (!this.lockedStretcher) {
  3968. var c = this.lockedGrid.getView().el;
  3969. var a = this.lockedStretcher = c.createChild({
  3970. cls : "x-stretcher",
  3971. style : {
  3972. position : "absolute",
  3973. width : "1px",
  3974. height : 0,
  3975. top : 0,
  3976. left : 0
  3977. }
  3978. }, c.dom.firstChild)
  3979. }
  3980. if (!e.rendered) {
  3981. e.getView().on("render", this.onLockedViewRender, this);
  3982. return
  3983. }
  3984. var d = this;
  3985. setTimeout(function() {
  3986. var f = e.getView().el;
  3987. if (f && f.dom) {
  3988. e.getView().el.un("scroll", d.onNormalViewScroll, d);
  3989. e.getView().el.on("scroll", d.onNormalViewScroll, d)
  3990. }
  3991. }, 0);
  3992. var b = e.verticalScroller;
  3993. b.stretcher.addCls("x-stretcher");
  3994. b.stretcher = new Ext.dom.CompositeElement([this.lockedStretcher,
  3995. b.stretcher])
  3996. },
  3997. onNormalViewGroupExpand : function() {
  3998. this.prepareFullRowHeightSync();
  3999. this.syncRowHeights()
  4000. },
  4001. overrideNodeStore : function(c) {
  4002. var a = c.onNodeCollapse;
  4003. var b = c.onNodeExpand;
  4004. c.onNodeCollapse = function() {
  4005. Ext.suspendLayouts();
  4006. a.apply(this, arguments);
  4007. Ext.resumeLayouts()
  4008. };
  4009. c.onNodeExpand = function() {
  4010. Ext.suspendLayouts();
  4011. b.apply(this, arguments);
  4012. Ext.resumeLayouts()
  4013. }
  4014. }
  4015. });
  4016. Ext.define("Sch.model.Customizable", {
  4017. extend : "Ext.data.Model",
  4018. customizableFields : null,
  4019. onClassExtended : function(b, d, a) {
  4020. var c = a.onBeforeCreated;
  4021. a.onBeforeCreated = function(f, k) {
  4022. c.call(this, f, k);
  4023. var j = f.prototype;
  4024. if (!j.customizableFields) {
  4025. return
  4026. }
  4027. j.customizableFields = (f.superclass.customizableFields || [])
  4028. .concat(j.customizableFields);
  4029. var g = j.customizableFields;
  4030. var i = {};
  4031. Ext.Array.each(g, function(l) {
  4032. if (typeof l == "string") {
  4033. l = {
  4034. name : l
  4035. }
  4036. }
  4037. i[l.name] = l
  4038. });
  4039. var e = j.fields;
  4040. var h = [];
  4041. e.each(function(l) {
  4042. if (l.isCustomizableField) {
  4043. h.push(l)
  4044. }
  4045. });
  4046. e.removeAll(h);
  4047. Ext.Object.each(i, function(l, o) {
  4048. o.isCustomizableField = true;
  4049. var p = o.name;
  4050. var t = p === "Id" ? "idProperty" : p.charAt(0).toLowerCase()
  4051. + p.substr(1) + "Field";
  4052. var q = j[t];
  4053. var s = q || p;
  4054. if (e.containsKey(s)) {
  4055. e.getByKey(s).isCustomizableField = true;
  4056. g.push(new Ext.data.Field(Ext.applyIf({
  4057. name : p,
  4058. isCustomizableField : true
  4059. }, e.getByKey(s))))
  4060. } else {
  4061. e.add(new Ext.data.Field(Ext.applyIf({
  4062. name : s,
  4063. isCustomizableField : true
  4064. }, o)))
  4065. }
  4066. var n = Ext.String.capitalize(p);
  4067. if (n != "Id") {
  4068. var r = "get" + n;
  4069. var m = "set" + n;
  4070. if (!j[r] || j[r].__getterFor__ && j[r].__getterFor__ != s) {
  4071. j[r] = function() {
  4072. return this.data[s]
  4073. };
  4074. j[r].__getterFor__ = s
  4075. }
  4076. if (!j[m] || j[m].__setterFor__ && j[m].__setterFor__ != s) {
  4077. j[m] = function(u) {
  4078. return this.set(s, u)
  4079. };
  4080. j[m].__setterFor__ = s
  4081. }
  4082. }
  4083. })
  4084. }
  4085. },
  4086. set : function(c, b) {
  4087. if (arguments.length === 2) {
  4088. this.previous = this.previous || {};
  4089. var a = this.get(c);
  4090. if (a !== b) {
  4091. this.previous[c] = a
  4092. }
  4093. }
  4094. this.callParent(arguments)
  4095. },
  4096. afterEdit : function() {
  4097. this.callParent(arguments);
  4098. delete this.previous
  4099. },
  4100. reject : function() {
  4101. var b = this, a = b.modified, c;
  4102. b.previous = b.previous || {};
  4103. for (c in a) {
  4104. if (a.hasOwnProperty(c)) {
  4105. if (typeof a[c] != "function") {
  4106. b.previous[c] = b.get(c)
  4107. }
  4108. }
  4109. }
  4110. b.callParent(arguments);
  4111. delete b.previous
  4112. }
  4113. });
  4114. Ext.define("Sch.patches.Model", {
  4115. extend : "Sch.util.Patch",
  4116. requires : "Sch.model.Customizable",
  4117. //reportURL : "http://www.sencha.com/forum/showthread.php?198250-4.1-Ext.data.Model-regression",
  4118. //description : "In Ext 4.1 Models cannot be subclassed",
  4119. maxVersion : "4.1.0",
  4120. applyFn : function() {
  4121. try {
  4122. Ext.define("Sch.foo", {
  4123. extend : "Ext.data.Model",
  4124. fields : ["a"]
  4125. });
  4126. Ext.define("Sch.foo.Sub", {
  4127. extend : "Sch.foo",
  4128. fields : ["a"]
  4129. })
  4130. } catch (a) {
  4131. Ext.data.Types.AUTO.convert = function(b) {
  4132. return b
  4133. }
  4134. }
  4135. }
  4136. });
  4137. Ext.define("Sch.model.Range", {
  4138. extend : "Sch.model.Customizable",
  4139. requires : ["Sch.util.Date", "Sch.patches.DataOperation"],
  4140. startDateField : "StartDate",
  4141. endDateField : "EndDate",
  4142. nameField : "Name",
  4143. clsField : "Cls",
  4144. customizableFields : [{
  4145. name : "StartDate",
  4146. type : "date",
  4147. dateFormat : "c"
  4148. }, {
  4149. name : "EndDate",
  4150. type : "date",
  4151. dateFormat : "c"
  4152. }, {
  4153. name : "Cls",
  4154. type : "string"
  4155. }, {
  4156. name : "Name",
  4157. type : "string"
  4158. }],
  4159. setStartDate : function(a, d) {
  4160. var c = this.getEndDate();
  4161. var b = this.getStartDate();
  4162. this.set(this.startDateField, a);
  4163. if (d === true && c && b) {
  4164. this.setEndDate(Sch.util.Date.add(a, Sch.util.Date.MILLI, c - b))
  4165. }
  4166. },
  4167. setEndDate : function(b, d) {
  4168. var a = this.getStartDate();
  4169. var c = this.getEndDate();
  4170. this.set(this.endDateField, b);
  4171. if (d === true && a && c) {
  4172. this.setStartDate(Sch.util.Date.add(b, Sch.util.Date.MILLI,
  4173. -(c - a)))
  4174. }
  4175. },
  4176. setStartEndDate : function(b, a) {
  4177. this.beginEdit();
  4178. this.set(this.startDateField, b);
  4179. this.set(this.endDateField, a);
  4180. this.endEdit()
  4181. },
  4182. getDates : function() {
  4183. var c = [], b = this.getEndDate();
  4184. for (var a = Ext.Date.clearTime(this.getStartDate(), true); a < b; a = Sch.util.Date
  4185. .add(a, Sch.util.Date.DAY, 1)) {
  4186. c.push(a)
  4187. }
  4188. return c
  4189. },
  4190. forEachDate : function(b, a) {
  4191. return Ext.each(this.getDates(), b, a)
  4192. },
  4193. isValid : function() {
  4194. var b = this.callParent(arguments);
  4195. if (b) {
  4196. var c = this.getStartDate(), a = this.getEndDate();
  4197. b = !c || !a || (a - c >= 0)
  4198. }
  4199. return b
  4200. },
  4201. shift : function(b, a) {
  4202. this.setStartEndDate(Sch.util.Date.add(this.getStartDate(), b, a),
  4203. Sch.util.Date.add(this.getEndDate(), b, a))
  4204. }
  4205. });
  4206. Ext.define("Sch.model.Event", {
  4207. extend : "Sch.model.Range",
  4208. idProperty : "Id",
  4209. customizableFields : [{
  4210. name : "Id"
  4211. }, {
  4212. name : "ResourceId"
  4213. }, {
  4214. name : "Draggable",
  4215. type : "boolean",
  4216. persist : false,
  4217. defaultValue : true
  4218. }, {
  4219. name : "Resizable",
  4220. persist : false,
  4221. defaultValue : true
  4222. }],
  4223. resourceIdField : "ResourceId",
  4224. draggableField : "Draggable",
  4225. resizableField : "Resizable",
  4226. getResource : function(b) {
  4227. if (this.stores.length > 0) {
  4228. var a = this.stores[0].resourceStore;
  4229. b = b || this.get(this.resourceIdField);
  4230. if (Ext.data.TreeStore && a instanceof Ext.data.TreeStore) {
  4231. return a.getNodeById(b)
  4232. || a.getRootNode().findChildBy(function(c) {
  4233. return c.internalId === b
  4234. })
  4235. } else {
  4236. return a.getById(b) || a.data.map[b]
  4237. }
  4238. }
  4239. return null
  4240. },
  4241. setResource : function(a) {
  4242. this.set(this.resourceIdField, (a instanceof Ext.data.Model)
  4243. ? a.getId() || a.internalId
  4244. : a)
  4245. },
  4246. assign : function(a) {
  4247. this.setResource.apply(this, arguments)
  4248. },
  4249. unassign : function(a) {
  4250. },
  4251. isDraggable : function() {
  4252. return this.getDraggable()
  4253. },
  4254. isResizable : function() {
  4255. return this.getResizable()
  4256. },
  4257. isPersistable : function() {
  4258. var b = this.getResources();
  4259. var a = true;
  4260. Ext.each(b, function(c) {
  4261. if (c.phantom) {
  4262. a = false;
  4263. return false
  4264. }
  4265. });
  4266. return a
  4267. },
  4268. forEachResource : function(d, c) {
  4269. var a = this.getResources();
  4270. for (var b = 0; b < a.length; b++) {
  4271. if (d.call(c || this, a[b]) === false) {
  4272. return
  4273. }
  4274. }
  4275. },
  4276. getResources : function() {
  4277. var a = this.getResource();
  4278. return a ? [a] : []
  4279. }
  4280. });
  4281. Ext.define("Sch.model.Resource", {
  4282. extend : "Sch.model.Customizable",
  4283. idProperty : "Id",
  4284. nameField : "Name",
  4285. customizableFields : ["Id", {
  4286. name : "Name",
  4287. type : "string"
  4288. }],
  4289. getEventStore : function() {
  4290. return this.stores[0] && this.stores[0].eventStore
  4291. || this.parentNode && this.parentNode.getEventStore()
  4292. },
  4293. getEvents : function(d) {
  4294. var c = [], e, f = this.getId() || this.internalId;
  4295. d = d || this.getEventStore();
  4296. for (var b = 0, a = d.getCount(); b < a; b++) {
  4297. e = d.getAt(b);
  4298. if (e.data[e.resourceIdField] === f) {
  4299. c.push(e)
  4300. }
  4301. }
  4302. return c
  4303. }
  4304. });
  4305. Ext.define("Sch.data.mixin.EventStore", {
  4306. model : "Sch.model.Event",
  4307. requires : ["Sch.util.Date"],
  4308. isEventStore : true,
  4309. setResourceStore : function(a) {
  4310. if (this.resourceStore) {
  4311. this.resourceStore.un({
  4312. beforesync : this.onResourceStoreBeforeSync,
  4313. write : this.onResourceStoreWrite,
  4314. scope : this
  4315. })
  4316. }
  4317. this.resourceStore = a;
  4318. if (a) {
  4319. a.on({
  4320. beforesync : this.onResourceStoreBeforeSync,
  4321. write : this.onResourceStoreWrite,
  4322. scope : this
  4323. })
  4324. }
  4325. },
  4326. onResourceStoreBeforeSync : function(b, c) {
  4327. var a = b.create;
  4328. if (a) {
  4329. for (var e, d = a.length - 1; d >= 0; d--) {
  4330. e = a[d];
  4331. e._phantomId = e.internalId
  4332. }
  4333. }
  4334. },
  4335. onResourceStoreWrite : function(c, b) {
  4336. if (b.wasSuccessful()) {
  4337. var d = this, a = b.getRecords();
  4338. Ext.each(a, function(e) {
  4339. if (e._phantomId && !e.phantom) {
  4340. d.each(function(f) {
  4341. if (f.getResourceId() === e._phantomId) {
  4342. f.assign(e)
  4343. }
  4344. })
  4345. }
  4346. })
  4347. }
  4348. },
  4349. isDateRangeAvailable : function(f, a, b, d) {
  4350. var c = true, e = Sch.util.Date;
  4351. this.each(function(g) {
  4352. if (e
  4353. .intersectSpans(f, a, g.getStartDate(), g
  4354. .getEndDate())
  4355. && d === g.getResource() && (!b || b !== g)) {
  4356. c = false;
  4357. return false
  4358. }
  4359. });
  4360. return c
  4361. },
  4362. getEventsInTimeSpan : function(d, b, a) {
  4363. if (a !== false) {
  4364. var c = Sch.util.Date;
  4365. return this.queryBy(function(g) {
  4366. var f = g.getStartDate(), e = g.getEndDate();
  4367. return f && e && c.intersectSpans(f, e, d, b)
  4368. })
  4369. } else {
  4370. return this.queryBy(function(g) {
  4371. var f = g.getStartDate(), e = g.getEndDate();
  4372. return f && e && (f - d >= 0) && (b - e >= 0)
  4373. })
  4374. }
  4375. },
  4376. getTotalTimeSpan : function() {
  4377. var a = new Date(9999, 0, 1), b = new Date(0), c = Sch.util.Date;
  4378. this.each(function(d) {
  4379. if (d.getStartDate()) {
  4380. a = c.min(d.getStartDate(), a)
  4381. }
  4382. if (d.getEndDate()) {
  4383. b = c.max(d.getEndDate(), b)
  4384. }
  4385. });
  4386. a = a < new Date(9999, 0, 1) ? a : null;
  4387. b = b > new Date(0) ? b : null;
  4388. return {
  4389. start : a || null,
  4390. end : b || a || null
  4391. }
  4392. },
  4393. getEventsForResource : function(e) {
  4394. var c = [], d, f = e.getId() || e.internalId;
  4395. for (var b = 0, a = this.getCount(); b < a; b++) {
  4396. d = this.getAt(b);
  4397. if (d.data[d.resourceIdField] === f) {
  4398. c.push(d)
  4399. }
  4400. }
  4401. return c
  4402. },
  4403. getClosestSuccessor : function(g, e) {
  4404. var c = Infinity, a = g.getEnd(), f, h;
  4405. e = e || this.getRange();
  4406. for (var d = 0, b = e.length; d < b; d++) {
  4407. h = e[d].getStart() - a;
  4408. if (h >= 0 && h < c) {
  4409. f = e[d];
  4410. c = h
  4411. }
  4412. }
  4413. return f
  4414. }
  4415. });
  4416. Ext.define("Sch.data.EventStore", {
  4417. extend : "Ext.data.Store",
  4418. mixins : ["Sch.data.mixin.EventStore"],
  4419. getByInternalId : function(a) {
  4420. return this.data.getByKey(a)
  4421. }
  4422. });
  4423. Ext.define("Sch.data.mixin.ResourceStore", {});
  4424. Ext.define("Sch.data.FilterableNodeStore", {
  4425. extend : "Ext.data.NodeStore",
  4426. onNodeExpand : function(f, d, c) {
  4427. var b = [];
  4428. for (var e = 0; e < d.length; e++) {
  4429. var a = d[e];
  4430. if (!(a.isHidden && a.isHidden() || a.hidden || a.data.hidden)) {
  4431. b[b.length] = a
  4432. }
  4433. }
  4434. return this.callParent([f, b, c])
  4435. }
  4436. });
  4437. Ext.define("Sch.data.mixin.FilterableTreeStore", {
  4438. requires : ["Sch.data.FilterableNodeStore"],
  4439. nodeStoreClassName : "Sch.data.FilterableNodeStore",
  4440. nodeStore : null,
  4441. isFilteredFlag : false,
  4442. initTreeFiltering : function() {
  4443. if (!this.nodeStore) {
  4444. this.nodeStore = this.createNodeStore(this)
  4445. }
  4446. this.addEvents("filter-set", "filter-clear",
  4447. "nodestore-datachange-start", "nodestore-datachange-end")
  4448. },
  4449. createNodeStore : function(a) {
  4450. return Ext.create(this.nodeStoreClassName, {
  4451. treeStore : a,
  4452. recursive : true,
  4453. rootVisible : this.rootVisible
  4454. })
  4455. },
  4456. clearTreeFilter : function() {
  4457. if (!this.isTreeFiltered()) {
  4458. return
  4459. }
  4460. this.refreshNodeStoreContent();
  4461. this.isFilteredFlag = false;
  4462. this.fireEvent("filter-clear", this)
  4463. },
  4464. refreshNodeStoreContent : function(f) {
  4465. var a = this.getRootNode(), d = [];
  4466. var c = this.rootVisible;
  4467. var b = function(i) {
  4468. if (i.isHidden && i.isHidden() || i.hidden || i.data.hidden) {
  4469. return
  4470. }
  4471. if (c || i != a) {
  4472. d[d.length] = i
  4473. }
  4474. if (!i.data.leaf && i.isExpanded()) {
  4475. var j = i.childNodes, h = j.length;
  4476. for (var g = 0; g < h; g++) {
  4477. b(j[g])
  4478. }
  4479. }
  4480. };
  4481. b(a);
  4482. this.fireEvent("nodestore-datachange-start", this);
  4483. var e = this.nodeStore;
  4484. if (!this.loadDataInNodeStore || !this.loadDataInNodeStore(d)) {
  4485. e.loadRecords(d)
  4486. }
  4487. if (!f) {
  4488. e.fireEvent("clear", e)
  4489. }
  4490. this.fireEvent("nodestore-datachange-end", this)
  4491. },
  4492. getIndexInTotalDataset : function(b) {
  4493. var a = this.getRootNode();
  4494. index = -1;
  4495. var d = this.rootVisible;
  4496. if (!d && b == a) {
  4497. return -1
  4498. }
  4499. var c = function(g) {
  4500. if (g.isHidden && g.isHidden() || g.hidden || g.data.hidden) {
  4501. if (g == b) {
  4502. return false
  4503. }
  4504. }
  4505. if (d || g != a) {
  4506. index++
  4507. }
  4508. if (g == b) {
  4509. return false
  4510. }
  4511. if (!g.data.leaf && g.isExpanded()) {
  4512. var h = g.childNodes, f = h.length;
  4513. for (var e = 0; e < f; e++) {
  4514. if (c(h[e]) === false) {
  4515. return false
  4516. }
  4517. }
  4518. }
  4519. };
  4520. c(a);
  4521. return index
  4522. },
  4523. isTreeFiltered : function() {
  4524. return this.isFilteredFlag
  4525. },
  4526. filterTreeBy : function(s, b) {
  4527. var g;
  4528. if (arguments.length == 1 && Ext.isObject(arguments[0])) {
  4529. b = s.scope;
  4530. g = s.filter
  4531. } else {
  4532. g = s;
  4533. s = {}
  4534. }
  4535. this.fireEvent("nodestore-datachange-start", this);
  4536. s = s || {};
  4537. var j = s.shallow;
  4538. var r = s.checkParents || j;
  4539. var h = s.fullMathchingParents;
  4540. var c = s.onlyParents || h;
  4541. var e = this.rootVisible;
  4542. if (c && r) {
  4543. throw new Error("Can't combine `onlyParents` and `checkParents` options")
  4544. }
  4545. var o = {};
  4546. var m = this.getRootNode(), d = [];
  4547. var a = function(t) {
  4548. var i = t.parentNode;
  4549. while (i && !o[i.internalId]) {
  4550. o[i.internalId] = true;
  4551. i = i.parentNode
  4552. }
  4553. };
  4554. var k = function(v) {
  4555. if (v.isHidden && v.isHidden() || v.hidden || v.data.hidden) {
  4556. return
  4557. }
  4558. var t, w, u, i;
  4559. if (v.data.leaf) {
  4560. if (g.call(b, v, o)) {
  4561. d[d.length] = v;
  4562. a(v)
  4563. }
  4564. } else {
  4565. if (e || v != m) {
  4566. d[d.length] = v
  4567. }
  4568. if (c) {
  4569. t = g.call(b, v);
  4570. w = v.childNodes;
  4571. u = w.length;
  4572. if (t) {
  4573. o[v.internalId] = true;
  4574. a(v);
  4575. if (h) {
  4576. v.cascadeBy(function(x) {
  4577. d[d.length] = x;
  4578. if (!x.data.leaf) {
  4579. o[x.internalId] = true
  4580. }
  4581. });
  4582. return
  4583. }
  4584. }
  4585. for (i = 0; i < u; i++) {
  4586. if (t && w[i].data.leaf) {
  4587. d[d.length] = w[i]
  4588. } else {
  4589. if (!w[i].data.leaf) {
  4590. k(w[i])
  4591. }
  4592. }
  4593. }
  4594. } else {
  4595. if (r) {
  4596. t = g.call(b, v, o);
  4597. if (t) {
  4598. o[v.internalId] = true;
  4599. a(v)
  4600. }
  4601. }
  4602. if (!r || !j || j && (t || v == m && !e)) {
  4603. w = v.childNodes;
  4604. u = w.length;
  4605. for (i = 0; i < u; i++) {
  4606. k(w[i])
  4607. }
  4608. }
  4609. }
  4610. }
  4611. };
  4612. k(m);
  4613. var f = [];
  4614. for (var p = 0, q = d.length; p < q; p++) {
  4615. var l = d[p];
  4616. if (l.data.leaf || o[l.internalId]) {
  4617. f[f.length] = l
  4618. }
  4619. }
  4620. var n = this.nodeStore;
  4621. if (!this.loadDataInNodeStore || !this.loadDataInNodeStore(f)) {
  4622. n.loadRecords(f, false);
  4623. n.fireEvent("clear", n)
  4624. }
  4625. this.isFilteredFlag = true;
  4626. this.fireEvent("nodestore-datachange-end", this);
  4627. this.fireEvent("filter-set", this)
  4628. },
  4629. hideNodesBy : function(b, a) {
  4630. if (this.isFiltered()) {
  4631. throw new Error("Can't hide nodes of the filtered tree store")
  4632. }
  4633. var c = this;
  4634. a = a || this;
  4635. this.getRootNode().cascadeBy(function(d) {
  4636. d.hidden = b.call(a, d, c)
  4637. });
  4638. this.refreshNodeStoreContent()
  4639. },
  4640. showAllNodes : function() {
  4641. this.getRootNode().cascadeBy(function(a) {
  4642. a.hidden = a.data.hidden = false
  4643. });
  4644. this.refreshNodeStoreContent()
  4645. }
  4646. });
  4647. Ext.define("Sch.data.mixin.BufferableTreeStore", {
  4648. viewSize : 50,
  4649. buffered : false,
  4650. rangeStart : null,
  4651. rangeEnd : null,
  4652. initTreeBuffering : function() {
  4653. if (!this.buffered) {
  4654. return
  4655. }
  4656. var b = this;
  4657. var a = {
  4658. append : this.updateBufferedNodeStore,
  4659. insert : this.updateBufferedNodeStore,
  4660. remove : this.updateBufferedNodeStore,
  4661. move : this.updateBufferedNodeStore,
  4662. expand : this.updateBufferedNodeStore,
  4663. collapse : this.updateBufferedNodeStore,
  4664. sort : this.updateBufferedNodeStore,
  4665. scope : this,
  4666. buffer : 1
  4667. };
  4668. this.on(a);
  4669. this.on("root-fill-start", function() {
  4670. b.nodeStore.suspendEvents();
  4671. b.un(a);
  4672. b.nodeStore.setNode()
  4673. });
  4674. this.on("root-fill-end", function() {
  4675. b.nodeStore.resumeEvents();
  4676. b.on(a);
  4677. this.updateBufferedNodeStore()
  4678. })
  4679. },
  4680. updateBufferedNodeStore : function() {
  4681. this.refreshNodeStoreContent(true)
  4682. },
  4683. loadDataInNodeStore : function(a) {
  4684. if (!this.buffered) {
  4685. return false
  4686. }
  4687. var b = this.nodeStore;
  4688. b.totalCount = a.length;
  4689. if (!a.length) {
  4690. b.removeAll()
  4691. }
  4692. b.cachePage(a, 1);
  4693. this.guaranteeRange(this.rangeStart || 0, this.rangeEnd
  4694. || this.viewSize || 50);
  4695. return true
  4696. },
  4697. guaranteeRange : function(e, d) {
  4698. var b = this.viewSize || 50;
  4699. var f = this.nodeStore;
  4700. var a = f.getTotalCount();
  4701. if (a) {
  4702. var c = d - e + 1;
  4703. if (c < b && a >= c) {
  4704. d = e + b - 1
  4705. }
  4706. if (d >= a) {
  4707. e = a - (d - e);
  4708. d = a - 1;
  4709. e = Math.max(0, e)
  4710. }
  4711. f.guaranteeRange(e, d)
  4712. }
  4713. },
  4714. createNodeStore : function(a) {
  4715. var b = Ext.create(this.nodeStoreClassName
  4716. || "Ext.data.NodeStore", {
  4717. treeStore : a,
  4718. recursive : true,
  4719. rootVisible : this.rootVisible,
  4720. buffered : a.buffered,
  4721. purgePageCount : 0,
  4722. pageSize : 10000000000
  4723. });
  4724. if (a.buffered) {
  4725. this.mon(b, "guaranteedrange", function(d, e, c) {
  4726. this.rangeStart = e;
  4727. this.rangeEnd = c
  4728. }, this)
  4729. }
  4730. return b
  4731. }
  4732. });
  4733. Ext.define("Sch.data.ResourceStore", {
  4734. extend : "Ext.data.Store",
  4735. model : "Sch.model.Resource",
  4736. mixins : ["Sch.data.mixin.ResourceStore"]
  4737. });
  4738. Ext.define("Sch.data.ResourceTreeStore", {
  4739. extend : "Ext.data.TreeStore",
  4740. model : "Sch.model.Resource",
  4741. mixins : ["Sch.data.mixin.ResourceStore",
  4742. "Sch.data.mixin.BufferableTreeStore",
  4743. "Sch.data.mixin.FilterableTreeStore"],
  4744. constructor : function() {
  4745. this.callParent(arguments);
  4746. this.initTreeFiltering()
  4747. }
  4748. });
  4749. Ext.define("Sch.data.TimeAxis", {
  4750. extend : "Ext.util.Observable",
  4751. requires : ["Ext.data.JsonStore", "Sch.util.Date"],
  4752. continuous : true,
  4753. autoAdjust : true,
  4754. constructor : function(a) {
  4755. Ext.apply(this, a);
  4756. this.originalContinuous = this.continuous;
  4757. this.addEvents("beforereconfigure", "reconfigure");
  4758. this.tickStore = new Ext.data.JsonStore({
  4759. fields : ["start", "end"]
  4760. });
  4761. this.tickStore.on("datachanged", function() {
  4762. this.fireEvent("reconfigure", this)
  4763. }, this);
  4764. this.callParent(arguments)
  4765. },
  4766. reconfigure : function(a) {
  4767. Ext.apply(this, a);
  4768. var c = this.tickStore, b = this.generateTicks(this.start, this.end,
  4769. this.unit, this.increment || 1, this.mainUnit);
  4770. if (this.fireEvent("beforereconfigure", this, this.start, this.end) !== false) {
  4771. c.suspendEvents(true);
  4772. c.loadData(b);
  4773. if (c.getCount() === 0) {
  4774. Ext.Error
  4775. .raise("Invalid time axis configuration or filter, please check your input data.")
  4776. }
  4777. c.resumeEvents()
  4778. }
  4779. },
  4780. setTimeSpan : function(b, a) {
  4781. this.reconfigure({
  4782. start : b,
  4783. end : a
  4784. })
  4785. },
  4786. filterBy : function(b, a) {
  4787. this.continuous = false;
  4788. a = a || this;
  4789. var c = this.tickStore;
  4790. c.clearFilter(true);
  4791. c.suspendEvents(true);
  4792. c.filter([{
  4793. filterFn : function(e, d) {
  4794. return b.call(a, e.data, d)
  4795. }
  4796. }]);
  4797. if (c.getCount() === 0) {
  4798. Ext.Error
  4799. .raise("Invalid time axis filter - no columns passed through the filter. Please check your filter method.");
  4800. this.clearFilter()
  4801. }
  4802. c.resumeEvents()
  4803. },
  4804. isContinuous : function() {
  4805. return this.continuous && !this.tickStore.isFiltered()
  4806. },
  4807. clearFilter : function() {
  4808. this.continuous = this.originalContinuous;
  4809. this.tickStore.clearFilter()
  4810. },
  4811. generateTicks : function(a, d, g, i) {
  4812. var h = [], f, b = Sch.util.Date, e = 0;
  4813. g = g || this.unit;
  4814. i = i || this.increment;
  4815. if (this.autoAdjust) {
  4816. a = this.floorDate(a || this.getStart(), false);
  4817. d = this.ceilDate(d || b.add(a, this.mainUnit, this.defaultSpan),
  4818. false)
  4819. }
  4820. while (a < d) {
  4821. f = this.getNext(a, g, i);
  4822. if (g === b.HOUR && i > 1 && h.length > 0 && e === 0) {
  4823. var c = h[h.length - 1];
  4824. e = ((c.start.getHours() + i) % 24) - c.end.getHours();
  4825. if (e !== 0) {
  4826. f = b.add(f, b.HOUR, e)
  4827. }
  4828. }
  4829. h.push({
  4830. start : a,
  4831. end : f
  4832. });
  4833. a = f
  4834. }
  4835. return h
  4836. },
  4837. getTickFromDate : function(c) {
  4838. if (this.getStart() > c || this.getEnd() < c) {
  4839. return -1
  4840. }
  4841. var f = this.tickStore.getRange(), e, a, d, b;
  4842. for (d = 0, b = f.length; d < b; d++) {
  4843. a = f[d].data.end;
  4844. if (c <= a) {
  4845. e = f[d].data.start;
  4846. return d + (c > e ? (c - e) / (a - e) : 0)
  4847. }
  4848. }
  4849. return -1
  4850. },
  4851. getDateFromTick : function(d, f) {
  4852. var g = this.tickStore.getCount();
  4853. if (d === g) {
  4854. return this.getEnd()
  4855. }
  4856. var a = Math.floor(d), e = d - a, c = this.getAt(a);
  4857. var b = Sch.util.Date.add(c.start, Sch.util.Date.MILLI, e
  4858. * (c.end - c.start));
  4859. if (f) {
  4860. b = this[f + "Date"](b)
  4861. }
  4862. return b
  4863. },
  4864. getAt : function(a) {
  4865. return this.tickStore.getAt(a).data
  4866. },
  4867. getCount : function() {
  4868. return this.tickStore.getCount()
  4869. },
  4870. getTicks : function() {
  4871. var a = [];
  4872. this.tickStore.each(function(b) {
  4873. a.push(b.data)
  4874. });
  4875. return a
  4876. },
  4877. getStart : function() {
  4878. var a = this.tickStore.first();
  4879. if (a) {
  4880. return Ext.Date.clone(a.data.start)
  4881. }
  4882. return null
  4883. },
  4884. getEnd : function() {
  4885. var a = this.tickStore.last();
  4886. if (a) {
  4887. return Ext.Date.clone(a.data.end)
  4888. }
  4889. return null
  4890. },
  4891. roundDate : function(r) {
  4892. var l = Ext.Date.clone(r), b = this.getStart(), s = this.resolutionIncrement;
  4893. switch (this.resolutionUnit) {
  4894. case Sch.util.Date.MILLI :
  4895. var e = Sch.util.Date.getDurationInMilliseconds(b, l), d = Math
  4896. .round(e / s)
  4897. * s;
  4898. l = Sch.util.Date.add(b, Sch.util.Date.MILLI, d);
  4899. break;
  4900. case Sch.util.Date.SECOND :
  4901. var i = Sch.util.Date.getDurationInSeconds(b, l), q = Math
  4902. .round(i / s)
  4903. * s;
  4904. l = Sch.util.Date.add(b, Sch.util.Date.MILLI, q * 1000);
  4905. break;
  4906. case Sch.util.Date.MINUTE :
  4907. var n = Sch.util.Date.getDurationInMinutes(b, l), a = Math
  4908. .round(n / s)
  4909. * s;
  4910. l = Sch.util.Date.add(b, Sch.util.Date.SECOND, a * 60);
  4911. break;
  4912. case Sch.util.Date.HOUR :
  4913. var m = Sch.util.Date.getDurationInHours(this.getStart(), l), j = Math
  4914. .round(m / s)
  4915. * s;
  4916. l = Sch.util.Date.add(b, Sch.util.Date.MINUTE, j * 60);
  4917. break;
  4918. case Sch.util.Date.DAY :
  4919. var c = Sch.util.Date.getDurationInDays(b, l), f = Math.round(c
  4920. / s)
  4921. * s;
  4922. l = Sch.util.Date.add(b, Sch.util.Date.DAY, f);
  4923. break;
  4924. case Sch.util.Date.WEEK :
  4925. Ext.Date.clearTime(l);
  4926. var o = l.getDay() - this.weekStartDay, t;
  4927. if (o < 0) {
  4928. o = 7 + o
  4929. }
  4930. if (Math.round(o / 7) === 1) {
  4931. t = 7 - o
  4932. } else {
  4933. t = -o
  4934. }
  4935. l = Sch.util.Date.add(l, Sch.util.Date.DAY, t);
  4936. break;
  4937. case Sch.util.Date.MONTH :
  4938. var p = Sch.util.Date.getDurationInMonths(b, l)
  4939. + (l.getDate() / Ext.Date.getDaysInMonth(l)), h = Math
  4940. .round(p / s)
  4941. * s;
  4942. l = Sch.util.Date.add(b, Sch.util.Date.MONTH, h);
  4943. break;
  4944. case Sch.util.Date.QUARTER :
  4945. Ext.Date.clearTime(l);
  4946. l.setDate(1);
  4947. l = Sch.util.Date.add(l, Sch.util.Date.MONTH, 3
  4948. - (l.getMonth() % 3));
  4949. break;
  4950. case Sch.util.Date.YEAR :
  4951. var k = Sch.util.Date.getDurationInYears(b, l), g = Math
  4952. .round(k / s)
  4953. * s;
  4954. l = Sch.util.Date.add(b, Sch.util.Date.YEAR, g);
  4955. break
  4956. }
  4957. return l
  4958. },
  4959. floorDate : function(t, d, v) {
  4960. d = d !== false;
  4961. var n = Ext.Date.clone(t), b = d ? this.getStart() : null, u = this.resolutionIncrement, k;
  4962. if (v) {
  4963. k = v
  4964. } else {
  4965. k = d ? this.resolutionUnit : this.mainUnit
  4966. }
  4967. switch (k) {
  4968. case Sch.util.Date.MILLI :
  4969. if (d) {
  4970. var f = Sch.util.Date.getDurationInMilliseconds(b, n), e = Math
  4971. .floor(f / u)
  4972. * u;
  4973. n = Sch.util.Date.add(b, Sch.util.Date.MILLI, e)
  4974. }
  4975. break;
  4976. case Sch.util.Date.SECOND :
  4977. if (d) {
  4978. var j = Sch.util.Date.getDurationInSeconds(b, n), s = Math
  4979. .floor(j / u)
  4980. * u;
  4981. n = Sch.util.Date.add(b, Sch.util.Date.MILLI, s * 1000)
  4982. } else {
  4983. n.setMilliseconds(0)
  4984. }
  4985. break;
  4986. case Sch.util.Date.MINUTE :
  4987. if (d) {
  4988. var p = Sch.util.Date.getDurationInMinutes(b, n), a = Math
  4989. .floor(p / u)
  4990. * u;
  4991. n = Sch.util.Date.add(b, Sch.util.Date.SECOND, a * 60)
  4992. } else {
  4993. n.setSeconds(0);
  4994. n.setMilliseconds(0)
  4995. }
  4996. break;
  4997. case Sch.util.Date.HOUR :
  4998. if (d) {
  4999. var o = Sch.util.Date
  5000. .getDurationInHours(this.getStart(), n), l = Math
  5001. .floor(o / u)
  5002. * u;
  5003. n = Sch.util.Date.add(b, Sch.util.Date.MINUTE, l * 60)
  5004. } else {
  5005. n.setMinutes(0);
  5006. n.setSeconds(0);
  5007. n.setMilliseconds(0)
  5008. }
  5009. break;
  5010. case Sch.util.Date.DAY :
  5011. if (d) {
  5012. var c = Sch.util.Date.getDurationInDays(b, n), g = Math
  5013. .floor(c / u)
  5014. * u;
  5015. n = Sch.util.Date.add(b, Sch.util.Date.DAY, g)
  5016. } else {
  5017. Ext.Date.clearTime(n)
  5018. }
  5019. break;
  5020. case Sch.util.Date.WEEK :
  5021. var r = n.getDay();
  5022. Ext.Date.clearTime(n);
  5023. if (r !== this.weekStartDay) {
  5024. n = Sch.util.Date.add(n, Sch.util.Date.DAY,
  5025. -(r > this.weekStartDay
  5026. ? (r - this.weekStartDay)
  5027. : (7 - r - this.weekStartDay)))
  5028. }
  5029. break;
  5030. case Sch.util.Date.MONTH :
  5031. if (d) {
  5032. var q = Sch.util.Date.getDurationInMonths(b, n), i = Math
  5033. .floor(q / u)
  5034. * u;
  5035. n = Sch.util.Date.add(b, Sch.util.Date.MONTH, i)
  5036. } else {
  5037. Ext.Date.clearTime(n);
  5038. n.setDate(1)
  5039. }
  5040. break;
  5041. case Sch.util.Date.QUARTER :
  5042. Ext.Date.clearTime(n);
  5043. n.setDate(1);
  5044. n = Sch.util.Date.add(n, Sch.util.Date.MONTH,
  5045. -(n.getMonth() % 3));
  5046. break;
  5047. case Sch.util.Date.YEAR :
  5048. if (d) {
  5049. var m = Sch.util.Date.getDurationInYears(b, n), h = Math
  5050. .floor(m / u)
  5051. * u;
  5052. n = Sch.util.Date.add(b, Sch.util.Date.YEAR, h)
  5053. } else {
  5054. n = new Date(t.getFullYear(), 0, 1)
  5055. }
  5056. break
  5057. }
  5058. return n
  5059. },
  5060. ceilDate : function(c, b, f) {
  5061. var e = Ext.Date.clone(c);
  5062. b = b !== false;
  5063. var a = b ? this.resolutionIncrement : 1, g = false, d;
  5064. if (f) {
  5065. d = f
  5066. } else {
  5067. d = b ? this.resolutionUnit : this.mainUnit
  5068. }
  5069. switch (d) {
  5070. case Sch.util.Date.DAY :
  5071. if (e.getMinutes() > 0 || e.getSeconds() > 0
  5072. || e.getMilliseconds() > 0) {
  5073. g = true
  5074. }
  5075. break;
  5076. case Sch.util.Date.WEEK :
  5077. Ext.Date.clearTime(e);
  5078. if (e.getDay() !== this.weekStartDay) {
  5079. g = true
  5080. }
  5081. break;
  5082. case Sch.util.Date.MONTH :
  5083. Ext.Date.clearTime(e);
  5084. if (e.getDate() !== 1) {
  5085. g = true
  5086. }
  5087. break;
  5088. case Sch.util.Date.QUARTER :
  5089. Ext.Date.clearTime(e);
  5090. if (e.getMonth() % 3 !== 0) {
  5091. g = true
  5092. }
  5093. break;
  5094. case Sch.util.Date.YEAR :
  5095. Ext.Date.clearTime(e);
  5096. if (e.getMonth() !== 0 && e.getDate() !== 1) {
  5097. g = true
  5098. }
  5099. break;
  5100. default :
  5101. break
  5102. }
  5103. if (g) {
  5104. return this.getNext(e, d, a)
  5105. } else {
  5106. return e
  5107. }
  5108. },
  5109. getNext : function(b, c, a) {
  5110. return Sch.util.Date.getNext(b, c, a, this.weekStartDay)
  5111. },
  5112. getResolution : function() {
  5113. return {
  5114. unit : this.resolutionUnit,
  5115. increment : this.resolutionIncrement
  5116. }
  5117. },
  5118. setResolution : function(b, a) {
  5119. this.resolutionUnit = b;
  5120. this.resolutionIncrement = a || 1
  5121. },
  5122. shiftNext : function(a) {
  5123. a = a || this.getShiftIncrement();
  5124. var b = this.getShiftUnit();
  5125. this.setTimeSpan(Sch.util.Date.add(this.getStart(), b, a),
  5126. Sch.util.Date.add(this.getEnd(), b, a))
  5127. },
  5128. shiftPrevious : function(a) {
  5129. a = -(a || this.getShiftIncrement());
  5130. var b = this.getShiftUnit();
  5131. this.setTimeSpan(Sch.util.Date.add(this.getStart(), b, a),
  5132. Sch.util.Date.add(this.getEnd(), b, a))
  5133. },
  5134. getShiftUnit : function() {
  5135. return this.shiftUnit || this.getMainUnit()
  5136. },
  5137. getShiftIncrement : function() {
  5138. return this.shiftIncrement || 1
  5139. },
  5140. getUnit : function() {
  5141. return this.unit
  5142. },
  5143. getIncrement : function() {
  5144. return this.increment
  5145. },
  5146. timeSpanInAxis : function(b, a) {
  5147. if (this.continuous) {
  5148. return Sch.util.Date.intersectSpans(b, a, this.getStart(), this
  5149. .getEnd())
  5150. } else {
  5151. return (b < this.getStart() && a > this.getEnd())
  5152. || this.getTickFromDate(b) !== this.getTickFromDate(a)
  5153. }
  5154. },
  5155. forEachInterval : function(b, a, c) {
  5156. c = c || this;
  5157. if (b === "top" || (b === "middle" && this.headerConfig.bottom)) {
  5158. this.forEachAuxInterval(b, a, c)
  5159. } else {
  5160. this.tickStore.each(function(e, d) {
  5161. return a.call(c, e.data.start, e.data.end, d)
  5162. })
  5163. }
  5164. },
  5165. forEachMainInterval : function(a, b) {
  5166. this.forEachInterval("middle", a, b)
  5167. },
  5168. forEachAuxInterval : function(b, a, f) {
  5169. f = f || this;
  5170. var c = this.getEnd(), g = this.getStart(), e = 0, d;
  5171. while (g < c) {
  5172. d = Sch.util.Date.min(this.getNext(g, this.headerConfig[b].unit,
  5173. this.headerConfig[b].increment || 1), c);
  5174. a.call(f, g, d, e);
  5175. g = d;
  5176. e++
  5177. }
  5178. }
  5179. });
  5180. Ext.define("Sch.view.Horizontal", {
  5181. props : {
  5182. translateToScheduleCoordinate : function(a) {
  5183. return a - this.el.getX() + this.el.getScroll().left
  5184. },
  5185. translateToPageCoordinate : function(a) {
  5186. return a + this.el.getX() - this.el.getScroll().left
  5187. },
  5188. getDateFromXY : function(h, f, e) {
  5189. var b, a = e ? h[0] : this.translateToScheduleCoordinate(h[0]), d = a
  5190. / this.getActualTimeColumnWidth(), c = this.timeAxis
  5191. .getCount();
  5192. if (d < 0 || d > c) {
  5193. b = null
  5194. } else {
  5195. var g = d - this.resolveColumnIndex(a);
  5196. if (g > 2 && d >= c) {
  5197. return null
  5198. }
  5199. b = this.timeAxis.getDateFromTick(d, f)
  5200. }
  5201. return b
  5202. },
  5203. getXYFromDate : function(b, d) {
  5204. var a, c = this.timeAxis.getTickFromDate(b);
  5205. if (c >= 0) {
  5206. a = this.getActualTimeColumnWidth() * c
  5207. }
  5208. if (d === false) {
  5209. a = this.translateToPageCoordinate(a)
  5210. }
  5211. return [Math.round(a), 0]
  5212. },
  5213. getEventBox : function(e, b) {
  5214. var a = Math.floor(this.getXYFromDate(e)[0]), c = Math.floor(this
  5215. .getXYFromDate(b)[0]), d = Math;
  5216. if (this.managedEventSizing) {
  5217. return {
  5218. top : Math.max(0, (this.barMargin
  5219. - (Ext.isIE && !Ext.isStrict)
  5220. ? 0
  5221. : this.eventBorderWidth
  5222. - this.cellBorderWidth)),
  5223. left : d.min(a, c),
  5224. width : d.max(1, d.abs(a - c) - this.eventBorderWidth),
  5225. height : this.rowHeight - (2 * this.barMargin)
  5226. - this.eventBorderWidth
  5227. }
  5228. }
  5229. return {
  5230. left : d.min(a, c),
  5231. width : d.max(1, d.abs(a - c))
  5232. }
  5233. },
  5234. layoutEvents : function(a) {
  5235. var c = Ext.Array.clone(a);
  5236. c.sort(this.sortEvents);
  5237. var b = this.layoutEventsInBands(0, c);
  5238. return b
  5239. },
  5240. layoutEventsInBands : function(d, a) {
  5241. var c = a[0], b = d === 0
  5242. ? this.barMargin
  5243. : (d * this.rowHeight - ((d - 1) * this.barMargin));
  5244. if (b >= this.cellBorderWidth) {
  5245. b -= this.cellBorderWidth
  5246. }
  5247. while (c) {
  5248. c.top = b;
  5249. Ext.Array.remove(a, c);
  5250. c = this.findClosestSuccessor(c, a)
  5251. }
  5252. d++;
  5253. if (a.length > 0) {
  5254. return this.layoutEventsInBands(d, a)
  5255. } else {
  5256. return d
  5257. }
  5258. },
  5259. getScheduleRegion : function(d, f) {
  5260. var h = d ? Ext.fly(this.getNodeByRecord(d)).getRegion() : this.el
  5261. .down(".x-grid-table").getRegion(), e = this.timeAxis
  5262. .getStart(), j = this.timeAxis.getEnd(), b = this
  5263. .getDateConstraints(d, f)
  5264. || {
  5265. start : e,
  5266. end : j
  5267. }, c = this.translateToPageCoordinate(this
  5268. .getXYFromDate(b.start)[0]), i = this
  5269. .translateToPageCoordinate(this.getXYFromDate(b.end)[0])
  5270. - this.eventBorderWidth, g = h.top + this.barMargin, a = h.bottom
  5271. - this.barMargin - this.eventBorderWidth;
  5272. return new Ext.util.Region(g, Math.max(c, i), a, Math.min(c, i))
  5273. },
  5274. getResourceRegion : function(h, d, g) {
  5275. var k = Ext.fly(this.getNodeByRecord(h)).getRegion(), i = this.timeAxis
  5276. .getStart(), n = this.timeAxis.getEnd(), c = d
  5277. ? Sch.util.Date.max(i, d)
  5278. : i, e = g ? Sch.util.Date.min(n, g) : n, f = this
  5279. .getXYFromDate(c)[0], m = this.getXYFromDate(e)[0]
  5280. - this.eventBorderWidth, l = this.el.getTop(), b = this.el
  5281. .getScroll(), j = k.top + 1 - l + b.top, a = k.bottom - 1
  5282. - l + b.top;
  5283. return new Ext.util.Region(j, Math.max(f, m), a, Math.min(f, m))
  5284. },
  5285. collectRowData : function(g, p, o) {
  5286. var c = this.eventStore.getEventsForResource(p);
  5287. if (c.length === 0 || this.headerCt.getColumnCount() === 0) {
  5288. g.rowHeight = this.rowHeight;
  5289. return g
  5290. }
  5291. var a = Sch.util.Date, m = this.timeAxis, n = m.getStart(), r = m
  5292. .getEnd(), k = [], j, f;
  5293. for (j = 0, f = c.length; j < f; j++) {
  5294. var b = c[j], d = b.getStartDate(), h = b.getEndDate();
  5295. if (d && h && m.timeSpanInAxis(d, h)) {
  5296. var q = this.generateTplData(b, n, r, p, o);
  5297. k[k.length] = q
  5298. }
  5299. }
  5300. var e = 1;
  5301. if (this.dynamicRowHeight) {
  5302. e = this.layoutEvents(k)
  5303. }
  5304. g.rowHeight = (e * this.rowHeight) - ((e - 1) * this.barMargin);
  5305. g[this.getFirstTimeColumn().id] += "&#160;"
  5306. + this.eventTpl.apply(k);
  5307. return g
  5308. },
  5309. resolveResource : function(a) {
  5310. var b = this.findItemByChild(a);
  5311. if (b) {
  5312. return this.getRecord(b)
  5313. }
  5314. return null
  5315. },
  5316. getTimeSpanRegion : function(b, h, g) {
  5317. var d = this.getXYFromDate(b)[0], f = this.getXYFromDate(h || b)[0], a, c;
  5318. if (this.store.buffered) {
  5319. var e;
  5320. if (this.panel.verticalScroller.stretcher instanceof Ext.CompositeElement) {
  5321. e = this.panel.verticalScroller.stretcher.first()
  5322. } else {
  5323. e = this.el.down(".x-stretcher")
  5324. }
  5325. if (e.dom.clientHeight) {
  5326. c = e
  5327. }
  5328. }
  5329. if (!c) {
  5330. c = this.el.down(".x-grid-table")
  5331. }
  5332. if (g) {
  5333. a = Math.max(c ? c.dom.clientHeight : 0,
  5334. this.el.dom.clientHeight)
  5335. } else {
  5336. a = c ? c.dom.clientHeight : 0
  5337. }
  5338. return new Ext.util.Region(0, Math.max(d, f), a, Math.min(d, f))
  5339. },
  5340. getStartEndDatesFromRegion : function(c, b) {
  5341. var a = this.getDateFromXY([c.left, 0], b), d = this.getDateFromXY(
  5342. [c.right, 0], b);
  5343. if (d && a) {
  5344. return {
  5345. start : Sch.util.Date.min(a, d),
  5346. end : Sch.util.Date.max(a, d)
  5347. }
  5348. } else {
  5349. return null
  5350. }
  5351. },
  5352. onEventAdd : function(m, h) {
  5353. var e = {};
  5354. for (var g = 0, c = h.length; g < c; g++) {
  5355. var a = h[g].getResources();
  5356. for (var f = 0, d = a.length; f < d; f++) {
  5357. var b = a[f];
  5358. e[b.getId()] = b
  5359. }
  5360. }
  5361. Ext.Object.each(e, function(j, i) {
  5362. this.onUpdate(this.resourceStore, i)
  5363. }, this)
  5364. },
  5365. onEventRemove : function(e, b) {
  5366. var h = b.getResources();
  5367. var f = this.resourceStore;
  5368. var a = Ext.tree.View && this instanceof Ext.tree.View;
  5369. var d = function(i) {
  5370. if (a && this.store.indexOf(i)) {
  5371. this.onUpdate(this.store, i)
  5372. } else {
  5373. if (f.indexOf(i) >= 0) {
  5374. this.onUpdate(f, i)
  5375. }
  5376. }
  5377. };
  5378. if (h.length > 1) {
  5379. Ext.each(h, d, this)
  5380. } else {
  5381. var c = this.getElementFromEventRecord(b);
  5382. if (c) {
  5383. var g = this.resolveResource(c);
  5384. c.fadeOut({
  5385. callback : function() {
  5386. d.call(this, g)
  5387. },
  5388. scope : this
  5389. })
  5390. }
  5391. }
  5392. },
  5393. onEventUpdate : function(b, c, a) {
  5394. var d = c.previous;
  5395. if (d && d[c.resourceIdField]) {
  5396. var e = c.getResource(d[c.resourceIdField]);
  5397. if (e) {
  5398. this.onUpdate(this.resourceStore, e)
  5399. }
  5400. }
  5401. var f = c.getResources();
  5402. Ext.each(f, function(g) {
  5403. this.onUpdate(this.resourceStore, g)
  5404. }, this)
  5405. },
  5406. getSingleTickInPixels : function() {
  5407. return this.getActualTimeColumnWidth()
  5408. },
  5409. getColumnWidth : function() {
  5410. if (this.getTimeAxisColumn()) {
  5411. return this.getTimeAxisColumn().getTimeColumnWidth()
  5412. }
  5413. },
  5414. setColumnWidth : function(b, a) {
  5415. if (this.getTimeAxisColumn()) {
  5416. this.getTimeAxisColumn().setTimeColumnWidth(b);
  5417. if (!a) {
  5418. this.refreshKeepingScroll()
  5419. }
  5420. }
  5421. this.fireEvent("columnwidthchange", this, b)
  5422. },
  5423. getVisibleDateRange : function() {
  5424. if (!this.rendered) {
  5425. return null
  5426. }
  5427. var c = this.getEl().getScroll(), b = this.panel.getStart(), f = this.panel
  5428. .getEnd(), e = this.getWidth(), d = this.getEl()
  5429. .down(".x-grid-table").dom, a = d.clientWidth;
  5430. if (a < e) {
  5431. return {
  5432. startDate : b,
  5433. endDate : f
  5434. }
  5435. }
  5436. return {
  5437. startDate : this.getDateFromXY([c.left, 0], null, true),
  5438. endDate : this.getDateFromXY([Math.min(c.left + e, a), 0],
  5439. null, true)
  5440. }
  5441. }
  5442. }
  5443. });
  5444. Ext.define("Sch.view.Vertical", {
  5445. props : {
  5446. translateToScheduleCoordinate : function(a) {
  5447. return a - this.el.getY() + this.el.getScroll().top
  5448. },
  5449. translateToPageCoordinate : function(c) {
  5450. var b = this.el, a = b.getScroll();
  5451. return c + b.getY() - a.top
  5452. },
  5453. getDateFromXY : function(f, e, d) {
  5454. var b, g = d ? f[1] : this.translateToScheduleCoordinate(f[1]);
  5455. var c = g / this.rowHeight, a = this.timeAxis.getCount();
  5456. if (c < 0 || c > a) {
  5457. b = null
  5458. } else {
  5459. b = this.timeAxis.getDateFromTick(c, e)
  5460. }
  5461. return b
  5462. },
  5463. getXYFromDate : function(a, c) {
  5464. var d = -1, b = this.timeAxis.getTickFromDate(a);
  5465. if (b >= 0) {
  5466. d = this.rowHeight * b
  5467. }
  5468. if (c === false) {
  5469. d = this.translateToPageCoordinate(d)
  5470. }
  5471. return [0, Math.round(d)]
  5472. },
  5473. getEventBox : function(e, b) {
  5474. var a = Math.floor(this.getXYFromDate(e)[1]), c = Math.floor(this
  5475. .getXYFromDate(b)[1]), d = Math;
  5476. if (this.managedEventSizing) {
  5477. return {
  5478. left : this.barMargin,
  5479. width : this.panel.resourceColumnWidth
  5480. - (2 * this.barMargin) - this.eventBorderWidth,
  5481. top : d.max(0, d.min(a, c) - this.eventBorderWidth),
  5482. height : d.max(1, d.abs(a - c))
  5483. }
  5484. }
  5485. return {
  5486. top : d.min(a, c),
  5487. height : d.max(1, d.abs(a - c))
  5488. }
  5489. },
  5490. getScheduleRegion : function(d, f) {
  5491. var g = d ? Ext.fly(this.getCellByPosition({
  5492. column : this.resourceStore.indexOf(d),
  5493. row : 0
  5494. })).getRegion() : this.el.down(".x-grid-table").getRegion(), e = this.timeAxis
  5495. .getStart(), j = this.timeAxis.getEnd(), a = this
  5496. .getDateConstraints(d, f)
  5497. || {
  5498. start : e,
  5499. end : j
  5500. }, c = this.translateToPageCoordinate(this
  5501. .getXYFromDate(Sch.util.Date.min(e, a.start))[1]), i = this
  5502. .translateToPageCoordinate(this.getXYFromDate(Sch.util.Date
  5503. .max(j, a.end))[1]), b = g.left + this.barMargin, h = (d
  5504. ? (g.left + this.panel.resourceColumnWidth)
  5505. : g.right)
  5506. - this.barMargin;
  5507. return new Ext.util.Region(Math.min(c, i), h, Math.max(c, i), b)
  5508. },
  5509. getResourceRegion : function(h, b, g) {
  5510. var d = this.resourceStore.indexOf(h)
  5511. * this.panel.resourceColumnWidth, i = this.timeAxis
  5512. .getStart(), l = this.timeAxis.getEnd(), a = b
  5513. ? Sch.util.Date.max(i, b)
  5514. : i, e = g ? Sch.util.Date.min(l, g) : l, f = this
  5515. .getXYFromDate(a)[1], k = this.getXYFromDate(e)[1], c = d
  5516. + this.barMargin + this.cellBorderWidth, j = d
  5517. + this.panel.resourceColumnWidth - this.barMargin
  5518. - this.cellBorderWidth;
  5519. return new Ext.util.Region(Math.min(f, k), j, Math.max(f, k), c)
  5520. },
  5521. layoutEvents : function(r) {
  5522. if (r.length === 0) {
  5523. return
  5524. }
  5525. r.sort(this.sortEvents);
  5526. var b, d, a = Sch.util.Date, q = 1, o, n, g = this.panel.resourceColumnWidth
  5527. - (2 * this.barMargin), k, e;
  5528. for (var f = 0, c = r.length; f < c; f++) {
  5529. k = r[f];
  5530. b = k.start;
  5531. d = k.end;
  5532. n = this.findStartSlot(r, k);
  5533. var m = this.getCluster(r, f);
  5534. if (m.length > 1) {
  5535. k.left = n.start;
  5536. k.width = n.end - n.start;
  5537. e = 1;
  5538. while (e < (m.length - 1) && m[e + 1].start - k.start === 0) {
  5539. e++
  5540. }
  5541. var p = this.findStartSlot(r, m[e]);
  5542. if (p && p.start < 0.8) {
  5543. m = m.slice(0, e)
  5544. }
  5545. }
  5546. var h = m.length, s = (n.end - n.start) / h;
  5547. for (e = 0; e < h; e++) {
  5548. m[e].width = s;
  5549. m[e].left = n.start + (e * s)
  5550. }
  5551. f += h - 1
  5552. }
  5553. for (f = 0, c = r.length; f < c; f++) {
  5554. r[f].width = r[f].width * g;
  5555. r[f].left = this.barMargin + (r[f].left * g)
  5556. }
  5557. },
  5558. findStartSlot : function(o, c) {
  5559. var b = Sch.util.Date, d = c.start, g = c.end, e = 0, f, n = 0, h, m, a = Ext.Array
  5560. .indexOf(o, c), l = this.getPriorOverlappingEvents(o, c), k;
  5561. if (l.length === 0) {
  5562. return {
  5563. start : 0,
  5564. end : 1
  5565. }
  5566. }
  5567. for (k = 0; k < l.length; k++) {
  5568. if (k === 0 && l[0].left > 0) {
  5569. return {
  5570. start : 0,
  5571. end : l[0].left
  5572. }
  5573. } else {
  5574. if (l[k].left + l[k].width < (k < l.length - 1
  5575. ? l[k + 1].left
  5576. : 1)) {
  5577. return {
  5578. start : l[k].left + l[k].width,
  5579. end : k < l.length - 1 ? l[k + 1].left : 1
  5580. }
  5581. }
  5582. }
  5583. }
  5584. return false
  5585. },
  5586. getPriorOverlappingEvents : function(e, f) {
  5587. var g = Sch.util.Date, h = f.start, b = f.end, c = [];
  5588. for (var d = 0, a = Ext.Array.indexOf(e, f); d < a; d++) {
  5589. if (g.intersectSpans(h, b, e[d].start, e[d].end)) {
  5590. c.push(e[d])
  5591. }
  5592. }
  5593. c.sort(function(j, i) {
  5594. return j.left < i.left ? -1 : 1
  5595. });
  5596. return c
  5597. },
  5598. getCluster : function(e, g) {
  5599. if (g >= e.length - 1) {
  5600. return [e[g]]
  5601. }
  5602. var c = [e[g]], b = e.length, h = e[g].start, a = e[g].end, f = Sch.util.Date, d = g
  5603. + 1;
  5604. while (d < b && f.intersectSpans(h, a, e[d].start, e[d].end)) {
  5605. c.push(e[d]);
  5606. h = f.max(h, e[d].start);
  5607. a = f.min(e[d].end, a);
  5608. d++
  5609. }
  5610. return c
  5611. },
  5612. collectRowData : function(j, b, m) {
  5613. if (m === 0) {
  5614. var n = Sch.util.Date, k = this.timeAxis, f = k.getStart(), e = k
  5615. .getEnd(), q = [], o = this.headerCt.getColumnCount(), h, a, g, t, u, r;
  5616. for (var p = 0; p < o; p++) {
  5617. t = this.getHeaderAtIndex(p);
  5618. a = [];
  5619. h = this.resourceStore.getAt(p);
  5620. g = this.eventStore.getEventsForResource(h);
  5621. for (u = 0, r = g.length; u < r; u++) {
  5622. var s = g[u], d = s.getStartDate(), c = s.getEndDate();
  5623. if (d && c && k.timeSpanInAxis(d, c)) {
  5624. a.push(this.generateTplData(s, f, e, h, p))
  5625. }
  5626. }
  5627. this.layoutEvents(a);
  5628. j[t.id] += "&#160;" + this.eventTpl.apply(a)
  5629. }
  5630. }
  5631. j.rowHeight = this.rowHeight;
  5632. if (Ext.isIE7 && Ext.isStrict) {
  5633. j.rowHeight -= 2
  5634. }
  5635. return j
  5636. },
  5637. resolveResource : function(a) {
  5638. a = Ext.fly(a).is(this.cellSelector) ? a : Ext.fly(a)
  5639. .up(this.cellSelector);
  5640. if (a) {
  5641. var b = this.getHeaderByCell(a.dom ? a.dom : a);
  5642. if (b) {
  5643. return this.resourceStore.getAt(this.headerCt
  5644. .getHeaderIndex(b))
  5645. }
  5646. }
  5647. return null
  5648. },
  5649. onEventUpdate : function(b, c) {
  5650. this.renderSingle(c);
  5651. var d = c.previous;
  5652. var a = c.getResource();
  5653. if (d && d[c.resourceIdField]) {
  5654. var e = c.getResource(d[c.resourceIdField]);
  5655. if (e) {
  5656. this.relayoutRenderedEvents(e)
  5657. }
  5658. }
  5659. if (a) {
  5660. this.relayoutRenderedEvents(a)
  5661. }
  5662. },
  5663. onEventAdd : function(a, b) {
  5664. if (b.length === 1) {
  5665. this.renderSingle(b[0]);
  5666. this.relayoutRenderedEvents(b[0].getResource())
  5667. } else {
  5668. this.onUpdate(this.store, this.store.first())
  5669. }
  5670. },
  5671. onEventRemove : function(a, b) {
  5672. if (b.length === 1) {
  5673. this
  5674. .relayoutRenderedEvents(this
  5675. .getResourceByEventRecord(b[0]))
  5676. } else {
  5677. this.onUpdate(this.store, this.store.first())
  5678. }
  5679. },
  5680. relayoutRenderedEvents : function(g) {
  5681. var f = [], c, a, e, d, b = this.eventStore.getEventsForResource(g);
  5682. if (b.length > 0) {
  5683. for (c = 0, a = b.length; c < a; c++) {
  5684. e = b[c];
  5685. d = this.getEventNodeByRecord(e);
  5686. if (d) {
  5687. f.push({
  5688. start : e.getStartDate(),
  5689. end : e.getEndDate(),
  5690. id : d.id
  5691. })
  5692. }
  5693. }
  5694. this.layoutEvents(f);
  5695. for (c = 0; c < f.length; c++) {
  5696. e = f[c];
  5697. Ext.fly(e.id).setStyle({
  5698. left : e.left + "px",
  5699. width : e.width + "px"
  5700. })
  5701. }
  5702. }
  5703. },
  5704. renderSingle : function(c) {
  5705. var f = c.getResource();
  5706. var b = this.getEventNodeByRecord(c);
  5707. var e = this.resourceStore.indexOf(f);
  5708. if (b) {
  5709. Ext.fly(b).remove()
  5710. }
  5711. if (e < 0) {
  5712. return
  5713. }
  5714. var a = this.getCell(this.store.getAt(0),
  5715. this.headerCt.getHeaderAtIndex(e)).first();
  5716. var d = this.generateTplData(c, this.timeAxis.getStart(),
  5717. this.timeAxis.getEnd(), f, e);
  5718. this.eventTpl.append(a, [d])
  5719. },
  5720. getTimeSpanRegion : function(b, f) {
  5721. var a = this.getXYFromDate(b)[1], e = this.getXYFromDate(f || b)[1], c = this.el
  5722. .down(".x-grid-table"), d = (c || this.el).dom.clientWidth;
  5723. return new Ext.util.Region(Math.min(a, e), d, Math.max(a, e), 0)
  5724. },
  5725. getStartEndDatesFromRegion : function(c, b) {
  5726. var a = this.getDateFromXY([0, c.top], b), d = this.getDateFromXY([
  5727. 0, c.bottom], b);
  5728. if (top && d) {
  5729. return {
  5730. start : Sch.util.Date.min(a, d),
  5731. end : Sch.util.Date.max(a, d)
  5732. }
  5733. } else {
  5734. return null
  5735. }
  5736. },
  5737. getSingleTickInPixels : function() {
  5738. return this.rowHeight
  5739. },
  5740. timeColumnRenderer : function(l, d, h, n, c, b) {
  5741. var a = "";
  5742. if (this.timeCellRenderer) {
  5743. var i = this.timeAxis, g = i.getAt(n), f = g.start, j = g.end, k = this.resourceStore, e = k
  5744. .getAt(c);
  5745. a = this.timeCellRenderer.call(this.timeCellRendererScope
  5746. || this, d, e, n, c, k, f, j)
  5747. }
  5748. if (Ext.isIE) {
  5749. d.tdAttr = 'style="z-index:' + (this.store.getCount() - n)
  5750. + '"'
  5751. }
  5752. if (c % 2 === 1) {
  5753. d.tdCls += " " + this.altColCls
  5754. }
  5755. return a
  5756. },
  5757. setColumnWidth : function(b, a) {
  5758. if (this.panel) {
  5759. this.panel.resourceColumnWidth = b
  5760. }
  5761. var c = this.headerCt;
  5762. c.suspendLayout = true;
  5763. c.items.each(function(d) {
  5764. if (d.rendered) {
  5765. d.minWidth = undefined;
  5766. d.setWidth(b)
  5767. }
  5768. });
  5769. c.suspendLayout = false;
  5770. c.doLayout();
  5771. if (!a) {
  5772. this.refresh()
  5773. }
  5774. this.fireEvent("columnwidthchange", this, b)
  5775. },
  5776. getVisibleDateRange : function() {
  5777. if (!this.rendered) {
  5778. return null
  5779. }
  5780. var c = this.getEl().getScroll(), b = this.panel.getStart(), e = this.panel
  5781. .getEnd(), a = this.getHeight();
  5782. var d = Ext.query(".x-grid-table", this.getEl().dom)[0];
  5783. if (d.clientHeight < a) {
  5784. return {
  5785. startDate : b,
  5786. endDate : e
  5787. }
  5788. }
  5789. return {
  5790. startDate : this.getDateFromXY([0, c.top], null, true),
  5791. endDate : this.getDateFromXY([0, c.top + a], null, true)
  5792. }
  5793. }
  5794. }
  5795. });
  5796. Ext.define("Sch.selection.EventModel", {
  5797. extend : "Ext.selection.Model",
  5798. alias : "selection.eventmodel",
  5799. requires : ["Ext.util.KeyNav"],
  5800. deselectOnContainerClick : true,
  5801. constructor : function(a) {
  5802. this.addEvents("beforedeselect", "beforeselect", "deselect", "select");
  5803. this.callParent(arguments)
  5804. },
  5805. bindStore : function(a, b) {
  5806. this.callParent([this.view.getEventStore(), b])
  5807. },
  5808. bindComponent : function(a) {
  5809. var b = this, c = {
  5810. refresh : b.refresh,
  5811. scope : b
  5812. };
  5813. b.view = a;
  5814. b.bindStore(a.getEventStore());
  5815. a.on({
  5816. eventclick : b.onEventClick,
  5817. itemclick : b.onItemClick,
  5818. scope : this
  5819. });
  5820. a.on(c)
  5821. },
  5822. onEventClick : function(b, a, c) {
  5823. this.selectWithEvent(a, c)
  5824. },
  5825. onItemClick : function() {
  5826. if (this.deselectOnContainerClick) {
  5827. this.deselectAll()
  5828. }
  5829. },
  5830. onSelectChange : function(d, b, j, a) {
  5831. var f = this, g = f.view, h = f.store, e = b ? "select" : "deselect", c = 0;
  5832. if ((j || f.fireEvent("before" + e, f, d)) !== false && a() !== false) {
  5833. if (b) {
  5834. g.onEventSelect(d, j)
  5835. } else {
  5836. g.onEventDeselect(d, j)
  5837. }
  5838. if (!j) {
  5839. f.fireEvent(e, f, d)
  5840. }
  5841. }
  5842. },
  5843. selectRange : function() {
  5844. },
  5845. selectNode : function(c, d, a) {
  5846. var b = this.view.resolveEventRecord(c);
  5847. if (b) {
  5848. this.select(b, d, a)
  5849. }
  5850. },
  5851. deselectNode : function(c, d, a) {
  5852. var b = this.view.resolveEventRecord(c);
  5853. if (b) {
  5854. this.deselect(b, a)
  5855. }
  5856. }
  5857. });
  5858. Ext.define("Sch.plugin.Printable", {
  5859. extend : "Ext.AbstractPlugin",
  5860. lockableScope : "top",
  5861. docType : "<!DOCTYPE HTML>",
  5862. beforePrint : Ext.emptyFn,
  5863. afterPrint : Ext.emptyFn,
  5864. autoPrintAndClose : true,
  5865. fakeBackgroundColor : true,
  5866. scheduler : null,
  5867. constructor : function(a) {
  5868. Ext.apply(this, a)
  5869. },
  5870. init : function(a) {
  5871. this.scheduler = a;
  5872. a.print = Ext.Function.bind(this.print, this)
  5873. },
  5874. mainTpl : new Ext.XTemplate(
  5875. '{docType}<html class="x-border-box {htmlClasses}"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /><title>{title}</title>{styles}</head><body class="sch-print-body {bodyClasses}"><div class="sch-print-ct {componentClasses}" style="width:{totalWidth}px"><div class="sch-print-headerbg" style="border-left-width:{totalWidth}px;height:{headerHeight}px;"></div><div class="sch-print-header-wrap">{[this.printLockedHeader(values)]}{[this.printNormalHeader(values)]}</div>{[this.printLockedGrid(values)]}{[this.printNormalGrid(values)]}</div><script type="text/javascript">{setupScript}<\/script></body></html>',
  5876. {
  5877. printLockedHeader : function(a) {
  5878. var b = "";
  5879. if (a.lockedGrid) {
  5880. b += '<div style="left:-' + a.lockedScroll
  5881. + "px;margin-right:-" + a.lockedScroll
  5882. + "px;width:"
  5883. + (a.lockedWidth + a.lockedScroll) + 'px"';
  5884. b += 'class="sch-print-lockedheader x-grid-header-ct x-grid-header-ct-default x-docked x-docked-top x-grid-header-ct-docked-top x-grid-header-ct-default-docked-top x-box-layout-ct x-docked-noborder-top x-docked-noborder-right x-docked-noborder-left">';
  5885. b += a.lockedHeader;
  5886. b += "</div>"
  5887. }
  5888. return b
  5889. },
  5890. printNormalHeader : function(a) {
  5891. var b = "";
  5892. if (a.normalGrid) {
  5893. b += '<div style="left:'
  5894. + (a.lockedGrid ? a.lockedWidth : "0")
  5895. + "px;width:"
  5896. + a.normalWidth
  5897. + 'px;" class="sch-print-normalheader x-grid-header-ct x-grid-header-ct-default x-docked x-docked-top x-grid-header-ct-docked-top x-grid-header-ct-default-docked-top x-box-layout-ct x-docked-noborder-top x-docked-noborder-right x-docked-noborder-left">';
  5898. b += '<div style="margin-left:-' + a.normalScroll
  5899. + 'px">' + a.normalHeader + "</div>";
  5900. b += "</div>"
  5901. }
  5902. return b
  5903. },
  5904. printLockedGrid : function(a) {
  5905. var b = "";
  5906. if (a.lockedGrid) {
  5907. b += '<div id="lockedRowsCt" style="left:-'
  5908. + a.lockedScroll + "px;margin-right:-"
  5909. + a.lockedScroll + "px;width:" + a.lockedWidth
  5910. + a.lockedScroll + "px;top:" + a.headerHeight
  5911. + 'px;" class="sch-print-locked-rows-ct '
  5912. + a.innerLockedClasses
  5913. + ' x-grid-inner-locked">';
  5914. b += a.lockedRows;
  5915. b += "</div>"
  5916. }
  5917. return b
  5918. },
  5919. printNormalGrid : function(a) {
  5920. var b = "";
  5921. if (a.normalGrid) {
  5922. b += '<div id="normalRowsCt" style="left:'
  5923. + (a.lockedGrid ? a.lockedWidth : "0")
  5924. + "px;top:" + a.headerHeight + "px;width:"
  5925. + a.normalWidth
  5926. + 'px" class="sch-print-normal-rows-ct '
  5927. + a.innerNormalClasses + '">';
  5928. b += '<div style="position:relative;overflow:visible;margin-left:-'
  5929. + a.normalScroll
  5930. + 'px">'
  5931. + a.normalRows
  5932. + "</div>";
  5933. b += "</div>"
  5934. }
  5935. return b
  5936. }
  5937. }),
  5938. getGridContent : function(l) {
  5939. var k = l.normalGrid, d = l.lockedGrid, m = d.getView(), e = k
  5940. .getView(), h, c, j, g, i, a, f;
  5941. this.beforePrint(l);
  5942. if (d.collapsed && !k.collapsed) {
  5943. a = d.getWidth() + k.getWidth()
  5944. } else {
  5945. a = k.getWidth();
  5946. f = d.getWidth()
  5947. }
  5948. var b = m.store.getRange();
  5949. c = m.tpl.apply(m.collectData(b, 0));
  5950. j = e.tpl.apply(e.collectData(b, 0));
  5951. g = m.el.getScroll().left;
  5952. i = e.el.getScroll().left;
  5953. if (Sch.feature && Sch.feature.AbstractTimeSpan) {
  5954. Ext.each((l.normalGrid.plugins || []).concat(l.columnLinesFeature
  5955. || []), function(n) {
  5956. if (n instanceof Sch.feature.AbstractTimeSpan) {
  5957. j = n.generateMarkup(true) + j
  5958. }
  5959. })
  5960. }
  5961. this.afterPrint(l);
  5962. return {
  5963. normalHeader : k.headerCt.el.dom.innerHTML,
  5964. lockedHeader : d.headerCt.el.dom.innerHTML,
  5965. lockedGrid : !d.collapsed,
  5966. normalGrid : !k.collapsed,
  5967. lockedRows : c,
  5968. normalRows : j,
  5969. lockedScroll : g,
  5970. normalScroll : i,
  5971. lockedWidth : f,
  5972. normalWidth : a,
  5973. headerHeight : k.headerCt.getHeight(),
  5974. innerLockedClasses : d.view.el.dom.className,
  5975. innerNormalClasses : k.view.el.dom.className
  5976. + (this.fakeBackgroundColor
  5977. ? " sch-print-fake-background"
  5978. : ""),
  5979. width : l.getWidth()
  5980. }
  5981. },
  5982. getStylesheets : function() {
  5983. return Ext.getDoc().select('link[rel="stylesheet"]')
  5984. },
  5985. print : function() {
  5986. var g = this.scheduler;
  5987. if (!(this.mainTpl instanceof Ext.Template)) {
  5988. var a = 22;
  5989. this.mainTpl = Ext.create("Ext.XTemplate", this.mainTpl, {
  5990. compiled : true,
  5991. disableFormats : true
  5992. })
  5993. }
  5994. var h = g.getView(), i = this.getStylesheets(), e = Ext
  5995. .get(Ext.core.DomHelper.createDom({
  5996. tag : "div"
  5997. })), b;
  5998. i.each(function(j) {
  5999. e.appendChild(j.dom.cloneNode(true))
  6000. });
  6001. b = e.dom.innerHTML + "";
  6002. var f = this.getGridContent(g), c = this.mainTpl.apply(Ext.apply({
  6003. waitText : this.waitText,
  6004. docType : this.docType,
  6005. htmlClasses : "",
  6006. bodyClasses : Ext.getBody().dom.className,
  6007. componentClasses : g.el.dom.className,
  6008. title : (g.title || ""),
  6009. styles : b,
  6010. totalWidth : g.getWidth(),
  6011. setupScript : "(" + this.setupScript.toString() + ")();"
  6012. }, f));
  6013. var d = window.open("", "printgrid");
  6014. this.printWindow = d;
  6015. d.document.write(c);
  6016. d.document.close();
  6017. if (this.autoPrintAndClose) {
  6018. d.print();
  6019. if (!Ext.isChrome) {
  6020. d.close()
  6021. }
  6022. }
  6023. },
  6024. setupScript : function() {
  6025. var f = document.getElementById("lockedRowsCt"), d = document
  6026. .getElementById("normalRowsCt"), b = f
  6027. && f.getElementsByTagName("tr"), a = d
  6028. && d.getElementsByTagName("tr"), e = a && b ? a.length : 0, c = 0;
  6029. for (; c < e; c++) {
  6030. b[c].style.height = a[c].style.height
  6031. }
  6032. }
  6033. });
  6034. Ext.define("Sch.plugin.Export", {
  6035. extend : "Ext.util.Observable",
  6036. alternateClassName : "Sch.plugin.PdfExport",
  6037. mixins : ["Ext.AbstractPlugin"],
  6038. lockableScope : "top",
  6039. printServer : undefined,
  6040. tpl : new Ext.XTemplate(
  6041. '<!DOCTYPE html><html class="x-border-box {htmlClasses}"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /><title>{column}/{row}</title>{styles}</head><body class="x-webkit {bodyClasses}">{[this.showHeader(values)]}<div class="{componentClasses}" style="height:{bodyHeight}px; width:{totalWidth}px; position: relative !important">{HTML}</div></body></html>',
  6042. {
  6043. disableFormats : true,
  6044. showHeader : function(a) {
  6045. if (a.showHeader) {
  6046. return '<div class="sch-export-header" style="width:'
  6047. + a.totalWidth + 'px"><h2>' + a.column + "/"
  6048. + a.row + "</h2></div>"
  6049. }
  6050. return ""
  6051. }
  6052. }),
  6053. exportStatus : false,
  6054. exportDialogClassName : "Sch.widget.ExportDialog",
  6055. exportDialogConfig : {},
  6056. defaultConfig : {
  6057. format : "A4",
  6058. orientation : "portrait",
  6059. range : "complete",
  6060. showHeader : true
  6061. },
  6062. pageSizes : {
  6063. A5 : {
  6064. width : 5.8,
  6065. height : 8.3
  6066. },
  6067. A4 : {
  6068. width : 8.3,
  6069. height : 11.7
  6070. },
  6071. A3 : {
  6072. width : 11.7,
  6073. height : 16.5
  6074. },
  6075. Letter : {
  6076. width : 8.5,
  6077. height : 11
  6078. }
  6079. },
  6080. openAfterExport : true,
  6081. fileFormat : "pdf",
  6082. DPI : 72,
  6083. constructor : function(a) {
  6084. this.callParent(arguments);
  6085. this.addEvents("hidedialogwindow", "showdialogerror",
  6086. "updateprogressbar");
  6087. this.setFileFormat(this.fileFormat)
  6088. },
  6089. init : function(a) {
  6090. this.scheduler = a;
  6091. a.showExportDialog = Ext.Function.bind(this.showExportDialog, this);
  6092. a.doExport = Ext.Function.bind(this.doExport, this);
  6093. a.isExporting = Ext.Function.bind(this.isExporting, this)
  6094. },
  6095. setFileFormat : function(a) {
  6096. if (typeof a !== "string") {
  6097. this.fileFormat = "pdf"
  6098. } else {
  6099. a = a.toLowerCase();
  6100. if (a === "png") {
  6101. this.fileFormat = a
  6102. } else {
  6103. this.fileFormat = "pdf"
  6104. }
  6105. }
  6106. },
  6107. isExporting : function() {
  6108. return this.exportStatus
  6109. },
  6110. showExportDialog : function() {
  6111. var b = this, a = b.scheduler.getSchedulingView(), c;
  6112. if (b.win) {
  6113. b.win.destroy();
  6114. b.win = null
  6115. }
  6116. b.win = Ext.create(b.exportDialogClassName, {
  6117. plugin : b,
  6118. exportDialogConfig : Ext.apply({
  6119. startDate : this.scheduler.getStart(),
  6120. endDate : this.scheduler.getEnd(),
  6121. rowHeight : a.rowHeight,
  6122. columnWidth : a.getSingleTickInPixels()
  6123. }, b.exportDialogConfig)
  6124. });
  6125. b.win.show()
  6126. },
  6127. getStylesheets : function() {
  6128. var c = Ext.getDoc().select('link[rel="stylesheet"]'), a = Ext
  6129. .get(Ext.core.DomHelper.createDom({
  6130. tag : "div"
  6131. })), b;
  6132. c.each(function(d) {
  6133. a.appendChild(d.dom.cloneNode(true))
  6134. });
  6135. b = a.dom.innerHTML + "";
  6136. return b
  6137. },
  6138. doExport : function(l, i, n) {
  6139. var A = this, m = A.scheduler, o = m.getSchedulingView(), k = A
  6140. .getStylesheets(), y = l || A.defaultConfig;
  6141. A.exportStatus = true;
  6142. A.mask();
  6143. A.fireEvent("updateprogressbar", 0.1);
  6144. if (m.expandAll) {
  6145. m.expandAll()
  6146. }
  6147. var w = m.lockedGrid, p = m.normalGrid, f = o.rowHeight, z = m.timeAxis
  6148. .getTicks(), q = o.getSingleTickInPixels(), b = {
  6149. width : m.getWidth(),
  6150. height : m.getHeight(),
  6151. rowHeight : f,
  6152. columnWidth : q,
  6153. startDate : m.getStart(),
  6154. endDate : m.getEnd(),
  6155. normalWidth : p.getWidth(),
  6156. normalPosition : p.getPosition()
  6157. }, u, g;
  6158. if (y.orientation === "landscape") {
  6159. u = A.pageSizes[y.format].height * A.DPI;
  6160. g = A.pageSizes[y.format].width * A.DPI
  6161. } else {
  6162. u = A.pageSizes[y.format].width * A.DPI;
  6163. g = A.pageSizes[y.format].height * A.DPI
  6164. }
  6165. var x = 41, t = p.headerCt.getHeight(), e = Math.floor(g) - t
  6166. - (y.showHeader ? x : 0);
  6167. if (y.range !== "complete") {
  6168. var d, a, j, c, r;
  6169. if (y.range === "date") {
  6170. d = new Date(y.dateFrom);
  6171. a = new Date(y.dateTo);
  6172. if (Sch.util.Date.getDurationInDays(d, a < 1)) {
  6173. a = Sch.util.Date.add(a, Sch.util.Date.DAY, 1);
  6174. a = Sch.util.Date.constrain(a, m.getStart(), m.getEnd())
  6175. }
  6176. } else {
  6177. if (y.range === "current") {
  6178. j = o.getVisibleDateRange();
  6179. d = j.startDate;
  6180. a = j.endDate
  6181. }
  6182. }
  6183. c = Math.floor(o.timeAxis.getTickFromDate(d));
  6184. r = Math.floor(o.timeAxis.getTickFromDate(a));
  6185. z = z.filter(function(C, B) {
  6186. return B >= c && B <= r
  6187. });
  6188. m.setTimeSpan(d, a)
  6189. }
  6190. m.setWidth(u);
  6191. m.setTimeColumnWidth(q);
  6192. var h = A.calculatePages(y, z, q, u, e), v = {
  6193. ticks : z,
  6194. printHeight : e,
  6195. paperWidth : u,
  6196. headerHeight : t,
  6197. styles : k,
  6198. config : y
  6199. }, s = A.getExportJsonHtml(h, v);
  6200. A.fireEvent("updateprogressbar", 0.4);
  6201. if (A.printServer) {
  6202. Ext.Ajax.request({
  6203. type : "POST",
  6204. url : A.printServer,
  6205. params : {
  6206. html : {
  6207. array : s
  6208. },
  6209. format : y.format,
  6210. orientation : y.orientation,
  6211. range : y.range,
  6212. fileFormat : A.fileFormat
  6213. },
  6214. success : function(B) {
  6215. A.onSuccess(B, i, n)
  6216. },
  6217. failure : function(B) {
  6218. A.onFailure(B, n)
  6219. },
  6220. scope : A
  6221. })
  6222. } else {
  6223. throw "Server url not defined !"
  6224. }
  6225. A.restorePanel(b)
  6226. },
  6227. calculatePages : function(c, p, h, l, b) {
  6228. var m = this, n = m.scheduler, e = n.lockedGrid, a = n
  6229. .getSchedulingView().rowHeight, k = e.getWidth(), j = Math
  6230. .floor(l / h), g = Math.floor((l - k) / h), d = Math
  6231. .ceil((p.length - g) / j)
  6232. + 1, o = n.getSchedulingView().store.getCount(), i = Math
  6233. .floor(b / a), f = Math.ceil(o / i);
  6234. return {
  6235. columnsAmountLocked : g,
  6236. columnsAmountNormal : j,
  6237. rowsAmount : i,
  6238. rowPages : f,
  6239. columnPages : d,
  6240. timeColumnWidth : h,
  6241. lockedGridWidth : k,
  6242. rowHeight : a,
  6243. panelHTML : {}
  6244. }
  6245. },
  6246. getExportJsonHtml : function(g, B) {
  6247. var E = this, n = E.scheduler, r = g.columnsAmountLocked, t = g.columnsAmountNormal, h = g.rowsAmount, s = g.rowPages, a = g.columnPages, o = g.panelHTML, q = g.timeColumnWidth, A = B.paperWidth, d = B.printHeight, x = B.headerHeight, l = B.styles, C = B.config, D = B.ticks, w = [], j, c, m, e, b, f;
  6248. for (var z = 0; z < a; z += 1) {
  6249. if (z === 0) {
  6250. j = Ext.Number.constrain((r - 1), z, (D.length - 1));
  6251. n.setTimeSpan(D[z].start, D[j].end)
  6252. } else {
  6253. if (!c) {
  6254. c = n.lockedGrid.hide()
  6255. }
  6256. if (D[j + t]) {
  6257. n.setTimeSpan(D[j + 1].start, D[j + t].end);
  6258. j = j + t
  6259. } else {
  6260. n.setTimeSpan(D[j + 1].start, D[D.length - 1].end)
  6261. }
  6262. }
  6263. n.setTimeColumnWidth(q);
  6264. var u = new RegExp(/x-ie\d?|x-gecko/g), y = Ext.getBody().dom.className
  6265. .replace(u, ""), p = n.el.dom.className;
  6266. for (var v = 0; v < s; v += 1) {
  6267. E.hideRows(h, v);
  6268. o.dom = n.body.dom.innerHTML;
  6269. o.k = v;
  6270. o.i = z;
  6271. e = E.resizePanelHTML(o);
  6272. m = E.tpl.apply(Ext.apply({
  6273. bodyClasses : y,
  6274. bodyHeight : d + x,
  6275. componentClasses : p,
  6276. styles : l,
  6277. showHeader : C.showHeader,
  6278. HTML : e.dom.innerHTML,
  6279. totalWidth : A,
  6280. headerHeight : x,
  6281. column : z + 1,
  6282. row : v + 1
  6283. }));
  6284. f = {
  6285. html : m
  6286. };
  6287. w.push(f);
  6288. E.showRows()
  6289. }
  6290. }
  6291. this.exportStatus = false;
  6292. return Ext.JSON.encode(w)
  6293. },
  6294. resizePanelHTML : function(g) {
  6295. var h = Ext.get(Ext.core.DomHelper.createDom({
  6296. tag : "div",
  6297. html : g.dom
  6298. })), c = this.scheduler, f = c.lockedGrid, d = c.normalGrid, e, a;
  6299. if (Ext.isIE6 || Ext.isIE7 || Ext.isIEQuirks) {
  6300. var b = document.createDocumentFragment();
  6301. b.appendChild(h.dom);
  6302. e = [b.getElementById(c.id + "-targetEl"),
  6303. b.getElementById(c.id + "-innerCt"),
  6304. b.getElementById(f.id), b.getElementById(f.body.id),
  6305. b.getElementById(f.body.child(".x-grid-view").id)];
  6306. a = [b.getElementById(d.id), b.getElementById(d.headerCt.id),
  6307. b.getElementById(d.body.id),
  6308. b.getElementById(d.getView().id)];
  6309. Ext.Array.each(e, function(i) {
  6310. if (i !== null) {
  6311. i.style.height = "100%"
  6312. }
  6313. });
  6314. Ext.Array.each(a, function(j, i) {
  6315. if (j !== null) {
  6316. if (i === 1) {
  6317. j.style.width = "100%"
  6318. } else {
  6319. j.style.height = "100%";
  6320. j.style.width = "100%"
  6321. }
  6322. }
  6323. });
  6324. h.dom.innerHTML = b.firstChild.innerHTML
  6325. } else {
  6326. e = [h.select("#" + c.id + "-targetEl").first(),
  6327. h.select("#" + c.id + "-innerCt").first(),
  6328. h.select("#" + f.id).first(),
  6329. h.select("#" + f.body.id).first(),
  6330. h.select("#" + f.body.child(".x-grid-view").id).first()];
  6331. a = [h.select("#" + d.id).first(),
  6332. h.select("#" + d.headerCt.id).first(),
  6333. h.select("#" + d.body.id).first(),
  6334. h.select("#" + d.getView().id).first()];
  6335. Ext.Array.each(e, function(i) {
  6336. if (i) {
  6337. i.setHeight("100%")
  6338. }
  6339. });
  6340. Ext.Array.each(a, function(j, i) {
  6341. if (i === 1) {
  6342. j.setWidth("100%")
  6343. } else {
  6344. j.applyStyles({
  6345. height : "100%",
  6346. width : "100%"
  6347. })
  6348. }
  6349. })
  6350. }
  6351. return h
  6352. },
  6353. getWin : function() {
  6354. return this.win || null
  6355. },
  6356. onSuccess : function(c, h, b) {
  6357. var d = this, g = d.getWin(), a;
  6358. try {
  6359. a = Ext.JSON.decode(c.responseText)
  6360. } catch (f) {
  6361. this.onFailure(c, b);
  6362. return
  6363. }
  6364. d.fireEvent("updateprogressbar", 1);
  6365. if (a.success) {
  6366. setTimeout(function() {
  6367. d.fireEvent("hidedialogwindow");
  6368. d.unmask();
  6369. if (d.openAfterExport) {
  6370. window.open(a.url, "ExportedPanel")
  6371. }
  6372. }, g ? g.hideTime : 3000)
  6373. } else {
  6374. d.fireEvent("showdialogerror", g, a.msg);
  6375. d.unmask()
  6376. }
  6377. if (h) {
  6378. h.call(this, c)
  6379. }
  6380. },
  6381. onFailure : function(b, a) {
  6382. var c = this.getWin();
  6383. this.fireEvent("showdialogerror", c);
  6384. this.unmask();
  6385. if (a) {
  6386. a.call(this, b)
  6387. }
  6388. },
  6389. hideRows : function(d, f) {
  6390. var c = this.scheduler.lockedGrid.getEl().select(".x-grid-row"), a = this.scheduler.normalGrid
  6391. .getEl().select(".x-grid-row"), g = d * f, b = g + d;
  6392. for (var e = 0; e < a.elements.length; e += 1) {
  6393. if (e < g || e >= b) {
  6394. c.elements[e].className += " sch-none";
  6395. a.elements[e].className += " sch-none"
  6396. }
  6397. }
  6398. },
  6399. showRows : function() {
  6400. var b = this.scheduler.lockedGrid.getEl().select(".x-grid-row"), a = this.scheduler.normalGrid
  6401. .getEl().select(".x-grid-row");
  6402. b.each(function(c) {
  6403. c.removeCls("sch-none")
  6404. });
  6405. a.each(function(c) {
  6406. c.removeCls("sch-none")
  6407. })
  6408. },
  6409. mask : function() {
  6410. var a = Ext.getBody().mask();
  6411. a.addCls("sch-export-mask")
  6412. },
  6413. unmask : function() {
  6414. Ext.getBody().unmask()
  6415. },
  6416. restorePanel : function(a) {
  6417. var b = this.scheduler;
  6418. b.setWidth(a.width);
  6419. b.setHeight(a.height);
  6420. b.setTimeSpan(a.startDate, a.endDate);
  6421. b.setTimeColumnWidth(a.columnWidth, true);
  6422. b.getSchedulingView().setRowHeight(a.rowHeight);
  6423. b.lockedGrid.show();
  6424. b.normalGrid.setWidth(a.normalWidth);
  6425. b.normalGrid.setPosition(a.normalPosition[0])
  6426. },
  6427. destroy : function() {
  6428. if (this.win) {
  6429. this.win.destroy()
  6430. }
  6431. }
  6432. });
  6433. Ext.define("Sch.plugin.Lines", {
  6434. extend : "Sch.feature.AbstractTimeSpan",
  6435. cls : "sch-timeline",
  6436. showTip : true,
  6437. innerTpl : null,
  6438. init : function(b) {
  6439. this.callParent(arguments);
  6440. var a = this.schedulerView;
  6441. if (Ext.isString(this.innerTpl)) {
  6442. this.innerTpl = new Ext.XTemplate(this.innerTpl)
  6443. }
  6444. var c = this.innerTpl;
  6445. if (!this.template) {
  6446. this.template = new Ext.XTemplate(
  6447. '<tpl for=".">',
  6448. '<div id="'
  6449. + this.uniqueCls
  6450. + '-{id}"'
  6451. + (this.showTip
  6452. ? 'title="{[this.getTipText(values)]}" '
  6453. : "")
  6454. + 'class="'
  6455. + this.cls
  6456. + " "
  6457. + this.uniqueCls
  6458. + ' {Cls}" style="left:{left}px;top:{top}px;height:{height}px;width:{width}px">'
  6459. + (c ? "{[this.renderInner(values)]}" : "")
  6460. + "</div>", "</tpl>", {
  6461. getTipText : function(d) {
  6462. return a.getFormattedDate(d.Date) + " "
  6463. + (d.Text || "")
  6464. },
  6465. renderInner : function(d) {
  6466. return c.apply(d)
  6467. }
  6468. })
  6469. }
  6470. },
  6471. getElementData : function(j, m, c) {
  6472. var n = this.store, h = this.schedulerView, e = c || n.getRange(), g = [], a, b, k;
  6473. for (var f = 0, d = e.length; f < d; f++) {
  6474. a = e[f];
  6475. b = a.get("Date");
  6476. if (b && Sch.util.Date.betweenLesser(b, j, m)) {
  6477. k = h.getTimeSpanRegion(b, null, this.expandToFitView);
  6478. g[g.length] = Ext.apply({
  6479. id : a.internalId,
  6480. left : k.left,
  6481. top : k.top,
  6482. width : 1,
  6483. height : k.bottom - k.top
  6484. }, a.data)
  6485. }
  6486. }
  6487. return g
  6488. }
  6489. });
  6490. Ext.define("Sch.plugin.CurrentTimeLine", {
  6491. extend : "Sch.plugin.Lines",
  6492. tooltipText : "Current time",
  6493. updateInterval : 60000,
  6494. autoUpdate : true,
  6495. expandToFitView : true,
  6496. init : function(c) {
  6497. var b = Ext.create("Ext.data.JsonStore", {
  6498. fields : ["Date", "Cls", "Text"],
  6499. data : [{
  6500. Date : new Date(),
  6501. Cls : "sch-todayLine",
  6502. Text : this.tooltipText
  6503. }]
  6504. });
  6505. var a = b.first();
  6506. if (this.autoUpdate) {
  6507. this.runner = Ext.create("Ext.util.TaskRunner");
  6508. this.runner.start({
  6509. run : function() {
  6510. a.set("Date", new Date())
  6511. },
  6512. interval : this.updateInterval
  6513. })
  6514. }
  6515. c.on("destroy", this.onHostDestroy, this);
  6516. this.store = b;
  6517. this.callParent(arguments)
  6518. },
  6519. onHostDestroy : function() {
  6520. if (this.runner) {
  6521. this.runner.stopAll()
  6522. }
  6523. if (this.store.autoDestroy) {
  6524. this.store.destroy()
  6525. }
  6526. }
  6527. });
  6528. Ext.define("Sch.plugin.DragSelector", {
  6529. extend : "Sch.util.DragTracker",
  6530. mixins : ["Ext.AbstractPlugin"],
  6531. lockableScope : "normal",
  6532. constructor : function(a) {
  6533. a = a || {};
  6534. Ext.applyIf(a, {
  6535. onBeforeStart : this.onBeforeStart,
  6536. onStart : this.onStart,
  6537. onDrag : this.onDrag,
  6538. onEnd : this.onEnd
  6539. });
  6540. this.callParent(arguments)
  6541. },
  6542. init : function(a) {
  6543. a.on({
  6544. afterrender : this.onSchedulerRender,
  6545. destroy : this.onSchedulerDestroy,
  6546. scope : this
  6547. });
  6548. this.scheduler = a
  6549. },
  6550. onBeforeStart : function(a) {
  6551. return a.ctrlKey
  6552. },
  6553. onStart : function(b) {
  6554. var c = this.schedulerView;
  6555. if (!this.proxy) {
  6556. this.proxy = c.el.createChild({
  6557. cls : "sch-drag-selector x-view-selector"
  6558. })
  6559. } else {
  6560. this.proxy.show()
  6561. }
  6562. this.bodyRegion = c.getScheduleRegion();
  6563. var a = [];
  6564. c.getEventNodes().each(function(d) {
  6565. a[a.length] = {
  6566. region : d.getRegion(),
  6567. node : d.dom
  6568. }
  6569. }, this);
  6570. this.eventData = a;
  6571. this.sm.deselectAll()
  6572. },
  6573. onDrag : function(h) {
  6574. var j = this.sm, f = this.eventData, b = this.getRegion()
  6575. .constrainTo(this.bodyRegion), c, d, a, g;
  6576. this.proxy.setRegion(b);
  6577. for (c = 0, a = f.length; c < a; c++) {
  6578. d = f[c];
  6579. g = b.intersect(d.region);
  6580. if (g && !d.selected) {
  6581. d.selected = true;
  6582. j.selectNode(d.node, true)
  6583. } else {
  6584. if (!g && d.selected) {
  6585. d.selected = false;
  6586. j.deselectNode(d.node)
  6587. }
  6588. }
  6589. }
  6590. },
  6591. onEnd : function(a) {
  6592. if (this.proxy) {
  6593. this.proxy.setDisplayed(false)
  6594. }
  6595. },
  6596. onSchedulerRender : function(a) {
  6597. this.sm = a.getEventSelectionModel();
  6598. this.schedulerView = a.getSchedulingView();
  6599. this.initEl(a.el)
  6600. },
  6601. onSchedulerDestroy : function() {
  6602. Ext.destroy(this.proxy);
  6603. this.destroy()
  6604. }
  6605. });
  6606. Ext.define("Sch.plugin.EventEditor", {
  6607. extend : "Ext.form.FormPanel",
  6608. mixins : ["Ext.AbstractPlugin"],
  6609. alias : "widget.eventeditor",
  6610. lockableScope : "normal",
  6611. requires : ["Sch.util.Date"],
  6612. saveText : "Save",
  6613. deleteText : "Delete",
  6614. cancelText : "Cancel",
  6615. hideOnBlur : true,
  6616. startDateField : null,
  6617. startTimeField : null,
  6618. durationField : null,
  6619. timeConfig : null,
  6620. dateConfig : null,
  6621. durationConfig : null,
  6622. durationUnit : null,
  6623. durationText : null,
  6624. triggerEvent : "eventdblclick",
  6625. fieldsPanelConfig : null,
  6626. dateFormat : "Y-m-d",
  6627. timeFormat : "H:i",
  6628. cls : "sch-eventeditor",
  6629. border : false,
  6630. shadow : false,
  6631. dynamicForm : true,
  6632. eventRecord : null,
  6633. hidden : true,
  6634. collapsed : true,
  6635. currentForm : null,
  6636. scheduler : null,
  6637. schedulerView : null,
  6638. preventHeader : true,
  6639. floating : true,
  6640. hideMode : "offsets",
  6641. ignoreCls : "sch-event-editor-ignore-click",
  6642. layout : {
  6643. type : "vbox",
  6644. align : "stretch"
  6645. },
  6646. constrain : false,
  6647. constructor : function(a) {
  6648. a = a || {};
  6649. Ext.apply(this, a);
  6650. this.durationUnit = this.durationUnit || Sch.util.Date.HOUR;
  6651. this.addEvents("beforeeventdelete", "beforeeventsave");
  6652. this.callParent(arguments)
  6653. },
  6654. initComponent : function() {
  6655. if (!this.fieldsPanelConfig) {
  6656. throw "Must define a fieldsPanelConfig property"
  6657. }
  6658. Ext.apply(this, {
  6659. fbar : this.buttons || this.buildButtons(),
  6660. items : [{
  6661. layout : "hbox",
  6662. height : 35,
  6663. border : false,
  6664. cls : "sch-eventeditor-timefields",
  6665. items : this.buildDurationFields()
  6666. }, Ext.applyIf(this.fieldsPanelConfig, {
  6667. flex : 1,
  6668. activeItem : 0
  6669. })]
  6670. });
  6671. this.callParent(arguments)
  6672. },
  6673. init : function(a) {
  6674. this.ownerCt = a;
  6675. this.scheduler = a;
  6676. this.schedulerView = a.getSchedulingView();
  6677. this.eventStore = a.getEventStore();
  6678. this.schedulerView.on({
  6679. afterrender : this.onSchedulerRender,
  6680. destroy : this.onSchedulerDestroy,
  6681. dragcreateend : this.onDragCreateEnd,
  6682. scope : this
  6683. });
  6684. if (this.triggerEvent) {
  6685. this.schedulerView.on(this.triggerEvent, this.onActivateEditor,
  6686. this)
  6687. }
  6688. this.schedulerView.registerEventEditor(this)
  6689. },
  6690. onSchedulerRender : function() {
  6691. this.render(Ext.getBody());
  6692. if (this.hideOnBlur) {
  6693. this.mon(Ext.getDoc(), "mousedown", this.onMouseDown, this)
  6694. }
  6695. },
  6696. show : function(b, f) {
  6697. if (this.deleteButton) {
  6698. this.deleteButton.setVisible(this.eventStore.indexOf(b) >= 0)
  6699. }
  6700. this.eventRecord = b;
  6701. this.durationField.setValue(Sch.util.Date.getDurationInUnit(b
  6702. .getStartDate(), b.getEndDate(), this.durationUnit));
  6703. var a = b.getStartDate();
  6704. this.startDateField.setValue(a);
  6705. this.startTimeField.setValue(a);
  6706. var d = this.scheduler.up("[floating=true]");
  6707. if (d) {
  6708. this.getEl().setZIndex(d.getEl().getZIndex() + 1);
  6709. d.addCls(this.ignoreCls)
  6710. }
  6711. this.callParent();
  6712. f = f || this.schedulerView.getElementFromEventRecord(b);
  6713. this.alignTo(f, this.scheduler.orientation == "horizontal"
  6714. ? "bl"
  6715. : "tl-tr", this.getConstrainOffsets(f));
  6716. this.expand(!this.constrain);
  6717. if (this.constrain) {
  6718. this.doConstrain(Ext.util.Region.getRegion(Ext.getBody()))
  6719. }
  6720. var g, e = b.get("EventType");
  6721. if (e && this.dynamicForm) {
  6722. var h = this.items.getAt(1), c = h.query("> component[EventType="
  6723. + e + "]");
  6724. if (!c.length) {
  6725. throw "Can't find form for EventType=" + e
  6726. }
  6727. if (!h.getLayout().setActiveItem) {
  6728. throw "Can't switch active component in the 'fieldsPanel'"
  6729. }
  6730. g = c[0];
  6731. if (!(g instanceof Ext.form.Panel)) {
  6732. throw "Each child component of 'fieldsPanel' should be a 'form'"
  6733. }
  6734. h.getLayout().setActiveItem(g)
  6735. } else {
  6736. g = this
  6737. }
  6738. this.currentForm = g;
  6739. g.getForm().loadRecord(b)
  6740. },
  6741. getConstrainOffsets : function(a) {
  6742. return [0, 0]
  6743. },
  6744. onSaveClick : function() {
  6745. var d = this, g = d.eventRecord, a = this.currentForm.getForm();
  6746. if (a.isValid() && this.fireEvent("beforeeventsave", this, g) !== false) {
  6747. var c = d.startDateField.getValue(), h, b = d.startTimeField
  6748. .getValue(), f = d.durationField.getValue();
  6749. if (c && f >= 0) {
  6750. if (b) {
  6751. Sch.util.Date.copyTimeValues(c, b)
  6752. }
  6753. h = Sch.util.Date.add(c, this.durationUnit, f)
  6754. } else {
  6755. return
  6756. }
  6757. var e = g.getResource() || this.resourceRecord;
  6758. if (!this.schedulerView.allowOverlap
  6759. && !this.schedulerView.isDateRangeAvailable(c, h, g, e)) {
  6760. return
  6761. }
  6762. g.beginEdit();
  6763. var i = g.endEdit;
  6764. g.endEdit = Ext.emptyFn;
  6765. a.updateRecord(g);
  6766. g.endEdit = i;
  6767. g.setStartDate(c);
  6768. g.setEndDate(h);
  6769. g.endEdit();
  6770. if (this.eventStore.indexOf(this.eventRecord) < 0) {
  6771. if (this.schedulerView.fireEvent("beforeeventadd",
  6772. this.schedulerView, g) !== false) {
  6773. this.eventStore.add(g)
  6774. }
  6775. }
  6776. d.collapse(null, true)
  6777. }
  6778. },
  6779. onDeleteClick : function() {
  6780. if (this.fireEvent("beforeeventdelete", this, this.eventRecord) !== false) {
  6781. this.eventStore.remove(this.eventRecord)
  6782. }
  6783. this.collapse(null, true)
  6784. },
  6785. onCancelClick : function() {
  6786. this.collapse(null, true)
  6787. },
  6788. buildButtons : function() {
  6789. this.saveButton = new Ext.Button({
  6790. text : this.saveText,
  6791. scope : this,
  6792. handler : this.onSaveClick
  6793. });
  6794. this.deleteButton = new Ext.Button({
  6795. text : this.deleteText,
  6796. scope : this,
  6797. handler : this.onDeleteClick
  6798. });
  6799. this.cancelButton = new Ext.Button({
  6800. text : this.cancelText,
  6801. scope : this,
  6802. handler : this.onCancelClick
  6803. });
  6804. return [this.saveButton, this.deleteButton, this.cancelButton]
  6805. },
  6806. buildDurationFields : function() {
  6807. this.startDateField = new Ext.form.field.Date(Ext.apply({
  6808. width : 90,
  6809. allowBlank : false,
  6810. format : this.dateFormat
  6811. }, this.dateConfig || {}));
  6812. this.startDateField.getPicker().addCls(this.ignoreCls);
  6813. this.startTimeField = new Ext.form.field.Time(Ext.apply({
  6814. width : 70,
  6815. style : "margin-left : 5px",
  6816. allowBlank : false,
  6817. format : this.timeFormat
  6818. }, this.timeConfig || {}));
  6819. this.startTimeField.getPicker().addCls(this.ignoreCls);
  6820. this.durationField = new Ext.form.field.Number(Ext.apply({
  6821. width : 45,
  6822. value : 0,
  6823. minValue : 0,
  6824. allowNegative : false,
  6825. style : "margin-left : 15px"
  6826. }, this.durationConfig || {}));
  6827. this.durationLabel = Ext.create("Ext.form.Label", {
  6828. text : this.getDurationText(),
  6829. style : "margin-left : 5px"
  6830. });
  6831. return [this.startDateField, this.startTimeField, this.durationField,
  6832. this.durationLabel]
  6833. },
  6834. onActivateEditor : function(b, a) {
  6835. this.show(a)
  6836. },
  6837. onMouseDown : function(a) {
  6838. if (this.collapsed || a.within(this.getEl())
  6839. || a.getTarget("." + this.ignoreCls, 9)) {
  6840. return
  6841. }
  6842. this.collapse()
  6843. },
  6844. onSchedulerDestroy : function() {
  6845. this.destroy()
  6846. },
  6847. onDragCreateEnd : function(b, a, c) {
  6848. if (!this.dragProxyEl && this.schedulerView.dragCreator) {
  6849. this.dragProxyEl = this.schedulerView.dragCreator.getProxy()
  6850. }
  6851. this.resourceRecord = c;
  6852. this.schedulerView.onEventCreated(a);
  6853. this.show(a, this.dragProxyEl)
  6854. },
  6855. hide : function() {
  6856. this.callParent(arguments);
  6857. var a = this.dragProxyEl;
  6858. if (a) {
  6859. a.hide()
  6860. }
  6861. },
  6862. afterCollapse : function() {
  6863. this.hide();
  6864. this.callParent(arguments)
  6865. },
  6866. getDurationText : function() {
  6867. if (this.durationText) {
  6868. return this.durationText
  6869. }
  6870. return Sch.util.Date.getShortNameOfUnit(Sch.util.Date
  6871. .getNameOfUnit(this.durationUnit))
  6872. }
  6873. });
  6874. Ext.define("Sch.plugin.EventTools", {
  6875. extend : "Ext.Container",
  6876. mixins : ["Ext.AbstractPlugin"],
  6877. lockableScope : "normal",
  6878. hideDelay : 500,
  6879. align : "right",
  6880. defaults : {
  6881. xtype : "tool",
  6882. baseCls : "sch-tool",
  6883. overCls : "sch-tool-over",
  6884. width : 20,
  6885. height : 20,
  6886. visibleFn : Ext.emptyFn
  6887. },
  6888. fadeOutTimer : null,
  6889. lastTarget : null,
  6890. lastPosition : null,
  6891. cachedSize : null,
  6892. offset : {
  6893. x : 0,
  6894. y : 1
  6895. },
  6896. autoRender : true,
  6897. floating : true,
  6898. hideMode : "offsets",
  6899. getRecord : function() {
  6900. return this.record
  6901. },
  6902. init : function(a) {
  6903. if (!this.items) {
  6904. throw "Must define items property for this plugin to function correctly"
  6905. }
  6906. this.addCls("sch-event-tools");
  6907. this.scheduler = a;
  6908. a.on({
  6909. eventresizestart : this.onOperationStart,
  6910. eventresizeend : this.onOperationEnd,
  6911. eventdragstart : this.onOperationStart,
  6912. eventdrop : this.onOperationEnd,
  6913. eventmouseenter : this.onEventMouseEnter,
  6914. eventmouseleave : this.onContainerMouseLeave,
  6915. scope : this
  6916. })
  6917. },
  6918. onRender : function() {
  6919. this.callParent(arguments);
  6920. this.scheduler.mon(this.el, {
  6921. mouseenter : this.onContainerMouseEnter,
  6922. mouseleave : this.onContainerMouseLeave,
  6923. scope : this
  6924. })
  6925. },
  6926. onEventMouseEnter : function(f, a, e) {
  6927. if (!this.rendered) {
  6928. this.doAutoRender();
  6929. this.hide()
  6930. }
  6931. var d = e.getTarget(f.eventSelector);
  6932. var c = Ext.fly(d).getBox();
  6933. this.lastTarget = d;
  6934. this.record = a;
  6935. this.items.each(function(g) {
  6936. g.setVisible(g.visibleFn(a) !== false)
  6937. }, this);
  6938. this.doLayout();
  6939. var b = this.getSize();
  6940. this.lastPosition = [e.getXY()[0] - (b.width / 2),
  6941. c.y - b.height - this.offset.y];
  6942. this.onContainerMouseEnter()
  6943. },
  6944. onContainerMouseEnter : function() {
  6945. window.clearTimeout(this.fadeOutTimer);
  6946. this.setPosition.apply(this, this.lastPosition);
  6947. this.el.fadeIn()
  6948. },
  6949. onContainerMouseLeave : function() {
  6950. window.clearTimeout(this.fadeOutTimer);
  6951. this.fadeOutTimer = Ext.defer(this.el.fadeOut, this.hideDelay, this.el)
  6952. },
  6953. onOperationStart : function() {
  6954. this.scheduler.un("eventmouseenter", this.onEventMouseEnter, this);
  6955. window.clearTimeout(this.fadeOutTimer);
  6956. this.hide()
  6957. },
  6958. hide : function() {
  6959. this.el.hide()
  6960. },
  6961. onOperationEnd : function() {
  6962. this.scheduler.on("eventmouseenter", this.onEventMouseEnter, this)
  6963. }
  6964. });
  6965. Ext.define("Sch.plugin.Pan", {
  6966. alias : "plugin.pan",
  6967. extend : "Ext.AbstractPlugin",
  6968. lockableScope : "normal",
  6969. enableVerticalPan : true,
  6970. panel : null,
  6971. constructor : function(a) {
  6972. Ext.apply(this, a)
  6973. },
  6974. init : function(a) {
  6975. this.panel = a.normalGrid || a;
  6976. this.view = a.getSchedulingView();
  6977. this.view.on("afterrender", this.onRender, this)
  6978. },
  6979. onRender : function(a) {
  6980. this.view.el.on("mousedown", this.onMouseDown, this)
  6981. },
  6982. onMouseDown : function(b, a) {
  6983. if (b.getTarget("." + this.view.timeCellCls, 10)
  6984. && !b.getTarget(this.view.eventSelector)) {
  6985. this.mouseX = b.getPageX();
  6986. this.mouseY = b.getPageY();
  6987. Ext.getBody().on("mousemove", this.onMouseMove, this);
  6988. Ext.getDoc().on("mouseup", this.onMouseUp, this);
  6989. if (Ext.isIE || Ext.isGecko) {
  6990. Ext.getBody().on("mouseenter", this.onMouseUp, this)
  6991. }
  6992. b.stopEvent()
  6993. }
  6994. },
  6995. onMouseMove : function(d) {
  6996. d.stopEvent();
  6997. var a = d.getPageX(), f = d.getPageY(), c = a - this.mouseX, b = f
  6998. - this.mouseY;
  6999. this.panel.scrollByDeltaX(-c);
  7000. this.mouseX = a;
  7001. this.mouseY = f;
  7002. if (this.enableVerticalPan) {
  7003. this.panel.scrollByDeltaY(-b)
  7004. }
  7005. },
  7006. onMouseUp : function(a) {
  7007. Ext.getBody().un("mousemove", this.onMouseMove, this);
  7008. Ext.getDoc().un("mouseup", this.onMouseUp, this);
  7009. if (Ext.isIE || Ext.isGecko) {
  7010. Ext.getBody().un("mouseenter", this.onMouseUp, this)
  7011. }
  7012. }
  7013. });
  7014. Ext.define("Sch.plugin.SimpleEditor", {
  7015. extend : "Ext.Editor",
  7016. mixins : ["Ext.AbstractPlugin"],
  7017. lockableScope : "normal",
  7018. cls : "sch-simpleeditor",
  7019. allowBlur : false,
  7020. newEventText : "New booking...",
  7021. delegate : ".sch-event-inner",
  7022. dataIndex : null,
  7023. completeOnEnter : true,
  7024. cancelOnEsc : true,
  7025. ignoreNoChange : true,
  7026. height : 19,
  7027. autoSize : {
  7028. width : "boundEl"
  7029. },
  7030. constructor : function(a) {
  7031. a = a || {};
  7032. a.field = a.field || Ext.create("Ext.form.TextField", {
  7033. selectOnFocus : true
  7034. });
  7035. this.callParent(arguments)
  7036. },
  7037. init : function(a) {
  7038. this.scheduler = a.getSchedulingView();
  7039. a.on("afterrender", this.onSchedulerRender, this);
  7040. this.scheduler.registerEventEditor(this);
  7041. this.dataIndex = this.dataIndex
  7042. || this.scheduler.getEventStore().model.prototype.nameField
  7043. },
  7044. edit : function(a, b) {
  7045. b = b || this.scheduler.getElementFromEventRecord(a);
  7046. this.startEdit(b.child(this.delegate));
  7047. this.record = a;
  7048. this.setValue(this.record.get(this.dataIndex))
  7049. },
  7050. onSchedulerRender : function(a) {
  7051. this.on({
  7052. startedit : this.onBeforeEdit,
  7053. complete : function(e, f, d) {
  7054. var b = this.record;
  7055. var c = this.scheduler.eventStore;
  7056. b.set(this.dataIndex, f);
  7057. if (c.indexOf(b) < 0) {
  7058. if (this.scheduler
  7059. .fireEvent("beforeeventadd",
  7060. this.scheduler, b) !== false) {
  7061. c.add(b)
  7062. }
  7063. }
  7064. this.onAfterEdit()
  7065. },
  7066. canceledit : this.onAfterEdit,
  7067. hide : function() {
  7068. if (this.dragProxyEl) {
  7069. this.dragProxyEl.hide()
  7070. }
  7071. },
  7072. scope : this
  7073. });
  7074. a.on({
  7075. eventdblclick : function(b, c, d) {
  7076. this.edit(c)
  7077. },
  7078. dragcreateend : this.onDragCreateEnd,
  7079. scope : this
  7080. })
  7081. },
  7082. onBeforeEdit : function() {
  7083. if (!this.allowBlur) {
  7084. Ext.getBody().on("mousedown", this.onMouseDown, this);
  7085. this.scheduler.on("eventmousedown", function() {
  7086. this.cancelEdit()
  7087. }, this)
  7088. }
  7089. },
  7090. onAfterEdit : function() {
  7091. if (!this.allowBlur) {
  7092. Ext.getBody().un("mousedown", this.onMouseDown, this);
  7093. this.scheduler.un("eventmousedown", function() {
  7094. this.cancelEdit()
  7095. }, this)
  7096. }
  7097. },
  7098. onMouseDown : function(b, a) {
  7099. if (this.editing && this.el && !b.within(this.el)) {
  7100. this.cancelEdit()
  7101. }
  7102. },
  7103. onDragCreateEnd : function(b, a) {
  7104. if (!this.dragProxyEl && this.scheduler.dragCreator) {
  7105. this.dragProxyEl = this.scheduler.dragCreator.getProxy()
  7106. }
  7107. this.scheduler.onEventCreated(a);
  7108. if (a.get(this.dataIndex) === "") {
  7109. a.set(this.dataIndex, this.newEventText)
  7110. }
  7111. this.edit(a, this.dragProxyEl)
  7112. }
  7113. });
  7114. Ext.define("Sch.plugin.SummaryColumn", {
  7115. extend : "Ext.grid.column.Column",
  7116. mixins : ["Ext.AbstractPlugin"],
  7117. lockableScope : "top",
  7118. alias : "widget.summarycolumn",
  7119. showPercent : false,
  7120. nbrDecimals : 1,
  7121. sortable : false,
  7122. fixed : true,
  7123. menuDisabled : true,
  7124. width : 80,
  7125. dataIndex : "_sch_not_used",
  7126. constructor : function(a) {
  7127. this.scope = this;
  7128. this.callParent(arguments)
  7129. },
  7130. init : function(a) {
  7131. if (!("eventStore" in a)) {
  7132. return
  7133. }
  7134. this.scheduler = a;
  7135. this.scheduler.lockedGridDependsOnSchedule = true;
  7136. this.eventStore = a.eventStore
  7137. },
  7138. renderer : function(j, a, f) {
  7139. var h = this.scheduler, k = this.eventStore, e = h.getStart(), i = h
  7140. .getEnd(), c = 0, b = this.calculate(f.getEvents(), e,
  7141. i);
  7142. if (b <= 0) {
  7143. return ""
  7144. }
  7145. if (this.showPercent) {
  7146. var d = Sch.util.Date.getDurationInMinutes(e, i);
  7147. return (Math.round((b * 100) / d)) + " %"
  7148. } else {
  7149. if (b > 1440) {
  7150. return (b / 1440).toFixed(this.nbrDecimals) + " "
  7151. + Sch.util.Date.getShortNameOfUnit("DAY")
  7152. }
  7153. if (b >= 30) {
  7154. return (b / 60).toFixed(this.nbrDecimals) + " "
  7155. + Sch.util.Date.getShortNameOfUnit("HOUR")
  7156. }
  7157. return b + " " + Sch.util.Date.getShortNameOfUnit("MINUTE")
  7158. }
  7159. },
  7160. calculate : function(c, g, d) {
  7161. var e = 0, b, a, f = Sch.util.Date;
  7162. Ext.each(c, function(h) {
  7163. b = h.getStartDate();
  7164. a = h.getEndDate();
  7165. if (f.intersectSpans(g, d, b, a)) {
  7166. e += f.getDurationInMinutes(f.max(b, g), f.min(
  7167. a, d))
  7168. }
  7169. });
  7170. return e
  7171. }
  7172. });
  7173. Ext.define("Sch.plugin.Zones", {
  7174. extend : "Sch.feature.AbstractTimeSpan",
  7175. innerTpl : null,
  7176. requires : ["Sch.model.Range"],
  7177. cls : "sch-zone",
  7178. init : function(a) {
  7179. if (Ext.isString(this.innerTpl)) {
  7180. this.innerTpl = new Ext.XTemplate(this.innerTpl)
  7181. }
  7182. var b = this.innerTpl;
  7183. if (!this.template) {
  7184. this.template = new Ext.XTemplate(
  7185. '<tpl for="."><div id="'
  7186. + this.uniqueCls
  7187. + '-{id}" class="'
  7188. + this.cls
  7189. + " "
  7190. + this.uniqueCls
  7191. + ' {Cls}" style="left:{left}px;top:{top}px;height:{height}px;width:{width}px;{style}">'
  7192. + (b ? "{[this.renderInner(values)]}" : "")
  7193. + "</div></tpl>", {
  7194. renderInner : function(c) {
  7195. return b.apply(c)
  7196. }
  7197. })
  7198. }
  7199. this.callParent(arguments)
  7200. },
  7201. getElementData : function(k, o, d, p) {
  7202. var q = this.store, j = this.schedulerView, f = d || q.getRange(), h = [], a, n, c, m;
  7203. for (var g = 0, e = f.length; g < e; g++) {
  7204. a = f[g];
  7205. n = a.getStartDate();
  7206. c = a.getEndDate();
  7207. if (n && c && Sch.util.Date.intersectSpans(n, c, k, o)) {
  7208. m = j.getTimeSpanRegion(Sch.util.Date.max(n, k), Sch.util.Date
  7209. .min(c, o), this.expandToFitView);
  7210. var b = m.right - m.left;
  7211. h[h.length] = Ext.apply({
  7212. id : a.internalId,
  7213. left : m.left,
  7214. top : m.top,
  7215. width : p ? 0 : b,
  7216. height : m.bottom - m.top,
  7217. style : p ? ("border-left-width:" + b + "px") : "",
  7218. Cls : a.getCls()
  7219. }, a.data)
  7220. }
  7221. }
  7222. return h
  7223. }
  7224. });
  7225. Ext.define("Sch.plugin.TimeGap", {
  7226. extend : "Sch.plugin.Zones",
  7227. getZoneCls : Ext.emptyFn,
  7228. init : function(a) {
  7229. this.store = new Ext.data.JsonStore({
  7230. model : "Sch.model.Range"
  7231. });
  7232. this.scheduler = a;
  7233. a.mon(a.eventStore, {
  7234. load : this.populateStore,
  7235. update : this.populateStore,
  7236. remove : this.populateStore,
  7237. add : this.populateStore,
  7238. datachanged : this.populateStore,
  7239. scope : this
  7240. });
  7241. a.on("viewchange", this.populateStore, this);
  7242. this.schedulerView = a.getSchedulingView();
  7243. this.callParent(arguments)
  7244. },
  7245. populateStore : function(c) {
  7246. var b = this.schedulerView.getEventsInView(), f = [], e = this.scheduler
  7247. .getStart(), i = this.scheduler.getEnd(), d = b.getCount(), j = e, h, g = 0, a;
  7248. b.sortBy(function(l, k) {
  7249. return l.getStartDate() - k.getStartDate()
  7250. });
  7251. a = b.getAt(0);
  7252. while (j < i && g < d) {
  7253. h = a.getStartDate();
  7254. if (!Sch.util.Date.betweenLesser(j, h, a.getEndDate()) && j < h) {
  7255. f.push(new this.store.model({
  7256. StartDate : j,
  7257. EndDate : h,
  7258. Cls : this.getZoneCls(j, h) || ""
  7259. }))
  7260. }
  7261. j = Sch.util.Date.max(a.getEndDate(), j);
  7262. g++;
  7263. a = b.getAt(g)
  7264. }
  7265. if (j < i) {
  7266. f.push(new this.store.model({
  7267. StartDate : j,
  7268. EndDate : i,
  7269. Cls : this.getZoneCls(j, i) || ""
  7270. }))
  7271. }
  7272. this.store.removeAll(f.length > 0);
  7273. this.store.add(f)
  7274. }
  7275. });
  7276. Ext.define("Sch.plugin.TreeCellEditing", {
  7277. extend : "Ext.grid.plugin.CellEditing",
  7278. init : function(a) {
  7279. this._grid = a;
  7280. this.on("beforeedit", this.checkReadOnly, this);
  7281. this.callParent(arguments)
  7282. },
  7283. checkReadOnly : function() {
  7284. var a = this._grid;
  7285. if (!(a instanceof Sch.panel.TimelineTreePanel)) {
  7286. a = a.up("tablepanel")
  7287. }
  7288. return !a.isReadOnly()
  7289. },
  7290. startEditByClick : function(c, a, h, b, g, d, f) {
  7291. if (f.getTarget(c.expanderSelector)) {
  7292. return
  7293. }
  7294. this.callParent(arguments)
  7295. },
  7296. startEdit : function(a, f) {
  7297. if (!a || !f) {
  7298. return
  7299. }
  7300. var d = this, b = d.getEditor(a, f), e = a.get(f.dataIndex), c = d
  7301. .getEditingContext(a, f);
  7302. a = c.record;
  7303. f = c.column;
  7304. d.completeEdit();
  7305. if (f && !f.getEditor(a)) {
  7306. return false
  7307. }
  7308. if (b) {
  7309. c.originalValue = c.value = e;
  7310. if (d.beforeEdit(c) === false
  7311. || d.fireEvent("beforeedit", c) === false || c.cancel) {
  7312. return false
  7313. }
  7314. d.context = c;
  7315. d.setActiveEditor(b);
  7316. d.setActiveRecord(a);
  7317. d.setActiveColumn(f);
  7318. d.grid.view.focusCell({
  7319. column : c.colIdx,
  7320. row : c.rowIdx
  7321. });
  7322. d.editTask.delay(15, d.showEditor, d, [b, c, c.value])
  7323. } else {
  7324. d.grid.getView().getEl(f).focus((Ext.isWebKit || Ext.isIE)
  7325. ? 10
  7326. : false)
  7327. }
  7328. },
  7329. showEditor : function(b, c, g) {
  7330. var e = this, a = c.record, f = c.column, h = e.grid
  7331. .getSelectionModel(), d = h.getCurrentPosition
  7332. && h.getCurrentPosition();
  7333. e.context = c;
  7334. e.setActiveEditor(b);
  7335. e.setActiveRecord(a);
  7336. e.setActiveColumn(f);
  7337. if (h.selectByPosition
  7338. && (!d || d.column !== c.colIdx || d.row !== c.rowIdx)) {
  7339. h.selectByPosition({
  7340. row : c.rowIdx,
  7341. column : c.colIdx
  7342. })
  7343. }
  7344. b.startEdit(e.getCell(a, f), g, c);
  7345. e.editing = true;
  7346. e.scroll = e.view.el.getScroll()
  7347. },
  7348. getEditingContext : function(e, c) {
  7349. var f = this, a = f.grid, i = a.store, b, d, g = a.getView(), h;
  7350. if (Ext.isNumber(e)) {
  7351. b = e;
  7352. e = i.getAt(b)
  7353. } else {
  7354. if (i instanceof Ext.data.Store) {
  7355. b = i.indexOf(e)
  7356. } else {
  7357. b = g.indexOf(g.getNode(e))
  7358. }
  7359. }
  7360. if (Ext.isNumber(c)) {
  7361. d = c;
  7362. c = a.headerCt.getHeaderAtIndex(d)
  7363. } else {
  7364. d = c.getIndex()
  7365. }
  7366. h = e.get(c.dataIndex);
  7367. return {
  7368. grid : a,
  7369. record : e,
  7370. field : c.dataIndex,
  7371. value : h,
  7372. row : g.getNode(b),
  7373. column : c,
  7374. rowIdx : b,
  7375. colIdx : d
  7376. }
  7377. },
  7378. startEditByPosition : function(a) {
  7379. var f = this, d = f.grid, h = d.getSelectionModel(), b = f.view, e = this.view
  7380. .getNode(a.row), g = d.headerCt.getHeaderAtIndex(a.column), c = b
  7381. .getRecord(e);
  7382. if (h.selectByPosition) {
  7383. h.selectByPosition(a)
  7384. }
  7385. f.startEdit(c, g)
  7386. },
  7387. onEditComplete : function(c, g, b) {
  7388. var f = this, d = f.grid, e = f.getActiveColumn(), h = d
  7389. .getSelectionModel(), a;
  7390. if (e) {
  7391. a = f.context.record;
  7392. f.setActiveEditor(null);
  7393. f.setActiveColumn(null);
  7394. f.setActiveRecord(null);
  7395. if (!f.validateEdit()) {
  7396. return
  7397. }
  7398. if (!f.context.doNotUpdateRecord && !a.isEqual(g, b)) {
  7399. a.set(e.dataIndex, g)
  7400. }
  7401. if (h.setCurrentPosition) {
  7402. h.setCurrentPosition(h.getCurrentPosition())
  7403. }
  7404. d.getView().getEl(e).focus();
  7405. f.context.value = g;
  7406. f.fireEvent("edit", f, f.context)
  7407. }
  7408. },
  7409. onSpecialKey : function(a, f, d) {
  7410. if (!Ext.versions.extjs.equals("4.1.2.381")) {
  7411. return this.callParent(arguments)
  7412. }
  7413. var c = this, b = this.grid, g;
  7414. if (d.getKey() === d.TAB) {
  7415. d.stopEvent();
  7416. if (a) {
  7417. a.onEditorTab(d)
  7418. }
  7419. g = b.getSelectionModel();
  7420. if (g.onEditorTab) {
  7421. return g.onEditorTab(b === c.grid ? c : c.lockingPartner, d)
  7422. }
  7423. }
  7424. }
  7425. });
  7426. Ext.define("Sch.plugin.ResourceZones", {
  7427. extend : "Sch.plugin.Zones",
  7428. store : null,
  7429. cls : "sch-resourcezone",
  7430. getElementData : function(e, h, a) {
  7431. var g = this.store, f = this.schedulerView, d = [], i, b, c;
  7432. if (f.getNodes().length > 0) {
  7433. Ext.each(a || g.getRange(), function(j) {
  7434. var k = j.getResource();
  7435. i = j.getStartDate();
  7436. b = j.getEndDate();
  7437. if (k
  7438. && (f.resourceStore.indexOf ? f.resourceStore : f.store)
  7439. .indexOf(k) >= 0
  7440. && Sch.util.Date.intersectSpans(i, b, e, h)) {
  7441. c = f.getResourceRegion(k, i, b);
  7442. d[d.length] = Ext.apply({
  7443. id : j.internalId,
  7444. left : c.left,
  7445. top : c.top,
  7446. width : c.right - c.left,
  7447. height : c.bottom - c.top,
  7448. Cls : j.getCls()
  7449. }, j.data)
  7450. }
  7451. })
  7452. }
  7453. return d
  7454. }
  7455. });
  7456. Ext.define("Sch.widget.ResizePicker", {
  7457. extend : "Ext.Panel",
  7458. alias : "widget.dualrangepicker",
  7459. width : 200,
  7460. height : 200,
  7461. border : true,
  7462. collapsible : false,
  7463. bodyStyle : "position:absolute; margin:5px",
  7464. verticalCfg : {
  7465. height : 120,
  7466. value : 24,
  7467. increment : 2,
  7468. minValue : 20,
  7469. maxValue : 80,
  7470. reverse : true,
  7471. disabled : true
  7472. },
  7473. horizontalCfg : {
  7474. width : 120,
  7475. value : 100,
  7476. minValue : 25,
  7477. increment : 5,
  7478. maxValue : 200,
  7479. disable : true
  7480. },
  7481. initComponent : function() {
  7482. var a = this;
  7483. a.addEvents("change", "changecomplete", "select");
  7484. a.horizontalCfg.value = a.dialogConfig.columnWidth;
  7485. a.verticalCfg.value = a.dialogConfig.rowHeight;
  7486. a.verticalCfg.disabled = a.dialogConfig.scrollerDisabled || false;
  7487. a.dockedItems = [a.vertical = new Ext.slider.Single(Ext.apply({
  7488. dock : "left",
  7489. style : "margin-top:10px",
  7490. vertical : true,
  7491. listeners : {
  7492. change : a.onSliderChange,
  7493. changecomplete : a.onSliderChangeComplete,
  7494. scope : a
  7495. }
  7496. }, a.verticalCfg)),
  7497. a.horizontal = new Ext.slider.Single(Ext.apply({
  7498. dock : "top",
  7499. style : "margin-left:28px",
  7500. listeners : {
  7501. change : a.onSliderChange,
  7502. changecomplete : a.onSliderChangeComplete,
  7503. scope : a
  7504. }
  7505. }, a.horizontalCfg))];
  7506. a.callParent(arguments)
  7507. },
  7508. afterRender : function() {
  7509. var b = this;
  7510. b.addCls("sch-ux-range-picker");
  7511. b.valueHandle = this.body.createChild({
  7512. cls : "sch-ux-range-value",
  7513. cn : {
  7514. tag : "span"
  7515. }
  7516. });
  7517. b.valueSpan = this.valueHandle.down("span");
  7518. var a = new Ext.dd.DD(this.valueHandle);
  7519. Ext.apply(a, {
  7520. startDrag : function() {
  7521. b.dragging = true;
  7522. this.constrainTo(b.body)
  7523. },
  7524. onDrag : function() {
  7525. b.onHandleDrag.apply(b, arguments)
  7526. },
  7527. endDrag : function() {
  7528. b.onHandleEndDrag.apply(b, arguments);
  7529. b.dragging = false
  7530. },
  7531. scope : this
  7532. });
  7533. this.setValues(this.getValues());
  7534. this.callParent(arguments);
  7535. this.body.on("click", this.onBodyClick, this)
  7536. },
  7537. onBodyClick : function(c, a) {
  7538. var b = [c.getXY()[0] - 8 - this.body.getX(),
  7539. c.getXY()[1] - 8 - this.body.getY()];
  7540. this.valueHandle.setLeft(Ext.Number.constrain(b[0], 0, this
  7541. .getAvailableWidth()));
  7542. this.valueHandle.setTop(Ext.Number.constrain(b[1], 0, this
  7543. .getAvailableHeight()));
  7544. this.setValues(this.getValuesFromXY([this.valueHandle.getLeft(true),
  7545. this.valueHandle.getTop(true)]));
  7546. this.onSliderChangeComplete()
  7547. },
  7548. getAvailableWidth : function() {
  7549. return this.body.getWidth() - 18
  7550. },
  7551. getAvailableHeight : function() {
  7552. return this.body.getHeight() - 18
  7553. },
  7554. onHandleDrag : function() {
  7555. this.setValues(this.getValuesFromXY([this.valueHandle.getLeft(true),
  7556. this.valueHandle.getTop(true)]))
  7557. },
  7558. onHandleEndDrag : function() {
  7559. this.setValues(this.getValuesFromXY([this.valueHandle.getLeft(true),
  7560. this.valueHandle.getTop(true)]))
  7561. },
  7562. getValuesFromXY : function(d) {
  7563. var c = d[0] / this.getAvailableWidth();
  7564. var a = d[1] / this.getAvailableHeight();
  7565. var e = Math
  7566. .round((this.horizontalCfg.maxValue - this.horizontalCfg.minValue)
  7567. * c);
  7568. var b = Math
  7569. .round((this.verticalCfg.maxValue - this.verticalCfg.minValue)
  7570. * a)
  7571. + this.verticalCfg.minValue;
  7572. return [e + this.horizontalCfg.minValue, b]
  7573. },
  7574. getXYFromValues : function(d) {
  7575. var b = this.horizontalCfg.maxValue - this.horizontalCfg.minValue;
  7576. var f = this.verticalCfg.maxValue - this.verticalCfg.minValue;
  7577. var a = Math.round((d[0] - this.horizontalCfg.minValue)
  7578. * this.getAvailableWidth() / b);
  7579. var c = d[1] - this.verticalCfg.minValue;
  7580. var e = Math.round(c * this.getAvailableHeight() / f);
  7581. return [a, e]
  7582. },
  7583. updatePosition : function() {
  7584. var a = this.getValues();
  7585. var b = this.getXYFromValues(a);
  7586. this.valueHandle.setLeft(Ext.Number.constrain(b[0], 0, this
  7587. .getAvailableWidth()));
  7588. if (this.verticalCfg.disabled) {
  7589. this.valueHandle.setTop(this.dialogConfig.rowHeight)
  7590. } else {
  7591. this.valueHandle.setTop(Ext.Number.constrain(b[1], 0, this
  7592. .getAvailableHeight()))
  7593. }
  7594. this.positionValueText();
  7595. this.setValueText(a)
  7596. },
  7597. positionValueText : function() {
  7598. var a = this.valueHandle.getTop(true);
  7599. var b = this.valueHandle.getLeft(true);
  7600. this.valueSpan.setLeft(b > 30 ? -30 : 10);
  7601. this.valueSpan.setTop(a > 10 ? -20 : 20)
  7602. },
  7603. setValueText : function(a) {
  7604. if (this.verticalCfg.disabled) {
  7605. a[1] = this.dialogConfig.rowHeight
  7606. }
  7607. this.valueSpan.update("[" + a.toString() + "]")
  7608. },
  7609. setValues : function(a) {
  7610. this.horizontal.setValue(a[0]);
  7611. if (this.verticalCfg.reverse) {
  7612. if (!this.verticalCfg.disabled) {
  7613. this.vertical.setValue(this.verticalCfg.maxValue
  7614. + this.verticalCfg.minValue - a[1])
  7615. }
  7616. } else {
  7617. if (!this.verticalCfg.disabled) {
  7618. this.vertical.setValue(a[1])
  7619. }
  7620. }
  7621. if (!this.dragging) {
  7622. this.updatePosition()
  7623. }
  7624. this.positionValueText();
  7625. this.setValueText(a)
  7626. },
  7627. getValues : function() {
  7628. var a = this.vertical.getValue();
  7629. if (this.verticalCfg.reverse) {
  7630. a = this.verticalCfg.maxValue - a + this.verticalCfg.minValue
  7631. }
  7632. return [this.horizontal.getValue(), a]
  7633. },
  7634. onSliderChange : function() {
  7635. this.fireEvent("change", this, this.getValues());
  7636. if (!this.dragging) {
  7637. this.updatePosition()
  7638. }
  7639. },
  7640. onSliderChangeComplete : function() {
  7641. this.fireEvent("changecomplete", this, this.getValues())
  7642. },
  7643. afterLayout : function() {
  7644. this.callParent(arguments);
  7645. this.updatePosition()
  7646. }
  7647. });
  7648. Ext.define("Sch.widget.ExportDialogForm", {
  7649. extend : "Ext.form.Panel",
  7650. requires : ["Ext.ProgressBar", "Sch.widget.ResizePicker"],
  7651. border : false,
  7652. bodyPadding : "10 10 0 10",
  7653. autoHeight : true,
  7654. initComponent : function() {
  7655. var a = this;
  7656. a.createFields();
  7657. Ext.apply(this, {
  7658. fieldDefaults : {
  7659. labelAlign : "top",
  7660. labelWidth : 100,
  7661. anchor : "90%"
  7662. },
  7663. items : [a.rangeField, a.resizePicker, a.dateFromField,
  7664. a.dateToField, a.showHeaderField, a.formatField,
  7665. a.orientationField,
  7666. a.progressBar || a.createProgressBar()]
  7667. });
  7668. a.callParent(arguments);
  7669. a.on({
  7670. hideprogressbar : a.hideProgressBar,
  7671. showprogressbar : a.showProgressBar,
  7672. updateprogressbar : a.updateProgressBar,
  7673. scope : a
  7674. })
  7675. },
  7676. createFields : function() {
  7677. var b = this, a = b.dialogConfig;
  7678. b.rangeField = new Ext.form.field.ComboBox({
  7679. xtype : "combo",
  7680. value : "complete",
  7681. triggerAction : "all",
  7682. cls : "sch-export-dialog-range",
  7683. forceSelection : true,
  7684. editable : false,
  7685. fieldLabel : a.rangeFieldLabel,
  7686. name : "range",
  7687. queryMode : "local",
  7688. displayField : "name",
  7689. valueField : "value",
  7690. store : Ext.create("Ext.data.Store", {
  7691. fields : ["name", "value"],
  7692. data : [{
  7693. name : a.completeView,
  7694. value : "complete"
  7695. }, {
  7696. name : a.dateRange,
  7697. value : "date"
  7698. }, {
  7699. name : a.currentView,
  7700. value : "current"
  7701. }]
  7702. }),
  7703. listeners : {
  7704. change : b.onRangeChange,
  7705. scope : b
  7706. }
  7707. });
  7708. b.resizePicker = new Sch.widget.ResizePicker({
  7709. dialogConfig : a,
  7710. hidden : true,
  7711. padding : "0 0 5 0"
  7712. });
  7713. b.dateFromField = new Ext.form.field.Date({
  7714. fieldLabel : a.dateRangeFrom,
  7715. labelAlign : "left",
  7716. labelWidth : 80,
  7717. baseBodyCls : "sch-exportdialogform-date",
  7718. padding : "10 0 5 0",
  7719. name : "dateFrom",
  7720. format : a.dateRangeFormat || Ext.Date.defaultFormat,
  7721. hidden : true,
  7722. allowBlank : false,
  7723. maxValue : a.endDate,
  7724. minValue : a.startDate,
  7725. value : a.startDate,
  7726. validator : function(c) {
  7727. return Ext.Date.parse(c, this.format) >= new Date(a.startDate)
  7728. }
  7729. });
  7730. b.dateToField = new Ext.form.field.Date({
  7731. fieldLabel : a.dateRangeTo,
  7732. labelAlign : "left",
  7733. labelWidth : 80,
  7734. name : "dateTo",
  7735. format : a.dateRangeFormat || Ext.Date.defaultFormat,
  7736. baseBodyCls : "sch-exportdialogform-date",
  7737. hidden : true,
  7738. allowBlank : false,
  7739. maxValue : a.endDate,
  7740. minValue : a.startDate,
  7741. value : a.endDate,
  7742. validator : function(c) {
  7743. return Ext.Date.parse(c, this.format) <= new Date(a.endDate)
  7744. }
  7745. });
  7746. b.showHeaderField = new Ext.form.field.Checkbox({
  7747. xtype : "checkboxfield",
  7748. fieldLabel : b.dialogConfig.showHeaderLabel,
  7749. name : "showHeader",
  7750. checked : true
  7751. });
  7752. b.formatField = new Ext.form.field.ComboBox({
  7753. value : "A4",
  7754. triggerAction : "all",
  7755. forceSelection : true,
  7756. editable : false,
  7757. fieldLabel : a.formatFieldLabel,
  7758. name : "format",
  7759. queryMode : "local",
  7760. store : ["A5", "A4", "A3", "Letter"]
  7761. });
  7762. b.orientationField = new Ext.form.field.ComboBox({
  7763. value : "portrait",
  7764. triggerAction : "all",
  7765. baseBodyCls : "sch-exportdialogform-orientation",
  7766. forceSelection : true,
  7767. editable : false,
  7768. fieldLabel : b.dialogConfig.orientationFieldLabel,
  7769. afterSubTpl : new Ext.XTemplate('<span id="sch-exportdialog-imagePortrait"></span><span id="sch-exportdialog-imageLandscape" class="sch-none"></span>'),
  7770. name : "orientation",
  7771. displayField : "name",
  7772. valueField : "value",
  7773. queryMode : "local",
  7774. store : Ext.create("Ext.data.Store", {
  7775. fields : ["name", "value"],
  7776. data : [{
  7777. name : a.orientationPortrait,
  7778. value : "portrait"
  7779. }, {
  7780. name : a.orientationLandscape,
  7781. value : "landscape"
  7782. }]
  7783. }),
  7784. listeners : {
  7785. change : function(d, c) {
  7786. switch (c) {
  7787. case "landscape" :
  7788. Ext.fly("sch-exportdialog-imagePortrait")
  7789. .toggleCls("sch-none");
  7790. Ext.fly("sch-exportdialog-imageLandscape")
  7791. .toggleCls("sch-none");
  7792. break;
  7793. case "portrait" :
  7794. Ext.fly("sch-exportdialog-imagePortrait")
  7795. .toggleCls("sch-none");
  7796. Ext.fly("sch-exportdialog-imageLandscape")
  7797. .toggleCls("sch-none");
  7798. break
  7799. }
  7800. }
  7801. }
  7802. })
  7803. },
  7804. createProgressBar : function() {
  7805. return this.progressBar = new Ext.ProgressBar({
  7806. text : this.config.progressBarText,
  7807. animate : true,
  7808. hidden : true,
  7809. id : "print-widget-progressbar"
  7810. })
  7811. },
  7812. onRangeChange : function(b, a) {
  7813. switch (a) {
  7814. case "complete" :
  7815. this.dateFromField.hide();
  7816. this.dateToField.hide();
  7817. this.resizePicker.hide();
  7818. break;
  7819. case "date" :
  7820. this.dateFromField.show();
  7821. this.dateToField.show();
  7822. this.resizePicker.hide();
  7823. break;
  7824. case "current" :
  7825. this.dateFromField.hide();
  7826. this.dateToField.hide();
  7827. this.resizePicker.show();
  7828. this.resizePicker.expand(true);
  7829. break
  7830. }
  7831. },
  7832. showProgressBar : function() {
  7833. if (this.progressBar) {
  7834. this.progressBar.show()
  7835. }
  7836. },
  7837. hideProgressBar : function() {
  7838. if (this.progressBar) {
  7839. this.progressBar.hide()
  7840. }
  7841. },
  7842. updateProgressBar : function(a) {
  7843. if (this.progressBar) {
  7844. this.progressBar.updateProgress(a)
  7845. }
  7846. }
  7847. });
  7848. Ext.define("Sch.widget.ExportDialog", {
  7849. alternateClassName : "Sch.widget.PdfExportDialog",
  7850. extend : "Ext.window.Window",
  7851. alias : "widget.exportdialog",
  7852. modal : false,
  7853. width : 240,
  7854. cls : "sch-exportdialog",
  7855. frame : false,
  7856. layout : "card",
  7857. draggable : false,
  7858. padding : 0,
  7859. plugin : null,
  7860. hideTime : 2000,
  7861. buttonsPanel : null,
  7862. buttonsPanelScope : null,
  7863. progressBar : null,
  7864. generalError : "An error occured, try again.",
  7865. title : "Export Settings",
  7866. formatFieldLabel : "Paper format",
  7867. orientationFieldLabel : "Orientation",
  7868. rangeFieldLabel : "Export range",
  7869. showHeaderLabel : "Add page number",
  7870. orientationPortrait : "Portrait",
  7871. orientationLandscape : "Landscape",
  7872. completeView : "Complete schedule",
  7873. currentView : "Current view",
  7874. dateRange : "Date range",
  7875. dateRangeFrom : "Export from",
  7876. pickerText : "Resize column/rows to desired value",
  7877. dateRangeTo : "Export to",
  7878. exportButtonText : "Export",
  7879. cancelButtonText : "Cancel",
  7880. progressBarText : "Exporting...",
  7881. dateRangeFormat : "",
  7882. requires : ["Sch.widget.ExportDialogForm"],
  7883. constructor : function(a) {
  7884. Ext.apply(this, a.exportDialogConfig);
  7885. this.config = Ext.apply({
  7886. progressBarText : this.progressBarText,
  7887. cancelButtonText : this.cancelButtonText,
  7888. exportButtonText : this.exportButtonText,
  7889. dateRangeTo : this.dateRangeTo,
  7890. pickerText : this.pickerText,
  7891. dateRangeFrom : this.dateRangeFrom,
  7892. dateRange : this.dateRange,
  7893. currentView : this.currentView,
  7894. formatFieldLabel : this.formatFieldLabel,
  7895. orientationFieldLabel : this.orientationFieldLabel,
  7896. rangeFieldLabel : this.rangeFieldLabel,
  7897. showHeaderLabel : this.showHeaderLabel,
  7898. orientationPortrait : this.orientationPortrait,
  7899. orientationLandscape : this.orientationLandscape,
  7900. completeView : this.completeView,
  7901. dateRangeFormat : this.dateRangeFormat
  7902. }, a.exportDialogConfig);
  7903. this.callParent(arguments)
  7904. },
  7905. initComponent : function() {
  7906. var b = this, a = {
  7907. hidedialogwindow : b.destroy,
  7908. showdialogerror : b.showError,
  7909. updateprogressbar : function(c) {
  7910. b.fireEvent("updateprogressbar", c)
  7911. },
  7912. scope : this
  7913. };
  7914. Ext.apply(this, {
  7915. items : [b.form = b.buildForm(b.config),
  7916. b.createMessageElement()],
  7917. fbar : b.buildButtons(b.buttonsPanelScope || b)
  7918. });
  7919. b.callParent(arguments);
  7920. b.plugin.on(a)
  7921. },
  7922. afterRender : function() {
  7923. var a = this;
  7924. a.on("changecomplete", function(c, b) {
  7925. a.plugin.scheduler.setTimeColumnWidth(b[0], true);
  7926. if (!a.config.scrollerDisabled) {
  7927. if (a.form.resizePicker.verticalCfg.reverse) {
  7928. var d = b[1];
  7929. a.plugin.scheduler.getSchedulingView()
  7930. .setRowHeight(d)
  7931. } else {
  7932. a.plugin.scheduler.getSchedulingView()
  7933. .setRowHeight(b[1])
  7934. }
  7935. }
  7936. });
  7937. a.relayEvents(a.form.resizePicker, ["change", "changecomplete",
  7938. "select"]);
  7939. a.form.relayEvents(a, ["updateprogressbar", "hideprogressbar",
  7940. "showprogressbar"]);
  7941. a.callParent(arguments);
  7942. a.switchTab(0)
  7943. },
  7944. createMessageElement : function() {
  7945. var a = this;
  7946. return a.messageElement = new Ext.Component({
  7947. autoEl : {
  7948. tag : "div",
  7949. cls : "sch-exportdialog-msg"
  7950. }
  7951. })
  7952. },
  7953. buildButtons : function(a) {
  7954. return [{
  7955. xtype : "button",
  7956. scale : "medium",
  7957. text : this.exportButtonText,
  7958. handler : function() {
  7959. var c = this.form.getForm();
  7960. if (c.isValid()) {
  7961. var b = c.getValues();
  7962. this.fireEvent("showprogressbar");
  7963. this.plugin.doExport(b)
  7964. }
  7965. },
  7966. scope : a
  7967. }, {
  7968. xtype : "button",
  7969. scale : "medium",
  7970. text : this.cancelButtonText,
  7971. handler : function() {
  7972. this.destroy()
  7973. },
  7974. scope : a
  7975. }]
  7976. },
  7977. buildForm : function(a) {
  7978. return new Sch.widget.ExportDialogForm({
  7979. progressBar : this.progressBar,
  7980. dialogConfig : a
  7981. })
  7982. },
  7983. switchTab : function(a) {
  7984. this.getLayout().setActiveItem(a)
  7985. },
  7986. showError : function(b, a) {
  7987. var c = b, d = a || c.generalError;
  7988. c.fireEvent("hideprogressbar");
  7989. c.switchTab(1);
  7990. c.messageElement.getEl().setHTML(d);
  7991. setTimeout(function() {
  7992. c.hide()
  7993. }, c.hideTime)
  7994. }
  7995. });
  7996. Ext.define("Sch.feature.ColumnLines", {
  7997. extend : "Sch.plugin.Lines",
  7998. cls : "sch-column-line",
  7999. showTip : false,
  8000. requires : ["Ext.data.Store"],
  8001. init : function(b) {
  8002. this.timeAxis = b.getTimeAxis();
  8003. this.store = Ext.create("Ext.data.JsonStore", {
  8004. model : Ext.define("Sch.model.TimeLine", {
  8005. extend : "Ext.data.Model",
  8006. fields : ["start", {
  8007. name : "Date",
  8008. convert : function(d, c) {
  8009. return c.data.start
  8010. }
  8011. }]
  8012. }),
  8013. data : b.getOrientation() === "horizontal" ? this
  8014. .getData() : []
  8015. });
  8016. this.callParent(arguments);
  8017. var a = this.schedulerView;
  8018. a.timeAxis.on("reconfigure", this.populate, this)
  8019. },
  8020. populate : function() {
  8021. var a = this.schedulerView;
  8022. var b = a.getOrientation() === "horizontal"
  8023. && a.store.getCount() > 0;
  8024. this.store.removeAll(b);
  8025. if (b) {
  8026. this.store.add(this.getData())
  8027. }
  8028. },
  8029. getElementData : function() {
  8030. var a = this.schedulerView;
  8031. if (a.getOrientation() === "horizontal"
  8032. && a.store.getCount() > 0) {
  8033. return this.callParent(arguments)
  8034. }
  8035. return []
  8036. },
  8037. getData : function() {
  8038. var a = [];
  8039. this.timeAxis.forEachMainInterval(function(d, b, c) {
  8040. if (c > 0) {
  8041. a.push({
  8042. start : d
  8043. })
  8044. }
  8045. });
  8046. a.push({
  8047. start : this.timeAxis.getEnd()
  8048. });
  8049. return a
  8050. }
  8051. });
  8052. Ext.define("Sch.mixin.TimelineView", {
  8053. requires : ["Sch.column.Time", "Sch.data.TimeAxis"],
  8054. orientation : "horizontal",
  8055. overScheduledEventClass : "sch-event-hover",
  8056. selectedEventCls : "sch-event-selected",
  8057. altColCls : "sch-col-alt",
  8058. timeCellCls : "sch-timetd",
  8059. timeCellSelector : ".sch-timetd",
  8060. ScheduleEventMap : {
  8061. click : "Click",
  8062. mousedown : "MouseDown",
  8063. mouseup : "MouseUp",
  8064. dblclick : "DblClick",
  8065. contextmenu : "ContextMenu",
  8066. keydown : "KeyDown",
  8067. keyup : "KeyUp"
  8068. },
  8069. suppressFitCheck : 0,
  8070. forceFit : false,
  8071. inheritables : function() {
  8072. return {
  8073. cellBorderWidth : 1,
  8074. initComponent : function() {
  8075. this.setOrientation(this.panel._top.orientation
  8076. || this.orientation);
  8077. this.addEvents("beforetooltipshow", "scheduleclick",
  8078. "scheduledblclick", "schedulecontextmenu",
  8079. "columnwidthchange");
  8080. this.enableBubble("columnwidthchange");
  8081. var a = {}, c = Sch.util.Date;
  8082. a[c.DAY] = a[c.WEEK] = a[c.MONTH] = a[c.QUARTER] = a[c.YEAR] = null;
  8083. Ext.applyIf(this, {
  8084. eventPrefix : this.id + "-",
  8085. largeUnits : a
  8086. });
  8087. this.callParent(arguments);
  8088. if (this.orientation === "horizontal") {
  8089. this.getTimeAxisColumn().on("timeaxiscolumnreconfigured",
  8090. this.checkHorizontalFit, this)
  8091. }
  8092. var b = this.panel._top;
  8093. Ext.apply(this, {
  8094. eventRendererScope : b.eventRendererScope,
  8095. eventRenderer : b.eventRenderer,
  8096. eventBorderWidth : b.eventBorderWidth,
  8097. timeAxis : b.timeAxis,
  8098. dndValidatorFn : b.dndValidatorFn || Ext.emptyFn,
  8099. resizeValidatorFn : b.resizeValidatorFn
  8100. || Ext.emptyFn,
  8101. createValidatorFn : b.createValidatorFn
  8102. || Ext.emptyFn,
  8103. tooltipTpl : b.tooltipTpl,
  8104. validatorFnScope : b.validatorFnScope || this,
  8105. snapToIncrement : b.snapToIncrement,
  8106. timeCellRenderer : b.timeCellRenderer,
  8107. timeCellRendererScope : b.timeCellRendererScope,
  8108. readOnly : b.readOnly,
  8109. eventResizeHandles : b.eventResizeHandles,
  8110. enableEventDragDrop : b.enableEventDragDrop,
  8111. enableDragCreation : b.enableDragCreation,
  8112. dragConfig : b.dragConfig,
  8113. dropConfig : b.dropConfig,
  8114. resizeConfig : b.resizeConfig,
  8115. createConfig : b.createConfig,
  8116. tipCfg : b.tipCfg,
  8117. orientation : b.orientation,
  8118. getDateConstraints : b.getDateConstraints
  8119. || Ext.emptyFn
  8120. });
  8121. if (this.emptyText) {
  8122. this.emptyText = '<span class="sch-empty-text">'
  8123. + this.emptyText + "</span>"
  8124. }
  8125. },
  8126. onDestroy : function() {
  8127. if (this.tip) {
  8128. this.tip.destroy()
  8129. }
  8130. this.callParent(arguments)
  8131. },
  8132. afterComponentLayout : function() {
  8133. this.callParent(arguments);
  8134. var b = this.getWidth();
  8135. var a = this.getHeight();
  8136. if (b === this.__prevWidth && a === this.__prevHeight) {
  8137. return
  8138. }
  8139. this.__prevWidth = b;
  8140. this.__prevHeight = a;
  8141. if (!this.lockable && !this.suppressFitCheck) {
  8142. this.checkHorizontalFit()
  8143. }
  8144. },
  8145. beforeRender : function() {
  8146. this.callParent(arguments);
  8147. this.addCls("sch-timelineview");
  8148. if (this.readOnly) {
  8149. this.addCls(this._cmpCls + "-readonly")
  8150. }
  8151. },
  8152. afterRender : function() {
  8153. this.callParent(arguments);
  8154. if (this.overScheduledEventClass) {
  8155. this.mon(this.el, {
  8156. mouseover : this.onMouseOver,
  8157. mouseout : this.onMouseOut,
  8158. delegate : this.eventSelector,
  8159. scope : this
  8160. })
  8161. }
  8162. if (this.tooltipTpl) {
  8163. this.el.on("mousemove", this.setupTooltip, this, {
  8164. single : true
  8165. })
  8166. }
  8167. this.setupTimeCellEvents()
  8168. },
  8169. processUIEvent : function(f) {
  8170. var c = this, a = f.getTarget(this.eventSelector), d = c.ScheduleEventMap, b = f.type, g = false;
  8171. if (a && b in d) {
  8172. this.fireEvent(this.scheduledEventName + b, this, this
  8173. .resolveEventRecord(a), f);
  8174. g = !(this.panel.getSelectionModel() instanceof Ext.selection.RowModel)
  8175. }
  8176. if (!g) {
  8177. this.callParent(arguments)
  8178. }
  8179. },
  8180. refresh : function() {
  8181. this.fixedNodes = 0;
  8182. this.callParent(arguments)
  8183. },
  8184. clearViewEl : function() {
  8185. var c = this, b = c.getTargetEl();
  8186. b.down("table").remove();
  8187. if (this.emptyText) {
  8188. var a = b.down(".sch-empty-text");
  8189. if (a) {
  8190. a.remove()
  8191. }
  8192. }
  8193. },
  8194. onMouseOver : function(b, a) {
  8195. if (a !== this.lastItem) {
  8196. this.lastItem = a;
  8197. Ext.fly(a).addCls(this.overScheduledEventClass);
  8198. this.fireEvent("eventmouseenter", this, this
  8199. .resolveEventRecord(a), b)
  8200. }
  8201. },
  8202. onMouseOut : function(b, a) {
  8203. if (this.lastItem) {
  8204. if (!b.within(this.lastItem, true, true)) {
  8205. Ext.fly(this.lastItem)
  8206. .removeCls(this.overScheduledEventClass);
  8207. this.fireEvent("eventmouseleave", this, this
  8208. .resolveEventRecord(this.lastItem), b);
  8209. delete this.lastItem
  8210. }
  8211. }
  8212. },
  8213. highlightItem : function(b) {
  8214. if (b) {
  8215. var a = this;
  8216. a.clearHighlight();
  8217. a.highlightedItem = b;
  8218. Ext.fly(b).addCls(a.overItemCls)
  8219. }
  8220. },
  8221. shouldUpdateCell : function() {
  8222. return true
  8223. }
  8224. }
  8225. },
  8226. hasRightColumns : function() {
  8227. return this.headerCt.items.getCount() > 1
  8228. },
  8229. checkHorizontalFit : function() {
  8230. if (this.orientation === "horizontal") {
  8231. var a = this.getActualTimeColumnWidth();
  8232. var c = this.getFittingColumnWidth();
  8233. if (this.forceFit) {
  8234. if (c != a) {
  8235. this.fitColumns()
  8236. }
  8237. } else {
  8238. if (this.snapToIncrement) {
  8239. var b = this.calculateTimeColumnWidth(a);
  8240. if (b > 0 && b !== a) {
  8241. this.setColumnWidth(b)
  8242. }
  8243. } else {
  8244. if (a < c) {
  8245. this.fitColumns()
  8246. }
  8247. }
  8248. }
  8249. }
  8250. },
  8251. getTimeAxisColumn : function() {
  8252. return this.headerCt.items.get(0)
  8253. },
  8254. getFirstTimeColumn : function() {
  8255. return this.headerCt.getGridColumns()[0]
  8256. },
  8257. getFormattedDate : function(a) {
  8258. return Ext.Date.format(a, this.getDisplayDateFormat())
  8259. },
  8260. getFormattedEndDate : function(d, a) {
  8261. var b = this.timeAxis, c = b.getResolution().unit;
  8262. if (c in this.largeUnits
  8263. && d.getHours() === 0
  8264. && d.getMinutes() === 0
  8265. && !(d.getYear() === a.getYear()
  8266. && d.getMonth() === a.getMonth() && d.getDate() === a
  8267. .getDate())) {
  8268. d = Sch.util.Date.add(d, Sch.util.Date.DAY, -1)
  8269. }
  8270. return Ext.Date.format(d, this.getDisplayDateFormat())
  8271. },
  8272. getDisplayDateFormat : function() {
  8273. return this.displayDateFormat
  8274. },
  8275. setDisplayDateFormat : function(a) {
  8276. this.displayDateFormat = a
  8277. },
  8278. getSingleUnitInPixels : function(a) {
  8279. return Sch.util.Date.getUnitToBaseUnitRatio(this.timeAxis.getUnit(), a)
  8280. * this.getSingleTickInPixels() / this.timeAxis.getIncrement()
  8281. },
  8282. getSingleTickInPixels : function() {
  8283. throw "Must be implemented by horizontal/vertical"
  8284. },
  8285. scrollEventIntoView : function(f, c, a, j, k) {
  8286. k = k || this;
  8287. var h = this;
  8288. var d = this.panel._top.store;
  8289. var i = function(l) {
  8290. l.scrollIntoView(h.el, true, a);
  8291. if (c) {
  8292. if (typeof c === "boolean") {
  8293. l.highlight()
  8294. } else {
  8295. l.highlight(null, c)
  8296. }
  8297. }
  8298. j && j.call(k)
  8299. };
  8300. var e = Ext.data && Ext.data.TreeStore
  8301. && d instanceof Ext.data.TreeStore && !f.isVisible();
  8302. if (e) {
  8303. f.bubble(function(l) {
  8304. l.expand()
  8305. })
  8306. }
  8307. var b = this.getOuterElementFromEventRecord(f);
  8308. if (b) {
  8309. i(b)
  8310. } else {
  8311. var g = this.panel.verticalScroller;
  8312. if (d.buffered && g) {
  8313. Ext.Function.defer(function() {
  8314. g.scrollTo(d.getIndexInTotalDataset(f), false,
  8315. function() {
  8316. var l = h
  8317. .getOuterElementFromEventRecord(f);
  8318. if (l) {
  8319. i(l)
  8320. }
  8321. })
  8322. }, e ? 10 : 0)
  8323. }
  8324. }
  8325. },
  8326. calculateTimeColumnWidth : function(e) {
  8327. if (!this.panel.rendered) {
  8328. return e
  8329. }
  8330. var h = this.forceFit;
  8331. var b = 0, d = this.timeAxis.getUnit(), k = this.timeAxis.getCount(), g = Number.MAX_VALUE;
  8332. if (this.snapToIncrement) {
  8333. var i = this.timeAxis.getResolution(), j = i.unit, c = i.increment;
  8334. g = Sch.util.Date.getUnitToBaseUnitRatio(d, j) * c
  8335. }
  8336. var f = Sch.util.Date.getMeasuringUnit(d);
  8337. g = Math.min(g, Sch.util.Date.getUnitToBaseUnitRatio(d, f));
  8338. var a = Math.floor(this.getAvailableWidthForSchedule() / k);
  8339. b = (h || e < a) ? a : e;
  8340. if (g > 0 && (!h || g < 1)) {
  8341. b = Math.round(Math.max(1, Math[h ? "floor" : "round"](g * b)) / g)
  8342. }
  8343. return b
  8344. },
  8345. getFittingColumnWidth : function() {
  8346. var a = Math.floor(this.getAvailableWidthForSchedule()
  8347. / this.timeAxis.getCount());
  8348. return this.calculateTimeColumnWidth(a)
  8349. },
  8350. fitColumns : function(b) {
  8351. var a = 0;
  8352. if (this.orientation === "horizontal") {
  8353. a = this.getFittingColumnWidth()
  8354. } else {
  8355. a = Math.floor((this.panel.getWidth()
  8356. - Ext.getScrollbarSize().width - 1)
  8357. / this.headerCt.getColumnCount())
  8358. }
  8359. this.setColumnWidth(a, b)
  8360. },
  8361. getAvailableWidthForSchedule : function() {
  8362. var c = (this.lastBox && this.lastBox.width) || this.getWidth();
  8363. var a = this.headerCt.items.items;
  8364. for (var b = 1; b < a.length; b++) {
  8365. c -= a[b].getWidth()
  8366. }
  8367. return c - Ext.getScrollbarSize().width - 1
  8368. },
  8369. getRightColumnsWidth : function() {
  8370. var c = 0;
  8371. var a = this.headerCt.items.items;
  8372. for (var b = 1; b < a.length; b++) {
  8373. c += a[b].getWidth()
  8374. }
  8375. return c
  8376. },
  8377. fixRightColumnsPositions : function() {
  8378. var a = this.headerCt.items.items;
  8379. var c = a[0].getWidth();
  8380. for (var b = 1; b < a.length; b++) {
  8381. var d = a[b];
  8382. d.el.setLeft(c);
  8383. c += d.getWidth()
  8384. }
  8385. },
  8386. getElementFromEventRecord : function(a) {
  8387. return Ext.get(this.eventPrefix + a.internalId)
  8388. },
  8389. getEventNodeByRecord : function(a) {
  8390. return document.getElementById(this.eventPrefix + a.internalId)
  8391. },
  8392. getOuterElementFromEventRecord : function(a) {
  8393. return Ext.get(this.eventPrefix + a.internalId)
  8394. },
  8395. resolveColumnIndex : function(a) {
  8396. return Math.floor(a / this.getActualTimeColumnWidth())
  8397. },
  8398. getStartEndDatesFromRegion : function(b, a) {
  8399. throw "Must be implemented by horizontal/vertical"
  8400. },
  8401. setupTooltip : function() {
  8402. var b = this, a = Ext.apply({
  8403. renderTo : Ext.getBody(),
  8404. delegate : b.eventSelector,
  8405. target : b.el,
  8406. anchor : "b"
  8407. }, b.tipCfg);
  8408. b.tip = Ext.create("Ext.ToolTip", a);
  8409. b.tip.on({
  8410. beforeshow : function(d) {
  8411. if (!d.triggerElement || !d.triggerElement.id) {
  8412. return false
  8413. }
  8414. var c = this.resolveEventRecord(d.triggerElement);
  8415. if (!c
  8416. || this.fireEvent("beforetooltipshow", this, c) === false) {
  8417. return false
  8418. }
  8419. d.update(this.tooltipTpl.apply(this.getDataForTooltipTpl(c)));
  8420. return true
  8421. },
  8422. scope : this
  8423. })
  8424. },
  8425. getDataForTooltipTpl : function(a) {
  8426. return a.data
  8427. },
  8428. getTimeResolution : function() {
  8429. return this.timeAxis.getResolution()
  8430. },
  8431. setTimeResolution : function(b, a) {
  8432. this.timeAxis.setResolution(b, a);
  8433. if (this.snapToIncrement) {
  8434. this.refreshKeepingScroll()
  8435. }
  8436. },
  8437. getEventIdFromDomNodeId : function(a) {
  8438. return a.substring(this.eventPrefix.length)
  8439. },
  8440. getDateFromDomEvent : function(b, a) {
  8441. return this.getDateFromXY(b.getXY(), a)
  8442. },
  8443. handleScheduleEvent : function(c) {
  8444. var b = c.getTarget("." + this.timeCellCls, 2);
  8445. if (b) {
  8446. var a = this.getDateFromDomEvent(c, "floor");
  8447. this.fireEvent("schedule" + c.type, this, a, this.indexOf(this
  8448. .findItemByChild(b)), c)
  8449. }
  8450. },
  8451. setupTimeCellEvents : function() {
  8452. this.mon(this.el, {
  8453. click : this.handleScheduleEvent,
  8454. dblclick : this.handleScheduleEvent,
  8455. contextmenu : this.handleScheduleEvent,
  8456. scope : this
  8457. }, this)
  8458. },
  8459. getSnapPixelAmount : function() {
  8460. if (this.snapToIncrement) {
  8461. var a = this.timeAxis.getResolution();
  8462. return (a.increment || 1) * this.getSingleUnitInPixels(a.unit)
  8463. } else {
  8464. return 1
  8465. }
  8466. },
  8467. getActualTimeColumnWidth : function() {
  8468. return this.headerCt.items.get(0).getTimeColumnWidth()
  8469. },
  8470. setSnapEnabled : function(a) {
  8471. this.snapToIncrement = a;
  8472. if (a) {
  8473. this.refreshKeepingScroll()
  8474. }
  8475. },
  8476. setReadOnly : function(a) {
  8477. this.readOnly = a;
  8478. this[a ? "addCls" : "removeCls"](this._cmpCls + "-readonly")
  8479. },
  8480. isReadOnly : function() {
  8481. return this.readOnly
  8482. },
  8483. setOrientation : function(a) {
  8484. this.orientation = a;
  8485. Ext.apply(this, Sch.view[Ext.String.capitalize(a)].prototype.props)
  8486. },
  8487. getOrientation : function() {
  8488. return this.orientation
  8489. },
  8490. translateToScheduleCoordinate : function(a) {
  8491. throw "Abstract method call!"
  8492. },
  8493. translateToPageCoordinate : function(a) {
  8494. throw "Abstract method call!"
  8495. },
  8496. getDateFromXY : function(c, b, a) {
  8497. throw "Abstract method call!"
  8498. },
  8499. getXYFromDate : function(a, b) {
  8500. throw "Abstract method call!"
  8501. },
  8502. getTimeSpanRegion : function(a, b) {
  8503. throw "Abstract method call!"
  8504. },
  8505. getStart : function() {
  8506. return this.timeAxis.getStart()
  8507. },
  8508. getEnd : function() {
  8509. return this.timeAxis.getEnd()
  8510. },
  8511. setBarMargin : function(b, a) {
  8512. this.barMargin = b;
  8513. if (!a) {
  8514. this.refreshKeepingScroll()
  8515. }
  8516. },
  8517. setRowHeight : function(a, b) {
  8518. this.rowHeight = a || 24;
  8519. if (this.rendered && !b) {
  8520. this.refreshKeepingScroll()
  8521. }
  8522. },
  8523. refreshKeepingScroll : function(a) {
  8524. this.saveScrollState();
  8525. if (this.lightRefresh) {
  8526. this.lightRefresh()
  8527. } else {
  8528. this.refresh()
  8529. }
  8530. this.restoreScrollState()
  8531. },
  8532. refreshKeepingResourceScroll : function(c) {
  8533. var d = this.el.dom, b = d.scrollTop, a = d.scrollLeft;
  8534. if (this.lightRefresh) {
  8535. this.lightRefresh()
  8536. } else {
  8537. this.refresh()
  8538. }
  8539. if (this.getOrientation() === "horizontal") {
  8540. d.scrollTop = b
  8541. } else {
  8542. d.scrollLeft = a
  8543. }
  8544. },
  8545. lightRefresh : function() {
  8546. var a = this.refreshSize;
  8547. Ext.suspendLayouts();
  8548. this.refreshSize = Ext.emptyFn;
  8549. this.__lightRefresh = true;
  8550. this.refresh();
  8551. delete this.__lightRefresh;
  8552. this.refreshSize = a;
  8553. Ext.resumeLayouts()
  8554. }
  8555. }, function() {
  8556. Ext.apply(Sch, {
  8557. VERSION : "2.1.11"
  8558. })
  8559. });
  8560. Ext.define("Sch.view.TimelineGridView", {
  8561. extend : "Ext.grid.View",
  8562. mixins : ["Sch.mixin.TimelineView"]
  8563. }, function() {
  8564. this
  8565. .override(Sch.mixin.TimelineView.prototype.inheritables()
  8566. || {})
  8567. });
  8568. Ext.define("Sch.mixin.SchedulerView", {
  8569. uses : ["Sch.tooltip.Tooltip"],
  8570. requires : ["Sch.feature.DragCreator", "Sch.feature.DragDrop",
  8571. "Sch.feature.ResizeZone", "Sch.feature.Scheduling",
  8572. "Sch.column.Resource", "Sch.view.Horizontal", "Sch.view.Vertical"],
  8573. _cmpCls : "sch-schedulerview",
  8574. scheduledEventName : "event",
  8575. barMargin : 1,
  8576. eventResizeHandles : "end",
  8577. allowOverlap : true,
  8578. constrainDragToResource : false,
  8579. readOnly : false,
  8580. dynamicRowHeight : true,
  8581. managedEventSizing : true,
  8582. eventAnimations : true,
  8583. eventSelector : ".sch-event",
  8584. eventTpl : [
  8585. '<tpl for=".">',
  8586. '<div unselectable="on" id="{{evt-prefix}}{id}" style="left:{left}px;top:{top}px;height:{height}px;width:{width}px;{style}" class="sch-event x-unselectable {internalCls} {cls}">',
  8587. '<div unselectable="on" class="sch-event-inner {iconCls}">',
  8588. "{body}", "</div>", "</div>", "</tpl>"],
  8589. dndValidatorFn : function(b, a, c, f, d) {
  8590. return true
  8591. },
  8592. resizeValidatorFn : function(c, b, a, f, d) {
  8593. return true
  8594. },
  8595. createValidatorFn : function(b, a, d, c) {
  8596. return true
  8597. },
  8598. inheritables : function() {
  8599. return {
  8600. loadingText : "Loading events...",
  8601. trackOver : false,
  8602. overItemCls : "",
  8603. initComponent : function() {
  8604. this.addEvents("eventclick", "eventmousedown", "eventmouseup",
  8605. "eventdblclick", "eventcontextmenu", "eventmouseenter",
  8606. "eventmouseout", "beforeeventresize",
  8607. "eventresizestart", "eventpartialresize",
  8608. "eventresizeend", "beforeeventdrag", "eventdragstart",
  8609. "eventdrop", "aftereventdrop", "beforedragcreate",
  8610. "dragcreatestart", "dragcreateend", "afterdragcreate",
  8611. "beforeeventadd");
  8612. this.callParent(arguments);
  8613. var a = this.panel._top;
  8614. Ext.apply(this, {
  8615. eventStore : a.eventStore,
  8616. resourceStore : a.resourceStore,
  8617. eventBodyTemplate : a.eventBodyTemplate,
  8618. eventTpl : a.eventTpl || this.eventTpl,
  8619. eventBarTextField : a.eventBarTextField
  8620. || a.eventStore.model.prototype.nameField,
  8621. allowOverlap : a.allowOverlap,
  8622. eventBarIconClsField : a.eventBarIconClsField,
  8623. onEventCreated : a.onEventCreated || Ext.emptyFn,
  8624. constrainDragToResource : a.constrainDragToResource
  8625. });
  8626. var c = this;
  8627. if (Ext.isArray(c.eventTpl)) {
  8628. var e = Ext.Array.clone(c.eventTpl), b = '<div class="sch-resizable-handle sch-resizable-handle-{0}"></div>';
  8629. if (this.eventResizeHandles === "start"
  8630. || this.eventResizeHandles === "both") {
  8631. e.splice(2, 0, Ext.String.format(b, "start"))
  8632. }
  8633. if (this.eventResizeHandles === "end"
  8634. || this.eventResizeHandles === "both") {
  8635. e.splice(2, 0, Ext.String.format(b, "end"))
  8636. }
  8637. var d = e.join("").replace("{{evt-prefix}}",
  8638. this.eventPrefix);
  8639. c.eventTpl = Ext.create("Ext.XTemplate", d)
  8640. }
  8641. },
  8642. setReadOnly : function(a) {
  8643. if (this.dragCreator) {
  8644. this.dragCreator.setDisabled(a)
  8645. }
  8646. this.callParent(arguments)
  8647. },
  8648. prepareData : function(c, a, b) {
  8649. var d = this.callParent(arguments);
  8650. d = this.collectRowData(d, b, a);
  8651. return d
  8652. },
  8653. initFeatures : function() {
  8654. this.features = this.features || [];
  8655. this.features.push({
  8656. ftype : "scheduling"
  8657. });
  8658. this.callParent(arguments)
  8659. },
  8660. beforeRender : function() {
  8661. this.callParent(arguments);
  8662. this.addCls(this._cmpCls);
  8663. if (this.eventAnimations) {
  8664. this.addCls("sch-animations-enabled")
  8665. }
  8666. },
  8667. afterRender : function() {
  8668. this.callParent(arguments);
  8669. this.bindEventStore(this.eventStore, true);
  8670. this.setupEventListeners();
  8671. this.configureFunctionality();
  8672. var a = this.headerCt.resizer;
  8673. if (a) {
  8674. a.doResize = Ext.Function.createSequence(a.doResize,
  8675. this.afterHeaderResized, this)
  8676. }
  8677. },
  8678. onDestroy : function() {
  8679. this.bindEventStore(null);
  8680. this.callParent(arguments)
  8681. }
  8682. }
  8683. },
  8684. getRowHeight : function() {
  8685. return this.rowHeight
  8686. },
  8687. translateToScheduleCoordinate : function(a) {
  8688. throw "Must be defined by horizontal/vertical class"
  8689. },
  8690. getEventBox : function(b, a) {
  8691. throw "Must be defined by horizontal/vertical class"
  8692. },
  8693. generateTplData : function(a, d, k, f, e) {
  8694. var b = a.getStartDate(), c = a.getEndDate(), g = this.getEventBox(
  8695. Sch.util.Date.max(b, d), Sch.util.Date.min(c, k)), j = a
  8696. .getCls(), h;
  8697. j += " sch-event-resizable-" + a.getResizable();
  8698. if (a.dirty) {
  8699. j += " sch-dirty "
  8700. }
  8701. if (c > k) {
  8702. j += " sch-event-endsoutside "
  8703. }
  8704. if (b < d) {
  8705. j += " sch-event-startsoutside "
  8706. }
  8707. if (c - b === 0) {
  8708. j += " sch-event-milestone"
  8709. }
  8710. if (this.eventBarIconClsField) {
  8711. j += " sch-event-withicon "
  8712. }
  8713. if (a.isDraggable() === false) {
  8714. j += " sch-event-fixed "
  8715. }
  8716. if (c - b === 0) {
  8717. j += " sch-event-milestone "
  8718. }
  8719. h = Ext.apply(g, {
  8720. id : a.internalId,
  8721. internalCls : j,
  8722. start : b,
  8723. end : c,
  8724. iconCls : a.data[this.eventBarIconClsField] || ""
  8725. });
  8726. if (this.eventRenderer) {
  8727. var i = this.eventRenderer.call(this.eventRendererScope || this, a,
  8728. f, h, e);
  8729. if (Ext.isObject(i) && this.eventBodyTemplate) {
  8730. h.body = this.eventBodyTemplate.apply(i)
  8731. } else {
  8732. h.body = i
  8733. }
  8734. } else {
  8735. if (this.eventBodyTemplate) {
  8736. h.body = this.eventBodyTemplate.apply(a.data)
  8737. } else {
  8738. if (this.eventBarTextField) {
  8739. h.body = a.data[this.eventBarTextField]
  8740. }
  8741. }
  8742. }
  8743. return h
  8744. },
  8745. sortEvents : function(e, d) {
  8746. var c = (e.start - d.start === 0);
  8747. if (c) {
  8748. return e.end > d.end ? -1 : 1
  8749. } else {
  8750. return (e.start < d.start) ? -1 : 1
  8751. }
  8752. },
  8753. layoutEvents : function(a) {
  8754. throw "Must be defined by horizontal/vertical class"
  8755. },
  8756. findClosestSuccessor : function(g, e) {
  8757. var c = Infinity, f, a = g.end, h;
  8758. for (var d = 0, b = e.length; d < b; d++) {
  8759. h = e[d].start - a;
  8760. if (h >= 0 && h < c) {
  8761. f = e[d];
  8762. c = h
  8763. }
  8764. }
  8765. return f
  8766. },
  8767. resolveResource : function(a) {
  8768. throw "Must be defined by horizontal/vertical class"
  8769. },
  8770. getScheduleRegion : function(b, a) {
  8771. throw "Must be defined by horizontal/vertical class"
  8772. },
  8773. resolveEventRecord : function(b) {
  8774. var a = Ext.get(b);
  8775. if (!a.is(this.eventSelector)) {
  8776. a = a.up(this.eventSelector)
  8777. }
  8778. return this.getEventRecordFromDomId(a.id)
  8779. },
  8780. getResourceByEventRecord : function(a) {
  8781. return a.getResource()
  8782. },
  8783. getEventRecordFromDomId : function(b) {
  8784. var a = this.getEventIdFromDomNodeId(b);
  8785. return this.eventStore.getByInternalId(a)
  8786. },
  8787. configureFunctionality : function() {
  8788. var a = this.validatorFnScope || this;
  8789. if (this.eventResizeHandles !== "none" && Sch.feature.ResizeZone) {
  8790. this.resizePlug = Ext.create("Sch.feature.ResizeZone", Ext.applyIf(
  8791. {
  8792. schedulerView : this,
  8793. validatorFn : function(d, c, b, e) {
  8794. return (this.allowOverlap || this
  8795. .isDateRangeAvailable(b, e, c, d))
  8796. && this.resizeValidatorFn.apply(a,
  8797. arguments) !== false
  8798. },
  8799. validatorFnScope : this
  8800. }, this.resizeConfig || {}))
  8801. }
  8802. if (this.enableEventDragDrop !== false && Sch.feature.DragDrop) {
  8803. this.dragdropPlug = Ext.create("Sch.feature.DragDrop", this, {
  8804. validatorFn : function(c, b, d, g, f) {
  8805. return (this.allowOverlap || this.isDateRangeAvailable(d,
  8806. Sch.util.Date.add(d, Sch.util.Date.MILLI, g), c[0],
  8807. b))
  8808. && this.dndValidatorFn.apply(a, arguments) !== false
  8809. },
  8810. validatorFnScope : this,
  8811. dragConfig : this.dragConfig || {},
  8812. dropConfig : this.dropConfig || {}
  8813. })
  8814. }
  8815. if (this.enableDragCreation !== false && Sch.feature.DragCreator) {
  8816. this.dragCreator = Ext.create("Sch.feature.DragCreator", Ext
  8817. .applyIf({
  8818. schedulerView : this,
  8819. disabled : this.readOnly,
  8820. validatorFn : function(c, b, d) {
  8821. return (this.allowOverlap || this
  8822. .isDateRangeAvailable(b, d, null, c))
  8823. && this.createValidatorFn.apply(a,
  8824. arguments) !== false
  8825. },
  8826. validatorFnScope : this
  8827. }, this.createConfig || {}))
  8828. }
  8829. },
  8830. isDateRangeAvailable : function(d, a, b, c) {
  8831. return this.eventStore.isDateRangeAvailable(d, a, b, c)
  8832. },
  8833. getEventsInView : function() {
  8834. var b = this.timeAxis.getStart(), a = this.timeAxis.getEnd();
  8835. return this.eventStore.getEventsInTimeSpan(b, a)
  8836. },
  8837. getEventNodes : function() {
  8838. return this.el.select(this.eventSelector)
  8839. },
  8840. onBeforeDragDrop : function(a, c, b) {
  8841. return !this.readOnly
  8842. && !b.getTarget().className.match("sch-resizable-handle")
  8843. },
  8844. onDragDropStart : function() {
  8845. if (this.dragCreator) {
  8846. this.dragCreator.setDisabled(true)
  8847. }
  8848. if (this.tip) {
  8849. this.tip.hide();
  8850. this.tip.disable()
  8851. }
  8852. },
  8853. onDragDropEnd : function() {
  8854. if (this.dragCreator) {
  8855. this.dragCreator.setDisabled(false)
  8856. }
  8857. if (this.tip) {
  8858. this.tip.enable()
  8859. }
  8860. },
  8861. onBeforeDragCreate : function(b, c, a, d) {
  8862. return !this.readOnly && !d.ctrlKey
  8863. },
  8864. onDragCreateStart : function() {
  8865. if (this.overClass) {
  8866. var a = this.getView().mainBody;
  8867. this.mun(a, "mouseover", this.onMouseOver, this);
  8868. this.mun(a, "mouseout", this.onMouseOut, this)
  8869. }
  8870. if (this.tip) {
  8871. this.tip.hide();
  8872. this.tip.disable()
  8873. }
  8874. },
  8875. onDragCreateEnd : function(b, a, c) {
  8876. if (!this.eventEditor) {
  8877. if (this.fireEvent("beforeeventadd", this, a) !== false) {
  8878. this.onEventCreated(a);
  8879. this.eventStore.add(a)
  8880. }
  8881. this.dragCreator.getProxy().hide()
  8882. }
  8883. },
  8884. onEventCreated : function(a) {
  8885. },
  8886. onAfterDragCreate : function() {
  8887. if (this.overClass) {
  8888. this.mon(this.getView().mainBody, {
  8889. mouseover : this.onMouseOver,
  8890. mouseout : this.onMouseOut,
  8891. scope : this
  8892. })
  8893. }
  8894. if (this.tip) {
  8895. this.tip.enable()
  8896. }
  8897. },
  8898. onBeforeResize : function(a, c, b) {
  8899. return !this.readOnly
  8900. },
  8901. onResizeStart : function() {
  8902. if (this.tip) {
  8903. this.tip.hide();
  8904. this.tip.disable()
  8905. }
  8906. if (this.dragCreator) {
  8907. this.dragCreator.setDisabled(true)
  8908. }
  8909. },
  8910. onResizeEnd : function() {
  8911. if (this.tip) {
  8912. this.tip.enable()
  8913. }
  8914. if (this.dragCreator) {
  8915. this.dragCreator.setDisabled(false)
  8916. }
  8917. },
  8918. getEventStore : function() {
  8919. return this.eventStore
  8920. },
  8921. registerEventEditor : function(a) {
  8922. this.eventEditor = a
  8923. },
  8924. getEventEditor : function() {
  8925. return this.eventEditor
  8926. },
  8927. setupEventListeners : function() {
  8928. this.on({
  8929. beforeeventdrag : this.onBeforeDragDrop,
  8930. eventdragstart : this.onDragDropStart,
  8931. aftereventdrop : this.onDragDropEnd,
  8932. beforedragcreate : this.onBeforeDragCreate,
  8933. dragcreatestart : this.onDragCreateStart,
  8934. dragcreateend : this.onDragCreateEnd,
  8935. afterdragcreate : this.onAfterDragCreate,
  8936. beforeeventresize : this.onBeforeResize,
  8937. eventresizestart : this.onResizeStart,
  8938. eventresizeend : this.onResizeEnd,
  8939. scope : this
  8940. })
  8941. },
  8942. _onEventUpdate : function(b, c, a) {
  8943. if (a !== Ext.data.Model.COMMIT) {
  8944. this.onEventUpdate.apply(this, arguments)
  8945. }
  8946. },
  8947. _onEventAdd : function(a, b) {
  8948. this.onEventAdd.apply(this, arguments)
  8949. },
  8950. _onEventRemove : function(a, b) {
  8951. this.onEventRemove.apply(this, arguments)
  8952. },
  8953. bindEventStore : function(b, a) {
  8954. var d = this;
  8955. var c = {
  8956. scope : d,
  8957. refresh : d.onEventDataRefresh,
  8958. add : d._onEventAdd,
  8959. remove : d._onEventRemove,
  8960. update : d._onEventUpdate,
  8961. clear : d.refresh
  8962. };
  8963. if (Ext.ClassManager.isCreated("Ext.data.TreeStore")
  8964. && (b || d.eventStore) instanceof Ext.data.TreeStore) {
  8965. c.load = d.onEventDataRefresh
  8966. }
  8967. if (!a && d.eventStore) {
  8968. if (b !== d.eventStore && d.eventStore.autoDestroy) {
  8969. d.eventStore.destroy()
  8970. } else {
  8971. d.mun(d.eventStore, c)
  8972. }
  8973. if (!b) {
  8974. if (d.loadMask && d.loadMask.bindStore) {
  8975. d.loadMask.bindStore(null)
  8976. }
  8977. d.eventStore = null
  8978. }
  8979. }
  8980. if (b) {
  8981. b = Ext.data.StoreManager.lookup(b);
  8982. d.mon(b, c);
  8983. if (d.loadMask && d.loadMask.bindStore) {
  8984. d.loadMask.bindStore(b)
  8985. }
  8986. }
  8987. d.eventStore = b;
  8988. if (b && !a) {
  8989. d.refresh()
  8990. }
  8991. },
  8992. onEventDataRefresh : function() {
  8993. this.refreshKeepingScroll()
  8994. },
  8995. afterHeaderResized : function() {
  8996. var b = this.headerCt.resizer;
  8997. if (b && b.dragHd instanceof Sch.column.Resource) {
  8998. var a = b.dragHd.getWidth();
  8999. this.setColumnWidth(a)
  9000. }
  9001. },
  9002. onEventSelect : function(a) {
  9003. var b = this.getEventNodeByRecord(a);
  9004. if (b) {
  9005. Ext.fly(b).addCls(this.selectedEventCls)
  9006. }
  9007. },
  9008. onEventDeselect : function(a) {
  9009. var b = this.getEventNodeByRecord(a);
  9010. if (b) {
  9011. Ext.fly(b).removeCls(this.selectedEventCls)
  9012. }
  9013. }
  9014. });
  9015. Ext.define("Sch.view.SchedulerGridView", {
  9016. extend : "Sch.view.TimelineGridView",
  9017. mixins : ["Sch.mixin.SchedulerView"],
  9018. alias : "widget.schedulergridview",
  9019. alternateClassName : "Sch.HorizontalSchedulerView"
  9020. }, function() {
  9021. this.override(Sch.mixin.SchedulerView.prototype.inheritables()
  9022. || {})
  9023. });
  9024. Ext.define("Sch.mixin.Zoomable", {
  9025. zoomLevels : [{
  9026. width : 30,
  9027. increment : 1,
  9028. resolution : 1,
  9029. preset : "year",
  9030. resolutionUnit : "MONTH"
  9031. }, {
  9032. width : 50,
  9033. increment : 1,
  9034. resolution : 1,
  9035. preset : "year",
  9036. resolutionUnit : "MONTH"
  9037. }, {
  9038. width : 100,
  9039. increment : 1,
  9040. resolution : 1,
  9041. preset : "year",
  9042. resolutionUnit : "MONTH"
  9043. }, {
  9044. width : 200,
  9045. increment : 1,
  9046. resolution : 1,
  9047. preset : "year",
  9048. resolutionUnit : "MONTH"
  9049. }, {
  9050. width : 100,
  9051. increment : 1,
  9052. resolution : 7,
  9053. preset : "monthAndYear",
  9054. resolutionUnit : "DAY"
  9055. }, {
  9056. width : 30,
  9057. increment : 1,
  9058. resolution : 1,
  9059. preset : "weekDateAndMonth",
  9060. resolutionUnit : "DAY"
  9061. }, {
  9062. width : 35,
  9063. increment : 1,
  9064. resolution : 1,
  9065. preset : "weekAndMonth",
  9066. resolutionUnit : "DAY"
  9067. }, {
  9068. width : 50,
  9069. increment : 1,
  9070. resolution : 1,
  9071. preset : "weekAndMonth",
  9072. resolutionUnit : "DAY"
  9073. }, {
  9074. width : 20,
  9075. increment : 1,
  9076. resolution : 1,
  9077. preset : "weekAndDayLetter"
  9078. }, {
  9079. width : 50,
  9080. increment : 1,
  9081. resolution : 1,
  9082. preset : "weekAndDay",
  9083. resolutionUnit : "HOUR"
  9084. }, {
  9085. width : 100,
  9086. increment : 1,
  9087. resolution : 1,
  9088. preset : "weekAndDay",
  9089. resolutionUnit : "HOUR"
  9090. }, {
  9091. width : 50,
  9092. increment : 6,
  9093. resolution : 30,
  9094. preset : "hourAndDay",
  9095. resolutionUnit : "MINUTE"
  9096. }, {
  9097. width : 100,
  9098. increment : 6,
  9099. resolution : 30,
  9100. preset : "hourAndDay",
  9101. resolutionUnit : "MINUTE"
  9102. }, {
  9103. width : 60,
  9104. increment : 2,
  9105. resolution : 30,
  9106. preset : "hourAndDay",
  9107. resolutionUnit : "MINUTE"
  9108. }, {
  9109. width : 60,
  9110. increment : 1,
  9111. resolution : 30,
  9112. preset : "hourAndDay",
  9113. resolutionUnit : "MINUTE"
  9114. }, {
  9115. width : 30,
  9116. increment : 15,
  9117. resolution : 5,
  9118. preset : "minuteAndHour"
  9119. }, {
  9120. width : 60,
  9121. increment : 15,
  9122. resolution : 5,
  9123. preset : "minuteAndHour"
  9124. }, {
  9125. width : 130,
  9126. increment : 15,
  9127. resolution : 5,
  9128. preset : "minuteAndHour"
  9129. }, {
  9130. width : 60,
  9131. increment : 5,
  9132. resolution : 5,
  9133. preset : "minuteAndHour"
  9134. }, {
  9135. width : 100,
  9136. increment : 5,
  9137. resolution : 5,
  9138. preset : "minuteAndHour"
  9139. }],
  9140. minZoomLevel : null,
  9141. maxZoomLevel : null,
  9142. visibleZoomFactor : 5,
  9143. cachedCenterDate : null,
  9144. isFirstZoom : true,
  9145. isZooming : false,
  9146. initializeZooming : function() {
  9147. this.zoomLevels = this.zoomLevels.slice();
  9148. this.setMinZoomLevel(this.minZoomLevel || 0);
  9149. this.setMaxZoomLevel(this.maxZoomLevel !== null
  9150. ? this.maxZoomLevel
  9151. : this.zoomLevels.length - 1);
  9152. this.on("viewchange", this.clearCenterDateCache, this)
  9153. },
  9154. getZoomLevelUnit : function(b) {
  9155. var a = Sch.preset.Manager.getPreset(b.preset).headerConfig;
  9156. return a.bottom ? a.bottom.unit : a.middle.unit
  9157. },
  9158. getMilliSecondsPerPixelForZoomLevel : function(b) {
  9159. var a = Sch.util.Date;
  9160. return Math.round((a.add(new Date(1, 0, 1), this.getZoomLevelUnit(b),
  9161. b.increment) - new Date(1, 0, 1))
  9162. / b.width)
  9163. },
  9164. presetToZoomLevel : function(e) {
  9165. var d = Sch.preset.Manager.getPreset(e);
  9166. var c = d.headerConfig;
  9167. var a = c.bottom;
  9168. var b = c.middle;
  9169. return {
  9170. preset : e,
  9171. increment : (a ? a.increment : b.increment) || 1,
  9172. resolution : d.timeResolution.increment,
  9173. resolutionUnit : d.timeResolution.unit,
  9174. width : d.timeColumnWidth
  9175. }
  9176. },
  9177. calculateCurrentZoomLevel : function() {
  9178. var d = this.presetToZoomLevel(this.viewPreset);
  9179. var c = this.timeAxis.headerConfig;
  9180. var a = c.bottom;
  9181. var b = c.middle;
  9182. d.width = this.timeAxis.preset.timeColumnWidth;
  9183. d.increment = (a ? a.increment : b.increment) || 1;
  9184. return d
  9185. },
  9186. getCurrentZoomLevelIndex : function() {
  9187. var f = this.calculateCurrentZoomLevel();
  9188. var b = this.getMilliSecondsPerPixelForZoomLevel(f);
  9189. var e = this.zoomLevels;
  9190. for (var c = 0; c < e.length; c++) {
  9191. var d = this.getMilliSecondsPerPixelForZoomLevel(e[c]);
  9192. if (d == b) {
  9193. return c
  9194. }
  9195. if (c === 0 && b > d) {
  9196. return -0.5
  9197. }
  9198. if (c == e.length - 1 && b < d) {
  9199. return e.length - 1 + 0.5
  9200. }
  9201. var a = this.getMilliSecondsPerPixelForZoomLevel(e[c + 1]);
  9202. if (d > b && b > a) {
  9203. return c + 0.5
  9204. }
  9205. }
  9206. throw "Can't find current zoom level index"
  9207. },
  9208. setMaxZoomLevel : function(a) {
  9209. if (a < 0 || a >= this.zoomLevels.length) {
  9210. throw new Error("Invalid range for `setMinZoomLevel`")
  9211. }
  9212. this.maxZoomLevel = a
  9213. },
  9214. setMinZoomLevel : function(a) {
  9215. if (a < 0 || a >= this.zoomLevels.length) {
  9216. throw new Error("Invalid range for `setMinZoomLevel`")
  9217. }
  9218. this.minZoomLevel = a
  9219. },
  9220. getViewportCenterDateCached : function() {
  9221. if (this.cachedCenterDate) {
  9222. return this.cachedCenterDate
  9223. }
  9224. return this.cachedCenterDate = this.getViewportCenterDate()
  9225. },
  9226. clearCenterDateCache : function() {
  9227. this.cachedCenterDate = null
  9228. },
  9229. zoomToLevel : function(b) {
  9230. b = Ext.Number.constrain(b, this.minZoomLevel, this.maxZoomLevel);
  9231. var n = this.calculateCurrentZoomLevel();
  9232. var d = this.getMilliSecondsPerPixelForZoomLevel(n);
  9233. var i = this.zoomLevels[b];
  9234. var a = this.getMilliSecondsPerPixelForZoomLevel(i);
  9235. if (d == a) {
  9236. return null
  9237. }
  9238. var p = this;
  9239. var j = this.getSchedulingView();
  9240. var f = j.getEl();
  9241. if (this.isFirstZoom) {
  9242. this.isFirstZoom = false;
  9243. f.on("scroll", this.clearCenterDateCache, this)
  9244. }
  9245. var h = this.orientation == "vertical";
  9246. var e = this.getViewportCenterDateCached();
  9247. var k = h ? f.getHeight() : f.getWidth();
  9248. var l = Ext.clone(Sch.preset.Manager.getPreset(i.preset));
  9249. var o = this.calculateOptimalDateRange(e, k, i);
  9250. var c = l.headerConfig;
  9251. var g = c.bottom;
  9252. var r = c.middle;
  9253. l[h ? "rowHeight" : "timeColumnWidth"] = i.width;
  9254. if (g) {
  9255. g.increment = i.increment
  9256. } else {
  9257. r.increment = i.increment
  9258. }
  9259. this.isZooming = true;
  9260. this.viewPreset = i.preset;
  9261. var m = g ? g.unit : r.unit;
  9262. this.timeAxis.reconfigure({
  9263. preset : l,
  9264. headerConfig : c,
  9265. unit : m,
  9266. increment : i.increment,
  9267. resolutionUnit : Sch.util.Date.getUnitByName(i.resolutionUnit || m),
  9268. resolutionIncrement : i.resolution,
  9269. weekStartDay : this.weekStartDay,
  9270. mainUnit : r.unit,
  9271. shiftUnit : l.shiftUnit,
  9272. shiftIncrement : l.shiftIncrement || 1,
  9273. defaultSpan : l.defaultSpan || 1,
  9274. start : o.startDate || this.getStart(),
  9275. end : o.endDate || this.getEnd()
  9276. });
  9277. var q = j.getXYFromDate(e, true);
  9278. f.on("scroll", function() {
  9279. p.cachedCenterDate = e
  9280. }, this, {
  9281. single : true
  9282. });
  9283. if (h) {
  9284. f.scrollTo("top", q[1] - k / 2)
  9285. } else {
  9286. f.scrollTo("left", q[0] - k / 2)
  9287. }
  9288. p.isZooming = false;
  9289. this.fireEvent("zoomchange", this, b);
  9290. return b
  9291. },
  9292. zoomIn : function(a) {
  9293. a = a || 1;
  9294. var b = this.getCurrentZoomLevelIndex();
  9295. if (b >= this.zoomLevels.length - 1) {
  9296. return null
  9297. }
  9298. return this.zoomToLevel(Math.floor(b) + a)
  9299. },
  9300. zoomOut : function(a) {
  9301. a = a || 1;
  9302. var b = this.getCurrentZoomLevelIndex();
  9303. if (b <= 0) {
  9304. return null
  9305. }
  9306. return this.zoomToLevel(Math.ceil(b) - a)
  9307. },
  9308. zoomInFull : function() {
  9309. return this.zoomToLevel(this.maxZoomLevel)
  9310. },
  9311. zoomOutFull : function() {
  9312. return this.zoomToLevel(this.minZoomLevel)
  9313. },
  9314. calculateOptimalDateRange : function(c, h, e) {
  9315. var b = Sch.util.Date;
  9316. var i = Sch.preset.Manager.getPreset(e.preset).headerConfig;
  9317. var f = i.top ? i.top.unit : i.middle.unit;
  9318. var j = this.getZoomLevelUnit(e);
  9319. var d = Math.ceil(h / e.width * e.increment * this.visibleZoomFactor
  9320. / 2);
  9321. var a = b.add(c, j, -d);
  9322. var g = b.add(c, j, d);
  9323. return {
  9324. startDate : this.timeAxis.floorDate(a, false, f),
  9325. endDate : this.timeAxis.ceilDate(g, false, f)
  9326. }
  9327. }
  9328. });
  9329. Ext.define("Sch.mixin.TimelinePanel", {
  9330. requires : ["Sch.util.Patch", "Sch.patches.LoadMask", "Sch.patches.Model",
  9331. "Sch.patches.Table", "Sch.data.TimeAxis",
  9332. "Sch.feature.ColumnLines", "Sch.view.Locking",
  9333. "Sch.mixin.Lockable", "Sch.preset.Manager"],
  9334. mixins : ["Sch.mixin.Zoomable"],
  9335. orientation : "horizontal",
  9336. weekStartDay : 1,
  9337. snapToIncrement : false,
  9338. readOnly : false,
  9339. eventResizeHandles : "both",
  9340. viewPreset : "weekAndDay",
  9341. trackHeaderOver : true,
  9342. startDate : null,
  9343. endDate : null,
  9344. eventBorderWidth : 1,
  9345. tooltipTpl : null,
  9346. tipCfg : {
  9347. cls : "sch-tip",
  9348. showDelay : 1000,
  9349. hideDelay : 0,
  9350. autoHide : true,
  9351. anchor : "b"
  9352. },
  9353. lightWeight : true,
  9354. timeCellRenderer : null,
  9355. timeCellRendererScope : null,
  9356. inheritables : function() {
  9357. return {
  9358. columnLines : true,
  9359. enableColumnMove : false,
  9360. enableLocking : true,
  9361. lockable : true,
  9362. lockedXType : null,
  9363. normalXType : null,
  9364. initComponent : function() {
  9365. this.lightWeight = this.lightWeight && !this.timeCellRenderer;
  9366. this.addEvents("timeheaderdblclick", "beforeviewchange",
  9367. "viewchange");
  9368. if (!this.timeAxis) {
  9369. this.timeAxis = Ext.create("Sch.data.TimeAxis")
  9370. }
  9371. if (!this.columns && !this.colModel) {
  9372. this.columns = []
  9373. }
  9374. this.timeAxis.on("reconfigure", this.onTimeAxisReconfigure,
  9375. this);
  9376. if (this.enableLocking) {
  9377. this.self.mixin("lockable", Sch.mixin.Lockable);
  9378. var b = 0, a = this.columns.length, c;
  9379. for (; b < a; ++b) {
  9380. c = this.columns[b];
  9381. if (c.locked !== false) {
  9382. c.locked = true
  9383. }
  9384. c.lockable = false
  9385. }
  9386. this.switchViewPreset(this.viewPreset, this.startDate
  9387. || this.timeAxis.getStart(), this.endDate
  9388. || this.timeAxis.getEnd(), true)
  9389. }
  9390. this.callParent(arguments);
  9391. if (this.lockable) {
  9392. this.applyViewSettings(this.timeAxis.preset);
  9393. if (!this.viewPreset) {
  9394. throw "You must define a valid view preset object. See Sch.preset.Manager class for reference"
  9395. }
  9396. if (this.lightWeight && this.columnLines) {
  9397. this.columnLinesFeature = new Sch.feature.ColumnLines();
  9398. this.columnLinesFeature.init(this)
  9399. }
  9400. }
  9401. this.initializeZooming();
  9402. this.relayEvents(this.getView(), ["beforetooltipshow",
  9403. "scheduleclick", "scheduledblclick",
  9404. "schedulecontextmenu"])
  9405. },
  9406. getState : function() {
  9407. var a = this, b = a.callParent(arguments);
  9408. Ext.apply(b, {
  9409. viewPreset : a.viewPreset,
  9410. startDate : a.getStart(),
  9411. endDate : a.getEnd(),
  9412. zoomMinLevel : a.zoomMinLevel,
  9413. zoomMaxLevel : a.zoomMaxLevel,
  9414. currentZoomLevel : a.currentZoomLevel
  9415. });
  9416. return b
  9417. },
  9418. getOrientation : function() {
  9419. return this.orientation
  9420. },
  9421. applyState : function(b) {
  9422. var a = this;
  9423. a.callParent(arguments);
  9424. if (b && b.viewPreset) {
  9425. a.switchViewPreset(b.viewPreset, b.startDate, b.endDate)
  9426. }
  9427. if (b && b.currentZoomLevel) {
  9428. a.zoomToLevel(b.currentZoomLevel)
  9429. }
  9430. },
  9431. beforeRender : function() {
  9432. this.callParent(arguments);
  9433. if (this.lockable) {
  9434. this.addCls("sch-" + this.orientation)
  9435. }
  9436. },
  9437. afterRender : function() {
  9438. this.callParent(arguments);
  9439. if (this.lockable) {
  9440. this.lockedGrid.on("itemdblclick", function(d, c, e, g, f) {
  9441. if (this.orientation == "vertical" && c) {
  9442. this.fireEvent("timeheaderdblclick", this,
  9443. c.get("start"), c.get("end"), g, f)
  9444. }
  9445. }, this)
  9446. } else {
  9447. var b = this.headerCt;
  9448. if (b && b.reorderer && b.reorderer.dropZone) {
  9449. var a = b.reorderer.dropZone;
  9450. a.positionIndicator = Ext.Function.createSequence(
  9451. a.positionIndicator, function() {
  9452. this.valid = false
  9453. })
  9454. }
  9455. }
  9456. },
  9457. delayScroll : function() {
  9458. var a = this.getScrollTarget().el;
  9459. if (a) {
  9460. this.scrollTask.delay(10, function() {
  9461. if (a.dom) {
  9462. this.syncHorizontalScroll(a.dom.scrollLeft)
  9463. }
  9464. }, this)
  9465. }
  9466. }
  9467. }
  9468. },
  9469. setReadOnly : function(a) {
  9470. this.getSchedulingView().setReadOnly(a)
  9471. },
  9472. isReadOnly : function() {
  9473. return this.getSchedulingView().isReadOnly()
  9474. },
  9475. switchViewPreset : function(d, a, f, b) {
  9476. if (this.fireEvent("beforeviewchange", this, d, a, f) !== false) {
  9477. if (Ext.isString(d)) {
  9478. this.viewPreset = d;
  9479. d = Sch.preset.Manager.getPreset(d)
  9480. }
  9481. if (!d) {
  9482. throw "View preset not found"
  9483. }
  9484. var e = d.headerConfig;
  9485. var c = {
  9486. unit : e.bottom ? e.bottom.unit : e.middle.unit,
  9487. increment : (e.bottom ? e.bottom.increment : e.middle.increment)
  9488. || 1,
  9489. resolutionUnit : d.timeResolution.unit,
  9490. resolutionIncrement : d.timeResolution.increment,
  9491. weekStartDay : this.weekStartDay,
  9492. mainUnit : e.middle.unit,
  9493. shiftUnit : d.shiftUnit,
  9494. headerConfig : d.headerConfig,
  9495. shiftIncrement : d.shiftIncrement || 1,
  9496. preset : d,
  9497. defaultSpan : d.defaultSpan || 1
  9498. };
  9499. if (b) {
  9500. if (this.timeAxis.getCount() === 0 || a) {
  9501. c.start = a || new Date();
  9502. c.end = f
  9503. }
  9504. } else {
  9505. c.start = a || this.timeAxis.getStart();
  9506. c.end = f
  9507. }
  9508. if (!b) {
  9509. this.applyViewSettings(d)
  9510. }
  9511. this.timeAxis.reconfigure(c)
  9512. }
  9513. },
  9514. applyViewSettings : function(b) {
  9515. var a = this.getSchedulingView();
  9516. a.setDisplayDateFormat(b.displayDateFormat);
  9517. if (this.orientation === "horizontal") {
  9518. a.setRowHeight(this.rowHeight || b.rowHeight, true)
  9519. }
  9520. },
  9521. getStart : function() {
  9522. return this.timeAxis.getStart()
  9523. },
  9524. getEnd : function() {
  9525. return this.timeAxis.getEnd()
  9526. },
  9527. getViewportCenterDate : function() {
  9528. var b = this.getSchedulingView(), c = b.getEl(), a = c.getScroll(), d;
  9529. if (this.orientation === "vertical") {
  9530. d = [0, a.top + c.getHeight() / 2]
  9531. } else {
  9532. d = [a.left + c.getWidth() / 2, 0]
  9533. }
  9534. return b.getDateFromXY(d, null, true)
  9535. },
  9536. setTimeColumnWidth : function(b, a) {
  9537. this.getSchedulingView().setColumnWidth(b, a)
  9538. },
  9539. onTimeAxisReconfigure : function() {
  9540. this.fireEvent("viewchange", this);
  9541. if (this.stateful && this.lockedGrid) {
  9542. this.saveState()
  9543. }
  9544. },
  9545. getColumnsState : function() {
  9546. var b = this, a = b.lockedGrid.headerCt.getColumnsState();
  9547. return a
  9548. },
  9549. shiftNext : function(a) {
  9550. this.timeAxis.shiftNext(a)
  9551. },
  9552. shiftPrevious : function(a) {
  9553. this.timeAxis.shiftPrevious(a)
  9554. },
  9555. goToNow : function() {
  9556. this.setTimeSpan(new Date())
  9557. },
  9558. setTimeSpan : function(b, a) {
  9559. if (this.timeAxis) {
  9560. this.timeAxis.setTimeSpan(b, a)
  9561. }
  9562. },
  9563. setStart : function(a) {
  9564. this.setTimeSpan(a)
  9565. },
  9566. setEnd : function(a) {
  9567. this.setTimeSpan(null, a)
  9568. },
  9569. getTimeAxis : function() {
  9570. return this.timeAxis
  9571. },
  9572. getResourceByEventRecord : function(a) {
  9573. return a.getResource()
  9574. },
  9575. scrollToDate : function(c, b) {
  9576. var a = this.getSchedulingView(), d = a.getXYFromDate(c, true);
  9577. if (this.orientation == "horizontal") {
  9578. a.getEl().scrollTo("left", Math.max(0, d[0]), b)
  9579. } else {
  9580. a.getEl().scrollTo("top", Math.max(0, d[1]), b)
  9581. }
  9582. },
  9583. getSchedulingView : function() {
  9584. return this.lockable ? this.normalGrid.getView() : this.getView()
  9585. },
  9586. setOrientation : function(a) {
  9587. this.removeCls("sch-" + this.orientation);
  9588. this.addCls("sch-" + a);
  9589. this.orientation = a
  9590. }
  9591. });
  9592. Ext.define("Sch.mixin.SchedulerPanel", {
  9593. requires : ["Sch.view.SchedulerGridView", "Sch.model.Event",
  9594. "Sch.model.Resource", "Sch.data.EventStore",
  9595. "Sch.data.ResourceStore", "Sch.selection.EventModel",
  9596. "Sch.plugin.ResourceZones", "Sch.util.Date",
  9597. "Sch.column.timeAxis.Vertical"],
  9598. resourceColumnWidth : null,
  9599. eventBarIconClsField : "",
  9600. eventSelModelType : "eventmodel",
  9601. eventSelModel : null,
  9602. enableEventDragDrop : true,
  9603. enableDragCreation : true,
  9604. dragConfig : null,
  9605. dropConfig : null,
  9606. eventBarTextField : null,
  9607. allowOverlap : true,
  9608. startParamName : "startDate",
  9609. endParamName : "endDate",
  9610. passStartEndParameters : false,
  9611. eventRenderer : null,
  9612. eventRendererScope : null,
  9613. eventStore : null,
  9614. resourceStore : null,
  9615. eventTpl : null,
  9616. eventBodyTemplate : null,
  9617. resourceZones : null,
  9618. componentCls : "sch-schedulerpanel",
  9619. lockedGridDependsOnSchedule : false,
  9620. initStores : function() {
  9621. var b = this.resourceStore;
  9622. if (!b) {
  9623. Ext.Error.raise("You must specify a resourceStore config")
  9624. }
  9625. if (!this.eventStore) {
  9626. Ext.Error.raise("You must specify an eventStore config")
  9627. }
  9628. this.eventStore = Ext.StoreManager.lookup(this.eventStore);
  9629. this.resourceStore = Ext.StoreManager.lookup(b);
  9630. if (!this.eventStore.isEventStore) {
  9631. Ext.Error
  9632. .raise("Your eventStore should be a Sch.data.EventStore (or consume the Sch.data.mixin.EventStore)")
  9633. }
  9634. Ext.applyIf(this, {
  9635. store : b,
  9636. resourceStore : b
  9637. });
  9638. this.resourceStore.eventStore = this.eventStore;
  9639. this.eventStore.setResourceStore(this.resourceStore);
  9640. if (this.lockable) {
  9641. if (this.resourceZones) {
  9642. this.plugins = this.plugins || [];
  9643. var a = Ext.StoreManager.lookup(this.resourceZones);
  9644. a.setResourceStore(this.resourceStore);
  9645. this.resourceZonesPlug = Ext.create("Sch.plugin.ResourceZones",
  9646. {
  9647. store : a
  9648. });
  9649. this.plugins.push(this.resourceZonesPlug)
  9650. }
  9651. if (this.passStartEndParameters) {
  9652. this.eventStore.on("beforeload", this.applyStartEndParameters,
  9653. this)
  9654. }
  9655. }
  9656. },
  9657. inheritables : function() {
  9658. return {
  9659. initComponent : function() {
  9660. this.initStores();
  9661. if (this.eventBodyTemplate
  9662. && Ext.isString(this.eventBodyTemplate)) {
  9663. this.eventBodyTemplate = Ext.create("Ext.XTemplate",
  9664. this.eventBodyTemplate)
  9665. }
  9666. this.callParent(arguments);
  9667. this.relayEvents(this.getView(), ["eventclick",
  9668. "eventmousedown", "eventmouseup",
  9669. "eventdblclick", "eventcontextmenu",
  9670. "eventmouseenter", "eventmouseleave",
  9671. "beforeeventresize", "eventresizestart",
  9672. "eventpartialresize", "eventresizeend",
  9673. "beforeeventdrag", "eventdragstart",
  9674. "eventdrop", "aftereventdrop",
  9675. "beforedragcreate", "dragcreatestart",
  9676. "dragcreateend", "afterdragcreate",
  9677. "beforeeventadd"]);
  9678. this.addEvents("orientationchange")
  9679. },
  9680. setOrientation : function(a, d) {
  9681. if (a === this.orientation && !d) {
  9682. return
  9683. }
  9684. this.callParent(arguments);
  9685. var c = this, f = c.normalGrid, h = c.lockedGrid, g = c
  9686. .getSchedulingView(), b = f.headerCt;
  9687. g.setOrientation(a);
  9688. b.suspendLayouts();
  9689. b.items.each(function(i) {
  9690. b.remove(i)
  9691. });
  9692. b.resumeLayouts();
  9693. if (a === "horizontal") {
  9694. c.mun(c.resourceStore, {
  9695. clear : c.refreshResourceColumns,
  9696. datachanged : c.refreshResourceColumns,
  9697. load : c.refreshResourceColumns,
  9698. scope : c
  9699. });
  9700. g.suspendEvents();
  9701. g.setRowHeight(c.rowHeight || c.timeAxis.preset.rowHeight,
  9702. true);
  9703. g.suppressFitCheck++;
  9704. c.reconfigureLockable(c.resourceStore, c.columns);
  9705. g.suppressFitCheck--;
  9706. g.resumeEvents();
  9707. g.setColumnWidth(c.timeAxis.preset.timeColumnWidth || 60,
  9708. true);
  9709. g.checkHorizontalFit();
  9710. g.getTimeAxisColumn().on({
  9711. timeaxiscolumnreconfigured : g.checkHorizontalFit,
  9712. scope : g
  9713. })
  9714. } else {
  9715. g.setRowHeight(c.timeAxis.preset.timeColumnWidth || 60,
  9716. true);
  9717. g.setColumnWidth(c.timeAxis.preset.resourceColumnWidth
  9718. || 100, true);
  9719. c.mon(c.resourceStore, {
  9720. clear : c.refreshResourceColumns,
  9721. datachanged : c.refreshResourceColumns,
  9722. load : c.refreshResourceColumns,
  9723. scope : c
  9724. });
  9725. var e = c.processColumns(c.columns);
  9726. c.reconfigureLockable(c.timeAxis.tickStore, e.locked.items);
  9727. f.reconfigure(c.timeAxis.tickStore, c
  9728. .createResourceColumns())
  9729. }
  9730. f.view.refresh();
  9731. h.view.refresh();
  9732. this.fireEvent("orientationchange", this, a)
  9733. },
  9734. applyViewSettings : function(c) {
  9735. this.callParent(arguments);
  9736. var b = this.getSchedulingView(), a;
  9737. if (this.orientation === "horizontal") {
  9738. a = this.rowHeight = this.rowHeight || c.rowHeight
  9739. } else {
  9740. a = this.timeColumnWidth = this.timeColumnWidth
  9741. || c.timeColumnWidth || 60;
  9742. b.setColumnWidth(c.resourceColumnWidth || 100, true)
  9743. }
  9744. b.setRowHeight(a, true)
  9745. },
  9746. afterRender : function() {
  9747. this.callParent(arguments);
  9748. if (this.lockable && this.lockedGridDependsOnSchedule) {
  9749. if (!this.syncRowHeight) {
  9750. this.normalGrid.getView().on("refresh",
  9751. this.onNormalViewRefresh, this);
  9752. this.normalGrid.getView().on("itemupdate",
  9753. this.onNormalViewItemUpdate, this)
  9754. }
  9755. }
  9756. }
  9757. }
  9758. },
  9759. getResourceStore : function() {
  9760. return this.resourceStore
  9761. },
  9762. getEventStore : function() {
  9763. return this.eventStore
  9764. },
  9765. getEventSelectionModel : function() {
  9766. if (this.eventSelModel && this.eventSelModel.events) {
  9767. return this.eventSelModel
  9768. }
  9769. if (!this.eventSelModel) {
  9770. this.eventSelModel = {}
  9771. }
  9772. var a = this.eventSelModel;
  9773. var b = "SINGLE";
  9774. if (this.simpleSelect) {
  9775. b = "SIMPLE"
  9776. } else {
  9777. if (this.multiSelect) {
  9778. b = "MULTI"
  9779. }
  9780. }
  9781. Ext.applyIf(a, {
  9782. allowDeselect : this.allowDeselect,
  9783. mode : b
  9784. });
  9785. if (!a.events) {
  9786. a = this.eventSelModel = Ext.create("selection."
  9787. + this.eventSelModelType, a)
  9788. }
  9789. if (!a.hasRelaySetup) {
  9790. this.relayEvents(a, ["selectionchange", "deselect", "select"]);
  9791. a.hasRelaySetup = true
  9792. }
  9793. if (this.disableSelection) {
  9794. a.locked = true
  9795. }
  9796. return a
  9797. },
  9798. applyStartEndParameters : function(b, a) {
  9799. a.params = a.params || {};
  9800. a.params[this.startParamName] = this.getStart();
  9801. a.params[this.endParamName] = this.getEnd()
  9802. },
  9803. refreshResourceColumns : function() {
  9804. var a = this.normalGrid.headerCt;
  9805. if (a.getColumnCount() > 0) {
  9806. a.removeAll()
  9807. }
  9808. a.add(this.createResourceColumns());
  9809. this.getView().refresh()
  9810. },
  9811. createResourceColumns : function() {
  9812. var b = [], a = this.getSchedulingView();
  9813. var c = this;
  9814. this.resourceStore.each(function(d) {
  9815. b.push(Ext.create("Sch.column.Resource", {
  9816. tdCls : a.timeCellCls,
  9817. renderer : a.timeColumnRenderer,
  9818. scope : a,
  9819. width : c.resourceColumnWidth
  9820. || c.timeAxis.preset.resourceColumnWidth || 100,
  9821. text : d.getName()
  9822. }))
  9823. });
  9824. return b
  9825. }
  9826. });
  9827. Ext.define("Sch.mixin.FilterableTreeView", {
  9828. initTreeFiltering : function() {
  9829. var a = function() {
  9830. var b = this.up("tablepanel").store;
  9831. this.mon(b, "nodestore-datachange-start",
  9832. this.onFilterChangeStart, this);
  9833. this.mon(b, "nodestore-datachange-end",
  9834. this.onFilterChangeEnd, this);
  9835. this.mon(b, "filter-clear", this.onFilterCleared, this);
  9836. this.mon(b, "filter-set", this.onFilterSet, this)
  9837. };
  9838. if (this.rendered) {
  9839. a.call(this)
  9840. } else {
  9841. this.on("beforerender", a, this, {
  9842. single : true
  9843. })
  9844. }
  9845. },
  9846. onFilterChangeStart : function() {
  9847. Ext.suspendLayouts()
  9848. },
  9849. onFilterChangeEnd : function() {
  9850. Ext.resumeLayouts()
  9851. },
  9852. onFilterCleared : function() {
  9853. delete this.toggle;
  9854. var a = this.getEl();
  9855. if (a) {
  9856. a.removeCls("sch-tree-filtered")
  9857. }
  9858. },
  9859. onFilterSet : function() {
  9860. this.toggle = function() {
  9861. };
  9862. var a = this.getEl();
  9863. if (a) {
  9864. a.addCls("sch-tree-filtered")
  9865. }
  9866. }
  9867. });
  9868. Ext.define("Sch.view.TimelineTreeView", {
  9869. extend : "Ext.tree.View",
  9870. mixins : ["Sch.mixin.TimelineView", "Sch.mixin.FilterableTreeView"],
  9871. requires : ["Sch.patches.TreeView"],
  9872. cellBorderWidth : 0,
  9873. constructor : function() {
  9874. this.callParent(arguments);
  9875. this.initTreeFiltering()
  9876. }
  9877. }, function() {
  9878. this
  9879. .override(Sch.mixin.TimelineView.prototype.inheritables()
  9880. || {})
  9881. });
  9882. Ext.define("Sch.view.SchedulerTreeView", {
  9883. extend : "Sch.view.TimelineTreeView",
  9884. alias : "widget.schedulertreeview",
  9885. mixins : ["Sch.mixin.SchedulerView"]
  9886. }, function() {
  9887. this.override(Sch.mixin.SchedulerView.prototype.inheritables()
  9888. || {})
  9889. });
  9890. Ext.define("Sch.panel.TimelineGridPanel", {
  9891. extend : "Ext.grid.Panel",
  9892. mixins : ["Sch.mixin.TimelinePanel"]
  9893. }, function() {
  9894. this.override(Sch.mixin.TimelinePanel.prototype.inheritables()
  9895. || {})
  9896. });
  9897. Ext.define("Sch.panel.TimelineTreePanel", {
  9898. extend : "Ext.tree.Panel",
  9899. requires : ["Ext.data.TreeStore"],
  9900. mixins : ["Sch.mixin.TimelinePanel"],
  9901. useArrows : true,
  9902. rootVisible : false,
  9903. constructor : function(a) {
  9904. a = a || {};
  9905. a.animate = false;
  9906. this.callParent(arguments)
  9907. },
  9908. initComponent : function() {
  9909. this.callParent(arguments);
  9910. if (this.lockable
  9911. && this.lockedGrid.headerCt.query("treecolumn").length === 0) {
  9912. Ext.Error
  9913. .raise("You must define an Ext.tree.Column (or use xtype : 'treecolumn').")
  9914. }
  9915. },
  9916. onRootChange : function(a) {
  9917. if (!this.lockable) {
  9918. this.callParent(arguments)
  9919. }
  9920. },
  9921. bindStore : function(b) {
  9922. this.callParent(arguments);
  9923. if (Ext.getVersion("extjs").isGreaterThanOrEqual("4.1.2")) {
  9924. var c = this, a = c.getView();
  9925. if (b.buffered && c.verticalScroll) {
  9926. c.verticalScroller = new Ext.grid.PagingScroller(Ext.apply({
  9927. panel : c,
  9928. store : b,
  9929. view : c.view
  9930. }, c.initialConfig.verticalScroller))
  9931. }
  9932. if (b && b.buffered) {
  9933. a.preserveScrollOnRefresh = true
  9934. } else {
  9935. if (c.invalidateScrollerOnRefresh !== undefined) {
  9936. a.preserveScrollOnRefresh = !c.invalidateScrollerOnRefresh
  9937. }
  9938. }
  9939. }
  9940. }
  9941. }, function() {
  9942. this.override(Sch.mixin.TimelinePanel.prototype.inheritables() || {})
  9943. });
  9944. Ext.define("Sch.panel.SchedulerGrid", {
  9945. extend : "Sch.panel.TimelineGridPanel",
  9946. mixins : ["Sch.mixin.SchedulerPanel"],
  9947. alias : ["widget.schedulergrid", "widget.schedulerpanel"],
  9948. alternateClassName : "Sch.SchedulerPanel",
  9949. viewType : "schedulergridview",
  9950. lockedXType : "gridpanel",
  9951. normalXType : "schedulergrid",
  9952. onRender : function() {
  9953. this.callParent(arguments);
  9954. if (this.lockable && this.orientation === "vertical") {
  9955. this.refreshResourceColumns(true)
  9956. }
  9957. }
  9958. }, function() {
  9959. this.override(Sch.mixin.SchedulerPanel.prototype.inheritables()
  9960. || {})
  9961. });
  9962. Ext.define("Sch.panel.SchedulerTree", {
  9963. extend : "Sch.panel.TimelineTreePanel",
  9964. mixins : ["Sch.mixin.SchedulerPanel"],
  9965. alias : ["widget.schedulertree"],
  9966. requires : ["Sch.view.SchedulerTreeView"],
  9967. lockedXType : "treepanel",
  9968. normalXType : "schedulertree",
  9969. viewType : "schedulertreeview",
  9970. setOrientation : function(a) {
  9971. if (a == "vertical") {
  9972. Ext.Error
  9973. .raise("Sch.panel.SchedulerTree does not support vertical orientation")
  9974. }
  9975. },
  9976. initComponent : function() {
  9977. this.callParent(arguments);
  9978. if (!this.lockable
  9979. && (this.resourceStore instanceof Ext.data.TreeStore)) {
  9980. this.getView().store.eventStore = this.eventStore
  9981. }
  9982. }
  9983. }, function() {
  9984. this.override(Sch.mixin.SchedulerPanel.prototype.inheritables() || {})
  9985. });
  9986. Ext.onReady(function() {
  9987. /*if (window.location.href.match("bryntum.com|ext-scheduler.com")) {
  9988. return
  9989. } else {
  9990. if (Sch && Sch.view && Sch.view.TimelineGridView) {
  9991. var b = false;
  9992. Sch.view.TimelineGridView.override({
  9993. refresh : function() {
  9994. this.callOverridden(arguments);
  9995. if (b || !this.rendered) {
  9996. return
  9997. }
  9998. b = true;
  9999. Ext.Function.defer(function() {
  10000. this.el.select(this.eventSelector)
  10001. .setOpacity(0.15)
  10002. }, 10 * 60 * 1000, this);
  10003. var c = this.el.parent().createChild({
  10004. tag : "a",
  10005. href : "http://www.bryntum.com/store",
  10006. title : "Click here to purchase a license",
  10007. style : "display:block;height:54px;width:230px;background: #fff url(http://www.bryntum.com/site-images/bryntum-trial.png) no-repeat;z-index:10000;border:1px solid #ddd;-webkit-box-shadow: 2px 2px 2px rgba(100, 100, 100, 0.5);-moz-box-shadow: 2px 2px 2px rgba(100, 100, 100, 0.5);-moz-border-radius:5px;-webkit-border-radius:5px;position:absolute;bottom:10px;right:15px;"
  10008. });
  10009. try {
  10010. if (!Ext.util.Cookies.get("bmeval")) {
  10011. Ext.util.Cookies.set("bmeval",
  10012. new Date().getTime(), Ext.Date.add(
  10013. new Date(), Ext.Date.YEAR, 2))
  10014. } else {
  10015. var g = Ext.util.Cookies.get("bmeval"), d = new Date(parseInt(
  10016. g, 10));
  10017. if (Ext.Date.add(d, Ext.Date.DAY, 45) < new Date()) {
  10018. this.el.select(this.eventSelector).hide();
  10019. this.el.mask("Trial Period Expired!").setStyle(
  10020. "z-index", 10000);
  10021. this.refresh = Ext.emptyFn
  10022. }
  10023. }
  10024. } catch (f) {
  10025. }
  10026. }
  10027. })
  10028. }
  10029. if (Sch && Sch.view && Sch.view.TimelineTreeView) {
  10030. var a = false;
  10031. Sch.view.TimelineTreeView.override({
  10032. refresh : function() {
  10033. this.callOverridden(arguments);
  10034. if (a || !this.rendered) {
  10035. return
  10036. }
  10037. a = true;
  10038. Ext.Function.defer(function() {
  10039. this.el.select(this.eventSelector)
  10040. .setOpacity(0.15)
  10041. }, 10 * 60 * 1000, this);
  10042. var c = this.el.parent().createChild({
  10043. tag : "a",
  10044. href : "http://www.bryntum.com/store",
  10045. title : "Click here to purchase a license",
  10046. style : "display:block;height:54px;width:230px;background: #fff url(http://www.bryntum.com/site-images/bryntum-trial.png) no-repeat;z-index:10000;border:1px solid #ddd;-webkit-box-shadow: 2px 2px 2px rgba(100, 100, 100, 0.5);-moz-box-shadow: 2px 2px 2px rgba(100, 100, 100, 0.5);-moz-border-radius:5px;-webkit-border-radius:5px;position:absolute;bottom:10px;right:15px;"
  10047. });
  10048. Ext.Function.defer(c.fadeOut, 10000, c);
  10049. try {
  10050. if (!Ext.util.Cookies.get("bmeval")) {
  10051. Ext.util.Cookies.set("bmeval",
  10052. new Date().getTime(), Ext.Date.add(
  10053. new Date(), Ext.Date.YEAR, 2))
  10054. } else {
  10055. var g = Ext.util.Cookies.get("bmeval"), d = new Date(parseInt(
  10056. g, 10));
  10057. if (Ext.Date.add(d, Ext.Date.DAY, 45) < new Date()) {
  10058. this.el.select(this.eventSelector).hide();
  10059. this.el.mask("Trial Period Expired!").setStyle(
  10060. "z-index", 10000);
  10061. this.refresh = Ext.emptyFn
  10062. }
  10063. }
  10064. } catch (f) {
  10065. }
  10066. }
  10067. })
  10068. }
  10069. }*/
  10070. });
  10071. Ext.data.Connection.override({
  10072. parseStatus : function(b) {
  10073. var a = this.callOverridden(arguments);
  10074. if (b === 0) {
  10075. a.success = true
  10076. }
  10077. return a
  10078. }
  10079. });