123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397 |
- (function(factory) {
- if (typeof define === 'function' && define.amd) {
- define([ 'jquery', 'moment' ], factory);
- }
- else {
- factory(jQuery, moment);
- }
- })(function($, moment) {
- ;;
- var defaults = {
- lang: 'en',
- defaultTimedEventDuration: '02:00:00',
- defaultAllDayEventDuration: { days: 1 },
- forceEventDuration: false,
- nextDayThreshold: '09:00:00',
-
- defaultView: 'month',
- aspectRatio: 1.35,
- header: {
- left: 'title',
- center: '',
- right: 'today prev,next'
- },
- weekends: true,
- weekNumbers: false,
- weekNumberTitle: 'W',
- weekNumberCalculation: 'local',
-
-
-
-
- lazyFetching: true,
- startParam: 'start',
- endParam: 'end',
- timezoneParam: 'timezone',
- timezone: false,
-
-
-
- titleFormat: {
- month: 'MMMM YYYY',
- week: 'll',
- day: 'LL'
- },
- columnFormat: {
- month: 'ddd',
- week: generateWeekColumnFormat,
- day: 'dddd'
- },
- timeFormat: {
- 'default': generateShortTimeFormat
- },
- displayEventEnd: {
- month: false,
- basicWeek: false,
- 'default': true
- },
-
-
- isRTL: false,
- defaultButtonText: {
- prev: "prev",
- next: "next",
- prevYear: "prev year",
- nextYear: "next year",
- today: 'today',
- month: 'month',
- week: 'week',
- day: 'day'
- },
- buttonIcons: {
- prev: 'left-single-arrow',
- next: 'right-single-arrow',
- prevYear: 'left-double-arrow',
- nextYear: 'right-double-arrow'
- },
-
-
- theme: false,
- themeButtonIcons: {
- prev: 'circle-triangle-w',
- next: 'circle-triangle-e',
- prevYear: 'seek-prev',
- nextYear: 'seek-next'
- },
- dragOpacity: .75,
- dragRevertDuration: 500,
- dragScroll: true,
-
-
- unselectAuto: true,
-
- dropAccept: '*',
- eventLimit: false,
- eventLimitText: 'more',
- eventLimitClick: 'popover',
- dayPopoverFormat: 'LL',
-
- handleWindowResize: true,
- windowResizeDelay: 200
-
- };
- function generateShortTimeFormat(options, langData) {
- return langData.longDateFormat('LT')
- .replace(':mm', '(:mm)')
- .replace(/(\Wmm)$/, '($1)')
- .replace(/\s*a$/i, 't');
- }
- function generateWeekColumnFormat(options, langData) {
- var format = langData.longDateFormat('L');
- format = format.replace(/^Y+[^\w\s]*|[^\w\s]*Y+$/g, '');
- if (options.isRTL) {
- format += ' ddd';
- }
- else {
- format = 'ddd ' + format;
- }
- return format;
- }
- var langOptionHash = {
- en: {
- columnFormat: {
- week: 'ddd M/D'
- },
- dayPopoverFormat: 'dddd, MMMM D'
- }
- };
- var rtlDefaults = {
- header: {
- left: 'next,prev today',
- center: '',
- right: 'title'
- },
- buttonIcons: {
- prev: 'right-single-arrow',
- next: 'left-single-arrow',
- prevYear: 'right-double-arrow',
- nextYear: 'left-double-arrow'
- },
- themeButtonIcons: {
- prev: 'circle-triangle-e',
- next: 'circle-triangle-w',
- nextYear: 'seek-prev',
- prevYear: 'seek-next'
- }
- };
- ;;
- var fc = $.fullCalendar = { version: "2.1.1" };
- var fcViews = fc.views = {};
- $.fn.fullCalendar = function(options) {
- var args = Array.prototype.slice.call(arguments, 1);
- var res = this;
- this.each(function(i, _element) {
- var element = $(_element);
- var calendar = element.data('fullCalendar');
- var singleRes;
-
- if (typeof options === 'string') {
- if (calendar && $.isFunction(calendar[options])) {
- singleRes = calendar[options].apply(calendar, args);
- if (!i) {
- res = singleRes;
- }
- if (options === 'destroy') {
- element.removeData('fullCalendar');
- }
- }
- }
-
- else if (!calendar) {
- calendar = new Calendar(element, options);
- element.data('fullCalendar', calendar);
- calendar.render();
- }
- });
-
- return res;
- };
- function setDefaults(d) {
- mergeOptions(defaults, d);
- }
- function mergeOptions(target) {
- function mergeIntoTarget(name, value) {
- if ($.isPlainObject(value) && $.isPlainObject(target[name]) && !isForcedAtomicOption(name)) {
-
- target[name] = mergeOptions({}, target[name], value);
- }
- else if (value !== undefined) {
- target[name] = value;
- }
- }
- for (var i=1; i<arguments.length; i++) {
- $.each(arguments[i], mergeIntoTarget);
- }
- return target;
- }
- function isForcedAtomicOption(name) {
-
-
- return /(Time|Duration)$/.test(name);
- }
- ;;
- fc.langs = langOptionHash;
- fc.datepickerLang = function(langCode, datepickerLangCode, options) {
- var langOptions = langOptionHash[langCode];
-
- if (!langOptions) {
- langOptions = langOptionHash[langCode] = {};
- }
-
- mergeOptions(langOptions, {
- isRTL: options.isRTL,
- weekNumberTitle: options.weekHeader,
- titleFormat: {
- month: options.showMonthAfterYear ?
- 'YYYY[' + options.yearSuffix + '] MMMM' :
- 'MMMM YYYY[' + options.yearSuffix + ']'
- },
- defaultButtonText: {
-
- prev: stripHtmlEntities(options.prevText),
- next: stripHtmlEntities(options.nextText),
- today: stripHtmlEntities(options.currentText)
- }
- });
-
- if ($.datepicker) {
-
-
-
-
- $.datepicker.regional[datepickerLangCode] =
- $.datepicker.regional[langCode] =
- options;
-
- $.datepicker.regional.en = $.datepicker.regional[''];
-
- $.datepicker.setDefaults(options);
- }
- };
- fc.lang = function(langCode, options) {
- var langOptions;
- if (options) {
- langOptions = langOptionHash[langCode];
-
- if (!langOptions) {
- langOptions = langOptionHash[langCode] = {};
- }
- mergeOptions(langOptions, options || {});
- }
-
- defaults.lang = langCode;
- };
- ;;
-
- function Calendar(element, instanceOptions) {
- var t = this;
-
-
-
- instanceOptions = instanceOptions || {};
- var options = mergeOptions({}, defaults, instanceOptions);
- var langOptions;
-
- if (options.lang in langOptionHash) {
- langOptions = langOptionHash[options.lang];
- }
- else {
- langOptions = langOptionHash[defaults.lang];
- }
- if (langOptions) {
- options = mergeOptions({}, defaults, langOptions, instanceOptions);
- }
- if (options.isRTL) {
- options = mergeOptions({}, defaults, rtlDefaults, langOptions || {}, instanceOptions);
- }
-
-
-
- t.options = options;
- t.render = render;
- t.destroy = destroy;
- t.refetchEvents = refetchEvents;
- t.reportEvents = reportEvents;
- t.reportEventChange = reportEventChange;
- t.rerenderEvents = renderEvents;
- t.changeView = changeView;
- t.select = select;
- t.unselect = unselect;
- t.prev = prev;
- t.next = next;
- t.prevYear = prevYear;
- t.nextYear = nextYear;
- t.today = today;
- t.gotoDate = gotoDate;
- t.incrementDate = incrementDate;
- t.zoomTo = zoomTo;
- t.getDate = getDate;
- t.getCalendar = getCalendar;
- t.getView = getView;
- t.option = option;
- t.trigger = trigger;
-
-
-
-
-
- function getLocaleData(langCode) {
- var f = moment.localeData || moment.langData;
- return f.call(moment, langCode) ||
- f.call(moment, 'en');
- }
- var localeData = createObject(getLocaleData(options.lang));
- if (options.monthNames) {
- localeData._months = options.monthNames;
- }
- if (options.monthNamesShort) {
- localeData._monthsShort = options.monthNamesShort;
- }
- if (options.dayNames) {
- localeData._weekdays = options.dayNames;
- }
- if (options.dayNamesShort) {
- localeData._weekdaysShort = options.dayNamesShort;
- }
- if (options.firstDay != null) {
- var _week = createObject(localeData._week);
- _week.dow = options.firstDay;
- localeData._week = _week;
- }
-
-
- t.defaultAllDayEventDuration = moment.duration(options.defaultAllDayEventDuration);
- t.defaultTimedEventDuration = moment.duration(options.defaultTimedEventDuration);
-
-
- t.moment = function() {
- var mom;
- if (options.timezone === 'local') {
- mom = fc.moment.apply(null, arguments);
-
- if (mom.hasTime()) {
- mom.local();
- }
- }
- else if (options.timezone === 'UTC') {
- mom = fc.moment.utc.apply(null, arguments);
- }
- else {
- mom = fc.moment.parseZone.apply(null, arguments);
- }
- if ('_locale' in mom) {
- mom._locale = localeData;
- }
- else {
- mom._lang = localeData;
- }
- return mom;
- };
-
-
- t.getIsAmbigTimezone = function() {
- return options.timezone !== 'local' && options.timezone !== 'UTC';
- };
-
-
- t.rezoneDate = function(date) {
- return t.moment(date.toArray());
- };
-
-
- t.getNow = function() {
- var now = options.now;
- if (typeof now === 'function') {
- now = now();
- }
- return t.moment(now);
- };
-
-
- t.calculateWeekNumber = function(mom) {
- var calc = options.weekNumberCalculation;
- if (typeof calc === 'function') {
- return calc(mom);
- }
- else if (calc === 'local') {
- return mom.week();
- }
- else if (calc.toUpperCase() === 'ISO') {
- return mom.isoWeek();
- }
- };
-
- t.getEventEnd = function(event) {
- if (event.end) {
- return event.end.clone();
- }
- else {
- return t.getDefaultEventEnd(event.allDay, event.start);
- }
- };
-
- t.getDefaultEventEnd = function(allDay, start) {
- var end = start.clone();
- if (allDay) {
- end.stripTime().add(t.defaultAllDayEventDuration);
- }
- else {
- end.add(t.defaultTimedEventDuration);
- }
- if (t.getIsAmbigTimezone()) {
- end.stripZone();
- }
- return end;
- };
-
-
-
- t.formatRange = function(m1, m2, formatStr) {
-
- if (typeof formatStr === 'function') {
- formatStr = formatStr.call(t, options, localeData);
- }
- return formatRange(m1, m2, formatStr, null, options.isRTL);
- };
-
- t.formatDate = function(mom, formatStr) {
-
- if (typeof formatStr === 'function') {
- formatStr = formatStr.call(t, options, localeData);
- }
- return formatDate(mom, formatStr);
- };
-
-
-
- EventManager.call(t, options);
- var isFetchNeeded = t.isFetchNeeded;
- var fetchEvents = t.fetchEvents;
-
-
- var _element = element[0];
- var header;
- var headerElement;
- var content;
- var tm;
- var currentView;
- var suggestedViewHeight;
- var windowResizeProxy;
- var ignoreWindowResize = 0;
- var date;
- var events = [];
-
-
-
-
-
- if (options.defaultDate != null) {
- date = t.moment(options.defaultDate);
- }
- else {
- date = t.getNow();
- }
-
-
- function render(inc) {
- if (!content) {
- initialRender();
- }
- else if (elementVisible()) {
-
- calcSize();
- renderView(inc);
- }
- }
-
-
- function initialRender() {
- tm = options.theme ? 'ui' : 'fc';
- element.addClass('fc');
- if (options.isRTL) {
- element.addClass('fc-rtl');
- }
- else {
- element.addClass('fc-ltr');
- }
- if (options.theme) {
- element.addClass('ui-widget');
- }
- else {
- element.addClass('fc-unthemed');
- }
- content = $("<div class='fc-view-container'/>").prependTo(element);
- header = new Header(t, options);
- headerElement = header.render();
- if (headerElement) {
- element.prepend(headerElement);
- }
- changeView(options.defaultView);
- if (options.handleWindowResize) {
- windowResizeProxy = debounce(windowResize, options.windowResizeDelay);
- $(window).resize(windowResizeProxy);
- }
- }
-
-
- function destroy() {
- if (currentView) {
- currentView.destroy();
- }
- header.destroy();
- content.remove();
- element.removeClass('fc fc-ltr fc-rtl fc-unthemed ui-widget');
- $(window).unbind('resize', windowResizeProxy);
- }
-
-
- function elementVisible() {
- return element.is(':visible');
- }
-
-
-
-
- function changeView(viewName) {
- renderView(0, viewName);
- }
-
- function renderView(delta, viewName) {
- ignoreWindowResize++;
-
- if (currentView && viewName && currentView.name !== viewName) {
- header.deactivateButton(currentView.name);
- freezeContentHeight();
- if (currentView.start) {
- currentView.destroy();
- }
- currentView.el.remove();
- currentView = null;
- }
-
- if (!currentView && viewName) {
- currentView = new fcViews[viewName](t);
- currentView.el = $("<div class='fc-view fc-" + viewName + "-view' />").appendTo(content);
- header.activateButton(viewName);
- }
- if (currentView) {
-
- if (delta) {
- date = currentView.incrementDate(date, delta);
- }
-
- if (
- !currentView.start ||
- delta ||
- !date.isWithin(currentView.intervalStart, currentView.intervalEnd)
- ) {
- if (elementVisible()) {
- freezeContentHeight();
- if (currentView.start) {
- currentView.destroy();
- }
- currentView.render(date);
- unfreezeContentHeight();
-
- updateTitle();
- updateTodayButton();
- getAndRenderEvents();
- }
- }
- }
- unfreezeContentHeight();
- ignoreWindowResize--;
- }
-
-
-
-
- t.getSuggestedViewHeight = function() {
- if (suggestedViewHeight === undefined) {
- calcSize();
- }
- return suggestedViewHeight;
- };
- t.isHeightAuto = function() {
- return options.contentHeight === 'auto' || options.height === 'auto';
- };
-
-
- function updateSize(shouldRecalc) {
- if (elementVisible()) {
- if (shouldRecalc) {
- _calcSize();
- }
- ignoreWindowResize++;
- currentView.updateSize(true);
- ignoreWindowResize--;
- return true;
- }
- }
- function calcSize() {
- if (elementVisible()) {
- _calcSize();
- }
- }
-
-
- function _calcSize() {
- if (typeof options.contentHeight === 'number') {
- suggestedViewHeight = options.contentHeight;
- }
- else if (typeof options.height === 'number') {
- suggestedViewHeight = options.height - (headerElement ? headerElement.outerHeight(true) : 0);
- }
- else {
- suggestedViewHeight = Math.round(content.width() / Math.max(options.aspectRatio, .5));
- }
- }
-
-
- function windowResize(ev) {
- if (
- !ignoreWindowResize &&
- ev.target === window &&
- currentView.start
- ) {
- if (updateSize(true)) {
- currentView.trigger('windowResize', _element);
- }
- }
- }
-
-
-
-
-
- function refetchEvents() {
- destroyEvents();
- fetchAndRenderEvents();
- }
- function renderEvents() {
- if (elementVisible()) {
- freezeContentHeight();
- currentView.destroyEvents();
- currentView.renderEvents(events);
- unfreezeContentHeight();
- }
- }
- function destroyEvents() {
- freezeContentHeight();
- currentView.destroyEvents();
- unfreezeContentHeight();
- }
-
- function getAndRenderEvents() {
- if (!options.lazyFetching || isFetchNeeded(currentView.start, currentView.end)) {
- fetchAndRenderEvents();
- }
- else {
- renderEvents();
- }
- }
- function fetchAndRenderEvents() {
- fetchEvents(currentView.start, currentView.end);
-
-
- }
-
-
- function reportEvents(_events) {
- events = _events;
- renderEvents();
- }
-
- function reportEventChange() {
- renderEvents();
- }
-
- function updateTitle() {
- header.updateTitle(currentView.title);
- }
- function updateTodayButton() {
- var now = t.getNow();
- if (now.isWithin(currentView.intervalStart, currentView.intervalEnd)) {
- header.disableButton('today');
- }
- else {
- header.enableButton('today');
- }
- }
-
-
-
- function select(start, end) {
- start = t.moment(start);
- if (end) {
- end = t.moment(end);
- }
- else if (start.hasTime()) {
- end = start.clone().add(t.defaultTimedEventDuration);
- }
- else {
- end = start.clone().add(t.defaultAllDayEventDuration);
- }
- currentView.select(start, end);
- }
-
- function unselect() {
- if (currentView) {
- currentView.unselect();
- }
- }
-
-
-
-
-
-
- function prev() {
- renderView(-1);
- }
-
-
- function next() {
- renderView(1);
- }
-
-
- function prevYear() {
- date.add(-1, 'years');
- renderView();
- }
-
-
- function nextYear() {
- date.add(1, 'years');
- renderView();
- }
-
-
- function today() {
- date = t.getNow();
- renderView();
- }
-
-
- function gotoDate(dateInput) {
- date = t.moment(dateInput);
- renderView();
- }
-
-
- function incrementDate(delta) {
- date.add(moment.duration(delta));
- renderView();
- }
-
-
- function zoomTo(newDate, viewName) {
- var viewStr;
- var match;
- if (!viewName || fcViews[viewName] === undefined) {
- viewName = viewName || 'day';
- viewStr = header.getViewsWithButtons().join(' ');
-
- match = viewStr.match(new RegExp('\\w+' + capitaliseFirstLetter(viewName)));
-
- if (!match) {
- match = viewStr.match(/\w+Day/);
- }
- viewName = match ? match[0] : 'agendaDay';
- }
- date = newDate;
- changeView(viewName);
- }
-
-
- function getDate() {
- return date.clone();
- }
-
- function freezeContentHeight() {
- content.css({
- width: '100%',
- height: content.height(),
- overflow: 'hidden'
- });
- }
- function unfreezeContentHeight() {
- content.css({
- width: '',
- height: '',
- overflow: ''
- });
- }
-
-
-
-
-
- function getCalendar() {
- return t;
- }
-
- function getView() {
- return currentView;
- }
-
-
- function option(name, value) {
- if (value === undefined) {
- return options[name];
- }
- if (name == 'height' || name == 'contentHeight' || name == 'aspectRatio') {
- options[name] = value;
- updateSize(true);
- }
- }
-
-
- function trigger(name, thisObj) {
- if (options[name]) {
- return options[name].apply(
- thisObj || _element,
- Array.prototype.slice.call(arguments, 2)
- );
- }
- }
- }
- ;;
- function Header(calendar, options) {
- var t = this;
-
-
- t.render = render;
- t.destroy = destroy;
- t.updateTitle = updateTitle;
- t.activateButton = activateButton;
- t.deactivateButton = deactivateButton;
- t.disableButton = disableButton;
- t.enableButton = enableButton;
- t.getViewsWithButtons = getViewsWithButtons;
-
-
- var el = $();
- var viewsWithButtons = [];
- var tm;
- function render() {
- var sections = options.header;
- tm = options.theme ? 'ui' : 'fc';
- if (sections) {
- el = $("<div class='fc-toolbar'/>")
- .append(renderSection('left'))
- .append(renderSection('right'))
- .append(renderSection('center'))
- .append('<div class="fc-clear"/>');
- return el;
- }
- }
-
-
- function destroy() {
- el.remove();
- }
-
-
- function renderSection(position) {
- var sectionEl = $('<div class="fc-' + position + '"/>');
- var buttonStr = options.header[position];
- if (buttonStr) {
- $.each(buttonStr.split(' '), function(i) {
- var groupChildren = $();
- var isOnlyButtons = true;
- var groupEl;
- $.each(this.split(','), function(j, buttonName) {
- var buttonClick;
- var themeIcon;
- var normalIcon;
- var defaultText;
- var customText;
- var innerHtml;
- var classes;
- var button;
- if (buttonName == 'title') {
- groupChildren = groupChildren.add($('<h2> </h2>'));
- isOnlyButtons = false;
- }
- else {
- if (calendar[buttonName]) {
- buttonClick = function() {
- calendar[buttonName]();
- };
- }
- else if (fcViews[buttonName]) {
- buttonClick = function() {
- calendar.changeView(buttonName);
- };
- viewsWithButtons.push(buttonName);
- }
- if (buttonClick) {
-
- themeIcon = smartProperty(options.themeButtonIcons, buttonName);
- normalIcon = smartProperty(options.buttonIcons, buttonName);
- defaultText = smartProperty(options.defaultButtonText, buttonName);
- customText = smartProperty(options.buttonText, buttonName);
- if (customText) {
- innerHtml = htmlEscape(customText);
- }
- else if (themeIcon && options.theme) {
- innerHtml = "<span class='ui-icon ui-icon-" + themeIcon + "'></span>";
- }
- else if (normalIcon && !options.theme) {
- innerHtml = "<span class='fc-icon fc-icon-" + normalIcon + "'></span>";
- }
- else {
- innerHtml = htmlEscape(defaultText || buttonName);
- }
- classes = [
- 'fc-' + buttonName + '-button',
- tm + '-button',
- tm + '-state-default'
- ];
- button = $(
- '<button type="button" class="' + classes.join(' ') + '">' +
- innerHtml +
- '</button>'
- )
- .click(function() {
-
- if (!button.hasClass(tm + '-state-disabled')) {
- buttonClick();
-
-
- if (
- button.hasClass(tm + '-state-active') ||
- button.hasClass(tm + '-state-disabled')
- ) {
- button.removeClass(tm + '-state-hover');
- }
- }
- })
- .mousedown(function() {
-
-
- button
- .not('.' + tm + '-state-active')
- .not('.' + tm + '-state-disabled')
- .addClass(tm + '-state-down');
- })
- .mouseup(function() {
-
- button.removeClass(tm + '-state-down');
- })
- .hover(
- function() {
-
-
- button
- .not('.' + tm + '-state-active')
- .not('.' + tm + '-state-disabled')
- .addClass(tm + '-state-hover');
- },
- function() {
-
- button
- .removeClass(tm + '-state-hover')
- .removeClass(tm + '-state-down');
- }
- );
- groupChildren = groupChildren.add(button);
- }
- }
- });
- if (isOnlyButtons) {
- groupChildren
- .first().addClass(tm + '-corner-left').end()
- .last().addClass(tm + '-corner-right').end();
- }
- if (groupChildren.length > 1) {
- groupEl = $('<div/>');
- if (isOnlyButtons) {
- groupEl.addClass('fc-button-group');
- }
- groupEl.append(groupChildren);
- sectionEl.append(groupEl);
- }
- else {
- sectionEl.append(groupChildren);
- }
- });
- }
- return sectionEl;
- }
-
-
- function updateTitle(text) {
- el.find('h2').text(text);
- }
-
-
- function activateButton(buttonName) {
- el.find('.fc-' + buttonName + '-button')
- .addClass(tm + '-state-active');
- }
-
-
- function deactivateButton(buttonName) {
- el.find('.fc-' + buttonName + '-button')
- .removeClass(tm + '-state-active');
- }
-
-
- function disableButton(buttonName) {
- el.find('.fc-' + buttonName + '-button')
- .attr('disabled', 'disabled')
- .addClass(tm + '-state-disabled');
- }
-
-
- function enableButton(buttonName) {
- el.find('.fc-' + buttonName + '-button')
- .removeAttr('disabled')
- .removeClass(tm + '-state-disabled');
- }
- function getViewsWithButtons() {
- return viewsWithButtons;
- }
- }
- ;;
- fc.sourceNormalizers = [];
- fc.sourceFetchers = [];
- var ajaxDefaults = {
- dataType: 'json',
- cache: false
- };
- var eventGUID = 1;
- function EventManager(options) {
- var t = this;
-
-
-
- t.isFetchNeeded = isFetchNeeded;
- t.fetchEvents = fetchEvents;
- t.addEventSource = addEventSource;
- t.removeEventSource = removeEventSource;
- t.updateEvent = updateEvent;
- t.renderEvent = renderEvent;
- t.removeEvents = removeEvents;
- t.clientEvents = clientEvents;
- t.mutateEvent = mutateEvent;
-
-
-
- var trigger = t.trigger;
- var getView = t.getView;
- var reportEvents = t.reportEvents;
- var getEventEnd = t.getEventEnd;
-
-
-
- var stickySource = { events: [] };
- var sources = [ stickySource ];
- var rangeStart, rangeEnd;
- var currentFetchID = 0;
- var pendingSourceCnt = 0;
- var loadingLevel = 0;
- var cache = [];
- $.each(
- (options.events ? [ options.events ] : []).concat(options.eventSources || []),
- function(i, sourceInput) {
- var source = buildEventSource(sourceInput);
- if (source) {
- sources.push(source);
- }
- }
- );
-
-
-
-
-
-
- function isFetchNeeded(start, end) {
- return !rangeStart ||
-
- start.clone().stripZone() < rangeStart.clone().stripZone() ||
- end.clone().stripZone() > rangeEnd.clone().stripZone();
- }
-
-
- function fetchEvents(start, end) {
- rangeStart = start;
- rangeEnd = end;
- cache = [];
- var fetchID = ++currentFetchID;
- var len = sources.length;
- pendingSourceCnt = len;
- for (var i=0; i<len; i++) {
- fetchEventSource(sources[i], fetchID);
- }
- }
-
-
- function fetchEventSource(source, fetchID) {
- _fetchEventSource(source, function(events) {
- var isArraySource = $.isArray(source.events);
- var i;
- var event;
- if (fetchID == currentFetchID) {
- if (events) {
- for (i=0; i<events.length; i++) {
- event = events[i];
-
- if (!isArraySource) {
- event = buildEvent(event, source);
- }
- if (event) {
- cache.push(event);
- }
- }
- }
- pendingSourceCnt--;
- if (!pendingSourceCnt) {
- reportEvents(cache);
- }
- }
- });
- }
-
-
- function _fetchEventSource(source, callback) {
- var i;
- var fetchers = fc.sourceFetchers;
- var res;
- for (i=0; i<fetchers.length; i++) {
- res = fetchers[i].call(
- t,
- source,
- rangeStart.clone(),
- rangeEnd.clone(),
- options.timezone,
- callback
- );
- if (res === true) {
-
- return;
- }
- else if (typeof res == 'object') {
-
- _fetchEventSource(res, callback);
- return;
- }
- }
- var events = source.events;
- if (events) {
- if ($.isFunction(events)) {
- pushLoading();
- events.call(
- t,
- rangeStart.clone(),
- rangeEnd.clone(),
- options.timezone,
- function(events) {
- callback(events);
- popLoading();
- }
- );
- }
- else if ($.isArray(events)) {
- callback(events);
- }
- else {
- callback();
- }
- }else{
- var url = source.url;
- if (url) {
- var success = source.success;
- var error = source.error;
- var complete = source.complete;
-
- var customData;
- if ($.isFunction(source.data)) {
-
- customData = source.data();
- }
- else {
-
- customData = source.data;
- }
-
-
- var data = $.extend({}, customData || {});
- var startParam = firstDefined(source.startParam, options.startParam);
- var endParam = firstDefined(source.endParam, options.endParam);
- var timezoneParam = firstDefined(source.timezoneParam, options.timezoneParam);
- if (startParam) {
- data[startParam] = rangeStart.format();
- }
- if (endParam) {
- data[endParam] = rangeEnd.format();
- }
- if (options.timezone && options.timezone != 'local') {
- data[timezoneParam] = options.timezone;
- }
- pushLoading();
- $.ajax($.extend({}, ajaxDefaults, source, {
- data: data,
- success: function(events) {
- events = events || [];
- var res = applyAll(success, this, arguments);
- if ($.isArray(res)) {
- events = res;
- }
- callback(events);
- },
- error: function() {
- applyAll(error, this, arguments);
- callback();
- },
- complete: function() {
- applyAll(complete, this, arguments);
- popLoading();
- }
- }));
- }else{
- callback();
- }
- }
- }
-
-
-
-
-
- function addEventSource(sourceInput) {
- var source = buildEventSource(sourceInput);
- if (source) {
- sources.push(source);
- pendingSourceCnt++;
- fetchEventSource(source, currentFetchID);
- }
- }
- function buildEventSource(sourceInput) {
- var normalizers = fc.sourceNormalizers;
- var source;
- var i;
- if ($.isFunction(sourceInput) || $.isArray(sourceInput)) {
- source = { events: sourceInput };
- }
- else if (typeof sourceInput === 'string') {
- source = { url: sourceInput };
- }
- else if (typeof sourceInput === 'object') {
- source = $.extend({}, sourceInput);
- }
- if (source) {
-
- if (source.className) {
- if (typeof source.className === 'string') {
- source.className = source.className.split(/\s+/);
- }
-
- }
- else {
- source.className = [];
- }
-
- if ($.isArray(source.events)) {
- source.origArray = source.events;
- source.events = $.map(source.events, function(eventInput) {
- return buildEvent(eventInput, source);
- });
- }
- for (i=0; i<normalizers.length; i++) {
- normalizers[i].call(t, source);
- }
- return source;
- }
- }
- function removeEventSource(source) {
- sources = $.grep(sources, function(src) {
- return !isSourcesEqual(src, source);
- });
-
- cache = $.grep(cache, function(e) {
- return !isSourcesEqual(e.source, source);
- });
- reportEvents(cache);
- }
- function isSourcesEqual(source1, source2) {
- return source1 && source2 && getSourcePrimitive(source1) == getSourcePrimitive(source2);
- }
- function getSourcePrimitive(source) {
- return (
- (typeof source === 'object') ?
- (source.origArray || source.url || source.events) :
- null
- ) ||
- source;
- }
-
-
-
-
- function updateEvent(event) {
- event.start = t.moment(event.start);
- if (event.end) {
- event.end = t.moment(event.end);
- }
- mutateEvent(event);
- propagateMiscProperties(event);
- reportEvents(cache);
- }
- var miscCopyableProps = [
- 'title',
- 'url',
- 'allDay',
- 'className',
- 'editable',
- 'color',
- 'backgroundColor',
- 'borderColor',
- 'textColor'
- ];
- function propagateMiscProperties(event) {
- var i;
- var cachedEvent;
- var j;
- var prop;
- for (i=0; i<cache.length; i++) {
- cachedEvent = cache[i];
- if (cachedEvent._id == event._id && cachedEvent !== event) {
- for (j=0; j<miscCopyableProps.length; j++) {
- prop = miscCopyableProps[j];
- if (event[prop] !== undefined) {
- cachedEvent[prop] = event[prop];
- }
- }
- }
- }
- }
-
-
- function renderEvent(eventData, stick) {
- var event = buildEvent(eventData);
- if (event) {
- if (!event.source) {
- if (stick) {
- stickySource.events.push(event);
- event.source = stickySource;
- }
- cache.push(event);
- }
- reportEvents(cache);
- }
- }
-
-
- function removeEvents(filter) {
- var eventID;
- var i;
- if (filter == null) {
- filter = function() { return true; };
- }
- else if (!$.isFunction(filter)) {
- eventID = filter + '';
- filter = function(event) {
- return event._id == eventID;
- };
- }
-
- cache = $.grep(cache, filter, true);
-
-
-
- for (i=0; i<sources.length; i++) {
- if ($.isArray(sources[i].events)) {
- sources[i].events = $.grep(sources[i].events, filter, true);
- }
- }
- reportEvents(cache);
- }
-
-
- function clientEvents(filter) {
- if ($.isFunction(filter)) {
- return $.grep(cache, filter);
- }
- else if (filter != null) {
- filter += '';
- return $.grep(cache, function(e) {
- return e._id == filter;
- });
- }
- return cache;
- }
-
-
-
-
-
-
- function pushLoading() {
- if (!(loadingLevel++)) {
- trigger('loading', null, true, getView());
- }
- }
-
-
- function popLoading() {
- if (!(--loadingLevel)) {
- trigger('loading', null, false, getView());
- }
- }
-
-
-
-
- function buildEvent(data, source) {
- var out = {};
- var start;
- var end;
- var allDay;
- var allDayDefault;
- if (options.eventDataTransform) {
- data = options.eventDataTransform(data);
- }
- if (source && source.eventDataTransform) {
- data = source.eventDataTransform(data);
- }
- start = t.moment(data.start || data.date);
- if (!start.isValid()) {
- return;
- }
- end = null;
- if (data.end) {
- end = t.moment(data.end);
- if (!end.isValid()) {
- return;
- }
- }
- allDay = data.allDay;
- if (allDay === undefined) {
- allDayDefault = firstDefined(
- source ? source.allDayDefault : undefined,
- options.allDayDefault
- );
- if (allDayDefault !== undefined) {
-
- allDay = allDayDefault;
- }
- else {
-
- allDay = !start.hasTime() && (!end || !end.hasTime());
- }
- }
-
- if (allDay) {
-
- if (start.hasTime()) {
- start.stripTime();
- }
- if (end && end.hasTime()) {
- end.stripTime();
- }
- }
- else {
-
- if (!start.hasTime()) {
- start = t.rezoneDate(start);
- }
- if (end && !end.hasTime()) {
- end = t.rezoneDate(end);
- }
- }
-
-
- $.extend(out, data);
- if (source) {
- out.source = source;
- }
- out._id = data._id || (data.id === undefined ? '_fc' + eventGUID++ : data.id + '');
- if (data.className) {
- if (typeof data.className == 'string') {
- out.className = data.className.split(/\s+/);
- }
- else {
- out.className = data.className;
- }
- }
- else {
- out.className = [];
- }
- out.allDay = allDay;
- out.start = start;
- out.end = end;
- if (options.forceEventDuration && !out.end) {
- out.end = getEventEnd(out);
- }
- backupEventDates(out);
- return out;
- }
-
-
-
-
-
-
-
-
-
- function mutateEvent(event, newStart, newEnd) {
- var oldAllDay = event._allDay;
- var oldStart = event._start;
- var oldEnd = event._end;
- var clearEnd = false;
- var newAllDay;
- var dateDelta;
- var durationDelta;
- var undoFunc;
-
- if (!newStart && !newEnd) {
- newStart = event.start;
- newEnd = event.end;
- }
-
-
-
- if (event.allDay != oldAllDay) {
- newAllDay = event.allDay;
- }
- else {
- newAllDay = !(newStart || newEnd).hasTime();
- }
-
- if (newAllDay) {
- if (newStart) {
- newStart = newStart.clone().stripTime();
- }
- if (newEnd) {
- newEnd = newEnd.clone().stripTime();
- }
- }
-
- if (newStart) {
- if (newAllDay) {
- dateDelta = dayishDiff(newStart, oldStart.clone().stripTime());
- }
- else {
- dateDelta = dayishDiff(newStart, oldStart);
- }
- }
- if (newAllDay != oldAllDay) {
-
- clearEnd = true;
- }
- else if (newEnd) {
- durationDelta = dayishDiff(
-
- newEnd || t.getDefaultEventEnd(newAllDay, newStart || oldStart),
- newStart || oldStart
- ).subtract(dayishDiff(
-
- oldEnd || t.getDefaultEventEnd(oldAllDay, oldStart),
- oldStart
- ));
- }
- undoFunc = mutateEvents(
- clientEvents(event._id),
- clearEnd,
- newAllDay,
- dateDelta,
- durationDelta
- );
- return {
- dateDelta: dateDelta,
- durationDelta: durationDelta,
- undo: undoFunc
- };
- }
-
-
-
-
-
-
-
-
- function mutateEvents(events, clearEnd, forceAllDay, dateDelta, durationDelta) {
- var isAmbigTimezone = t.getIsAmbigTimezone();
- var undoFunctions = [];
- $.each(events, function(i, event) {
- var oldAllDay = event._allDay;
- var oldStart = event._start;
- var oldEnd = event._end;
- var newAllDay = forceAllDay != null ? forceAllDay : oldAllDay;
- var newStart = oldStart.clone();
- var newEnd = (!clearEnd && oldEnd) ? oldEnd.clone() : null;
-
-
-
- if (newAllDay) {
- newStart.stripTime();
- if (newEnd) {
- newEnd.stripTime();
- }
- }
- else {
- if (!newStart.hasTime()) {
- newStart = t.rezoneDate(newStart);
- }
- if (newEnd && !newEnd.hasTime()) {
- newEnd = t.rezoneDate(newEnd);
- }
- }
-
- if (!newEnd && (options.forceEventDuration || +durationDelta)) {
- newEnd = t.getDefaultEventEnd(newAllDay, newStart);
- }
-
- newStart.add(dateDelta);
- if (newEnd) {
- newEnd.add(dateDelta).add(durationDelta);
- }
-
-
- if (isAmbigTimezone) {
- if (+dateDelta || +durationDelta) {
- newStart.stripZone();
- if (newEnd) {
- newEnd.stripZone();
- }
- }
- }
- event.allDay = newAllDay;
- event.start = newStart;
- event.end = newEnd;
- backupEventDates(event);
- undoFunctions.push(function() {
- event.allDay = oldAllDay;
- event.start = oldStart;
- event.end = oldEnd;
- backupEventDates(event);
- });
- });
- return function() {
- for (var i=0; i<undoFunctions.length; i++) {
- undoFunctions[i]();
- }
- };
- }
- }
- function backupEventDates(event) {
- event._allDay = event.allDay;
- event._start = event.start.clone();
- event._end = event.end ? event.end.clone() : null;
- }
- ;;
- function compensateScroll(rowEls, scrollbarWidths) {
- if (scrollbarWidths.left) {
- rowEls.css({
- 'border-left-width': 1,
- 'margin-left': scrollbarWidths.left - 1
- });
- }
- if (scrollbarWidths.right) {
- rowEls.css({
- 'border-right-width': 1,
- 'margin-right': scrollbarWidths.right - 1
- });
- }
- }
- function uncompensateScroll(rowEls) {
- rowEls.css({
- 'margin-left': '',
- 'margin-right': '',
- 'border-left-width': '',
- 'border-right-width': ''
- });
- }
- function distributeHeight(els, availableHeight, shouldRedistribute) {
-
-
- var minOffset1 = Math.floor(availableHeight / els.length);
- var minOffset2 = Math.floor(availableHeight - minOffset1 * (els.length - 1));
- var flexEls = [];
- var flexOffsets = [];
- var flexHeights = [];
- var usedHeight = 0;
- undistributeHeight(els);
-
-
- els.each(function(i, el) {
- var minOffset = i === els.length - 1 ? minOffset2 : minOffset1;
- var naturalOffset = $(el).outerHeight(true);
- if (naturalOffset < minOffset) {
- flexEls.push(el);
- flexOffsets.push(naturalOffset);
- flexHeights.push($(el).height());
- }
- else {
-
- usedHeight += naturalOffset;
- }
- });
-
- if (shouldRedistribute) {
- availableHeight -= usedHeight;
- minOffset1 = Math.floor(availableHeight / flexEls.length);
- minOffset2 = Math.floor(availableHeight - minOffset1 * (flexEls.length - 1));
- }
-
- $(flexEls).each(function(i, el) {
- var minOffset = i === flexEls.length - 1 ? minOffset2 : minOffset1;
- var naturalOffset = flexOffsets[i];
- var naturalHeight = flexHeights[i];
- var newHeight = minOffset - (naturalOffset - naturalHeight);
- if (naturalOffset < minOffset) {
- $(el).height(newHeight);
- }
- });
- }
- function undistributeHeight(els) {
- els.height('');
- }
- function matchCellWidths(els) {
- var maxInnerWidth = 0;
- els.find('> *').each(function(i, innerEl) {
- var innerWidth = $(innerEl).outerWidth();
- if (innerWidth > maxInnerWidth) {
- maxInnerWidth = innerWidth;
- }
- });
- maxInnerWidth++;
- els.width(maxInnerWidth);
- return maxInnerWidth;
- }
- function setPotentialScroller(containerEl, height) {
- containerEl.height(height).addClass('fc-scroller');
-
- if (containerEl[0].scrollHeight - 1 > containerEl[0].clientHeight) {
- return true;
- }
- unsetScroller(containerEl);
- return false;
- }
- function unsetScroller(containerEl) {
- containerEl.height('').removeClass('fc-scroller');
- }
- function getScrollParent(el) {
- var position = el.css('position'),
- scrollParent = el.parents().filter(function() {
- var parent = $(this);
- return (/(auto|scroll)/).test(
- parent.css('overflow') + parent.css('overflow-y') + parent.css('overflow-x')
- );
- }).eq(0);
- return position === 'fixed' || !scrollParent.length ? $(el[0].ownerDocument || document) : scrollParent;
- }
- function getScrollbarWidths(container) {
- var containerLeft = container.offset().left;
- var containerRight = containerLeft + container.width();
- var inner = container.children();
- var innerLeft = inner.offset().left;
- var innerRight = innerLeft + inner.outerWidth();
- return {
- left: innerLeft - containerLeft,
- right: containerRight - innerRight
- };
- }
- function isPrimaryMouseButton(ev) {
- return ev.which == 1 && !ev.ctrlKey;
- }
- function intersectionToSeg(subjectStart, subjectEnd, intervalStart, intervalEnd) {
- var segStart, segEnd;
- var isStart, isEnd;
- if (subjectEnd > intervalStart && subjectStart < intervalEnd) {
- if (subjectStart >= intervalStart) {
- segStart = subjectStart.clone();
- isStart = true;
- }
- else {
- segStart = intervalStart.clone();
- isStart = false;
- }
- if (subjectEnd <= intervalEnd) {
- segEnd = subjectEnd.clone();
- isEnd = true;
- }
- else {
- segEnd = intervalEnd.clone();
- isEnd = false;
- }
- return {
- start: segStart,
- end: segEnd,
- isStart: isStart,
- isEnd: isEnd
- };
- }
- }
- function smartProperty(obj, name) {
- obj = obj || {};
- if (obj[name] !== undefined) {
- return obj[name];
- }
- var parts = name.split(/(?=[A-Z])/),
- i = parts.length - 1, res;
- for (; i>=0; i--) {
- res = obj[parts[i].toLowerCase()];
- if (res !== undefined) {
- return res;
- }
- }
- return obj['default'];
- }
- var dayIDs = [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat' ];
- function dayishDiff(a, b) {
- return moment.duration({
- days: a.clone().stripTime().diff(b.clone().stripTime(), 'days'),
- ms: a.time() - b.time()
- });
- }
- function isNativeDate(input) {
- return Object.prototype.toString.call(input) === '[object Date]' || input instanceof Date;
- }
- function dateCompare(a, b) {
- return a - b;
- }
- fc.applyAll = applyAll;
- function createObject(proto) {
- var f = function() {};
- f.prototype = proto;
- return new f();
- }
- function extend(a, b) {
- for (var i in b) {
- if (b.hasOwnProperty(i)) {
- a[i] = b[i];
- }
- }
- }
- function applyAll(functions, thisObj, args) {
- if ($.isFunction(functions)) {
- functions = [ functions ];
- }
- if (functions) {
- var i;
- var ret;
- for (i=0; i<functions.length; i++) {
- ret = functions[i].apply(thisObj, args) || ret;
- }
- return ret;
- }
- }
- function firstDefined() {
- for (var i=0; i<arguments.length; i++) {
- if (arguments[i] !== undefined) {
- return arguments[i];
- }
- }
- }
- function htmlEscape(s) {
- return (s + '').replace(/&/g, '&')
- .replace(/</g, '<')
- .replace(/>/g, '>')
- .replace(/'/g, ''')
- .replace(/"/g, '"')
- .replace(/\n/g, '<br />');
- }
- function stripHtmlEntities(text) {
- return text.replace(/&.*?;/g, '');
- }
- function capitaliseFirstLetter(str) {
- return str.charAt(0).toUpperCase() + str.slice(1);
- }
- function debounce(func, wait) {
- var timeoutId;
- var args;
- var context;
- var timestamp;
- var later = function() {
- var last = +new Date() - timestamp;
- if (last < wait && last > 0) {
- timeoutId = setTimeout(later, wait - last);
- }
- else {
- timeoutId = null;
- func.apply(context, args);
- if (!timeoutId) {
- context = args = null;
- }
- }
- };
- return function() {
- context = this;
- args = arguments;
- timestamp = +new Date();
- if (!timeoutId) {
- timeoutId = setTimeout(later, wait);
- }
- };
- }
- ;;
- var ambigDateOfMonthRegex = /^\s*\d{4}-\d\d$/;
- var ambigTimeOrZoneRegex =
- /^\s*\d{4}-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?)?$/;
- fc.moment = function() {
- return makeMoment(arguments);
- };
- fc.moment.utc = function() {
- var mom = makeMoment(arguments, true);
-
- if (mom.hasTime()) {
- mom.utc();
- }
- return mom;
- };
- fc.moment.parseZone = function() {
- return makeMoment(arguments, true, true);
- };
- function makeMoment(args, parseAsUTC, parseZone) {
- var input = args[0];
- var isSingleString = args.length == 1 && typeof input === 'string';
- var isAmbigTime;
- var isAmbigZone;
- var ambigMatch;
- var output;
- if (moment.isMoment(input)) {
- output = moment.apply(null, args);
-
- if (input._ambigTime) {
- output._ambigTime = true;
- }
- if (input._ambigZone) {
- output._ambigZone = true;
- }
- }
- else if (isNativeDate(input) || input === undefined) {
- output = moment.apply(null, args);
- }
- else {
- isAmbigTime = false;
- isAmbigZone = false;
- if (isSingleString) {
- if (ambigDateOfMonthRegex.test(input)) {
-
- input += '-01';
- args = [ input ];
- isAmbigTime = true;
- isAmbigZone = true;
- }
- else if ((ambigMatch = ambigTimeOrZoneRegex.exec(input))) {
- isAmbigTime = !ambigMatch[5];
- isAmbigZone = true;
- }
- }
- else if ($.isArray(input)) {
-
- isAmbigZone = true;
- }
-
- if (parseAsUTC) {
- output = moment.utc.apply(moment, args);
- }
- else {
- output = moment.apply(null, args);
- }
- if (isAmbigTime) {
- output._ambigTime = true;
- output._ambigZone = true;
- }
- else if (parseZone) {
- if (isAmbigZone) {
- output._ambigZone = true;
- }
- else if (isSingleString) {
- output.zone(input);
- }
- }
- }
- return new FCMoment(output);
- }
- function FCMoment(internalData) {
- extend(this, internalData);
- }
- FCMoment.prototype = createObject(moment.fn);
- FCMoment.prototype.clone = function() {
- return makeMoment([ this ]);
- };
- FCMoment.prototype.time = function(time) {
- if (time == null) {
- return moment.duration({
- hours: this.hours(),
- minutes: this.minutes(),
- seconds: this.seconds(),
- milliseconds: this.milliseconds()
- });
- }
- else {
- delete this._ambigTime;
- if (!moment.isDuration(time) && !moment.isMoment(time)) {
- time = moment.duration(time);
- }
-
-
- var dayHours = 0;
- if (moment.isDuration(time)) {
- dayHours = Math.floor(time.asDays()) * 24;
- }
-
-
- return this.hours(dayHours + time.hours())
- .minutes(time.minutes())
- .seconds(time.seconds())
- .milliseconds(time.milliseconds());
- }
- };
- FCMoment.prototype.stripTime = function() {
- var a = this.toArray();
-
- moment.fn.utc.call(this);
- this.year(a[0])
- .month(a[1])
- .date(a[2])
- .hours(0)
- .minutes(0)
- .seconds(0)
- .milliseconds(0);
-
-
- this._ambigTime = true;
- this._ambigZone = true;
- return this;
- };
- FCMoment.prototype.hasTime = function() {
- return !this._ambigTime;
- };
- FCMoment.prototype.stripZone = function() {
- var a = this.toArray();
- var wasAmbigTime = this._ambigTime;
- moment.fn.utc.call(this);
- this.year(a[0])
- .month(a[1])
- .date(a[2])
- .hours(a[3])
- .minutes(a[4])
- .seconds(a[5])
- .milliseconds(a[6]);
- if (wasAmbigTime) {
-
- this._ambigTime = true;
- }
-
-
- this._ambigZone = true;
- return this;
- };
- FCMoment.prototype.hasZone = function() {
- return !this._ambigZone;
- };
- FCMoment.prototype.zone = function(tzo) {
- if (tzo != null) {
-
-
- delete this._ambigTime;
- delete this._ambigZone;
- }
- return moment.fn.zone.apply(this, arguments);
- };
- FCMoment.prototype.local = function() {
- var a = this.toArray();
- var wasAmbigZone = this._ambigZone;
-
- delete this._ambigTime;
- delete this._ambigZone;
- moment.fn.local.apply(this, arguments);
- if (wasAmbigZone) {
-
-
- this.year(a[0])
- .month(a[1])
- .date(a[2])
- .hours(a[3])
- .minutes(a[4])
- .seconds(a[5])
- .milliseconds(a[6]);
- }
- return this;
- };
- FCMoment.prototype.utc = function() {
-
- delete this._ambigTime;
- delete this._ambigZone;
- return moment.fn.utc.apply(this, arguments);
- };
- FCMoment.prototype.format = function() {
- if (arguments[0]) {
- return formatDate(this, arguments[0]);
- }
- if (this._ambigTime) {
- return momentFormat(this, 'YYYY-MM-DD');
- }
- if (this._ambigZone) {
- return momentFormat(this, 'YYYY-MM-DD[T]HH:mm:ss');
- }
- return momentFormat(this);
- };
- FCMoment.prototype.toISOString = function() {
- if (this._ambigTime) {
- return momentFormat(this, 'YYYY-MM-DD');
- }
- if (this._ambigZone) {
- return momentFormat(this, 'YYYY-MM-DD[T]HH:mm:ss');
- }
- return moment.fn.toISOString.apply(this, arguments);
- };
- FCMoment.prototype.isWithin = function(start, end) {
- var a = commonlyAmbiguate([ this, start, end ]);
- return a[0] >= a[1] && a[0] < a[2];
- };
- FCMoment.prototype.isSame = function(input, units) {
- var a;
- if (units) {
- a = commonlyAmbiguate([ this, input ], true);
- return moment.fn.isSame.call(a[0], a[1], units);
- }
- else {
- input = fc.moment.parseZone(input);
- return moment.fn.isSame.call(this, input) &&
- Boolean(this._ambigTime) === Boolean(input._ambigTime) &&
- Boolean(this._ambigZone) === Boolean(input._ambigZone);
- }
- };
- $.each([
- 'isBefore',
- 'isAfter'
- ], function(i, methodName) {
- FCMoment.prototype[methodName] = function(input, units) {
- var a = commonlyAmbiguate([ this, input ]);
- return moment.fn[methodName].call(a[0], a[1], units);
- };
- });
- function commonlyAmbiguate(inputs, preserveTime) {
- var outputs = [];
- var anyAmbigTime = false;
- var anyAmbigZone = false;
- var i;
- for (i=0; i<inputs.length; i++) {
- outputs.push(fc.moment.parseZone(inputs[i]));
- anyAmbigTime = anyAmbigTime || outputs[i]._ambigTime;
- anyAmbigZone = anyAmbigZone || outputs[i]._ambigZone;
- }
- for (i=0; i<outputs.length; i++) {
- if (anyAmbigTime && !preserveTime) {
- outputs[i].stripTime();
- }
- else if (anyAmbigZone) {
- outputs[i].stripZone();
- }
- }
- return outputs;
- }
- ;;
- function momentFormat(mom, formatStr) {
- return moment.fn.format.call(mom, formatStr);
- }
- function formatDate(date, formatStr) {
- return formatDateWithChunks(date, getFormatStringChunks(formatStr));
- }
- function formatDateWithChunks(date, chunks) {
- var s = '';
- var i;
- for (i=0; i<chunks.length; i++) {
- s += formatDateWithChunk(date, chunks[i]);
- }
- return s;
- }
- var tokenOverrides = {
- t: function(date) {
- return momentFormat(date, 'a').charAt(0);
- },
- T: function(date) {
- return momentFormat(date, 'A').charAt(0);
- }
- };
- function formatDateWithChunk(date, chunk) {
- var token;
- var maybeStr;
- if (typeof chunk === 'string') {
- return chunk;
- }
- else if ((token = chunk.token)) {
- if (tokenOverrides[token]) {
- return tokenOverrides[token](date);
- }
- return momentFormat(date, token);
- }
- else if (chunk.maybe) {
- maybeStr = formatDateWithChunks(date, chunk.maybe);
- if (maybeStr.match(/[1-9]/)) {
- return maybeStr;
- }
- }
- return '';
- }
- function formatRange(date1, date2, formatStr, separator, isRTL) {
- var localeData;
- date1 = fc.moment.parseZone(date1);
- date2 = fc.moment.parseZone(date2);
- localeData = (date1.localeData || date1.lang).call(date1);
-
- formatStr = localeData.longDateFormat(formatStr) || formatStr;
-
-
- separator = separator || ' - ';
- return formatRangeWithChunks(
- date1,
- date2,
- getFormatStringChunks(formatStr),
- separator,
- isRTL
- );
- }
- fc.formatRange = formatRange;
- function formatRangeWithChunks(date1, date2, chunks, separator, isRTL) {
- var chunkStr;
- var leftI;
- var leftStr = '';
- var rightI;
- var rightStr = '';
- var middleI;
- var middleStr1 = '';
- var middleStr2 = '';
- var middleStr = '';
-
-
- for (leftI=0; leftI<chunks.length; leftI++) {
- chunkStr = formatSimilarChunk(date1, date2, chunks[leftI]);
- if (chunkStr === false) {
- break;
- }
- leftStr += chunkStr;
- }
-
- for (rightI=chunks.length-1; rightI>leftI; rightI--) {
- chunkStr = formatSimilarChunk(date1, date2, chunks[rightI]);
- if (chunkStr === false) {
- break;
- }
- rightStr = chunkStr + rightStr;
- }
-
-
- for (middleI=leftI; middleI<=rightI; middleI++) {
- middleStr1 += formatDateWithChunk(date1, chunks[middleI]);
- middleStr2 += formatDateWithChunk(date2, chunks[middleI]);
- }
- if (middleStr1 || middleStr2) {
- if (isRTL) {
- middleStr = middleStr2 + separator + middleStr1;
- }
- else {
- middleStr = middleStr1 + separator + middleStr2;
- }
- }
- return leftStr + middleStr + rightStr;
- }
- var similarUnitMap = {
- Y: 'year',
- M: 'month',
- D: 'day',
- d: 'day',
-
- A: 'second',
- a: 'second',
- T: 'second',
- t: 'second',
- H: 'second',
- h: 'second',
- m: 'second',
- s: 'second'
- };
- function formatSimilarChunk(date1, date2, chunk) {
- var token;
- var unit;
- if (typeof chunk === 'string') {
- return chunk;
- }
- else if ((token = chunk.token)) {
- unit = similarUnitMap[token.charAt(0)];
-
- if (unit && date1.isSame(date2, unit)) {
- return momentFormat(date1, token);
-
- }
- }
- return false;
-
- }
- var formatStringChunkCache = {};
- function getFormatStringChunks(formatStr) {
- if (formatStr in formatStringChunkCache) {
- return formatStringChunkCache[formatStr];
- }
- return (formatStringChunkCache[formatStr] = chunkFormatString(formatStr));
- }
- function chunkFormatString(formatStr) {
- var chunks = [];
- var chunker = /\[([^\]]*)\]|\(([^\)]*)\)|(LT|(\w)\4*o?)|([^\w\[\(]+)/g;
- var match;
- while ((match = chunker.exec(formatStr))) {
- if (match[1]) {
- chunks.push(match[1]);
- }
- else if (match[2]) {
- chunks.push({ maybe: chunkFormatString(match[2]) });
- }
- else if (match[3]) {
- chunks.push({ token: match[3] });
- }
- else if (match[5]) {
- chunks.push(match[5]);
- }
- }
- return chunks;
- }
- ;;
- function Popover(options) {
- this.options = options || {};
- }
- Popover.prototype = {
- isHidden: true,
- options: null,
- el: null,
- documentMousedownProxy: null,
- margin: 10,
-
- show: function() {
- if (this.isHidden) {
- if (!this.el) {
- this.render();
- }
- this.el.show();
- this.position();
- this.isHidden = false;
- this.trigger('show');
- }
- },
-
- hide: function() {
- if (!this.isHidden) {
- this.el.hide();
- this.isHidden = true;
- this.trigger('hide');
- }
- },
-
- render: function() {
- var _this = this;
- var options = this.options;
- this.el = $('<div class="fc-popover"/>')
- .addClass(options.className || '')
- .css({
-
- top: 0,
- left: 0
- })
- .append(options.content)
- .appendTo(options.parentEl);
-
- this.el.on('click', '.fc-close', function() {
- _this.hide();
- });
- if (options.autoHide) {
- $(document).on('mousedown', this.documentMousedownProxy = $.proxy(this, 'documentMousedown'));
- }
- },
-
- documentMousedown: function(ev) {
-
- if (this.el && !$(ev.target).closest(this.el).length) {
- this.hide();
- }
- },
-
- destroy: function() {
- this.hide();
- if (this.el) {
- this.el.remove();
- this.el = null;
- }
- $(document).off('mousedown', this.documentMousedownProxy);
- },
-
- position: function() {
- var options = this.options;
- var origin = this.el.offsetParent().offset();
- var width = this.el.outerWidth();
- var height = this.el.outerHeight();
- var windowEl = $(window);
- var viewportEl = getScrollParent(this.el);
- var viewportTop;
- var viewportLeft;
- var viewportOffset;
- var top;
- var left;
-
- top = options.top || 0;
- if (options.left !== undefined) {
- left = options.left;
- }
- else if (options.right !== undefined) {
- left = options.right - width;
- }
- else {
- left = 0;
- }
- if (viewportEl.is(window) || viewportEl.is(document)) {
- viewportEl = windowEl;
- viewportTop = 0;
- viewportLeft = 0;
- }
- else {
- viewportOffset = viewportEl.offset();
- viewportTop = viewportOffset.top;
- viewportLeft = viewportOffset.left;
- }
-
- viewportTop += windowEl.scrollTop();
- viewportLeft += windowEl.scrollLeft();
-
- if (options.viewportConstrain !== false) {
- top = Math.min(top, viewportTop + viewportEl.outerHeight() - height - this.margin);
- top = Math.max(top, viewportTop + this.margin);
- left = Math.min(left, viewportLeft + viewportEl.outerWidth() - width - this.margin);
- left = Math.max(left, viewportLeft + this.margin);
- }
- this.el.css({
- top: top - origin.top,
- left: left - origin.left
- });
- },
-
-
-
- trigger: function(name) {
- if (this.options[name]) {
- this.options[name].apply(this, Array.prototype.slice.call(arguments, 1));
- }
- }
- };
- ;;
- function GridCoordMap(grid) {
- this.grid = grid;
- }
- GridCoordMap.prototype = {
- grid: null,
- rows: null,
- cols: null,
- containerEl: null,
- minX: null,
- maxX: null,
- minY: null,
- maxY: null,
-
- build: function() {
- this.grid.buildCoords(
- this.rows = [],
- this.cols = []
- );
- this.computeBounds();
- },
-
- getCell: function(x, y) {
- var cell = null;
- var rows = this.rows;
- var cols = this.cols;
- var r = -1;
- var c = -1;
- var i;
- if (this.inBounds(x, y)) {
- for (i = 0; i < rows.length; i++) {
- if (y >= rows[i][0] && y < rows[i][1]) {
- r = i;
- break;
- }
- }
- for (i = 0; i < cols.length; i++) {
- if (x >= cols[i][0] && x < cols[i][1]) {
- c = i;
- break;
- }
- }
- if (r >= 0 && c >= 0) {
- cell = { row: r, col: c };
- cell.grid = this.grid;
- cell.date = this.grid.getCellDate(cell);
- }
- }
- return cell;
- },
-
- computeBounds: function() {
- var containerOffset;
- if (this.containerEl) {
- containerOffset = this.containerEl.offset();
- this.minX = containerOffset.left;
- this.maxX = containerOffset.left + this.containerEl.outerWidth();
- this.minY = containerOffset.top;
- this.maxY = containerOffset.top + this.containerEl.outerHeight();
- }
- },
-
- inBounds: function(x, y) {
- if (this.containerEl) {
- return x >= this.minX && x < this.maxX && y >= this.minY && y < this.maxY;
- }
- return true;
- }
- };
- function ComboCoordMap(coordMaps) {
- this.coordMaps = coordMaps;
- }
- ComboCoordMap.prototype = {
- coordMaps: null,
-
- build: function() {
- var coordMaps = this.coordMaps;
- var i;
- for (i = 0; i < coordMaps.length; i++) {
- coordMaps[i].build();
- }
- },
-
- getCell: function(x, y) {
- var coordMaps = this.coordMaps;
- var cell = null;
- var i;
- for (i = 0; i < coordMaps.length && !cell; i++) {
- cell = coordMaps[i].getCell(x, y);
- }
- return cell;
- }
- };
- ;;
- function DragListener(coordMap, options) {
- this.coordMap = coordMap;
- this.options = options || {};
- }
- DragListener.prototype = {
- coordMap: null,
- options: null,
- isListening: false,
- isDragging: false,
-
- origCell: null,
- origDate: null,
-
- cell: null,
- date: null,
-
- mouseX0: null,
- mouseY0: null,
-
- mousemoveProxy: null,
- mouseupProxy: null,
- scrollEl: null,
- scrollBounds: null,
- scrollTopVel: null,
- scrollLeftVel: null,
- scrollIntervalId: null,
- scrollHandlerProxy: null,
- scrollSensitivity: 30,
- scrollSpeed: 200,
- scrollIntervalMs: 50,
-
- mousedown: function(ev) {
- if (isPrimaryMouseButton(ev)) {
- ev.preventDefault();
- this.startListening(ev);
-
- if (!this.options.distance) {
- this.startDrag(ev);
- }
- }
- },
-
- startListening: function(ev) {
- var scrollParent;
- var cell;
- if (!this.isListening) {
-
- if (ev && this.options.scroll) {
- scrollParent = getScrollParent($(ev.target));
- if (!scrollParent.is(window) && !scrollParent.is(document)) {
- this.scrollEl = scrollParent;
-
- this.scrollHandlerProxy = debounce($.proxy(this, 'scrollHandler'), 100);
- this.scrollEl.on('scroll', this.scrollHandlerProxy);
- }
- }
- this.computeCoords();
-
- if (ev) {
- cell = this.getCell(ev);
- this.origCell = cell;
- this.origDate = cell ? cell.date : null;
- this.mouseX0 = ev.pageX;
- this.mouseY0 = ev.pageY;
- }
- $(document)
- .on('mousemove', this.mousemoveProxy = $.proxy(this, 'mousemove'))
- .on('mouseup', this.mouseupProxy = $.proxy(this, 'mouseup'))
- .on('selectstart', this.preventDefault);
- this.isListening = true;
- this.trigger('listenStart', ev);
- }
- },
-
- computeCoords: function() {
- this.coordMap.build();
- this.computeScrollBounds();
- },
-
- mousemove: function(ev) {
- var minDistance;
- var distanceSq;
- if (!this.isDragging) {
-
- minDistance = this.options.distance || 1;
- distanceSq = Math.pow(ev.pageX - this.mouseX0, 2) + Math.pow(ev.pageY - this.mouseY0, 2);
- if (distanceSq >= minDistance * minDistance) {
- this.startDrag(ev);
- }
- }
- if (this.isDragging) {
- this.drag(ev);
- }
- },
-
-
- startDrag: function(ev) {
- var cell;
- if (!this.isListening) {
- this.startListening();
- }
- if (!this.isDragging) {
- this.isDragging = true;
- this.trigger('dragStart', ev);
-
- cell = this.getCell(ev);
- if (cell) {
- this.cellOver(cell, true);
- }
- }
- },
-
- drag: function(ev) {
- var cell;
- if (this.isDragging) {
- cell = this.getCell(ev);
- if (!isCellsEqual(cell, this.cell)) {
- if (this.cell) {
- this.cellOut();
- }
- if (cell) {
- this.cellOver(cell);
- }
- }
- this.dragScroll(ev);
- }
- },
-
- cellOver: function(cell) {
- this.cell = cell;
- this.date = cell.date;
- this.trigger('cellOver', cell, cell.date);
- },
-
- cellOut: function() {
- if (this.cell) {
- this.trigger('cellOut', this.cell);
- this.cell = null;
- this.date = null;
- }
- },
-
- mouseup: function(ev) {
- this.stopDrag(ev);
- this.stopListening(ev);
- },
-
-
- stopDrag: function(ev) {
- if (this.isDragging) {
- this.stopScrolling();
- this.trigger('dragStop', ev);
- this.isDragging = false;
- }
- },
-
- stopListening: function(ev) {
- if (this.isListening) {
-
- if (this.scrollEl) {
- this.scrollEl.off('scroll', this.scrollHandlerProxy);
- this.scrollHandlerProxy = null;
- }
- $(document)
- .off('mousemove', this.mousemoveProxy)
- .off('mouseup', this.mouseupProxy)
- .off('selectstart', this.preventDefault);
- this.mousemoveProxy = null;
- this.mouseupProxy = null;
- this.isListening = false;
- this.trigger('listenStop', ev);
- this.origCell = this.cell = null;
- this.origDate = this.date = null;
- }
- },
-
- getCell: function(ev) {
- return this.coordMap.getCell(ev.pageX, ev.pageY);
- },
-
-
- trigger: function(name) {
- if (this.options[name]) {
- this.options[name].apply(this, Array.prototype.slice.call(arguments, 1));
- }
- },
-
- preventDefault: function(ev) {
- ev.preventDefault();
- },
-
-
- computeScrollBounds: function() {
- var el = this.scrollEl;
- var offset;
- if (el) {
- offset = el.offset();
- this.scrollBounds = {
- top: offset.top,
- left: offset.left,
- bottom: offset.top + el.outerHeight(),
- right: offset.left + el.outerWidth()
- };
- }
- },
-
- dragScroll: function(ev) {
- var sensitivity = this.scrollSensitivity;
- var bounds = this.scrollBounds;
- var topCloseness, bottomCloseness;
- var leftCloseness, rightCloseness;
- var topVel = 0;
- var leftVel = 0;
- if (bounds) {
-
- topCloseness = (sensitivity - (ev.pageY - bounds.top)) / sensitivity;
- bottomCloseness = (sensitivity - (bounds.bottom - ev.pageY)) / sensitivity;
- leftCloseness = (sensitivity - (ev.pageX - bounds.left)) / sensitivity;
- rightCloseness = (sensitivity - (bounds.right - ev.pageX)) / sensitivity;
-
-
- if (topCloseness >= 0 && topCloseness <= 1) {
- topVel = topCloseness * this.scrollSpeed * -1;
- }
- else if (bottomCloseness >= 0 && bottomCloseness <= 1) {
- topVel = bottomCloseness * this.scrollSpeed;
- }
-
- if (leftCloseness >= 0 && leftCloseness <= 1) {
- leftVel = leftCloseness * this.scrollSpeed * -1;
- }
- else if (rightCloseness >= 0 && rightCloseness <= 1) {
- leftVel = rightCloseness * this.scrollSpeed;
- }
- }
- this.setScrollVel(topVel, leftVel);
- },
-
- setScrollVel: function(topVel, leftVel) {
- this.scrollTopVel = topVel;
- this.scrollLeftVel = leftVel;
- this.constrainScrollVel();
-
- if ((this.scrollTopVel || this.scrollLeftVel) && !this.scrollIntervalId) {
- this.scrollIntervalId = setInterval(
- $.proxy(this, 'scrollIntervalFunc'),
- this.scrollIntervalMs
- );
- }
- },
-
- constrainScrollVel: function() {
- var el = this.scrollEl;
- if (this.scrollTopVel < 0) {
- if (el.scrollTop() <= 0) {
- this.scrollTopVel = 0;
- }
- }
- else if (this.scrollTopVel > 0) {
- if (el.scrollTop() + el[0].clientHeight >= el[0].scrollHeight) {
- this.scrollTopVel = 0;
- }
- }
- if (this.scrollLeftVel < 0) {
- if (el.scrollLeft() <= 0) {
- this.scrollLeftVel = 0;
- }
- }
- else if (this.scrollLeftVel > 0) {
- if (el.scrollLeft() + el[0].clientWidth >= el[0].scrollWidth) {
- this.scrollLeftVel = 0;
- }
- }
- },
-
- scrollIntervalFunc: function() {
- var el = this.scrollEl;
- var frac = this.scrollIntervalMs / 1000;
-
- if (this.scrollTopVel) {
- el.scrollTop(el.scrollTop() + this.scrollTopVel * frac);
- }
- if (this.scrollLeftVel) {
- el.scrollLeft(el.scrollLeft() + this.scrollLeftVel * frac);
- }
- this.constrainScrollVel();
-
- if (!this.scrollTopVel && !this.scrollLeftVel) {
- this.stopScrolling();
- }
- },
-
- stopScrolling: function() {
- if (this.scrollIntervalId) {
- clearInterval(this.scrollIntervalId);
- this.scrollIntervalId = null;
-
- this.computeCoords();
- }
- },
-
- scrollHandler: function() {
-
- if (!this.scrollIntervalId) {
- this.computeCoords();
- }
- }
- };
- function isCellsEqual(cell1, cell2) {
- if (!cell1 && !cell2) {
- return true;
- }
- if (cell1 && cell2) {
- return cell1.grid === cell2.grid &&
- cell1.row === cell2.row &&
- cell1.col === cell2.col;
- }
- return false;
- }
- ;;
- function MouseFollower(sourceEl, options) {
- this.options = options = options || {};
- this.sourceEl = sourceEl;
- this.parentEl = options.parentEl ? $(options.parentEl) : sourceEl.parent();
- }
- MouseFollower.prototype = {
- options: null,
- sourceEl: null,
- el: null,
- parentEl: null,
-
- top0: null,
- left0: null,
-
- mouseY0: null,
- mouseX0: null,
-
- topDelta: null,
- leftDelta: null,
- mousemoveProxy: null,
- isFollowing: false,
- isHidden: false,
- isAnimating: false,
-
- start: function(ev) {
- if (!this.isFollowing) {
- this.isFollowing = true;
- this.mouseY0 = ev.pageY;
- this.mouseX0 = ev.pageX;
- this.topDelta = 0;
- this.leftDelta = 0;
- if (!this.isHidden) {
- this.updatePosition();
- }
- $(document).on('mousemove', this.mousemoveProxy = $.proxy(this, 'mousemove'));
- }
- },
-
-
- stop: function(shouldRevert, callback) {
- var _this = this;
- var revertDuration = this.options.revertDuration;
- function complete() {
- this.isAnimating = false;
- _this.destroyEl();
- this.top0 = this.left0 = null;
- if (callback) {
- callback();
- }
- }
- if (this.isFollowing && !this.isAnimating) {
- this.isFollowing = false;
- $(document).off('mousemove', this.mousemoveProxy);
- if (shouldRevert && revertDuration && !this.isHidden) {
- this.isAnimating = true;
- this.el.animate({
- top: this.top0,
- left: this.left0
- }, {
- duration: revertDuration,
- complete: complete
- });
- }
- else {
- complete();
- }
- }
- },
-
- getEl: function() {
- var el = this.el;
- if (!el) {
- this.sourceEl.width();
- el = this.el = this.sourceEl.clone()
- .css({
- position: 'absolute',
- visibility: '',
- display: this.isHidden ? 'none' : '',
- margin: 0,
- right: 'auto',
- bottom: 'auto',
- width: this.sourceEl.width(),
- height: this.sourceEl.height(),
- opacity: this.options.opacity || '',
- zIndex: this.options.zIndex
- })
- .appendTo(this.parentEl);
- }
- return el;
- },
-
- destroyEl: function() {
- if (this.el) {
- this.el.remove();
- this.el = null;
- }
- },
-
- updatePosition: function() {
- var sourceOffset;
- var origin;
- this.getEl();
-
- if (this.top0 === null) {
- this.sourceEl.width();
- sourceOffset = this.sourceEl.offset();
- origin = this.el.offsetParent().offset();
- this.top0 = sourceOffset.top - origin.top;
- this.left0 = sourceOffset.left - origin.left;
- }
- this.el.css({
- top: this.top0 + this.topDelta,
- left: this.left0 + this.leftDelta
- });
- },
-
- mousemove: function(ev) {
- this.topDelta = ev.pageY - this.mouseY0;
- this.leftDelta = ev.pageX - this.mouseX0;
- if (!this.isHidden) {
- this.updatePosition();
- }
- },
-
- hide: function() {
- if (!this.isHidden) {
- this.isHidden = true;
- if (this.el) {
- this.el.hide();
- }
- }
- },
-
- show: function() {
- if (this.isHidden) {
- this.isHidden = false;
- this.updatePosition();
- this.getEl().show();
- }
- }
- };
- ;;
- function RowRenderer(view) {
- this.view = view;
- }
- RowRenderer.prototype = {
- view: null,
- cellHtml: '<td/>',
-
-
-
- rowHtml: function(rowType, row) {
- var view = this.view;
- var renderCell = this.getHtmlRenderer('cell', rowType);
- var cellHtml = '';
- var col;
- var date;
- row = row || 0;
- for (col = 0; col < view.colCnt; col++) {
- date = view.cellToDate(row, col);
- cellHtml += renderCell(row, col, date);
- }
- cellHtml = this.bookendCells(cellHtml, rowType, row);
- return '<tr>' + cellHtml + '</tr>';
- },
-
-
-
-
- bookendCells: function(cells, rowType, row) {
- var view = this.view;
- var intro = this.getHtmlRenderer('intro', rowType)(row || 0);
- var outro = this.getHtmlRenderer('outro', rowType)(row || 0);
- var isRTL = view.opt('isRTL');
- var prependHtml = isRTL ? outro : intro;
- var appendHtml = isRTL ? intro : outro;
- if (typeof cells === 'string') {
- return prependHtml + cells + appendHtml;
- }
- else {
- return cells.prepend(prependHtml).append(appendHtml);
- }
- },
-
-
-
-
- getHtmlRenderer: function(rendererName, rowType) {
- var view = this.view;
- var generalName;
- var specificName;
- var provider;
- var renderer;
- generalName = rendererName + 'Html';
- if (rowType) {
- specificName = rowType + capitaliseFirstLetter(rendererName) + 'Html';
- }
- if (specificName && (renderer = view[specificName])) {
- provider = view;
- }
- else if (specificName && (renderer = this[specificName])) {
- provider = this;
- }
- else if ((renderer = view[generalName])) {
- provider = view;
- }
- else if ((renderer = this[generalName])) {
- provider = this;
- }
- if (typeof renderer === 'function') {
- return function(row) {
- return renderer.apply(provider, arguments) || '';
- };
- }
-
- return function() {
- return renderer || '';
- };
- }
- };
- ;;
- function Grid(view) {
- RowRenderer.call(this, view);
- this.coordMap = new GridCoordMap(this);
- }
- Grid.prototype = createObject(RowRenderer.prototype);
- $.extend(Grid.prototype, {
- el: null,
- coordMap: null,
- cellDuration: null,
-
-
- render: function() {
- this.bindHandlers();
- },
-
- destroy: function() {
-
- },
-
-
- buildCoords: function(rows, cols) {
-
- },
-
- getCellDate: function(cell) {
-
- },
-
- getCellDayEl: function(cell) {
-
- },
-
- rangeToSegs: function(start, end) {
-
- },
-
-
-
-
- bindHandlers: function() {
- var _this = this;
- this.el.on('mousedown', function(ev) {
- if (
- !$(ev.target).is('.fc-event-container *, .fc-more') &&
- !$(ev.target).closest('.fc-popover').length
- ) {
- _this.dayMousedown(ev);
- }
- });
- this.bindSegHandlers();
- },
-
- dayMousedown: function(ev) {
- var _this = this;
- var view = this.view;
- var isSelectable = view.opt('selectable');
- var dates = null;
- var start;
- var end;
- var dayEl;
-
-
-
- var dragListener = new DragListener(this.coordMap, {
-
- scroll: view.opt('dragScroll'),
- dragStart: function() {
- view.unselect();
- },
- cellOver: function(cell, date) {
- if (dragListener.origDate) {
- dayEl = _this.getCellDayEl(cell);
- dates = [ date, dragListener.origDate ].sort(dateCompare);
- start = dates[0];
- end = dates[1].clone().add(_this.cellDuration);
- if (isSelectable) {
- _this.renderSelection(start, end);
- }
- }
- },
- cellOut: function(cell, date) {
- dates = null;
- _this.destroySelection();
- },
- listenStop: function(ev) {
- if (dates) {
- if (dates[0].isSame(dates[1])) {
- view.trigger('dayClick', dayEl[0], start, ev);
- }
- if (isSelectable) {
-
- view.reportSelection(start, end, ev);
- }
- }
- }
- });
- dragListener.mousedown(ev);
- },
-
-
-
-
- renderDrag: function(start, end, seg) {
-
- },
-
- destroyDrag: function() {
-
- },
-
-
-
- renderResize: function(start, end, seg) {
-
- },
-
- destroyResize: function() {
-
- },
-
-
-
-
- renderRangeHelper: function(start, end, sourceSeg) {
- var view = this.view;
- var fakeEvent;
-
- if (!end && view.opt('forceEventDuration')) {
- end = view.calendar.getDefaultEventEnd(!start.hasTime(), start);
- }
- fakeEvent = sourceSeg ? createObject(sourceSeg.event) : {};
- fakeEvent.start = start;
- fakeEvent.end = end;
- fakeEvent.allDay = !(start.hasTime() || (end && end.hasTime()));
-
- fakeEvent.className = (fakeEvent.className || []).concat('fc-helper');
-
- if (!sourceSeg) {
- fakeEvent.editable = false;
- }
- this.renderHelper(fakeEvent, sourceSeg);
- },
-
- renderHelper: function(event, sourceSeg) {
-
- },
-
- destroyHelper: function() {
-
- },
-
-
- renderSelection: function(start, end) {
- this.renderHighlight(start, end);
- },
-
- destroySelection: function() {
- this.destroyHighlight();
- },
-
-
- renderHighlight: function(start, end) {
-
- },
-
- destroyHighlight: function() {
-
- },
-
-
- headHtml: function() {
- return '' +
- '<div class="fc-row ' + this.view.widgetHeaderClass + '">' +
- '<table>' +
- '<thead>' +
- this.rowHtml('head') +
- '</thead>' +
- '</table>' +
- '</div>';
- },
-
- headCellHtml: function(row, col, date) {
- var view = this.view;
- var calendar = view.calendar;
- var colFormat = view.opt('columnFormat');
- return '' +
- '<th class="fc-day-header ' + view.widgetHeaderClass + ' fc-' + dayIDs[date.day()] + '">' +
- htmlEscape(calendar.formatDate(date, colFormat)) +
- '</th>';
- },
-
- bgCellHtml: function(row, col, date) {
- var view = this.view;
- var classes = this.getDayClasses(date);
- classes.unshift('fc-day', view.widgetContentClass);
- return '<td class="' + classes.join(' ') + '" data-date="' + date.format() + '"></td>';
- },
-
- getDayClasses: function(date) {
- var view = this.view;
- var today = view.calendar.getNow().stripTime();
- var classes = [ 'fc-' + dayIDs[date.day()] ];
- if (
- view.name === 'month' &&
- date.month() != view.intervalStart.month()
- ) {
- classes.push('fc-other-month');
- }
- if (date.isSame(today, 'day')) {
- classes.push(
- 'fc-today',
- view.highlightStateClass
- );
- }
- else if (date < today) {
- classes.push('fc-past');
- }
- else {
- classes.push('fc-future');
- }
- return classes;
- }
- });
- ;;
- $.extend(Grid.prototype, {
- mousedOverSeg: null,
- isDraggingSeg: false,
- isResizingSeg: false,
-
- renderEvents: function(events) {
-
- },
-
- getSegs: function() {
-
- },
-
- destroyEvents: function() {
- this.triggerSegMouseout();
- },
-
- renderSegs: function(segs, disableResizing) {
- var view = this.view;
- var html = '';
- var renderedSegs = [];
- var i;
-
- for (i = 0; i < segs.length; i++) {
- html += this.renderSegHtml(segs[i], disableResizing);
- }
-
-
- $(html).each(function(i, node) {
- var seg = segs[i];
- var el = view.resolveEventEl(seg.event, $(node));
- if (el) {
- el.data('fc-seg', seg);
- seg.el = el;
- renderedSegs.push(seg);
- }
- });
- return renderedSegs;
- },
-
- renderSegHtml: function(seg, disableResizing) {
-
- },
-
- eventsToSegs: function(events, intervalStart, intervalEnd) {
- var _this = this;
- return $.map(events, function(event) {
- return _this.eventToSegs(event, intervalStart, intervalEnd);
- });
- },
-
-
-
- eventToSegs: function(event, intervalStart, intervalEnd) {
- var eventStart = event.start.clone().stripZone();
- var eventEnd = this.view.calendar.getEventEnd(event).stripZone();
- var segs;
- var i, seg;
- if (intervalStart && intervalEnd) {
- seg = intersectionToSeg(eventStart, eventEnd, intervalStart, intervalEnd);
- segs = seg ? [ seg ] : [];
- }
- else {
- segs = this.rangeToSegs(eventStart, eventEnd);
- }
-
- for (i = 0; i < segs.length; i++) {
- seg = segs[i];
- seg.event = event;
- seg.eventStartMS = +eventStart;
- seg.eventDurationMS = eventEnd - eventStart;
- }
- return segs;
- },
-
-
- bindSegHandlers: function() {
- var _this = this;
- var view = this.view;
- $.each(
- {
- mouseenter: function(seg, ev) {
- _this.triggerSegMouseover(seg, ev);
- },
- mouseleave: function(seg, ev) {
- _this.triggerSegMouseout(seg, ev);
- },
- click: function(seg, ev) {
- return view.trigger('eventClick', this, seg.event, ev);
- },
- mousedown: function(seg, ev) {
- if ($(ev.target).is('.fc-resizer') && view.isEventResizable(seg.event)) {
- _this.segResizeMousedown(seg, ev);
- }
- else if (view.isEventDraggable(seg.event)) {
- _this.segDragMousedown(seg, ev);
- }
- }
- },
- function(name, func) {
-
- _this.el.on(name, '.fc-event-container > *', function(ev) {
- var seg = $(this).data('fc-seg');
-
- if (seg && !_this.isDraggingSeg && !_this.isResizingSeg) {
- return func.call(this, seg, ev);
- }
- });
- }
- );
- },
-
- triggerSegMouseover: function(seg, ev) {
- if (!this.mousedOverSeg) {
- this.mousedOverSeg = seg;
- this.view.trigger('eventMouseover', seg.el[0], seg.event, ev);
- }
- },
-
-
- triggerSegMouseout: function(seg, ev) {
- ev = ev || {};
- if (this.mousedOverSeg) {
- seg = seg || this.mousedOverSeg;
- this.mousedOverSeg = null;
- this.view.trigger('eventMouseout', seg.el[0], seg.event, ev);
- }
- },
-
-
-
- segDragMousedown: function(seg, ev) {
- var _this = this;
- var view = this.view;
- var el = seg.el;
- var event = seg.event;
- var newStart, newEnd;
-
- var mouseFollower = new MouseFollower(seg.el, {
- parentEl: view.el,
- opacity: view.opt('dragOpacity'),
- revertDuration: view.opt('dragRevertDuration'),
- zIndex: 2
- });
-
-
- var dragListener = new DragListener(view.coordMap, {
- distance: 5,
- scroll: view.opt('dragScroll'),
- listenStart: function(ev) {
- mouseFollower.hide();
- mouseFollower.start(ev);
- },
- dragStart: function(ev) {
- _this.triggerSegMouseout(seg, ev);
- _this.isDraggingSeg = true;
- view.hideEvent(event);
- view.trigger('eventDragStart', el[0], event, ev, {});
- },
- cellOver: function(cell, date) {
- var origDate = seg.cellDate || dragListener.origDate;
- var res = _this.computeDraggedEventDates(seg, origDate, date);
- newStart = res.start;
- newEnd = res.end;
- if (view.renderDrag(newStart, newEnd, seg)) {
- mouseFollower.hide();
- }
- else {
- mouseFollower.show();
- }
- },
- cellOut: function() {
- newStart = null;
- view.destroyDrag();
- mouseFollower.show();
- },
- dragStop: function(ev) {
- var hasChanged = newStart && !newStart.isSame(event.start);
-
- mouseFollower.stop(!hasChanged, function() {
- _this.isDraggingSeg = false;
- view.destroyDrag();
- view.showEvent(event);
- view.trigger('eventDragStop', el[0], event, ev, {});
- if (hasChanged) {
- view.eventDrop(el[0], event, newStart, ev);
- }
- });
- },
- listenStop: function() {
- mouseFollower.stop();
- }
- });
- dragListener.mousedown(ev);
- },
-
- computeDraggedEventDates: function(seg, dragStartDate, dropDate) {
- var view = this.view;
- var event = seg.event;
- var start = event.start;
- var end = view.calendar.getEventEnd(event);
- var delta;
- var newStart;
- var newEnd;
- if (dropDate.hasTime() === dragStartDate.hasTime()) {
- delta = dayishDiff(dropDate, dragStartDate);
- newStart = start.clone().add(delta);
- if (event.end === null) {
- newEnd = null;
- }
- else {
- newEnd = end.clone().add(delta);
- }
- }
- else {
-
- newStart = dropDate;
- newEnd = null;
- }
- return { start: newStart, end: newEnd };
- },
-
-
-
- segResizeMousedown: function(seg, ev) {
- var _this = this;
- var view = this.view;
- var el = seg.el;
- var event = seg.event;
- var start = event.start;
- var end = view.calendar.getEventEnd(event);
- var newEnd = null;
- var dragListener;
- function destroy() {
- _this.destroyResize();
- view.showEvent(event);
- }
-
- dragListener = new DragListener(this.coordMap, {
- distance: 5,
- scroll: view.opt('dragScroll'),
- dragStart: function(ev) {
- _this.triggerSegMouseout(seg, ev);
- _this.isResizingSeg = true;
- view.trigger('eventResizeStart', el[0], event, ev, {});
- },
- cellOver: function(cell, date) {
-
- if (date.isBefore(start)) {
- date = start;
- }
- newEnd = date.clone().add(_this.cellDuration);
- if (newEnd.isSame(end)) {
- newEnd = null;
- destroy();
- }
- else {
- _this.renderResize(start, newEnd, seg);
- view.hideEvent(event);
- }
- },
- cellOut: function() {
- newEnd = null;
- destroy();
- },
- dragStop: function(ev) {
- _this.isResizingSeg = false;
- destroy();
- view.trigger('eventResizeStop', el[0], event, ev, {});
- if (newEnd) {
- view.eventResize(el[0], event, newEnd, ev);
- }
- }
- });
- dragListener.mousedown(ev);
- },
-
-
- getSegClasses: function(seg, isDraggable, isResizable) {
- var event = seg.event;
- var classes = [
- 'fc-event',
- seg.isStart ? 'fc-start' : 'fc-not-start',
- seg.isEnd ? 'fc-end' : 'fc-not-end'
- ].concat(
- event.className,
- event.source ? event.source.className : []
- );
- if (isDraggable) {
- classes.push('fc-draggable');
- }
- if (isResizable) {
- classes.push('fc-resizable');
- }
- return classes;
- },
-
- getEventSkinCss: function(event) {
- var view = this.view;
- var source = event.source || {};
- var eventColor = event.color;
- var sourceColor = source.color;
- var optionColor = view.opt('eventColor');
- var backgroundColor =
- event.backgroundColor ||
- eventColor ||
- source.backgroundColor ||
- sourceColor ||
- view.opt('eventBackgroundColor') ||
- optionColor;
- var borderColor =
- event.borderColor ||
- eventColor ||
- source.borderColor ||
- sourceColor ||
- view.opt('eventBorderColor') ||
- optionColor;
- var textColor =
- event.textColor ||
- source.textColor ||
- view.opt('eventTextColor');
- var statements = [];
- if (backgroundColor) {
- statements.push('background-color:' + backgroundColor);
- }
- if (borderColor) {
- statements.push('border-color:' + borderColor);
- }
- if (textColor) {
- statements.push('color:' + textColor);
- }
- return statements.join(';');
- }
- });
- function compareSegs(seg1, seg2) {
- return seg1.eventStartMS - seg2.eventStartMS ||
- seg2.eventDurationMS - seg1.eventDurationMS ||
- seg2.event.allDay - seg1.event.allDay ||
- (seg1.event.title || '').localeCompare(seg2.event.title);
- }
- ;;
- function DayGrid(view) {
- Grid.call(this, view);
- }
- DayGrid.prototype = createObject(Grid.prototype);
- $.extend(DayGrid.prototype, {
- numbersVisible: false,
- cellDuration: moment.duration({ days: 1 }),
- bottomCoordPadding: 0,
- rowEls: null,
- dayEls: null,
- helperEls: null,
- highlightEls: null,
-
-
-
- render: function(isRigid) {
- var view = this.view;
- var html = '';
- var row;
- for (row = 0; row < view.rowCnt; row++) {
- html += this.dayRowHtml(row, isRigid);
- }
- this.el.html(html);
- this.rowEls = this.el.find('.fc-row');
- this.dayEls = this.el.find('.fc-day');
-
- this.dayEls.each(function(i, node) {
- var date = view.cellToDate(Math.floor(i / view.colCnt), i % view.colCnt);
- view.trigger('dayRender', null, date, $(node));
- });
- Grid.prototype.render.call(this);
- },
- destroy: function() {
- this.destroySegPopover();
- },
-
- dayRowHtml: function(row, isRigid) {
- var view = this.view;
- var classes = [ 'fc-row', 'fc-week', view.widgetContentClass ];
- if (isRigid) {
- classes.push('fc-rigid');
- }
- return '' +
- '<div class="' + classes.join(' ') + '">' +
- '<div class="fc-bg">' +
- '<table>' +
- this.rowHtml('day', row) +
- '</table>' +
- '</div>' +
- '<div class="fc-content-skeleton">' +
- '<table>' +
- (this.numbersVisible ?
- '<thead>' +
- this.rowHtml('number', row) +
- '</thead>' :
- ''
- ) +
- '</table>' +
- '</div>' +
- '</div>';
- },
-
-
-
- dayCellHtml: function(row, col, date) {
- return this.bgCellHtml(row, col, date);
- },
-
-
- buildCoords: function(rows, cols) {
- var colCnt = this.view.colCnt;
- var e, n, p;
- this.dayEls.slice(0, colCnt).each(function(i, _e) {
- e = $(_e);
- n = e.offset().left;
- if (i) {
- p[1] = n;
- }
- p = [ n ];
- cols[i] = p;
- });
- p[1] = n + e.outerWidth();
- this.rowEls.each(function(i, _e) {
- e = $(_e);
- n = e.offset().top;
- if (i) {
- p[1] = n;
- }
- p = [ n ];
- rows[i] = p;
- });
- p[1] = n + e.outerHeight() + this.bottomCoordPadding;
- },
-
- getCellDate: function(cell) {
- return this.view.cellToDate(cell);
- },
-
- getCellDayEl: function(cell) {
- return this.dayEls.eq(cell.row * this.view.colCnt + cell.col);
- },
-
- rangeToSegs: function(start, end) {
- return this.view.rangeToSegments(start, end);
- },
-
-
-
-
- renderDrag: function(start, end, seg) {
- var opacity;
-
- this.renderHighlight(
- start,
- end || this.view.calendar.getDefaultEventEnd(true, start)
- );
-
- if (seg && !seg.el.closest(this.el).length) {
- this.renderRangeHelper(start, end, seg);
- opacity = this.view.opt('dragOpacity');
- if (opacity !== undefined) {
- this.helperEls.css('opacity', opacity);
- }
- return true;
- }
- },
-
- destroyDrag: function() {
- this.destroyHighlight();
- this.destroyHelper();
- },
-
-
- renderResize: function(start, end, seg) {
- this.renderHighlight(start, end);
- this.renderRangeHelper(start, end, seg);
- },
-
- destroyResize: function() {
- this.destroyHighlight();
- this.destroyHelper();
- },
-
-
- renderHelper: function(event, sourceSeg) {
- var helperNodes = [];
- var rowStructs = this.renderEventRows([ event ]);
-
- this.rowEls.each(function(row, rowNode) {
- var rowEl = $(rowNode);
- var skeletonEl = $('<div class="fc-helper-skeleton"><table/></div>');
- var skeletonTop;
-
- if (sourceSeg && sourceSeg.row === row) {
- skeletonTop = sourceSeg.el.position().top;
- }
- else {
- skeletonTop = rowEl.find('.fc-content-skeleton tbody').position().top;
- }
- skeletonEl.css('top', skeletonTop)
- .find('table')
- .append(rowStructs[row].tbodyEl);
- rowEl.append(skeletonEl);
- helperNodes.push(skeletonEl[0]);
- });
- this.helperEls = $(helperNodes);
- },
-
- destroyHelper: function() {
- if (this.helperEls) {
- this.helperEls.remove();
- this.helperEls = null;
- }
- },
-
-
- renderHighlight: function(start, end) {
- var segs = this.rangeToSegs(start, end);
- var highlightNodes = [];
- var i, seg;
- var el;
-
- for (i = 0; i < segs.length; i++) {
- seg = segs[i];
- el = $(
- this.highlightSkeletonHtml(seg.leftCol, seg.rightCol + 1)
- );
- el.appendTo(this.rowEls[seg.row]);
- highlightNodes.push(el[0]);
- }
- this.highlightEls = $(highlightNodes);
- },
-
- destroyHighlight: function() {
- if (this.highlightEls) {
- this.highlightEls.remove();
- this.highlightEls = null;
- }
- },
-
- highlightSkeletonHtml: function(startCol, endCol) {
- var colCnt = this.view.colCnt;
- var cellHtml = '';
- if (startCol > 0) {
- cellHtml += '<td colspan="' + startCol + '"/>';
- }
- if (endCol > startCol) {
- cellHtml += '<td colspan="' + (endCol - startCol) + '" class="fc-highlight" />';
- }
- if (colCnt > endCol) {
- cellHtml += '<td colspan="' + (colCnt - endCol) + '"/>';
- }
- cellHtml = this.bookendCells(cellHtml, 'highlight');
- return '' +
- '<div class="fc-highlight-skeleton">' +
- '<table>' +
- '<tr>' +
- cellHtml +
- '</tr>' +
- '</table>' +
- '</div>';
- }
- });
- ;;
- $.extend(DayGrid.prototype, {
- segs: null,
- rowStructs: null,
-
- renderEvents: function(events) {
- var rowStructs = this.rowStructs = this.renderEventRows(events);
- var segs = [];
-
- this.rowEls.each(function(i, rowNode) {
- $(rowNode).find('.fc-content-skeleton > table').append(
- rowStructs[i].tbodyEl
- );
- segs.push.apply(segs, rowStructs[i].segs);
- });
- this.segs = segs;
- },
-
- getSegs: function() {
- return (this.segs || []).concat(
- this.popoverSegs || []
- );
- },
-
- destroyEvents: function() {
- var rowStructs;
- var rowStruct;
- Grid.prototype.destroyEvents.call(this);
- rowStructs = this.rowStructs || [];
- while ((rowStruct = rowStructs.pop())) {
- rowStruct.tbodyEl.remove();
- }
- this.segs = null;
- this.destroySegPopover();
- },
-
-
- renderEventRows: function(events) {
- var segs = this.eventsToSegs(events);
- var rowStructs = [];
- var segRows;
- var row;
- segs = this.renderSegs(segs);
- segRows = this.groupSegRows(segs);
-
- for (row = 0; row < segRows.length; row++) {
- rowStructs.push(
- this.renderEventRow(row, segRows[row])
- );
- }
- return rowStructs;
- },
-
- renderSegHtml: function(seg, disableResizing) {
- var view = this.view;
- var isRTL = view.opt('isRTL');
- var event = seg.event;
- var isDraggable = view.isEventDraggable(event);
- var isResizable = !disableResizing && event.allDay && seg.isEnd && view.isEventResizable(event);
- var classes = this.getSegClasses(seg, isDraggable, isResizable);
- var skinCss = this.getEventSkinCss(event);
- var timeHtml = '';
- var titleHtml;
- classes.unshift('fc-day-grid-event');
-
- if (!event.allDay && seg.isStart) {
- timeHtml = '<span class="fc-time">' + htmlEscape(view.getEventTimeText(event)) + '</span>';
- }
- titleHtml =
-
- '<span class="fc-title" style="color:white">' +
- (htmlEscape(event.title || '') || ' ') +
- '</span>';
-
- return '<a class="' + classes.join(' ') + '"' +
- (event.url ?
- ' href="' + htmlEscape(event.url) + '"' :
- ''
- ) +
- (skinCss ?
- ' style="' + skinCss + '"' :
- ''
- ) +
- '>' +
-
- '<div class="fc-content" style="color:white">' +
- (isRTL ?
- titleHtml + ' ' + timeHtml :
- timeHtml + ' ' + titleHtml
- ) +
- '</div>' +
- (isResizable ?
- '<div class="fc-resizer"/>' :
- ''
- ) +
- '</a>';
- },
-
-
- renderEventRow: function(row, rowSegs) {
- var view = this.view;
- var colCnt = view.colCnt;
- var segLevels = this.buildSegLevels(rowSegs);
- var levelCnt = Math.max(1, segLevels.length);
- var tbody = $('<tbody/>');
- var segMatrix = [];
- var cellMatrix = [];
- var loneCellMatrix = [];
- var i, levelSegs;
- var col;
- var tr;
- var j, seg;
- var td;
-
- function emptyCellsUntil(endCol) {
- while (col < endCol) {
-
- td = (loneCellMatrix[i - 1] || [])[col];
- if (td) {
- td.attr(
- 'rowspan',
- parseInt(td.attr('rowspan') || 1, 10) + 1
- );
- }
- else {
- td = $('<td/>');
- tr.append(td);
- }
- cellMatrix[i][col] = td;
- loneCellMatrix[i][col] = td;
- col++;
- }
- }
- for (i = 0; i < levelCnt; i++) {
- levelSegs = segLevels[i];
- col = 0;
- tr = $('<tr/>');
- segMatrix.push([]);
- cellMatrix.push([]);
- loneCellMatrix.push([]);
-
-
- if (levelSegs) {
- for (j = 0; j < levelSegs.length; j++) {
- seg = levelSegs[j];
- emptyCellsUntil(seg.leftCol);
-
- td = $('<td class="fc-event-container"/>').append(seg.el);
- if (seg.leftCol != seg.rightCol) {
- td.attr('colspan', seg.rightCol - seg.leftCol + 1);
- }
- else {
- loneCellMatrix[i][col] = td;
- }
- while (col <= seg.rightCol) {
- cellMatrix[i][col] = td;
- segMatrix[i][col] = seg;
- col++;
- }
- tr.append(td);
- }
- }
- emptyCellsUntil(colCnt);
- this.bookendCells(tr, 'eventSkeleton');
- tbody.append(tr);
- }
- return {
- row: row,
- tbodyEl: tbody,
- cellMatrix: cellMatrix,
- segMatrix: segMatrix,
- segLevels: segLevels,
- segs: rowSegs
- };
- },
-
- buildSegLevels: function(segs) {
- var levels = [];
- var i, seg;
- var j;
-
-
- segs.sort(compareSegs);
-
- for (i = 0; i < segs.length; i++) {
- seg = segs[i];
-
- for (j = 0; j < levels.length; j++) {
- if (!isDaySegCollision(seg, levels[j])) {
- break;
- }
- }
-
- seg.level = j;
-
- (levels[j] || (levels[j] = [])).push(seg);
- }
-
- for (j = 0; j < levels.length; j++) {
- levels[j].sort(compareDaySegCols);
- }
- return levels;
- },
-
- groupSegRows: function(segs) {
- var view = this.view;
- var segRows = [];
- var i;
- for (i = 0; i < view.rowCnt; i++) {
- segRows.push([]);
- }
- for (i = 0; i < segs.length; i++) {
- segRows[segs[i].row].push(segs[i]);
- }
- return segRows;
- }
- });
- function isDaySegCollision(seg, otherSegs) {
- var i, otherSeg;
- for (i = 0; i < otherSegs.length; i++) {
- otherSeg = otherSegs[i];
- if (
- otherSeg.leftCol <= seg.rightCol &&
- otherSeg.rightCol >= seg.leftCol
- ) {
- return true;
- }
- }
- return false;
- }
- function compareDaySegCols(a, b) {
- return a.leftCol - b.leftCol;
- }
- ;;
- $.extend(DayGrid.prototype, {
- segPopover: null,
- popoverSegs: null,
- destroySegPopover: function() {
- if (this.segPopover) {
- this.segPopover.hide();
- }
- },
-
-
- limitRows: function(levelLimit) {
- var rowStructs = this.rowStructs || [];
- var row;
- var rowLevelLimit;
- for (row = 0; row < rowStructs.length; row++) {
- this.unlimitRow(row);
- if (!levelLimit) {
- rowLevelLimit = false;
- }
- else if (typeof levelLimit === 'number') {
- rowLevelLimit = levelLimit;
- }
- else {
- rowLevelLimit = this.computeRowLevelLimit(row);
- }
- if (rowLevelLimit !== false) {
- this.limitRow(row, rowLevelLimit);
- }
- }
- },
-
-
-
- computeRowLevelLimit: function(row) {
- var rowEl = this.rowEls.eq(row);
- var rowHeight = rowEl.height();
- var trEls = this.rowStructs[row].tbodyEl.children();
- var i, trEl;
-
- for (i = 0; i < trEls.length; i++) {
- trEl = trEls.eq(i).removeClass('fc-limited');
- if (trEl.position().top + trEl.outerHeight() > rowHeight) {
- return i;
- }
- }
- return false;
- },
-
-
-
- limitRow: function(row, levelLimit) {
- var _this = this;
- var view = this.view;
- var rowStruct = this.rowStructs[row];
- var moreNodes = [];
- var col = 0;
- var cell;
- var levelSegs;
- var cellMatrix;
- var limitedNodes;
- var i, seg;
- var segsBelow;
- var totalSegsBelow;
- var colSegsBelow;
- var td, rowspan;
- var segMoreNodes;
- var j;
- var moreTd, moreWrap, moreLink;
-
- function emptyCellsUntil(endCol) {
- while (col < endCol) {
- cell = { row: row, col: col };
- segsBelow = _this.getCellSegs(cell, levelLimit);
- if (segsBelow.length) {
- td = cellMatrix[levelLimit - 1][col];
- moreLink = _this.renderMoreLink(cell, segsBelow);
- moreWrap = $('<div/>').append(moreLink);
- td.append(moreWrap);
- moreNodes.push(moreWrap[0]);
- }
- col++;
- }
- }
- if (levelLimit && levelLimit < rowStruct.segLevels.length) {
- levelSegs = rowStruct.segLevels[levelLimit - 1];
- cellMatrix = rowStruct.cellMatrix;
- limitedNodes = rowStruct.tbodyEl.children().slice(levelLimit)
- .addClass('fc-limited').get();
-
- for (i = 0; i < levelSegs.length; i++) {
- seg = levelSegs[i];
- emptyCellsUntil(seg.leftCol);
-
- colSegsBelow = [];
- totalSegsBelow = 0;
- while (col <= seg.rightCol) {
- cell = { row: row, col: col };
- segsBelow = this.getCellSegs(cell, levelLimit);
- colSegsBelow.push(segsBelow);
- totalSegsBelow += segsBelow.length;
- col++;
- }
- if (totalSegsBelow) {
- td = cellMatrix[levelLimit - 1][seg.leftCol];
- rowspan = td.attr('rowspan') || 1;
- segMoreNodes = [];
-
- for (j = 0; j < colSegsBelow.length; j++) {
- moreTd = $('<td class="fc-more-cell"/>').attr('rowspan', rowspan);
- segsBelow = colSegsBelow[j];
- cell = { row: row, col: seg.leftCol + j };
- moreLink = this.renderMoreLink(cell, [ seg ].concat(segsBelow));
- moreWrap = $('<div/>').append(moreLink);
- moreTd.append(moreWrap);
- segMoreNodes.push(moreTd[0]);
- moreNodes.push(moreTd[0]);
- }
- td.addClass('fc-limited').after($(segMoreNodes));
- limitedNodes.push(td[0]);
- }
- }
- emptyCellsUntil(view.colCnt);
- rowStruct.moreEls = $(moreNodes);
- rowStruct.limitedEls = $(limitedNodes);
- }
- },
-
-
- unlimitRow: function(row) {
- var rowStruct = this.rowStructs[row];
- if (rowStruct.moreEls) {
- rowStruct.moreEls.remove();
- rowStruct.moreEls = null;
- }
- if (rowStruct.limitedEls) {
- rowStruct.limitedEls.removeClass('fc-limited');
- rowStruct.limitedEls = null;
- }
- },
-
-
- renderMoreLink: function(cell, hiddenSegs) {
- var _this = this;
- var view = this.view;
- return $('<a class="fc-more"/>')
- .text(
- this.getMoreLinkText(hiddenSegs.length)
- )
- .on('click', function(ev) {
- var clickOption = view.opt('eventLimitClick');
- var date = view.cellToDate(cell);
- var moreEl = $(this);
- var dayEl = _this.getCellDayEl(cell);
- var allSegs = _this.getCellSegs(cell);
-
- var reslicedAllSegs = _this.resliceDaySegs(allSegs, date);
- var reslicedHiddenSegs = _this.resliceDaySegs(hiddenSegs, date);
- if (typeof clickOption === 'function') {
-
- clickOption = view.trigger('eventLimitClick', null, {
- date: date,
- dayEl: dayEl,
- moreEl: moreEl,
- segs: reslicedAllSegs,
- hiddenSegs: reslicedHiddenSegs
- }, ev);
- }
- if (clickOption === 'popover') {
- _this.showSegPopover(date, cell, moreEl, reslicedAllSegs);
- }
- else if (typeof clickOption === 'string') {
- view.calendar.zoomTo(date, clickOption);
- }
- });
- },
-
- showSegPopover: function(date, cell, moreLink, segs) {
- var _this = this;
- var view = this.view;
- var moreWrap = moreLink.parent();
- var topEl;
- var options;
- if (view.rowCnt == 1) {
- topEl = this.view.el;
- }
- else {
- topEl = this.rowEls.eq(cell.row);
- }
- options = {
- className: 'fc-more-popover',
- content: this.renderSegPopoverContent(date, segs),
- parentEl: this.el,
- top: topEl.offset().top,
- autoHide: true,
- viewportConstrain: view.opt('popoverViewportConstrain'),
- hide: function() {
-
- _this.segPopover.destroy();
- _this.segPopover = null;
- _this.popoverSegs = null;
- }
- };
-
-
- if (view.opt('isRTL')) {
- options.right = moreWrap.offset().left + moreWrap.outerWidth() + 1;
- }
- else {
- options.left = moreWrap.offset().left - 1;
- }
- this.segPopover = new Popover(options);
- this.segPopover.show();
- },
-
- renderSegPopoverContent: function(date, segs) {
- var view = this.view;
- var isTheme = view.opt('theme');
- var title = date.format(view.opt('dayPopoverFormat'));
- var content = $(
- '<div class="fc-header ' + view.widgetHeaderClass + '">' +
- '<span class="fc-close ' +
- (isTheme ? 'ui-icon ui-icon-closethick' : 'fc-icon fc-icon-x') +
- '"></span>' +
- '<span class="fc-title">' +
- htmlEscape(title) +
- '</span>' +
- '<div class="fc-clear"/>' +
- '</div>' +
- '<div class="fc-body ' + view.widgetContentClass + '">' +
- '<div class="fc-event-container"></div>' +
- '</div>'
- );
- var segContainer = content.find('.fc-event-container');
- var i;
-
- segs = this.renderSegs(segs, true);
- this.popoverSegs = segs;
- for (i = 0; i < segs.length; i++) {
-
-
- segs[i].cellDate = date;
- segContainer.append(segs[i].el);
- }
- return content;
- },
-
- resliceDaySegs: function(segs, dayDate) {
- var events = $.map(segs, function(seg) {
- return seg.event;
- });
- var dayStart = dayDate.clone().stripTime();
- var dayEnd = dayStart.clone().add(1, 'days');
- return this.eventsToSegs(events, dayStart, dayEnd);
- },
-
- getMoreLinkText: function(num) {
- var view = this.view;
- var opt = view.opt('eventLimitText');
- if (typeof opt === 'function') {
- return opt(num);
- }
- else {
- return '+' + num + ' ' + opt;
- }
- },
-
-
- getCellSegs: function(cell, startLevel) {
- var segMatrix = this.rowStructs[cell.row].segMatrix;
- var level = startLevel || 0;
- var segs = [];
- var seg;
- while (level < segMatrix.length) {
- seg = segMatrix[level][cell.col];
- if (seg) {
- segs.push(seg);
- }
- level++;
- }
- return segs;
- }
- });
- ;;
- function TimeGrid(view) {
- Grid.call(this, view);
- }
- TimeGrid.prototype = createObject(Grid.prototype);
- $.extend(TimeGrid.prototype, {
- slotDuration: null,
- snapDuration: null,
- minTime: null,
- maxTime: null,
- dayEls: null,
- slatEls: null,
- slatTops: null,
- highlightEl: null,
- helperEl: null,
-
-
- render: function() {
- this.processOptions();
- this.el.html(this.renderHtml());
- this.dayEls = this.el.find('.fc-day');
- this.slatEls = this.el.find('.fc-slats tr');
- this.computeSlatTops();
- Grid.prototype.render.call(this);
- },
-
- renderHtml: function() {
- return '' +
- '<div class="fc-bg">' +
- '<table>' +
- this.rowHtml('slotBg') +
- '</table>' +
- '</div>' +
- '<div class="fc-slats">' +
- '<table>' +
- this.slatRowHtml() +
- '</table>' +
- '</div>';
- },
-
-
- slotBgCellHtml: function(row, col, date) {
- return this.bgCellHtml(row, col, date);
- },
-
- slatRowHtml: function() {
- var view = this.view;
- var calendar = view.calendar;
- var isRTL = view.opt('isRTL');
- var html = '';
- var slotNormal = this.slotDuration.asMinutes() % 15 === 0;
- var slotTime = moment.duration(+this.minTime);
- var slotDate;
- var minutes;
- var axisHtml;
-
- while (slotTime < this.maxTime) {
- slotDate = view.start.clone().time(slotTime);
- minutes = slotDate.minutes();
- axisHtml =
- '<td class="fc-axis fc-time ' + view.widgetContentClass + '" ' + view.axisStyleAttr() + '>' +
- ((!slotNormal || !minutes) ?
- '<span>' +
- htmlEscape(calendar.formatDate(slotDate, view.opt('axisFormat'))) +
- '</span>' :
- ''
- ) +
- '</td>';
- html +=
- '<tr ' + (!minutes ? '' : 'class="fc-minor"') + '>' +
- (!isRTL ? axisHtml : '') +
- '<td class="' + view.widgetContentClass + '"/>' +
- (isRTL ? axisHtml : '') +
- "</tr>";
- slotTime.add(this.slotDuration);
- }
- return html;
- },
-
- processOptions: function() {
- var view = this.view;
- var slotDuration = view.opt('slotDuration');
- var snapDuration = view.opt('snapDuration');
- slotDuration = moment.duration(slotDuration);
- snapDuration = snapDuration ? moment.duration(snapDuration) : slotDuration;
- this.slotDuration = slotDuration;
- this.snapDuration = snapDuration;
- this.cellDuration = snapDuration;
- this.minTime = moment.duration(view.opt('minTime'));
- this.maxTime = moment.duration(view.opt('maxTime'));
- },
-
- rangeToSegs: function(rangeStart, rangeEnd) {
- var view = this.view;
- var segs = [];
- var seg;
- var col;
- var cellDate;
- var colStart, colEnd;
-
- rangeStart = rangeStart.clone().stripZone();
- rangeEnd = rangeEnd.clone().stripZone();
- for (col = 0; col < view.colCnt; col++) {
- cellDate = view.cellToDate(0, col);
- colStart = cellDate.clone().time(this.minTime);
- colEnd = cellDate.clone().time(this.maxTime);
- seg = intersectionToSeg(rangeStart, rangeEnd, colStart, colEnd);
- if (seg) {
- seg.col = col;
- segs.push(seg);
- }
- }
- return segs;
- },
-
-
- resize: function() {
- this.computeSlatTops();
- this.updateSegVerticals();
- },
-
-
- buildCoords: function(rows, cols) {
- var colCnt = this.view.colCnt;
- var originTop = this.el.offset().top;
- var snapTime = moment.duration(+this.minTime);
- var p = null;
- var e, n;
- this.dayEls.slice(0, colCnt).each(function(i, _e) {
- e = $(_e);
- n = e.offset().left;
- if (p) {
- p[1] = n;
- }
- p = [ n ];
- cols[i] = p;
- });
- p[1] = n + e.outerWidth();
- p = null;
- while (snapTime < this.maxTime) {
- n = originTop + this.computeTimeTop(snapTime);
- if (p) {
- p[1] = n;
- }
- p = [ n ];
- rows.push(p);
- snapTime.add(this.snapDuration);
- }
- p[1] = originTop + this.computeTimeTop(snapTime);
- },
-
- getCellDate: function(cell) {
- var view = this.view;
- var calendar = view.calendar;
- return calendar.rezoneDate(
- view.cellToDate(0, cell.col)
- .time(this.minTime + this.snapDuration * cell.row)
- );
- },
-
- getCellDayEl: function(cell) {
- return this.dayEls.eq(cell.col);
- },
-
-
- computeDateTop: function(date, startOfDayDate) {
- return this.computeTimeTop(
- moment.duration(
- date.clone().stripZone() - startOfDayDate.clone().stripTime()
- )
- );
- },
-
- computeTimeTop: function(time) {
- var slatCoverage = (time - this.minTime) / this.slotDuration;
- var slatIndex;
- var slatRemainder;
- var slatTop;
- var slatBottom;
-
- slatCoverage = Math.max(0, slatCoverage);
- slatCoverage = Math.min(this.slatEls.length, slatCoverage);
- slatIndex = Math.floor(slatCoverage);
- slatRemainder = slatCoverage - slatIndex;
- slatTop = this.slatTops[slatIndex];
- if (slatRemainder) {
- slatBottom = this.slatTops[slatIndex + 1];
- return slatTop + (slatBottom - slatTop) * slatRemainder;
- }
- else {
- return slatTop;
- }
- },
-
-
- computeSlatTops: function() {
- var tops = [];
- var top;
- this.slatEls.each(function(i, node) {
- top = $(node).position().top;
- tops.push(top);
- });
- tops.push(top + this.slatEls.last().outerHeight());
- this.slatTops = tops;
- },
-
-
-
- renderDrag: function(start, end, seg) {
- var opacity;
- if (seg) {
- this.renderRangeHelper(start, end, seg);
- opacity = this.view.opt('dragOpacity');
- if (opacity !== undefined) {
- this.helperEl.css('opacity', opacity);
- }
- return true;
- }
- else {
-
- this.renderHighlight(
- start,
- end || this.view.calendar.getDefaultEventEnd(false, start)
- );
- }
- },
-
- destroyDrag: function() {
- this.destroyHelper();
- this.destroyHighlight();
- },
-
-
- renderResize: function(start, end, seg) {
- this.renderRangeHelper(start, end, seg);
- },
-
- destroyResize: function() {
- this.destroyHelper();
- },
-
-
- renderHelper: function(event, sourceSeg) {
- var res = this.renderEventTable([ event ]);
- var tableEl = res.tableEl;
- var segs = res.segs;
- var i, seg;
- var sourceEl;
-
- for (i = 0; i < segs.length; i++) {
- seg = segs[i];
- if (sourceSeg && sourceSeg.col === seg.col) {
- sourceEl = sourceSeg.el;
- seg.el.css({
- left: sourceEl.css('left'),
- right: sourceEl.css('right'),
- 'margin-left': sourceEl.css('margin-left'),
- 'margin-right': sourceEl.css('margin-right')
- });
- }
- }
- this.helperEl = $('<div class="fc-helper-skeleton"/>')
- .append(tableEl)
- .appendTo(this.el);
- },
-
- destroyHelper: function() {
- if (this.helperEl) {
- this.helperEl.remove();
- this.helperEl = null;
- }
- },
-
-
- renderSelection: function(start, end) {
- if (this.view.opt('selectHelper')) {
- this.renderRangeHelper(start, end);
- }
- else {
- this.renderHighlight(start, end);
- }
- },
-
- destroySelection: function() {
- this.destroyHelper();
- this.destroyHighlight();
- },
-
-
- renderHighlight: function(start, end) {
- this.highlightEl = $(
- this.highlightSkeletonHtml(start, end)
- ).appendTo(this.el);
- },
-
- destroyHighlight: function() {
- if (this.highlightEl) {
- this.highlightEl.remove();
- this.highlightEl = null;
- }
- },
-
-
- highlightSkeletonHtml: function(start, end) {
- var view = this.view;
- var segs = this.rangeToSegs(start, end);
- var cellHtml = '';
- var col = 0;
- var i, seg;
- var dayDate;
- var top, bottom;
- for (i = 0; i < segs.length; i++) {
- seg = segs[i];
-
- if (col < seg.col) {
- cellHtml += '<td colspan="' + (seg.col - col) + '"/>';
- col = seg.col;
- }
-
- dayDate = view.cellToDate(0, col);
- top = this.computeDateTop(seg.start, dayDate);
- bottom = this.computeDateTop(seg.end, dayDate);
-
-
- cellHtml +=
- '<td>' +
- '<div class="fc-highlight-container">' +
- '<div class="fc-highlight" style="top:' + top + 'px;bottom:-' + bottom + 'px"/>' +
- '</div>' +
- '</td>';
- col++;
- }
-
- if (col < view.colCnt) {
- cellHtml += '<td colspan="' + (view.colCnt - col) + '"/>';
- }
- cellHtml = this.bookendCells(cellHtml, 'highlight');
- return '' +
- '<div class="fc-highlight-skeleton">' +
- '<table>' +
- '<tr>' +
- cellHtml +
- '</tr>' +
- '</table>' +
- '</div>';
- }
- });
- ;;
- $.extend(TimeGrid.prototype, {
- segs: null,
- eventSkeletonEl: null,
-
- renderEvents: function(events) {
- var res = this.renderEventTable(events);
- this.eventSkeletonEl = $('<div class="fc-content-skeleton"/>').append(res.tableEl);
- this.el.append(this.eventSkeletonEl);
- this.segs = res.segs;
- },
-
- getSegs: function() {
- return this.segs || [];
- },
-
- destroyEvents: function() {
- Grid.prototype.destroyEvents.call(this);
- if (this.eventSkeletonEl) {
- this.eventSkeletonEl.remove();
- this.eventSkeletonEl = null;
- }
- this.segs = null;
- },
-
-
- renderEventTable: function(events) {
- var tableEl = $('<table><tr/></table>');
- var trEl = tableEl.find('tr');
- var segs = this.eventsToSegs(events);
- var segCols;
- var i, seg;
- var col, colSegs;
- var containerEl;
- segs = this.renderSegs(segs);
- segCols = this.groupSegCols(segs);
- this.computeSegVerticals(segs);
- for (col = 0; col < segCols.length; col++) {
- colSegs = segCols[col];
- placeSlotSegs(colSegs);
- containerEl = $('<div class="fc-event-container"/>');
-
- for (i = 0; i < colSegs.length; i++) {
- seg = colSegs[i];
- seg.el.css(this.generateSegPositionCss(seg));
-
- if (seg.bottom - seg.top < 30) {
- seg.el.addClass('fc-short');
- }
- containerEl.append(seg.el);
- }
- trEl.append($('<td/>').append(containerEl));
- }
- this.bookendCells(trEl, 'eventSkeleton');
- return {
- tableEl: tableEl,
- segs: segs
- };
- },
-
- updateSegVerticals: function() {
- var segs = this.segs;
- var i;
- if (segs) {
- this.computeSegVerticals(segs);
- for (i = 0; i < segs.length; i++) {
- segs[i].el.css(
- this.generateSegVerticalCss(segs[i])
- );
- }
- }
- },
-
- computeSegVerticals: function(segs) {
- var i, seg;
- for (i = 0; i < segs.length; i++) {
- seg = segs[i];
- seg.top = this.computeDateTop(seg.start, seg.start);
- seg.bottom = this.computeDateTop(seg.end, seg.start);
- }
- },
-
- renderSegHtml: function(seg, disableResizing) {
- var view = this.view;
- var event = seg.event;
- var isDraggable = view.isEventDraggable(event);
- var isResizable = !disableResizing && seg.isEnd && view.isEventResizable(event);
- var classes = this.getSegClasses(seg, isDraggable, isResizable);
- var skinCss = this.getEventSkinCss(event);
- var timeText;
- var fullTimeText;
- var startTimeText;
- classes.unshift('fc-time-grid-event');
- if (view.isMultiDayEvent(event)) {
-
-
-
- if (seg.isStart || seg.isEnd) {
- timeText = view.getEventTimeText(seg.start, seg.end);
- fullTimeText = view.getEventTimeText(seg.start, seg.end, 'LT');
- startTimeText = view.getEventTimeText(seg.start, null);
- }
- } else {
-
- timeText = view.getEventTimeText(event);
- fullTimeText = view.getEventTimeText(event, 'LT');
- startTimeText = view.getEventTimeText(event.start, null);
- }
- return '<a class="' + classes.join(' ') + '"' +
- (event.url ?
- ' href="' + htmlEscape(event.url) + '"' :
- ''
- ) +
- (skinCss ?
- ' style="' + skinCss + '"' :
- ''
- ) +
- '>' +
- '<div class="fc-content">' +
- (timeText ?
- '<div class="fc-time"' +
- ' data-start="' + htmlEscape(startTimeText) + '"' +
- ' data-full="' + htmlEscape(fullTimeText) + '"' +
- '>' +
- '<span>' + htmlEscape(timeText) + '</span>' +
- '</div>' :
- ''
- ) +
- (event.title ?
- '<div class="fc-title">' +
- htmlEscape(event.title) +
- '</div>' :
- ''
- ) +
- '</div>' +
- '<div class="fc-bg"/>' +
- (isResizable ?
- '<div class="fc-resizer"/>' :
- ''
- ) +
- '</a>';
- },
-
-
- generateSegPositionCss: function(seg) {
- var view = this.view;
- var isRTL = view.opt('isRTL');
- var shouldOverlap = view.opt('slotEventOverlap');
- var backwardCoord = seg.backwardCoord;
- var forwardCoord = seg.forwardCoord;
- var props = this.generateSegVerticalCss(seg);
- var left;
- var right;
- if (shouldOverlap) {
-
- forwardCoord = Math.min(1, backwardCoord + (forwardCoord - backwardCoord) * 2);
- }
- if (isRTL) {
- left = 1 - forwardCoord;
- right = backwardCoord;
- }
- else {
- left = backwardCoord;
- right = 1 - forwardCoord;
- }
- props.zIndex = seg.level + 1;
- props.left = left * 100 + '%';
- props.right = right * 100 + '%';
- if (shouldOverlap && seg.forwardPressure) {
-
- props[isRTL ? 'marginLeft' : 'marginRight'] = 10 * 2;
- }
- return props;
- },
-
- generateSegVerticalCss: function(seg) {
- return {
- top: seg.top,
- bottom: -seg.bottom
- };
- },
-
- groupSegCols: function(segs) {
- var view = this.view;
- var segCols = [];
- var i;
- for (i = 0; i < view.colCnt; i++) {
- segCols.push([]);
- }
- for (i = 0; i < segs.length; i++) {
- segCols[segs[i].col].push(segs[i]);
- }
- return segCols;
- }
- });
- function placeSlotSegs(segs) {
- var levels;
- var level0;
- var i;
- segs.sort(compareSegs);
- levels = buildSlotSegLevels(segs);
- computeForwardSlotSegs(levels);
- if ((level0 = levels[0])) {
- for (i = 0; i < level0.length; i++) {
- computeSlotSegPressures(level0[i]);
- }
- for (i = 0; i < level0.length; i++) {
- computeSlotSegCoords(level0[i], 0, 0);
- }
- }
- }
- function buildSlotSegLevels(segs) {
- var levels = [];
- var i, seg;
- var j;
- for (i=0; i<segs.length; i++) {
- seg = segs[i];
-
- for (j=0; j<levels.length; j++) {
- if (!computeSlotSegCollisions(seg, levels[j]).length) {
- break;
- }
- }
- seg.level = j;
- (levels[j] || (levels[j] = [])).push(seg);
- }
- return levels;
- }
- function computeForwardSlotSegs(levels) {
- var i, level;
- var j, seg;
- var k;
- for (i=0; i<levels.length; i++) {
- level = levels[i];
- for (j=0; j<level.length; j++) {
- seg = level[j];
- seg.forwardSegs = [];
- for (k=i+1; k<levels.length; k++) {
- computeSlotSegCollisions(seg, levels[k], seg.forwardSegs);
- }
- }
- }
- }
- function computeSlotSegPressures(seg) {
- var forwardSegs = seg.forwardSegs;
- var forwardPressure = 0;
- var i, forwardSeg;
- if (seg.forwardPressure === undefined) {
- for (i=0; i<forwardSegs.length; i++) {
- forwardSeg = forwardSegs[i];
-
- computeSlotSegPressures(forwardSeg);
-
-
- forwardPressure = Math.max(
- forwardPressure,
- 1 + forwardSeg.forwardPressure
- );
- }
- seg.forwardPressure = forwardPressure;
- }
- }
- function computeSlotSegCoords(seg, seriesBackwardPressure, seriesBackwardCoord) {
- var forwardSegs = seg.forwardSegs;
- var i;
- if (seg.forwardCoord === undefined) {
- if (!forwardSegs.length) {
-
- seg.forwardCoord = 1;
- }
- else {
-
- forwardSegs.sort(compareForwardSlotSegs);
-
-
- computeSlotSegCoords(forwardSegs[0], seriesBackwardPressure + 1, seriesBackwardCoord);
- seg.forwardCoord = forwardSegs[0].backwardCoord;
- }
-
- seg.backwardCoord = seg.forwardCoord -
- (seg.forwardCoord - seriesBackwardCoord) /
- (seriesBackwardPressure + 1);
-
-
- for (i=0; i<forwardSegs.length; i++) {
- computeSlotSegCoords(forwardSegs[i], 0, seg.forwardCoord);
- }
- }
- }
- function computeSlotSegCollisions(seg, otherSegs, results) {
- results = results || [];
- for (var i=0; i<otherSegs.length; i++) {
- if (isSlotSegCollision(seg, otherSegs[i])) {
- results.push(otherSegs[i]);
- }
- }
- return results;
- }
- function isSlotSegCollision(seg1, seg2) {
- return seg1.bottom > seg2.top && seg1.top < seg2.bottom;
- }
- function compareForwardSlotSegs(seg1, seg2) {
-
- return seg2.forwardPressure - seg1.forwardPressure ||
-
- (seg1.backwardCoord || 0) - (seg2.backwardCoord || 0) ||
-
- compareSegs(seg1, seg2);
- }
- ;;
- View.prototype = {
- calendar: null,
- coordMap: null,
- el: null,
-
- start: null,
- end: null,
- intervalStart: null,
- intervalEnd: null,
-
- rowCnt: null,
- colCnt: null,
- isSelected: false,
-
- scrollerEl: null,
- scrollTop: null,
-
- widgetHeaderClass: null,
- widgetContentClass: null,
- highlightStateClass: null,
-
- documentMousedownProxy: null,
- documentDragStartProxy: null,
-
- init: function() {
- var tm = this.opt('theme') ? 'ui' : 'fc';
- this.widgetHeaderClass = tm + '-widget-header';
- this.widgetContentClass = tm + '-widget-content';
- this.highlightStateClass = tm + '-state-highlight';
-
- this.documentMousedownProxy = $.proxy(this, 'documentMousedown');
- this.documentDragStartProxy = $.proxy(this, 'documentDragStart');
- },
-
-
- render: function() {
- this.updateSize();
- this.trigger('viewRender', this, this, this.el);
-
- $(document)
- .on('mousedown', this.documentMousedownProxy)
- .on('dragstart', this.documentDragStartProxy);
- },
-
- destroy: function() {
- this.unselect();
- this.trigger('viewDestroy', this, this, this.el);
- this.destroyEvents();
- this.el.empty();
- $(document)
- .off('mousedown', this.documentMousedownProxy)
- .off('dragstart', this.documentDragStartProxy);
- },
-
-
- incrementDate: function(date, delta) {
-
- },
-
-
- updateSize: function(isResize) {
- if (isResize) {
- this.recordScroll();
- }
- this.updateHeight();
- this.updateWidth();
- },
-
- updateWidth: function() {
-
- },
-
- updateHeight: function() {
- var calendar = this.calendar;
- this.setHeight(
- calendar.getSuggestedViewHeight(),
- calendar.isHeightAuto()
- );
- },
-
-
- setHeight: function(height, isAuto) {
-
- },
-
-
- computeScrollerHeight: function(totalHeight) {
- var both = this.el.add(this.scrollerEl);
- var otherHeight;
-
- both.css({
- position: 'relative',
- left: -1
- });
- otherHeight = this.el.outerHeight() - this.scrollerEl.height();
- both.css({ position: '', left: '' });
- return totalHeight - otherHeight;
- },
-
-
-
- recordScroll: function() {
- if (this.scrollerEl) {
- this.scrollTop = this.scrollerEl.scrollTop();
- }
- },
-
-
-
- restoreScroll: function() {
- if (this.scrollTop !== null) {
- this.scrollerEl.scrollTop(this.scrollTop);
- }
- },
-
-
-
- renderEvents: function(events) {
- this.segEach(function(seg) {
- this.trigger('eventAfterRender', seg.event, seg.event, seg.el);
- });
- this.trigger('eventAfterAllRender');
- },
-
-
- destroyEvents: function() {
- this.segEach(function(seg) {
- this.trigger('eventDestroy', seg.event, seg.event, seg.el);
- });
- },
-
-
- resolveEventEl: function(event, el) {
- var custom = this.trigger('eventRender', event, event, el);
- if (custom === false) {
- el = null;
- }
- else if (custom && custom !== true) {
- el = $(custom);
- }
- return el;
- },
-
- showEvent: function(event) {
- this.segEach(function(seg) {
- seg.el.css('visibility', '');
- }, event);
- },
-
- hideEvent: function(event) {
- this.segEach(function(seg) {
- seg.el.css('visibility', 'hidden');
- }, event);
- },
-
-
-
- segEach: function(func, event) {
- var segs = this.getSegs();
- var i;
- for (i = 0; i < segs.length; i++) {
- if (!event || segs[i].event._id === event._id) {
- func.call(this, segs[i]);
- }
- }
- },
-
- getSegs: function() {
-
- },
-
-
-
-
-
- renderDrag: function(start, end, seg) {
-
- },
-
- destroyDrag: function() {
-
- },
-
-
- documentDragStart: function(ev, ui) {
- var _this = this;
- var dropDate = null;
- var dragListener;
- if (this.opt('droppable')) {
-
- dragListener = new DragListener(this.coordMap, {
- cellOver: function(cell, date) {
- dropDate = date;
- _this.renderDrag(date);
- },
- cellOut: function() {
- dropDate = null;
- _this.destroyDrag();
- }
- });
-
- $(document).one('dragstop', function(ev, ui) {
- _this.destroyDrag();
- if (dropDate) {
- _this.trigger('drop', ev.target, dropDate, ev, ui);
- }
- });
- dragListener.startDrag(ev);
- }
- },
-
-
-
- select: function(start, end, ev) {
- this.unselect(ev);
- this.renderSelection(start, end);
- this.reportSelection(start, end, ev);
- },
-
- renderSelection: function(start, end) {
-
- },
-
- reportSelection: function(start, end, ev) {
- this.isSelected = true;
- this.trigger('select', null, start, end, ev);
- },
-
-
- unselect: function(ev) {
- if (this.isSelected) {
- this.isSelected = false;
- this.destroySelection();
- this.trigger('unselect', null, ev);
- }
- },
-
- destroySelection: function() {
-
- },
-
- documentMousedown: function(ev) {
- var ignore;
-
- if (this.isSelected && this.opt('unselectAuto') && isPrimaryMouseButton(ev)) {
-
- ignore = this.opt('unselectCancel');
- if (!ignore || !$(ev.target).closest(ignore).length) {
- this.unselect(ev);
- }
- }
- }
- };
- function View(calendar) {
- var t = this;
-
-
- t.calendar = calendar;
- t.opt = opt;
- t.trigger = trigger;
- t.isEventDraggable = isEventDraggable;
- t.isEventResizable = isEventResizable;
- t.eventDrop = eventDrop;
- t.eventResize = eventResize;
-
-
- var reportEventChange = calendar.reportEventChange;
-
-
- var options = calendar.options;
- var nextDayThreshold = moment.duration(options.nextDayThreshold);
- t.init();
-
-
- function opt(name) {
- var v = options[name];
- if ($.isPlainObject(v) && !isForcedAtomicOption(name)) {
- return smartProperty(v, t.name);
- }
- return v;
- }
-
- function trigger(name, thisObj) {
- return calendar.trigger.apply(
- calendar,
- [name, thisObj || t].concat(Array.prototype.slice.call(arguments, 2), [t])
- );
- }
-
-
-
- function isEventDraggable(event) {
- var source = event.source || {};
- return firstDefined(
- event.startEditable,
- source.startEditable,
- opt('eventStartEditable'),
- event.editable,
- source.editable,
- opt('editable')
- );
- }
-
-
- function isEventResizable(event) {
- var source = event.source || {};
- return firstDefined(
- event.durationEditable,
- source.durationEditable,
- opt('eventDurationEditable'),
- event.editable,
- source.editable,
- opt('editable')
- );
- }
-
-
-
-
-
-
-
-
-
-
- t.getEventTimeText = function(event, formatStr) {
- var start;
- var end;
- if (typeof event === 'object' && typeof formatStr === 'object') {
-
- start = event;
- end = formatStr;
- formatStr = arguments[2];
- }
- else {
-
- start = event.start;
- end = event.end;
- }
- formatStr = formatStr || opt('timeFormat');
- if (end && opt('displayEventEnd')) {
- return calendar.formatRange(start, end, formatStr);
- }
- else {
- return calendar.formatDate(start, formatStr);
- }
- };
-
-
-
-
- function eventDrop(el, event, newStart, ev) {
- var mutateResult = calendar.mutateEvent(event, newStart, null);
- trigger(
- 'eventDrop',
- el,
- event,
- mutateResult.dateDelta,
- function() {
- mutateResult.undo();
- reportEventChange();
- },
- ev,
- {}
- );
- reportEventChange();
- }
- function eventResize(el, event, newEnd, ev) {
- var mutateResult = calendar.mutateEvent(event, null, newEnd);
- trigger(
- 'eventResize',
- el,
- event,
- mutateResult.durationDelta,
- function() {
- mutateResult.undo();
- reportEventChange();
- },
- ev,
- {}
- );
- reportEventChange();
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- t.isHiddenDay = isHiddenDay;
- t.skipHiddenDays = skipHiddenDays;
- t.getCellsPerWeek = getCellsPerWeek;
- t.dateToCell = dateToCell;
- t.dateToDayOffset = dateToDayOffset;
- t.dayOffsetToCellOffset = dayOffsetToCellOffset;
- t.cellOffsetToCell = cellOffsetToCell;
- t.cellToDate = cellToDate;
- t.cellToCellOffset = cellToCellOffset;
- t.cellOffsetToDayOffset = cellOffsetToDayOffset;
- t.dayOffsetToDate = dayOffsetToDate;
- t.rangeToSegments = rangeToSegments;
- t.isMultiDayEvent = isMultiDayEvent;
-
- var hiddenDays = opt('hiddenDays') || [];
- var isHiddenDayHash = [];
- var cellsPerWeek;
- var dayToCellMap = [];
- var cellToDayMap = [];
- var isRTL = opt('isRTL');
-
- (function() {
- if (opt('weekends') === false) {
- hiddenDays.push(0, 6);
- }
-
-
- for (var dayIndex=0, cellIndex=0; dayIndex<7; dayIndex++) {
- dayToCellMap[dayIndex] = cellIndex;
- isHiddenDayHash[dayIndex] = $.inArray(dayIndex, hiddenDays) != -1;
- if (!isHiddenDayHash[dayIndex]) {
- cellToDayMap[cellIndex] = dayIndex;
- cellIndex++;
- }
- }
- cellsPerWeek = cellIndex;
- if (!cellsPerWeek) {
- throw 'invalid hiddenDays';
- }
- })();
-
-
- function isHiddenDay(day) {
- if (moment.isMoment(day)) {
- day = day.day();
- }
- return isHiddenDayHash[day];
- }
- function getCellsPerWeek() {
- return cellsPerWeek;
- }
-
-
-
-
- function skipHiddenDays(date, inc, isExclusive) {
- var out = date.clone();
- inc = inc || 1;
- while (
- isHiddenDayHash[(out.day() + (isExclusive ? inc : 0) + 7) % 7]
- ) {
- out.add(inc, 'days');
- }
- return out;
- }
-
-
-
-
-
-
-
- function cellToDate() {
- var cellOffset = cellToCellOffset.apply(null, arguments);
- var dayOffset = cellOffsetToDayOffset(cellOffset);
- var date = dayOffsetToDate(dayOffset);
- return date;
- }
-
-
-
-
- function cellToCellOffset(row, col) {
- var colCnt = t.colCnt;
-
- var dis = isRTL ? -1 : 1;
- var dit = isRTL ? colCnt - 1 : 0;
- if (typeof row == 'object') {
- col = row.col;
- row = row.row;
- }
- var cellOffset = row * colCnt + (col * dis + dit);
- return cellOffset;
- }
-
- function cellOffsetToDayOffset(cellOffset) {
- var day0 = t.start.day();
- cellOffset += dayToCellMap[day0];
- return Math.floor(cellOffset / cellsPerWeek) * 7 +
- cellToDayMap[
- (cellOffset % cellsPerWeek + cellsPerWeek) % cellsPerWeek
- ] -
- day0;
- }
-
- function dayOffsetToDate(dayOffset) {
- return t.start.clone().add(dayOffset, 'days');
- }
-
-
-
-
- function dateToCell(date) {
- var dayOffset = dateToDayOffset(date);
- var cellOffset = dayOffsetToCellOffset(dayOffset);
- var cell = cellOffsetToCell(cellOffset);
- return cell;
- }
-
- function dateToDayOffset(date) {
- return date.clone().stripTime().diff(t.start, 'days');
- }
-
- function dayOffsetToCellOffset(dayOffset) {
- var day0 = t.start.day();
- dayOffset += day0;
- return Math.floor(dayOffset / 7) * cellsPerWeek +
- dayToCellMap[
- (dayOffset % 7 + 7) % 7
- ] -
- dayToCellMap[day0];
- }
-
- function cellOffsetToCell(cellOffset) {
- var colCnt = t.colCnt;
-
- var dis = isRTL ? -1 : 1;
- var dit = isRTL ? colCnt - 1 : 0;
- var row = Math.floor(cellOffset / colCnt);
- var col = ((cellOffset % colCnt + colCnt) % colCnt) * dis + dit;
- return {
- row: row,
- col: col
- };
- }
-
-
-
-
-
-
-
-
-
- function rangeToSegments(start, end) {
- var rowCnt = t.rowCnt;
- var colCnt = t.colCnt;
- var segments = [];
-
- var dayRange = computeDayRange(start, end);
- var rangeDayOffsetStart = dateToDayOffset(dayRange.start);
- var rangeDayOffsetEnd = dateToDayOffset(dayRange.end);
-
-
- var rangeCellOffsetFirst = dayOffsetToCellOffset(rangeDayOffsetStart);
- var rangeCellOffsetLast = dayOffsetToCellOffset(rangeDayOffsetEnd) - 1;
-
- for (var row=0; row<rowCnt; row++) {
-
- var rowCellOffsetFirst = row * colCnt;
- var rowCellOffsetLast = rowCellOffsetFirst + colCnt - 1;
-
- var segmentCellOffsetFirst = Math.max(rangeCellOffsetFirst, rowCellOffsetFirst);
- var segmentCellOffsetLast = Math.min(rangeCellOffsetLast, rowCellOffsetLast);
-
- if (segmentCellOffsetFirst <= segmentCellOffsetLast) {
-
- var segmentCellFirst = cellOffsetToCell(segmentCellOffsetFirst);
- var segmentCellLast = cellOffsetToCell(segmentCellOffsetLast);
-
- var cols = [ segmentCellFirst.col, segmentCellLast.col ].sort();
-
-
-
-
- var isStart = cellOffsetToDayOffset(segmentCellOffsetFirst) == rangeDayOffsetStart;
- var isEnd = cellOffsetToDayOffset(segmentCellOffsetLast) + 1 == rangeDayOffsetEnd;
-
- segments.push({
- row: row,
- leftCol: cols[0],
- rightCol: cols[1],
- isStart: isStart,
- isEnd: isEnd
- });
- }
- }
- return segments;
- }
-
-
- function computeDayRange(start, end) {
- var startDay = start.clone().stripTime();
- var endDay;
- var endTimeMS;
- if (end) {
- endDay = end.clone().stripTime();
- endTimeMS = +end.time();
-
-
-
- if (endTimeMS && endTimeMS >= nextDayThreshold) {
- endDay.add(1, 'days');
- }
- }
-
-
- if (!end || endDay <= startDay) {
- endDay = startDay.clone().add(1, 'days');
- }
- return { start: startDay, end: endDay };
- }
-
- function isMultiDayEvent(event) {
- var range = computeDayRange(event.start, event.end);
- return range.end.diff(range.start, 'days') > 1;
- }
- }
- ;;
- function BasicView(calendar) {
- View.call(this, calendar);
- this.dayGrid = new DayGrid(this);
- this.coordMap = this.dayGrid.coordMap;
- }
- BasicView.prototype = createObject(View.prototype);
- $.extend(BasicView.prototype, {
- dayGrid: null,
- dayNumbersVisible: false,
- weekNumbersVisible: false,
- weekNumberWidth: null,
- headRowEl: null,
-
-
- render: function(rowCnt, colCnt, dayNumbersVisible) {
-
- this.rowCnt = rowCnt;
- this.colCnt = colCnt;
- this.dayNumbersVisible = dayNumbersVisible;
- this.weekNumbersVisible = this.opt('weekNumbers');
- this.dayGrid.numbersVisible = this.dayNumbersVisible || this.weekNumbersVisible;
- this.el.addClass('fc-basic-view').html(this.renderHtml());
- this.headRowEl = this.el.find('thead .fc-row');
- this.scrollerEl = this.el.find('.fc-day-grid-container');
- this.dayGrid.coordMap.containerEl = this.scrollerEl;
- this.dayGrid.el = this.el.find('.fc-day-grid');
- this.dayGrid.render(this.hasRigidRows());
- View.prototype.render.call(this);
- },
-
- destroy: function() {
- this.dayGrid.destroy();
- View.prototype.destroy.call(this);
- },
-
-
- renderHtml: function() {
- return '' +
- '<table>' +
- '<thead>' +
- '<tr>' +
- '<td class="' + this.widgetHeaderClass + '">' +
- this.dayGrid.headHtml() +
- '</td>' +
- '</tr>' +
- '</thead>' +
- '<tbody>' +
- '<tr>' +
- '<td class="' + this.widgetContentClass + '">' +
- '<div class="fc-day-grid-container">' +
- '<div class="fc-day-grid"/>' +
- '</div>' +
- '</td>' +
- '</tr>' +
- '</tbody>' +
- '</table>';
- },
-
-
- headIntroHtml: function() {
- if (this.weekNumbersVisible) {
- return '' +
- '<th class="fc-week-number ' + this.widgetHeaderClass + '" ' + this.weekNumberStyleAttr() + '>' +
- '<span>' +
- htmlEscape(this.opt('weekNumberTitle')) +
- '</span>' +
- '</th>';
- }
- },
-
-
- numberIntroHtml: function(row) {
- if (this.weekNumbersVisible) {
- return '' +
- '<td class="fc-week-number" ' + this.weekNumberStyleAttr() + '>' +
- '<span>' +
- this.calendar.calculateWeekNumber(this.cellToDate(row, 0)) +
- '</span>' +
- '</td>';
- }
- },
-
-
- dayIntroHtml: function() {
- if (this.weekNumbersVisible) {
- return '<td class="fc-week-number ' + this.widgetContentClass + '" ' +
- this.weekNumberStyleAttr() + '></td>';
- }
- },
-
-
- introHtml: function() {
- if (this.weekNumbersVisible) {
- return '<td class="fc-week-number" ' + this.weekNumberStyleAttr() + '></td>';
- }
- },
-
-
- numberCellHtml: function(row, col, date) {
- var classes;
- if (!this.dayNumbersVisible) {
- return '<td/>';
- }
- classes = this.dayGrid.getDayClasses(date);
- classes.unshift('fc-day-number');
- return '' +
- '<td class="' + classes.join(' ') + '" data-date="' + date.format() + '">' +
- date.date() +
- '</td>';
- },
-
- weekNumberStyleAttr: function() {
- if (this.weekNumberWidth !== null) {
- return 'style="width:' + this.weekNumberWidth + 'px"';
- }
- return '';
- },
-
- hasRigidRows: function() {
- var eventLimit = this.opt('eventLimit');
- return eventLimit && typeof eventLimit !== 'number';
- },
-
-
- updateWidth: function() {
- if (this.weekNumbersVisible) {
-
-
- this.weekNumberWidth = matchCellWidths(
- this.el.find('.fc-week-number')
- );
- }
- },
-
- setHeight: function(totalHeight, isAuto) {
- var eventLimit = this.opt('eventLimit');
- var scrollerHeight;
-
- unsetScroller(this.scrollerEl);
- uncompensateScroll(this.headRowEl);
- this.dayGrid.destroySegPopover();
-
- if (eventLimit && typeof eventLimit === 'number') {
- this.dayGrid.limitRows(eventLimit);
- }
- scrollerHeight = this.computeScrollerHeight(totalHeight);
- this.setGridHeight(scrollerHeight, isAuto);
-
- if (eventLimit && typeof eventLimit !== 'number') {
- this.dayGrid.limitRows(eventLimit);
- }
- if (!isAuto && setPotentialScroller(this.scrollerEl, scrollerHeight)) {
- compensateScroll(this.headRowEl, getScrollbarWidths(this.scrollerEl));
-
- scrollerHeight = this.computeScrollerHeight(totalHeight);
- this.scrollerEl.height(scrollerHeight);
- this.restoreScroll();
- }
- },
-
- setGridHeight: function(height, isAuto) {
- if (isAuto) {
- undistributeHeight(this.dayGrid.rowEls);
- }
- else {
- distributeHeight(this.dayGrid.rowEls, height, true);
- }
- },
-
-
- renderEvents: function(events) {
- this.dayGrid.renderEvents(events);
- this.updateHeight();
- View.prototype.renderEvents.call(this, events);
- },
-
- getSegs: function() {
- return this.dayGrid.getSegs();
- },
-
- destroyEvents: function() {
- View.prototype.destroyEvents.call(this);
- this.recordScroll();
- this.dayGrid.destroyEvents();
-
-
-
- },
-
-
-
- renderDrag: function(start, end, seg) {
- return this.dayGrid.renderDrag(start, end, seg);
- },
-
- destroyDrag: function() {
- this.dayGrid.destroyDrag();
- },
-
-
- renderSelection: function(start, end) {
- this.dayGrid.renderSelection(start, end);
- },
-
- destroySelection: function() {
- this.dayGrid.destroySelection();
- }
- });
- ;;
- setDefaults({
- fixedWeekCount: true
- });
- fcViews.month = MonthView;
- function MonthView(calendar) {
- BasicView.call(this, calendar);
- }
- MonthView.prototype = createObject(BasicView.prototype);
- $.extend(MonthView.prototype, {
- name: 'month',
- incrementDate: function(date, delta) {
- return date.clone().stripTime().add(delta, 'months').startOf('month');
- },
- render: function(date) {
- var rowCnt;
- this.intervalStart = date.clone().stripTime().startOf('month');
- this.intervalEnd = this.intervalStart.clone().add(1, 'months');
- this.start = this.intervalStart.clone();
- this.start = this.skipHiddenDays(this.start);
- this.start.startOf('week');
- this.start = this.skipHiddenDays(this.start);
- this.end = this.intervalEnd.clone();
- this.end = this.skipHiddenDays(this.end, -1, true);
- this.end.add((7 - this.end.weekday()) % 7, 'days');
- this.end = this.skipHiddenDays(this.end, -1, true);
- rowCnt = Math.ceil(
- this.end.diff(this.start, 'weeks', true)
- );
- if (this.isFixedWeeks()) {
- this.end.add(6 - rowCnt, 'weeks');
- rowCnt = 6;
- }
- var oldTitle = this.title;
- this.title = this.calendar.formatDate(this.intervalStart, this.opt('titleFormat'));
- if( oldTitle !== this.title ) {
- this.trigger( 'changedMonth', this.calendar.getDate() );
- }
- BasicView.prototype.render.call(this, rowCnt, this.getCellsPerWeek(), true);
- },
-
- setGridHeight: function(height, isAuto) {
- isAuto = isAuto || this.opt('weekMode') === 'variable';
-
- if (isAuto) {
- height *= this.rowCnt / 6;
- }
- distributeHeight(this.dayGrid.rowEls, height, !isAuto);
- },
- isFixedWeeks: function() {
- var weekMode = this.opt('weekMode');
- if (weekMode) {
- return weekMode === 'fixed';
- }
- return this.opt('fixedWeekCount');
- }
- });
- ;;
- fcViews.basicWeek = BasicWeekView;
- function BasicWeekView(calendar) {
- BasicView.call(this, calendar);
- }
- BasicWeekView.prototype = createObject(BasicView.prototype);
- $.extend(BasicWeekView.prototype, {
- name: 'basicWeek',
- incrementDate: function(date, delta) {
- return date.clone().stripTime().add(delta, 'weeks').startOf('week');
- },
- render: function(date) {
- this.intervalStart = date.clone().stripTime().startOf('week');
- this.intervalEnd = this.intervalStart.clone().add(1, 'weeks');
- this.start = this.skipHiddenDays(this.intervalStart);
- this.end = this.skipHiddenDays(this.intervalEnd, -1, true);
- this.title = this.calendar.formatRange(
- this.start,
- this.end.clone().subtract(1),
- this.opt('titleFormat'),
- ' \u2014 '
- );
- BasicView.prototype.render.call(this, 1, this.getCellsPerWeek(), false);
- }
-
- });
- ;;
- fcViews.basicDay = BasicDayView;
- function BasicDayView(calendar) {
- BasicView.call(this, calendar);
- }
- BasicDayView.prototype = createObject(BasicView.prototype);
- $.extend(BasicDayView.prototype, {
- name: 'basicDay',
- incrementDate: function(date, delta) {
- var out = date.clone().stripTime().add(delta, 'days');
- out = this.skipHiddenDays(out, delta < 0 ? -1 : 1);
- return out;
- },
- render: function(date) {
- this.start = this.intervalStart = date.clone().stripTime();
- this.end = this.intervalEnd = this.start.clone().add(1, 'days');
- this.title = this.calendar.formatDate(this.start, this.opt('titleFormat'));
- BasicView.prototype.render.call(this, 1, 1, false);
- }
- });
- ;;
- setDefaults({
- allDaySlot: true,
- allDayText: 'all-day',
- scrollTime: '06:00:00',
- slotDuration: '00:30:00',
- axisFormat: generateAgendaAxisFormat,
- timeFormat: {
- agenda: generateAgendaTimeFormat
- },
- minTime: '00:00:00',
- maxTime: '24:00:00',
- slotEventOverlap: true
- });
- var AGENDA_ALL_DAY_EVENT_LIMIT = 5;
- function generateAgendaAxisFormat(options, langData) {
- return langData.longDateFormat('LT')
- .replace(':mm', '(:mm)')
- .replace(/(\Wmm)$/, '($1)')
- .replace(/\s*a$/i, 'a');
- }
- function generateAgendaTimeFormat(options, langData) {
- return langData.longDateFormat('LT')
- .replace(/\s*a$/i, '');
- }
- function AgendaView(calendar) {
- View.call(this, calendar);
- this.timeGrid = new TimeGrid(this);
- if (this.opt('allDaySlot')) {
- this.dayGrid = new DayGrid(this);
-
- this.coordMap = new ComboCoordMap([
- this.dayGrid.coordMap,
- this.timeGrid.coordMap
- ]);
- }
- else {
- this.coordMap = this.timeGrid.coordMap;
- }
- }
- AgendaView.prototype = createObject(View.prototype);
- $.extend(AgendaView.prototype, {
- timeGrid: null,
- dayGrid: null,
- axisWidth: null,
- noScrollRowEls: null,
-
- bottomRuleEl: null,
- bottomRuleHeight: null,
-
-
-
- render: function(colCnt) {
-
- this.rowCnt = 1;
- this.colCnt = colCnt;
- this.el.addClass('fc-agenda-view').html(this.renderHtml());
-
- this.scrollerEl = this.el.find('.fc-time-grid-container');
- this.timeGrid.coordMap.containerEl = this.scrollerEl;
- this.timeGrid.el = this.el.find('.fc-time-grid');
- this.timeGrid.render();
-
- this.bottomRuleEl = $('<hr class="' + this.widgetHeaderClass + '"/>')
- .appendTo(this.timeGrid.el);
- if (this.dayGrid) {
- this.dayGrid.el = this.el.find('.fc-day-grid');
- this.dayGrid.render();
-
- this.dayGrid.bottomCoordPadding = this.dayGrid.el.next('hr').outerHeight();
- }
- this.noScrollRowEls = this.el.find('.fc-row:not(.fc-scroller *)');
- View.prototype.render.call(this);
- this.resetScroll();
- },
-
- destroy: function() {
- this.timeGrid.destroy();
- if (this.dayGrid) {
- this.dayGrid.destroy();
- }
- View.prototype.destroy.call(this);
- },
-
-
- renderHtml: function() {
- return '' +
- '<table>' +
- '<thead>' +
- '<tr>' +
- '<td class="' + this.widgetHeaderClass + '">' +
- this.timeGrid.headHtml() +
- '</td>' +
- '</tr>' +
- '</thead>' +
- '<tbody>' +
- '<tr>' +
- '<td class="' + this.widgetContentClass + '">' +
- (this.dayGrid ?
- '<div class="fc-day-grid"/>' +
- '<hr class="' + this.widgetHeaderClass + '"/>' :
- ''
- ) +
- '<div class="fc-time-grid-container">' +
- '<div class="fc-time-grid"/>' +
- '</div>' +
- '</td>' +
- '</tr>' +
- '</tbody>' +
- '</table>';
- },
-
-
- headIntroHtml: function() {
- var date;
- var weekNumber;
- var weekTitle;
- var weekText;
- if (this.opt('weekNumbers')) {
- date = this.cellToDate(0, 0);
- weekNumber = this.calendar.calculateWeekNumber(date);
- weekTitle = this.opt('weekNumberTitle');
- if (this.opt('isRTL')) {
- weekText = weekNumber + weekTitle;
- }
- else {
- weekText = weekTitle + weekNumber;
- }
- return '' +
- '<th class="fc-axis fc-week-number ' + this.widgetHeaderClass + '" ' + this.axisStyleAttr() + '>' +
- '<span>' +
- htmlEscape(weekText) +
- '</span>' +
- '</th>';
- }
- else {
- return '<th class="fc-axis ' + this.widgetHeaderClass + '" ' + this.axisStyleAttr() + '></th>';
- }
- },
-
-
- dayIntroHtml: function() {
- return '' +
- '<td class="fc-axis ' + this.widgetContentClass + '" ' + this.axisStyleAttr() + '>' +
- '<span>' +
- (this.opt('allDayHtml') || htmlEscape(this.opt('allDayText'))) +
- '</span>' +
- '</td>';
- },
-
- slotBgIntroHtml: function() {
- return '<td class="fc-axis ' + this.widgetContentClass + '" ' + this.axisStyleAttr() + '></td>';
- },
-
-
-
- introHtml: function() {
- return '<td class="fc-axis" ' + this.axisStyleAttr() + '></td>';
- },
-
- axisStyleAttr: function() {
- if (this.axisWidth !== null) {
- return 'style="width:' + this.axisWidth + 'px"';
- }
- return '';
- },
-
- updateSize: function(isResize) {
- if (isResize) {
- this.timeGrid.resize();
- }
- View.prototype.updateSize.call(this, isResize);
- },
-
- updateWidth: function() {
-
- this.axisWidth = matchCellWidths(this.el.find('.fc-axis'));
- },
-
- setHeight: function(totalHeight, isAuto) {
- var eventLimit;
- var scrollerHeight;
- if (this.bottomRuleHeight === null) {
-
- this.bottomRuleHeight = this.bottomRuleEl.outerHeight();
- }
- this.bottomRuleEl.hide();
-
- this.scrollerEl.css('overflow', '');
- unsetScroller(this.scrollerEl);
- uncompensateScroll(this.noScrollRowEls);
-
- if (this.dayGrid) {
- this.dayGrid.destroySegPopover();
- eventLimit = this.opt('eventLimit');
- if (eventLimit && typeof eventLimit !== 'number') {
- eventLimit = AGENDA_ALL_DAY_EVENT_LIMIT;
- }
- if (eventLimit) {
- this.dayGrid.limitRows(eventLimit);
- }
- }
- if (!isAuto) {
- scrollerHeight = this.computeScrollerHeight(totalHeight);
- if (setPotentialScroller(this.scrollerEl, scrollerHeight)) {
-
- compensateScroll(this.noScrollRowEls, getScrollbarWidths(this.scrollerEl));
-
-
- scrollerHeight = this.computeScrollerHeight(totalHeight);
- this.scrollerEl.height(scrollerHeight);
- this.restoreScroll();
- }
- else {
-
- this.scrollerEl.height(scrollerHeight).css('overflow', 'hidden');
- this.bottomRuleEl.show();
- }
- }
- },
-
- resetScroll: function() {
- var _this = this;
- var scrollTime = moment.duration(this.opt('scrollTime'));
- var top = this.timeGrid.computeTimeTop(scrollTime);
-
- top = Math.ceil(top);
- if (top) {
- top++;
- }
- function scroll() {
- _this.scrollerEl.scrollTop(top);
- }
- scroll();
- setTimeout(scroll, 0);
- },
-
-
- renderEvents: function(events) {
- var dayEvents = [];
- var timedEvents = [];
- var daySegs = [];
- var timedSegs;
- var i;
-
- for (i = 0; i < events.length; i++) {
- if (events[i].allDay) {
- dayEvents.push(events[i]);
- }
- else {
- timedEvents.push(events[i]);
- }
- }
-
- timedSegs = this.timeGrid.renderEvents(timedEvents);
- if (this.dayGrid) {
- daySegs = this.dayGrid.renderEvents(dayEvents);
- }
-
- this.updateHeight();
- View.prototype.renderEvents.call(this, events);
- },
-
- getSegs: function() {
- return this.timeGrid.getSegs().concat(
- this.dayGrid ? this.dayGrid.getSegs() : []
- );
- },
-
- destroyEvents: function() {
- View.prototype.destroyEvents.call(this);
-
-
- this.recordScroll();
-
- this.timeGrid.destroyEvents();
- if (this.dayGrid) {
- this.dayGrid.destroyEvents();
- }
-
-
-
- },
-
-
-
- renderDrag: function(start, end, seg) {
- if (start.hasTime()) {
- return this.timeGrid.renderDrag(start, end, seg);
- }
- else if (this.dayGrid) {
- return this.dayGrid.renderDrag(start, end, seg);
- }
- },
-
- destroyDrag: function() {
- this.timeGrid.destroyDrag();
- if (this.dayGrid) {
- this.dayGrid.destroyDrag();
- }
- },
-
-
- renderSelection: function(start, end) {
- if (start.hasTime() || end.hasTime()) {
- this.timeGrid.renderSelection(start, end);
- }
- else if (this.dayGrid) {
- this.dayGrid.renderSelection(start, end);
- }
- },
-
- destroySelection: function() {
- this.timeGrid.destroySelection();
- if (this.dayGrid) {
- this.dayGrid.destroySelection();
- }
- }
- });
- ;;
- fcViews.agendaWeek = AgendaWeekView;
- function AgendaWeekView(calendar) {
- AgendaView.call(this, calendar);
- }
- AgendaWeekView.prototype = createObject(AgendaView.prototype);
- $.extend(AgendaWeekView.prototype, {
- name: 'agendaWeek',
- incrementDate: function(date, delta) {
- return date.clone().stripTime().add(delta, 'weeks').startOf('week');
- },
- render: function(date) {
- this.intervalStart = date.clone().stripTime().startOf('week');
- this.intervalEnd = this.intervalStart.clone().add(1, 'weeks');
- this.start = this.skipHiddenDays(this.intervalStart);
- this.end = this.skipHiddenDays(this.intervalEnd, -1, true);
- this.title = this.calendar.formatRange(
- this.start,
- this.end.clone().subtract(1),
- this.opt('titleFormat'),
- ' \u2014 '
- );
- AgendaView.prototype.render.call(this, this.getCellsPerWeek());
- }
- });
- ;;
- fcViews.agendaDay = AgendaDayView;
- function AgendaDayView(calendar) {
- AgendaView.call(this, calendar);
- }
- AgendaDayView.prototype = createObject(AgendaView.prototype);
- $.extend(AgendaDayView.prototype, {
- name: 'agendaDay',
- incrementDate: function(date, delta) {
- var out = date.clone().stripTime().add(delta, 'days');
- out = this.skipHiddenDays(out, delta < 0 ? -1 : 1);
- return out;
- },
- render: function(date) {
- this.start = this.intervalStart = date.clone().stripTime();
- this.end = this.intervalEnd = this.start.clone().add(1, 'days');
- this.title = this.calendar.formatDate(this.start, this.opt('titleFormat'));
- AgendaView.prototype.render.call(this, 1);
- }
- });
- ;;
- });
|