sch-all-debug.js 266 KB

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