|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934 |
-
-
- (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',
-
-
-
-
- titleFormat: {
- month: 'MMMM YYYY',
- week: 'll',
- day: 'LL'
- },
- columnFormat: {
- month: 'ddd',
- week: generateWeekColumnFormat,
- day: 'dddd'
- },
- timeFormat: {
- 'default': generateShortTimeFormat
- },
-
-
- isRTL: false,
- buttonText: {
- 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'
- },
-
-
- unselectAuto: true,
-
- dropAccept: '*',
-
- handleWindowResize: true
-
- };
-
-
- 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'
- }
- }
- };
-
-
-
- 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.0.0-beta2" };
- 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 + ']'
- },
- buttonText: {
-
- 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 = rerenderEvents;
- 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.getDate = getDate;
- t.getCalendar = getCalendar;
- t.getView = getView;
- t.option = option;
- t.trigger = trigger;
-
-
-
-
-
-
-
- var langData = createObject(
- moment.langData(options.lang)
- );
-
- if (options.monthNames) {
- langData._months = options.monthNames;
- }
- if (options.monthNamesShort) {
- langData._monthsShort = options.monthNamesShort;
- }
- if (options.dayNames) {
- langData._weekdays = options.dayNames;
- }
- if (options.dayNamesShort) {
- langData._weekdaysShort = options.dayNamesShort;
- }
- if (options.firstDay) {
- var _week = createObject(langData._week);
- _week.dow = options.firstDay;
- langData._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);
- }
- else if (options.timezone === 'UTC') {
- mom = fc.moment.utc.apply(null, arguments);
- }
- else {
- mom = fc.moment.parseZone.apply(null, arguments);
- }
-
- mom._lang = langData;
-
- 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, langData);
- }
-
- return formatRange(m1, m2, formatStr, null, options.isRTL);
- };
-
-
-
- t.formatDate = function(mom, formatStr) {
-
-
- if (typeof formatStr === 'function') {
- formatStr = formatStr.call(t, options, langData);
- }
-
- 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 elementOuterWidth;
- var suggestedViewHeight;
- var resizeUID = 0;
- var ignoreWindowResize = 0;
- var date;
- var events = [];
- var _dragElement;
-
-
-
-
-
-
-
- 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');
- }
-
- content = $("<div class='fc-content' />")
- .prependTo(element);
-
- header = new Header(t, options);
- headerElement = header.render();
- if (headerElement) {
- element.prepend(headerElement);
- }
-
- changeView(options.defaultView);
-
- if (options.handleWindowResize) {
- $(window).resize(windowResize);
- }
-
-
- if (!bodyVisible()) {
- lateRender();
- }
- }
-
-
-
-
- function lateRender() {
- setTimeout(function() {
- if (!currentView.start && bodyVisible()) {
- renderView();
- }
- },0);
- }
-
-
- function destroy() {
-
- if (currentView) {
- trigger('viewDestroy', currentView, currentView, currentView.element);
- currentView.triggerEventDestroy();
- }
-
- $(window).unbind('resize', windowResize);
-
- header.destroy();
- content.remove();
- element.removeClass('fc fc-rtl ui-widget');
- }
-
-
- function elementVisible() {
- return element.is(':visible');
- }
-
-
- function bodyVisible() {
- return $('body').is(':visible');
- }
-
-
-
-
-
-
-
- function changeView(newViewName) {
- if (!currentView || newViewName != currentView.name) {
- _changeView(newViewName);
- }
- }
-
-
- function _changeView(newViewName) {
- ignoreWindowResize++;
-
- if (currentView) {
- trigger('viewDestroy', currentView, currentView, currentView.element);
- unselect();
- currentView.triggerEventDestroy();
- freezeContentHeight();
- currentView.element.remove();
- header.deactivateButton(currentView.name);
- }
-
- header.activateButton(newViewName);
-
- currentView = new fcViews[newViewName](
- $("<div class='fc-view fc-view-" + newViewName + "' />")
- .appendTo(content),
- t
- );
-
- renderView();
- unfreezeContentHeight();
-
- ignoreWindowResize--;
- }
-
-
- function renderView(inc) {
- if (
- !currentView.start ||
- inc ||
- !date.isWithin(currentView.intervalStart, currentView.intervalEnd)
- ) {
- if (elementVisible()) {
- _renderView(inc);
- }
- }
- }
-
-
- function _renderView(inc) {
- ignoreWindowResize++;
-
- if (currentView.start) {
- trigger('viewDestroy', currentView, currentView, currentView.element);
- unselect();
- clearEvents();
- }
-
- freezeContentHeight();
- if (inc) {
- date = currentView.incrementDate(date, inc);
- }
- currentView.render(date.clone());
- setSize();
- unfreezeContentHeight();
- (currentView.afterRender || noop)();
-
- updateTitle();
- updateTodayButton();
-
- trigger('viewRender', currentView, currentView, currentView.element);
-
- ignoreWindowResize--;
-
- getAndRenderEvents();
- }
-
-
-
-
-
-
-
- function updateSize() {
- if (elementVisible()) {
- unselect();
- clearEvents();
- calcSize();
- setSize();
- renderEvents();
- }
- }
-
-
- function calcSize() {
- if (options.contentHeight) {
- suggestedViewHeight = options.contentHeight;
- }
- else if (options.height) {
- suggestedViewHeight = options.height - (headerElement ? headerElement.height() : 0) - vsides(content);
- }
- else {
- suggestedViewHeight = Math.round(content.width() / Math.max(options.aspectRatio, .5));
- }
- }
-
-
- function setSize() {
-
- if (suggestedViewHeight === undefined) {
- calcSize();
-
-
- }
-
- ignoreWindowResize++;
- currentView.setHeight(suggestedViewHeight);
- currentView.setWidth(content.width());
- ignoreWindowResize--;
-
- elementOuterWidth = element.outerWidth();
- }
-
-
- function windowResize() {
- if (!ignoreWindowResize) {
- if (currentView.start) {
- var uid = ++resizeUID;
- setTimeout(function() {
- if (uid == resizeUID && !ignoreWindowResize && elementVisible()) {
- if (elementOuterWidth != (elementOuterWidth = element.outerWidth())) {
- ignoreWindowResize++;
- updateSize();
- currentView.trigger('windowResize', _element);
- ignoreWindowResize--;
- }
- }
- }, 200);
- }else{
-
- lateRender();
- }
- }
- }
-
-
-
-
-
-
-
-
- function refetchEvents() {
- clearEvents();
- fetchAndRenderEvents();
- }
-
-
- function rerenderEvents(modifiedEventID) {
- clearEvents();
- renderEvents(modifiedEventID);
- }
-
-
- function renderEvents(modifiedEventID) {
- if (elementVisible()) {
- currentView.renderEvents(events, modifiedEventID);
- currentView.trigger('eventAfterAllRender');
- }
- }
-
-
- function clearEvents() {
- currentView.triggerEventDestroy();
- currentView.clearEvents();
- currentView.clearEventData();
- }
-
-
- 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(eventID) {
- rerenderEvents(eventID);
- }
-
-
-
-
-
-
-
- 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) {
- currentView.select(start, end);
- }
-
-
- function unselect() {
- if (currentView) {
- currentView.unselect();
- }
- }
-
-
-
-
-
-
-
- function prev() {
- renderView(-1);
- }
-
-
- function next() {
- renderView(1);
- }
-
-
- function prevYear() {
- date.add('years', -1);
- renderView();
- }
-
-
- function nextYear() {
- date.add('years', 1);
- renderView();
- }
-
-
- function today() {
- date = t.getNow();
- renderView();
- }
-
-
- function gotoDate(dateInput) {
- date = t.moment(dateInput);
- renderView();
- }
-
-
- function incrementDate() {
- date.add.apply(date, arguments);
- renderView();
- }
-
-
- 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();
- }
- }
-
-
- function trigger(name, thisObj) {
- if (options[name]) {
- return options[name].apply(
- thisObj || _element,
- Array.prototype.slice.call(arguments, 2)
- );
- }
- }
-
-
-
-
-
-
- if (options.droppable) {
-
- $(document)
- .bind('dragstart', function(ev, ui) {
- var _e = ev.target;
- var e = $(_e);
- if (!e.parents('.fc').length) {
- var accept = options.dropAccept;
- if ($.isFunction(accept) ? accept.call(_e, e) : e.is(accept)) {
- _dragElement = _e;
- currentView.dragStart(_dragElement, ev, ui);
- }
- }
- })
- .bind('dragstop', function(ev, ui) {
- if (_dragElement) {
- currentView.dragStop(_dragElement, ev, ui);
- _dragElement = null;
- }
- });
- }
-
-
- }
-
- ;;
-
- 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;
-
-
-
- var element = $([]);
- var tm;
-
-
-
- function render() {
- tm = options.theme ? 'ui' : 'fc';
- var sections = options.header;
- if (sections) {
- element = $("<table class='fc-header' style='width:100%'/>")
- .append(
- $("<tr/>")
- .append(renderSection('left'))
- .append(renderSection('center'))
- .append(renderSection('right'))
- );
- return element;
- }
- }
-
-
- function destroy() {
- element.remove();
- }
-
-
- function renderSection(position) {
- var e = $("<td class='fc-header-" + position + "'/>");
- var buttonStr = options.header[position];
- if (buttonStr) {
- $.each(buttonStr.split(' '), function(i) {
- if (i > 0) {
- e.append("<span class='fc-header-space'/>");
- }
- var prevButton;
- $.each(this.split(','), function(j, buttonName) {
- if (buttonName == 'title') {
- e.append("<span class='fc-header-title'><h2> </h2></span>");
- if (prevButton) {
- prevButton.addClass(tm + '-corner-right');
- }
- prevButton = null;
- }else{
- var buttonClick;
- if (calendar[buttonName]) {
- buttonClick = calendar[buttonName];
- }
- else if (fcViews[buttonName]) {
- buttonClick = function() {
- button.removeClass(tm + '-state-hover');
- calendar.changeView(buttonName);
- };
- }
- if (buttonClick) {
-
-
- var themeIcon = smartProperty(options.themeButtonIcons, buttonName);
- var normalIcon = smartProperty(options.buttonIcons, buttonName);
- var text = smartProperty(options.buttonText, buttonName);
- var html;
-
- if (themeIcon && options.theme) {
- html = "<span class='ui-icon ui-icon-" + themeIcon + "'></span>";
- }
- else if (normalIcon && !options.theme) {
- html = "<span class='fc-icon fc-icon-" + normalIcon + "'></span>";
- }
- else {
- html = htmlEscape(text || buttonName);
- }
-
- var button = $(
- "<span class='fc-button fc-button-" + buttonName + " " + tm + "-state-default'>" +
- html +
- "</span>"
- )
- .click(function() {
- if (!button.hasClass(tm + '-state-disabled')) {
- buttonClick();
- }
- })
- .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');
- }
- )
- .appendTo(e);
- disableTextSelection(button);
- if (!prevButton) {
- button.addClass(tm + '-corner-left');
- }
- prevButton = button;
- }
- }
- });
- if (prevButton) {
- prevButton.addClass(tm + '-corner-right');
- }
- });
- }
- return e;
- }
-
-
- function updateTitle(html) {
- element.find('h2')
- .html(html);
- }
-
-
- function activateButton(buttonName) {
- element.find('span.fc-button-' + buttonName)
- .addClass(tm + '-state-active');
- }
-
-
- function deactivateButton(buttonName) {
- element.find('span.fc-button-' + buttonName)
- .removeClass(tm + '-state-active');
- }
-
-
- function disableButton(buttonName) {
- element.find('span.fc-button-' + buttonName)
- .addClass(tm + '-state-disabled');
- }
-
-
- function enableButton(buttonName) {
- element.find('span.fc-button-' + buttonName)
- .removeClass(tm + '-state-disabled');
- }
-
-
- }
-
- ;;
-
- 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 = [];
-
-
-
- var _sources = options.eventSources || [];
-
- if (options.events) {
- _sources.push(options.events);
- }
-
- for (var i=0; i<_sources.length; i++) {
- _addEventSource(_sources[i]);
- }
-
-
-
-
-
-
-
- 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) {
- if (fetchID == currentFetchID) {
-
- if (events) {
- for (var i=0; i<events.length; i++) {
- var event = buildEvent(events[i], 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(source) {
- source = _addEventSource(source);
- if (source) {
- pendingSourceCnt++;
- fetchEventSource(source, currentFetchID);
- }
- }
-
-
- function _addEventSource(source) {
- if ($.isFunction(source) || $.isArray(source)) {
- source = { events: source };
- }
- else if (typeof source == 'string') {
- source = { url: source };
- }
- if (typeof source == 'object') {
- normalizeSource(source);
- sources.push(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 updateEvent(event) {
- 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 i;
- if (!filter) {
- cache = [];
-
- for (i=0; i<sources.length; i++) {
- if ($.isArray(sources[i].events)) {
- sources[i].events = [];
- }
- }
- }else{
- if (!$.isFunction(filter)) {
- var id = filter + '';
- filter = function(e) {
- return e._id == id;
- };
- }
- 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) {
- 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;
-
-
- 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
- ));
- }
-
- return mutateEvents(
- clientEvents(event._id),
- clearEnd,
- newAllDay,
- dateDelta,
- durationDelta
- );
- }
-
-
-
-
-
-
-
-
-
-
- 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) {
- newStart.stripZone();
- }
- if (newEnd && (+dateDelta || +durationDelta)) {
- 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 normalizeSource(source) {
- if (source.className) {
-
- if (typeof source.className == 'string') {
- source.className = source.className.split(/\s+/);
- }
- }else{
- source.className = [];
- }
- var normalizers = fc.sourceNormalizers;
- for (var i=0; i<normalizers.length; i++) {
- normalizers[i].call(t, source);
- }
- }
-
-
- function isSourcesEqual(source1, source2) {
- return source1 && source2 && getSourcePrimitive(source1) == getSourcePrimitive(source2);
- }
-
-
- function getSourcePrimitive(source) {
- return ((typeof source == 'object') ? (source.events || source.url) : '') || source;
- }
-
-
- }
-
-
-
- function backupEventDates(event) {
- event._allDay = event.allDay;
- event._start = event.start.clone();
- event._end = event.end ? event.end.clone() : null;
- }
-
- ;;
-
- 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];
- }
- }
- }
-
-
-
-
-
-
- var dayIDs = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
-
-
-
-
- function dayishDiff(d1, d0) {
- return moment.duration({
- days: d1.clone().stripTime().diff(d0.clone().stripTime(), 'days'),
- ms: d1.time() - d0.time()
- });
- }
-
-
- function isNativeDate(input) {
- return Object.prototype.toString.call(input) === '[object Date]' ||
- input instanceof Date;
- }
-
-
-
-
-
-
- function lazySegBind(container, segs, bindHandlers) {
- container.unbind('mouseover').mouseover(function(ev) {
- var parent=ev.target, e,
- i, seg;
- while (parent != this) {
- e = parent;
- parent = parent.parentNode;
- }
- if ((i = e._fci) !== undefined) {
- e._fci = undefined;
- seg = segs[i];
- bindHandlers(seg.event, seg.element, seg);
- $(ev.target).trigger(ev);
- }
- ev.stopPropagation();
- });
- }
-
-
-
-
-
-
- function setOuterWidth(element, width, includeMargins) {
- for (var i=0, e; i<element.length; i++) {
- e = $(element[i]);
- e.width(Math.max(0, width - hsides(e, includeMargins)));
- }
- }
-
-
- function setOuterHeight(element, height, includeMargins) {
- for (var i=0, e; i<element.length; i++) {
- e = $(element[i]);
- e.height(Math.max(0, height - vsides(e, includeMargins)));
- }
- }
-
-
- function hsides(element, includeMargins) {
- return hpadding(element) + hborders(element) + (includeMargins ? hmargins(element) : 0);
- }
-
-
- function hpadding(element) {
- return (parseFloat($.css(element[0], 'paddingLeft', true)) || 0) +
- (parseFloat($.css(element[0], 'paddingRight', true)) || 0);
- }
-
-
- function hmargins(element) {
- return (parseFloat($.css(element[0], 'marginLeft', true)) || 0) +
- (parseFloat($.css(element[0], 'marginRight', true)) || 0);
- }
-
-
- function hborders(element) {
- return (parseFloat($.css(element[0], 'borderLeftWidth', true)) || 0) +
- (parseFloat($.css(element[0], 'borderRightWidth', true)) || 0);
- }
-
-
- function vsides(element, includeMargins) {
- return vpadding(element) + vborders(element) + (includeMargins ? vmargins(element) : 0);
- }
-
-
- function vpadding(element) {
- return (parseFloat($.css(element[0], 'paddingTop', true)) || 0) +
- (parseFloat($.css(element[0], 'paddingBottom', true)) || 0);
- }
-
-
- function vmargins(element) {
- return (parseFloat($.css(element[0], 'marginTop', true)) || 0) +
- (parseFloat($.css(element[0], 'marginBottom', true)) || 0);
- }
-
-
- function vborders(element) {
- return (parseFloat($.css(element[0], 'borderTopWidth', true)) || 0) +
- (parseFloat($.css(element[0], 'borderBottomWidth', true)) || 0);
- }
-
-
-
-
-
-
-
-
-
-
- function noop() { }
-
-
- function dateCompare(a, b) {
- return a - b;
- }
-
-
- function arrayMax(a) {
- return Math.max.apply(Math, a);
- }
-
-
- function smartProperty(obj, name) {
- 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'];
- }
-
-
- 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 disableTextSelection(element) {
- element
- .attr('unselectable', 'on')
- .css('MozUserSelect', 'none')
- .bind('selectstart.ui', function() { return false; });
- }
-
-
-
-
-
- function markFirstLast(e) {
- e.children()
- .removeClass('fc-first fc-last')
- .filter(':first-child')
- .addClass('fc-first')
- .end()
- .filter(':last-child')
- .addClass('fc-last');
- }
-
-
- function getSkinCss(event, opt) {
- var source = event.source || {};
- var eventColor = event.color;
- var sourceColor = source.color;
- var optionColor = opt('eventColor');
- var backgroundColor =
- event.backgroundColor ||
- eventColor ||
- source.backgroundColor ||
- sourceColor ||
- opt('eventBackgroundColor') ||
- optionColor;
- var borderColor =
- event.borderColor ||
- eventColor ||
- source.borderColor ||
- sourceColor ||
- opt('eventBorderColor') ||
- optionColor;
- var textColor =
- event.textColor ||
- source.textColor ||
- 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 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];
- }
- }
- }
-
-
- ;;
-
- 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() {
- return makeMoment(arguments, true);
- };
-
-
-
-
- fc.moment.parseZone = function() {
- return makeMoment(arguments, true, true);
- };
-
-
- function makeMoment(args, parseUTC, parseZone) {
- var input = args[0];
- var isSingleString = args.length == 1 && typeof input === 'string';
- var isAmbigTime = false;
- var isAmbigZone = false;
- var ambigMatch;
- var mom;
-
- if (isSingleString) {
- if (ambigDateOfMonthRegex.test(input)) {
-
- input += '-01';
- isAmbigTime = true;
- isAmbigZone = true;
- }
- else if ((ambigMatch = ambigTimeOrZoneRegex.exec(input))) {
- isAmbigTime = !ambigMatch[5];
- isAmbigZone = true;
- }
- }
- else if ($.isArray(input)) {
-
- isAmbigZone = true;
- }
-
-
- if (parseUTC || parseZone || isAmbigTime) {
- mom = moment.utc.apply(moment, args);
- }
- else {
- mom = moment.apply(null, args);
- }
-
- if (moment.isMoment(input)) {
- transferAmbigs(input, mom);
- }
-
- if (isAmbigTime) {
- mom._ambigTime = true;
- mom._ambigZone = true;
- }
-
- if (parseZone) {
- if (isAmbigZone) {
- mom._ambigZone = true;
- }
- else if (isSingleString) {
- mom.zone(input);
- }
- else if (isNativeDate(input) || input === undefined) {
-
-
-
- mom.local();
- }
- }
-
- return new FCMoment(mom);
- }
-
-
-
-
- function FCMoment(config) {
- extend(this, config);
- }
-
-
- 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);
- }
-
- return this.hours(time.hours() + time.days() * 24)
- .minutes(time.minutes())
- .seconds(time.seconds())
- .milliseconds(time.milliseconds());
- }
- };
-
-
-
-
- FCMoment.prototype.stripTime = function() {
- var a = this.toArray();
-
-
- moment.fn.utc.call(this);
-
- this._ambigTime = true;
- this._ambigZone = true;
-
- this.year(a[0])
- .month(a[1])
- .date(a[2])
- .hours(0)
- .minutes(0)
- .seconds(0)
- .milliseconds(0);
-
- return this;
- };
-
-
- FCMoment.prototype.hasTime = function() {
- return !this._ambigTime;
- };
-
-
-
-
-
-
-
-
- FCMoment.prototype.stripZone = function() {
- var a = this.toArray();
-
-
- moment.fn.utc.call(this);
-
- this._ambigZone = true;
-
- 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.hasZone = function() {
- return !this._ambigZone;
- };
-
-
- FCMoment.prototype.zone = function(tzo) {
- if (tzo != null) {
- delete this._ambigZone;
- }
- return moment.fn.zone.apply(this, arguments);
- };
-
-
-
- FCMoment.prototype.local = function() {
- delete this._ambigZone;
- return moment.fn.local.apply(this, arguments);
- };
-
-
-
- FCMoment.prototype.utc = function() {
- 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];
- };
-
-
- $.each([
- 'isBefore',
- 'isAfter',
- 'isSame'
- ], 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 transferAmbigs(src, dest) {
- if (src._ambigTime) {
- dest._ambigTime = true;
- }
- else if (dest._ambigTime) {
- delete dest._ambigTime;
- }
-
- if (src._ambigZone) {
- dest._ambigZone = true;
- }
- else if (dest._ambigZone) {
- delete dest._ambigZone;
- }
- }
-
-
-
- function commonlyAmbiguate(inputs) {
- var outputs = [];
- var anyAmbigTime = false;
- var anyAmbigZone = false;
- var i;
-
- for (i=0; i<inputs.length; i++) {
- outputs.push(fc.moment(inputs[i]));
- anyAmbigTime = anyAmbigTime || outputs[i]._ambigTime;
- anyAmbigZone = anyAmbigZone || outputs[i]._ambigZone;
- }
-
- for (i=0; i<outputs.length; i++) {
- if (anyAmbigTime) {
- 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) {
-
-
- formatStr = date1.lang().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'
- };
-
-
-
-
-
-
- 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 = /\[([^\]]*)\]|\(([^\)]*)\)|((\w)\4*o?T?)|([^\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;
- }
-
- ;;
-
- fcViews.month = MonthView;
-
- function MonthView(element, calendar) {
- var t = this;
-
-
-
- t.incrementDate = incrementDate;
- t.render = render;
-
-
-
- BasicView.call(t, element, calendar, 'month');
-
-
- function incrementDate(date, delta) {
- return date.clone().stripTime().add('months', delta).startOf('month');
- }
-
-
- function render(date) {
-
- t.intervalStart = date.clone().stripTime().startOf('month');
- t.intervalEnd = t.intervalStart.clone().add('months', 1);
-
- t.start = t.intervalStart.clone().startOf('week');
- t.start = t.skipHiddenDays(t.start);
-
- t.end = t.intervalEnd.clone().add('days', (7 - t.intervalEnd.weekday()) % 7);
- t.end = t.skipHiddenDays(t.end, -1, true);
-
- var rowCnt = Math.ceil(
- t.end.diff(t.start, 'weeks', true)
- );
- if (t.opt('weekMode') == 'fixed') {
- t.end.add('weeks', 6 - rowCnt);
- rowCnt = 6;
- }
-
- t.title = calendar.formatDate(t.intervalStart, t.opt('titleFormat'));
-
- t.renderBasic(rowCnt, t.getCellsPerWeek(), true);
- }
-
-
- }
-
- ;;
-
- fcViews.basicWeek = BasicWeekView;
-
- function BasicWeekView(element, calendar) {
- var t = this;
-
-
-
- t.incrementDate = incrementDate;
- t.render = render;
-
-
-
- BasicView.call(t, element, calendar, 'basicWeek');
-
-
- function incrementDate(date, delta) {
- return date.clone().stripTime().add('weeks', delta).startOf('week');
- }
-
-
- function render(date) {
-
- t.intervalStart = date.clone().stripTime().startOf('week');
- t.intervalEnd = t.intervalStart.clone().add('weeks', 1);
-
- t.start = t.skipHiddenDays(t.intervalStart);
- t.end = t.skipHiddenDays(t.intervalEnd, -1, true);
-
- t.title = calendar.formatRange(
- t.start,
- t.end.clone().subtract(1),
- t.opt('titleFormat'),
- ' \u2014 '
- );
-
- t.renderBasic(1, t.getCellsPerWeek(), false);
- }
-
-
- }
-
- ;;
-
- fcViews.basicDay = BasicDayView;
-
- function BasicDayView(element, calendar) {
- var t = this;
-
-
-
- t.incrementDate = incrementDate;
- t.render = render;
-
-
-
- BasicView.call(t, element, calendar, 'basicDay');
-
-
- function incrementDate(date, delta) {
- var out = date.clone().stripTime().add('days', delta);
- out = t.skipHiddenDays(out, delta < 0 ? -1 : 1);
- return out;
- }
-
-
- function render(date) {
-
- t.start = t.intervalStart = date.clone().stripTime();
- t.end = t.intervalEnd = t.start.clone().add('days', 1);
-
- t.title = calendar.formatDate(t.start, t.opt('titleFormat'));
-
- t.renderBasic(1, 1, false);
- }
-
-
- }
-
- ;;
-
- setDefaults({
- weekMode: 'fixed'
- });
-
-
- function BasicView(element, calendar, viewName) {
- var t = this;
-
-
-
- t.renderBasic = renderBasic;
- t.setHeight = setHeight;
- t.setWidth = setWidth;
- t.renderDayOverlay = renderDayOverlay;
- t.defaultSelectionEnd = defaultSelectionEnd;
- t.renderSelection = renderSelection;
- t.clearSelection = clearSelection;
- t.reportDayClick = reportDayClick;
- t.dragStart = dragStart;
- t.dragStop = dragStop;
- t.getHoverListener = function() { return hoverListener; };
- t.colLeft = colLeft;
- t.colRight = colRight;
- t.colContentLeft = colContentLeft;
- t.colContentRight = colContentRight;
- t.getIsCellAllDay = function() { return true; };
- t.allDayRow = allDayRow;
- t.getRowCnt = function() { return rowCnt; };
- t.getColCnt = function() { return colCnt; };
- t.getColWidth = function() { return colWidth; };
- t.getDaySegmentContainer = function() { return daySegmentContainer; };
-
-
-
- View.call(t, element, calendar, viewName);
- OverlayManager.call(t);
- SelectionManager.call(t);
- BasicEventRenderer.call(t);
- var opt = t.opt;
- var trigger = t.trigger;
- var renderOverlay = t.renderOverlay;
- var clearOverlays = t.clearOverlays;
- var daySelectionMousedown = t.daySelectionMousedown;
- var cellToDate = t.cellToDate;
- var dateToCell = t.dateToCell;
- var rangeToSegments = t.rangeToSegments;
- var formatDate = calendar.formatDate;
- var calculateWeekNumber = calendar.calculateWeekNumber;
-
-
-
-
- var table;
- var head;
- var headCells;
- var body;
- var bodyRows;
- var bodyCells;
- var bodyFirstCells;
- var firstRowCellInners;
- var firstRowCellContentInners;
- var daySegmentContainer;
-
- var viewWidth;
- var viewHeight;
- var colWidth;
- var weekNumberWidth;
-
- var rowCnt, colCnt;
- var showNumbers;
- var coordinateGrid;
- var hoverListener;
- var colPositions;
- var colContentPositions;
-
- var tm;
- var colFormat;
- var showWeekNumbers;
-
-
-
-
-
-
-
- disableTextSelection(element.addClass('fc-grid'));
-
-
- function renderBasic(_rowCnt, _colCnt, _showNumbers) {
- rowCnt = _rowCnt;
- colCnt = _colCnt;
- showNumbers = _showNumbers;
- updateOptions();
-
- if (!body) {
- buildEventContainer();
- }
-
- buildTable();
- }
-
-
- function updateOptions() {
- tm = opt('theme') ? 'ui' : 'fc';
- colFormat = opt('columnFormat');
- showWeekNumbers = opt('weekNumbers');
- }
-
-
- function buildEventContainer() {
- daySegmentContainer =
- $("<div class='fc-event-container' style='position:absolute;z-index:8;top:0;left:0'/>")
- .appendTo(element);
- }
-
-
- function buildTable() {
- var html = buildTableHTML();
-
- if (table) {
- table.remove();
- }
- table = $(html).appendTo(element);
-
- head = table.find('thead');
- headCells = head.find('.fc-day-header');
- body = table.find('tbody');
- bodyRows = body.find('tr');
- bodyCells = body.find('.fc-day');
- bodyFirstCells = bodyRows.find('td:first-child');
-
- firstRowCellInners = bodyRows.eq(0).find('.fc-day > div');
- firstRowCellContentInners = bodyRows.eq(0).find('.fc-day-content > div');
-
- markFirstLast(head.add(head.find('tr')));
- markFirstLast(bodyRows);
- bodyRows.eq(0).addClass('fc-first');
- bodyRows.filter(':last').addClass('fc-last');
-
- bodyCells.each(function(i, _cell) {
- var date = cellToDate(
- Math.floor(i / colCnt),
- i % colCnt
- );
- trigger('dayRender', t, date, $(_cell));
- });
-
- dayBind(bodyCells);
- }
-
-
-
-
-
-
-
- function buildTableHTML() {
- var html =
- "<table class='fc-border-separate' style='width:100%' cellspacing='0'>" +
- buildHeadHTML() +
- buildBodyHTML() +
- "</table>";
-
- return html;
- }
-
-
- function buildHeadHTML() {
- var headerClass = tm + "-widget-header";
- var html = '';
- var col;
- var date;
-
- html += "<thead><tr>";
-
- if (showWeekNumbers) {
- html +=
- "<th class='fc-week-number " + headerClass + "'>" +
- htmlEscape(opt('weekNumberTitle')) +
- "</th>";
- }
-
- for (col=0; col<colCnt; col++) {
- date = cellToDate(0, col);
- html +=
- "<th class='fc-day-header fc-" + dayIDs[date.day()] + " " + headerClass + "'>" +
- htmlEscape(formatDate(date, colFormat)) +
- "</th>";
- }
-
- html += "</tr></thead>";
-
- return html;
- }
-
-
- function buildBodyHTML() {
- var contentClass = tm + "-widget-content";
- var html = '';
- var row;
- var col;
- var date;
-
- html += "<tbody>";
-
- for (row=0; row<rowCnt; row++) {
-
- html += "<tr class='fc-week'>";
-
- if (showWeekNumbers) {
- date = cellToDate(row, 0);
- html +=
- "<td class='fc-week-number " + contentClass + "'>" +
- "<div>" +
- htmlEscape(calculateWeekNumber(date)) +
- "</div>" +
- "</td>";
- }
-
- for (col=0; col<colCnt; col++) {
- date = cellToDate(row, col);
- html += buildCellHTML(date);
- }
-
- html += "</tr>";
- }
-
- html += "</tbody>";
-
- return html;
- }
-
-
- function buildCellHTML(date) {
- var month = t.intervalStart.month();
- var today = calendar.getNow().stripTime();
- var html = '';
- var contentClass = tm + "-widget-content";
- var classNames = [
- 'fc-day',
- 'fc-' + dayIDs[date.day()],
- contentClass
- ];
-
- if (date.month() != month) {
- classNames.push('fc-other-month');
- }
- if (date.isSame(today, 'day')) {
- classNames.push(
- 'fc-today',
- tm + '-state-highlight'
- );
- }
- else if (date < today) {
- classNames.push('fc-past');
- }
- else {
- classNames.push('fc-future');
- }
-
- html +=
- "<td" +
- " class='" + classNames.join(' ') + "'" +
- " data-date='" + date.format() + "'" +
- ">" +
- "<div>";
-
- if (showNumbers) {
- html += "<div class='fc-day-number'>" + date.date() + "</div>";
- }
-
- html +=
- "<div class='fc-day-content'>" +
- "<div style='position:relative'> </div>" +
- "</div>" +
- "</div>" +
- "</td>";
-
- return html;
- }
-
-
-
-
-
-
-
- function setHeight(height) {
- viewHeight = height;
-
- var bodyHeight = Math.max(viewHeight - head.height(), 0);
- var rowHeight;
- var rowHeightLast;
- var cell;
-
- if (opt('weekMode') == 'variable') {
- rowHeight = rowHeightLast = Math.floor(bodyHeight / (rowCnt==1 ? 2 : 6));
- }else{
- rowHeight = Math.floor(bodyHeight / rowCnt);
- rowHeightLast = bodyHeight - rowHeight * (rowCnt-1);
- }
-
- bodyFirstCells.each(function(i, _cell) {
- if (i < rowCnt) {
- cell = $(_cell);
- cell.find('> div').css(
- 'min-height',
- (i==rowCnt-1 ? rowHeightLast : rowHeight) - vsides(cell)
- );
- }
- });
-
- }
-
-
- function setWidth(width) {
- viewWidth = width;
- colPositions.clear();
- colContentPositions.clear();
-
- weekNumberWidth = 0;
- if (showWeekNumbers) {
- weekNumberWidth = head.find('th.fc-week-number').outerWidth();
- }
-
- colWidth = Math.floor((viewWidth - weekNumberWidth) / colCnt);
- setOuterWidth(headCells.slice(0, -1), colWidth);
- }
-
-
-
-
-
-
-
- function dayBind(days) {
- days.click(dayClick)
- .mousedown(daySelectionMousedown);
- }
-
-
- function dayClick(ev) {
- if (!opt('selectable')) {
- var date = calendar.moment($(this).data('date'));
- trigger('dayClick', this, date, ev);
- }
- }
-
-
-
-
-
-
-
-
- function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) {
-
- if (refreshCoordinateGrid) {
- coordinateGrid.build();
- }
-
- var segments = rangeToSegments(overlayStart, overlayEnd);
-
- for (var i=0; i<segments.length; i++) {
- var segment = segments[i];
- dayBind(
- renderCellOverlay(
- segment.row,
- segment.leftCol,
- segment.row,
- segment.rightCol
- )
- );
- }
- }
-
-
- function renderCellOverlay(row0, col0, row1, col1) {
- var rect = coordinateGrid.rect(row0, col0, row1, col1, element);
- return renderOverlay(rect, element);
- }
-
-
-
-
-
-
-
- function defaultSelectionEnd(start) {
- return start.clone().stripTime().add('days', 1);
- }
-
-
- function renderSelection(start, end) {
- renderDayOverlay(start, end, true);
- }
-
-
- function clearSelection() {
- clearOverlays();
- }
-
-
- function reportDayClick(date, ev) {
- var cell = dateToCell(date);
- var _element = bodyCells[cell.row*colCnt + cell.col];
- trigger('dayClick', _element, date, ev);
- }
-
-
-
-
-
-
-
- function dragStart(_dragElement, ev, ui) {
- hoverListener.start(function(cell) {
- clearOverlays();
- if (cell) {
- var d1 = cellToDate(cell);
- var d2 = d1.clone().add(calendar.defaultAllDayEventDuration);
- renderDayOverlay(d1, d2);
- }
- }, ev);
- }
-
-
- function dragStop(_dragElement, ev, ui) {
- var cell = hoverListener.stop();
- clearOverlays();
- if (cell) {
- trigger(
- 'drop',
- _dragElement,
- cellToDate(cell),
- ev,
- ui
- );
- }
- }
-
-
-
-
-
-
-
- coordinateGrid = new CoordinateGrid(function(rows, cols) {
- var e, n, p;
- headCells.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();
- bodyRows.each(function(i, _e) {
- if (i < rowCnt) {
- e = $(_e);
- n = e.offset().top;
- if (i) {
- p[1] = n;
- }
- p = [n];
- rows[i] = p;
- }
- });
- p[1] = n + e.outerHeight();
- });
-
-
- hoverListener = new HoverListener(coordinateGrid);
-
- colPositions = new HorizontalPositionCache(function(col) {
- return firstRowCellInners.eq(col);
- });
-
- colContentPositions = new HorizontalPositionCache(function(col) {
- return firstRowCellContentInners.eq(col);
- });
-
-
- function colLeft(col) {
- return colPositions.left(col);
- }
-
-
- function colRight(col) {
- return colPositions.right(col);
- }
-
-
- function colContentLeft(col) {
- return colContentPositions.left(col);
- }
-
-
- function colContentRight(col) {
- return colContentPositions.right(col);
- }
-
-
- function allDayRow(i) {
- return bodyRows.eq(i);
- }
-
- }
-
- ;;
-
- function BasicEventRenderer() {
- var t = this;
-
-
-
- t.renderEvents = renderEvents;
- t.clearEvents = clearEvents;
-
-
-
- DayEventRenderer.call(t);
-
-
- function renderEvents(events, modifiedEventId) {
- t.renderDayEvents(events, modifiedEventId);
- }
-
-
- function clearEvents() {
- t.getDaySegmentContainer().empty();
- }
-
-
-
-
- }
-
- ;;
-
- fcViews.agendaWeek = AgendaWeekView;
-
- function AgendaWeekView(element, calendar) {
- var t = this;
-
-
-
- t.incrementDate = incrementDate;
- t.render = render;
-
-
-
- AgendaView.call(t, element, calendar, 'agendaWeek');
-
-
- function incrementDate(date, delta) {
- return date.clone().stripTime().add('weeks', delta).startOf('week');
- }
-
-
- function render(date) {
-
- t.intervalStart = date.clone().stripTime().startOf('week');
- t.intervalEnd = t.intervalStart.clone().add('weeks', 1);
-
- t.start = t.skipHiddenDays(t.intervalStart);
- t.end = t.skipHiddenDays(t.intervalEnd, -1, true);
-
- t.title = calendar.formatRange(
- t.start,
- t.end.clone().subtract(1),
- t.opt('titleFormat'),
- ' \u2014 '
- );
-
- t.renderAgenda(t.getCellsPerWeek());
- }
-
-
- }
-
- ;;
-
- fcViews.agendaDay = AgendaDayView;
-
- function AgendaDayView(element, calendar) {
- var t = this;
-
-
-
- t.incrementDate = incrementDate;
- t.render = render;
-
-
-
- AgendaView.call(t, element, calendar, 'agendaDay');
-
-
- function incrementDate(date, delta) {
- var out = date.clone().stripTime().add('days', delta);
- out = t.skipHiddenDays(out, delta < 0 ? -1 : 1);
- return out;
- }
-
-
- function render(date) {
-
- t.start = t.intervalStart = date.clone().stripTime();
- t.end = t.intervalEnd = t.start.clone().add('days', 1);
-
- t.title = calendar.formatDate(t.start, t.opt('titleFormat'));
-
- t.renderAgenda(1);
- }
-
-
- }
-
- ;;
-
- setDefaults({
- allDaySlot: true,
- allDayText: 'all-day',
-
- scrollTime: '06:00:00',
-
- slotDuration: '00:30:00',
-
- axisFormat: generateAgendaAxisFormat,
- timeFormat: {
- agenda: generateAgendaTimeFormat
- },
-
- dragOpacity: {
- agenda: .5
- },
- minTime: '00:00:00',
- maxTime: '24:00:00',
- slotEventOverlap: true
- });
-
-
- 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(element, calendar, viewName) {
- var t = this;
-
-
-
- t.renderAgenda = renderAgenda;
- t.setWidth = setWidth;
- t.setHeight = setHeight;
- t.afterRender = afterRender;
- t.computeDateTop = computeDateTop;
- t.getIsCellAllDay = getIsCellAllDay;
- t.allDayRow = function() { return allDayRow; };
- t.getCoordinateGrid = function() { return coordinateGrid; };
- t.getHoverListener = function() { return hoverListener; };
- t.colLeft = colLeft;
- t.colRight = colRight;
- t.colContentLeft = colContentLeft;
- t.colContentRight = colContentRight;
- t.getDaySegmentContainer = function() { return daySegmentContainer; };
- t.getSlotSegmentContainer = function() { return slotSegmentContainer; };
- t.getSlotContainer = function() { return slotContainer; };
- t.getRowCnt = function() { return 1; };
- t.getColCnt = function() { return colCnt; };
- t.getColWidth = function() { return colWidth; };
- t.getSnapHeight = function() { return snapHeight; };
- t.getSnapDuration = function() { return snapDuration; };
- t.getSlotHeight = function() { return slotHeight; };
- t.getSlotDuration = function() { return slotDuration; };
- t.getMinTime = function() { return minTime; };
- t.getMaxTime = function() { return maxTime; };
- t.defaultSelectionEnd = defaultSelectionEnd;
- t.renderDayOverlay = renderDayOverlay;
- t.renderSelection = renderSelection;
- t.clearSelection = clearSelection;
- t.reportDayClick = reportDayClick;
- t.dragStart = dragStart;
- t.dragStop = dragStop;
-
-
-
- View.call(t, element, calendar, viewName);
- OverlayManager.call(t);
- SelectionManager.call(t);
- AgendaEventRenderer.call(t);
- var opt = t.opt;
- var trigger = t.trigger;
- var renderOverlay = t.renderOverlay;
- var clearOverlays = t.clearOverlays;
- var reportSelection = t.reportSelection;
- var unselect = t.unselect;
- var daySelectionMousedown = t.daySelectionMousedown;
- var slotSegHtml = t.slotSegHtml;
- var cellToDate = t.cellToDate;
- var dateToCell = t.dateToCell;
- var rangeToSegments = t.rangeToSegments;
- var formatDate = calendar.formatDate;
- var calculateWeekNumber = calendar.calculateWeekNumber;
-
-
-
-
- var dayTable;
- var dayHead;
- var dayHeadCells;
- var dayBody;
- var dayBodyCells;
- var dayBodyCellInners;
- var dayBodyCellContentInners;
- var dayBodyFirstCell;
- var dayBodyFirstCellStretcher;
- var slotLayer;
- var daySegmentContainer;
- var allDayTable;
- var allDayRow;
- var slotScroller;
- var slotContainer;
- var slotSegmentContainer;
- var slotTable;
- var selectionHelper;
-
- var viewWidth;
- var viewHeight;
- var axisWidth;
- var colWidth;
- var gutterWidth;
-
- var slotDuration;
- var slotHeight;
-
- var snapDuration;
- var snapRatio;
- var snapHeight;
-
- var colCnt;
- var slotCnt;
- var coordinateGrid;
- var hoverListener;
- var colPositions;
- var colContentPositions;
- var slotTopCache = {};
-
- var tm;
- var rtl;
- var minTime;
- var maxTime;
- var colFormat;
-
-
-
-
-
-
-
- disableTextSelection(element.addClass('fc-agenda'));
-
-
- function renderAgenda(c) {
- colCnt = c;
- updateOptions();
-
- if (!dayTable) {
- buildSkeleton();
- }
- else {
- buildDayTable();
- }
- }
-
-
- function updateOptions() {
-
- tm = opt('theme') ? 'ui' : 'fc';
- rtl = opt('isRTL');
- colFormat = opt('columnFormat');
-
- minTime = moment.duration(opt('minTime'));
- maxTime = moment.duration(opt('maxTime'));
-
- slotDuration = moment.duration(opt('slotDuration'));
- snapDuration = opt('snapDuration');
- snapDuration = snapDuration ? moment.duration(snapDuration) : slotDuration;
- }
-
-
-
-
-
-
-
- function buildSkeleton() {
- var s;
- var headerClass = tm + "-widget-header";
- var contentClass = tm + "-widget-content";
- var slotTime;
- var slotDate;
- var minutes;
- var slotNormal = slotDuration.asMinutes() % 15 === 0;
-
- buildDayTable();
-
- slotLayer =
- $("<div style='position:absolute;z-index:2;left:0;width:100%'/>")
- .appendTo(element);
-
- if (opt('allDaySlot')) {
-
- daySegmentContainer =
- $("<div class='fc-event-container' style='position:absolute;z-index:8;top:0;left:0'/>")
- .appendTo(slotLayer);
-
- s =
- "<table style='width:100%' class='fc-agenda-allday' cellspacing='0'>" +
- "<tr>" +
- "<th class='" + headerClass + " fc-agenda-axis'>" +
- (
- opt('allDayHTML') ||
- htmlEscape(opt('allDayText'))
- ) +
- "</th>" +
- "<td>" +
- "<div class='fc-day-content'><div style='position:relative'/></div>" +
- "</td>" +
- "<th class='" + headerClass + " fc-agenda-gutter'> </th>" +
- "</tr>" +
- "</table>";
- allDayTable = $(s).appendTo(slotLayer);
- allDayRow = allDayTable.find('tr');
-
- dayBind(allDayRow.find('td'));
-
- slotLayer.append(
- "<div class='fc-agenda-divider " + headerClass + "'>" +
- "<div class='fc-agenda-divider-inner'/>" +
- "</div>"
- );
-
- }else{
-
- daySegmentContainer = $([]);
-
- }
-
- slotScroller =
- $("<div style='position:absolute;width:100%;overflow-x:hidden;overflow-y:auto'/>")
- .appendTo(slotLayer);
-
- slotContainer =
- $("<div style='position:relative;width:100%;overflow:hidden'/>")
- .appendTo(slotScroller);
-
- slotSegmentContainer =
- $("<div class='fc-event-container' style='position:absolute;z-index:8;top:0;left:0'/>")
- .appendTo(slotContainer);
-
- s =
- "<table class='fc-agenda-slots' style='width:100%' cellspacing='0'>" +
- "<tbody>";
-
- slotTime = moment.duration(+minTime);
- slotCnt = 0;
- while (slotTime < maxTime) {
- slotDate = t.start.clone().time(slotTime);
- minutes = slotDate.minutes();
- s +=
- "<tr class='fc-slot" + slotCnt + ' ' + (!minutes ? '' : 'fc-minor') + "'>" +
- "<th class='fc-agenda-axis " + headerClass + "'>" +
- ((!slotNormal || !minutes) ?
- htmlEscape(formatDate(slotDate, opt('axisFormat'))) :
- ' '
- ) +
- "</th>" +
- "<td class='" + contentClass + "'>" +
- "<div style='position:relative'> </div>" +
- "</td>" +
- "</tr>";
- slotTime.add(slotDuration);
- slotCnt++;
- }
-
- s +=
- "</tbody>" +
- "</table>";
-
- slotTable = $(s).appendTo(slotContainer);
-
- slotBind(slotTable.find('td'));
- }
-
-
-
-
-
-
-
- function buildDayTable() {
- var html = buildDayTableHTML();
-
- if (dayTable) {
- dayTable.remove();
- }
- dayTable = $(html).appendTo(element);
-
- dayHead = dayTable.find('thead');
- dayHeadCells = dayHead.find('th').slice(1, -1);
- dayBody = dayTable.find('tbody');
- dayBodyCells = dayBody.find('td').slice(0, -1);
- dayBodyCellInners = dayBodyCells.find('> div');
- dayBodyCellContentInners = dayBodyCells.find('.fc-day-content > div');
-
- dayBodyFirstCell = dayBodyCells.eq(0);
- dayBodyFirstCellStretcher = dayBodyCellInners.eq(0);
-
- markFirstLast(dayHead.add(dayHead.find('tr')));
- markFirstLast(dayBody.add(dayBody.find('tr')));
-
-
- }
-
-
- function buildDayTableHTML() {
- var html =
- "<table style='width:100%' class='fc-agenda-days fc-border-separate' cellspacing='0'>" +
- buildDayTableHeadHTML() +
- buildDayTableBodyHTML() +
- "</table>";
-
- return html;
- }
-
-
- function buildDayTableHeadHTML() {
- var headerClass = tm + "-widget-header";
- var date;
- var html = '';
- var weekText;
- var col;
-
- html +=
- "<thead>" +
- "<tr>";
-
- if (opt('weekNumbers')) {
- date = cellToDate(0, 0);
- weekText = calculateWeekNumber(date);
- if (rtl) {
- weekText += opt('weekNumberTitle');
- }
- else {
- weekText = opt('weekNumberTitle') + weekText;
- }
- html +=
- "<th class='fc-agenda-axis fc-week-number " + headerClass + "'>" +
- htmlEscape(weekText) +
- "</th>";
- }
- else {
- html += "<th class='fc-agenda-axis " + headerClass + "'> </th>";
- }
-
- for (col=0; col<colCnt; col++) {
- date = cellToDate(0, col);
- html +=
- "<th class='fc-" + dayIDs[date.day()] + " fc-col" + col + ' ' + headerClass + "'>" +
- htmlEscape(formatDate(date, colFormat)) +
- "</th>";
- }
-
- html +=
- "<th class='fc-agenda-gutter " + headerClass + "'> </th>" +
- "</tr>" +
- "</thead>";
-
- return html;
- }
-
-
- function buildDayTableBodyHTML() {
- var headerClass = tm + "-widget-header";
- var contentClass = tm + "-widget-content";
- var date;
- var today = calendar.getNow().stripTime();
- var col;
- var cellsHTML;
- var cellHTML;
- var classNames;
- var html = '';
-
- html +=
- "<tbody>" +
- "<tr>" +
- "<th class='fc-agenda-axis " + headerClass + "'> </th>";
-
- cellsHTML = '';
-
- for (col=0; col<colCnt; col++) {
-
- date = cellToDate(0, col);
-
- classNames = [
- 'fc-col' + col,
- 'fc-' + dayIDs[date.day()],
- contentClass
- ];
- if (date.isSame(today, 'day')) {
- classNames.push(
- tm + '-state-highlight',
- 'fc-today'
- );
- }
- else if (date < today) {
- classNames.push('fc-past');
- }
- else {
- classNames.push('fc-future');
- }
-
- cellHTML =
- "<td class='" + classNames.join(' ') + "'>" +
- "<div>" +
- "<div class='fc-day-content'>" +
- "<div style='position:relative'> </div>" +
- "</div>" +
- "</div>" +
- "</td>";
-
- cellsHTML += cellHTML;
- }
-
- html += cellsHTML;
- html +=
- "<td class='fc-agenda-gutter " + contentClass + "'> </td>" +
- "</tr>" +
- "</tbody>";
-
- return html;
- }
-
-
-
-
-
-
-
-
-
-
- function setHeight(height) {
- if (height === undefined) {
- height = viewHeight;
- }
- viewHeight = height;
- slotTopCache = {};
-
- var headHeight = dayBody.position().top;
- var allDayHeight = slotScroller.position().top;
- var bodyHeight = Math.min(
- height - headHeight,
- slotTable.height() + allDayHeight + 1
- );
-
- dayBodyFirstCellStretcher
- .height(bodyHeight - vsides(dayBodyFirstCell));
-
- slotLayer.css('top', headHeight);
-
- slotScroller.height(bodyHeight - allDayHeight - 1);
-
-
-
- var slotHeight0 = slotTable.find('tr:first').height() + 1;
- var slotHeight1 = slotTable.find('tr:eq(1)').height();
-
- slotHeight = (slotHeight0 + slotHeight1) / 2;
-
- snapRatio = slotDuration / snapDuration;
- snapHeight = slotHeight / snapRatio;
- }
-
-
- function setWidth(width) {
- viewWidth = width;
- colPositions.clear();
- colContentPositions.clear();
-
- var axisFirstCells = dayHead.find('th:first');
- if (allDayTable) {
- axisFirstCells = axisFirstCells.add(allDayTable.find('th:first'));
- }
- axisFirstCells = axisFirstCells.add(slotTable.find('th:first'));
-
- axisWidth = 0;
- setOuterWidth(
- axisFirstCells
- .width('')
- .each(function(i, _cell) {
- axisWidth = Math.max(axisWidth, $(_cell).outerWidth());
- }),
- axisWidth
- );
-
- var gutterCells = dayTable.find('.fc-agenda-gutter');
- if (allDayTable) {
- gutterCells = gutterCells.add(allDayTable.find('th.fc-agenda-gutter'));
- }
-
- var slotTableWidth = slotScroller[0].clientWidth;
-
- gutterWidth = slotScroller.width() - slotTableWidth;
- if (gutterWidth) {
- setOuterWidth(gutterCells, gutterWidth);
- gutterCells
- .show()
- .prev()
- .removeClass('fc-last');
- }else{
- gutterCells
- .hide()
- .prev()
- .addClass('fc-last');
- }
-
- colWidth = Math.floor((slotTableWidth - axisWidth) / colCnt);
- setOuterWidth(dayHeadCells.slice(0, -1), colWidth);
- }
-
-
-
-
-
-
-
- function resetScroll() {
- var top = computeTimeTop(
- moment.duration(opt('scrollTime'))
- ) + 1;
-
- function scroll() {
- slotScroller.scrollTop(top);
- }
-
- scroll();
- setTimeout(scroll, 0);
- }
-
-
- function afterRender() {
- resetScroll();
- }
-
-
-
-
-
-
-
- function dayBind(cells) {
- cells.click(slotClick)
- .mousedown(daySelectionMousedown);
- }
-
-
- function slotBind(cells) {
- cells.click(slotClick)
- .mousedown(slotSelectionMousedown);
- }
-
-
- function slotClick(ev) {
- if (!opt('selectable')) {
- var col = Math.min(colCnt-1, Math.floor((ev.pageX - dayTable.offset().left - axisWidth) / colWidth));
- var date = cellToDate(0, col);
- var match = this.parentNode.className.match(/fc-slot(\d+)/);
- if (match) {
- var slotIndex = parseInt(match[1]);
- date.add(minTime + slotIndex * slotDuration);
- date = calendar.rezoneDate(date);
- trigger(
- 'dayClick',
- dayBodyCells[col],
- date,
- ev
- );
- }else{
- trigger(
- 'dayClick',
- dayBodyCells[col],
- date,
- ev
- );
- }
- }
- }
-
-
-
-
-
-
-
-
- function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) {
-
- if (refreshCoordinateGrid) {
- coordinateGrid.build();
- }
-
- var segments = rangeToSegments(overlayStart, overlayEnd);
-
- for (var i=0; i<segments.length; i++) {
- var segment = segments[i];
- dayBind(
- renderCellOverlay(
- segment.row,
- segment.leftCol,
- segment.row,
- segment.rightCol
- )
- );
- }
- }
-
-
- function renderCellOverlay(row0, col0, row1, col1) {
- var rect = coordinateGrid.rect(row0, col0, row1, col1, slotLayer);
- return renderOverlay(rect, slotLayer);
- }
-
-
- function renderSlotOverlay(overlayStart, overlayEnd) {
-
-
- overlayStart = overlayStart.clone().stripZone();
- overlayEnd = overlayEnd.clone().stripZone();
-
- for (var i=0; i<colCnt; i++) {
-
- var dayStart = cellToDate(0, i);
- var dayEnd = dayStart.clone().add('days', 1);
-
- var stretchStart = dayStart < overlayStart ? overlayStart : dayStart;
- var stretchEnd = dayEnd < overlayEnd ? dayEnd : overlayEnd;
-
- if (stretchStart < stretchEnd) {
- var rect = coordinateGrid.rect(0, i, 0, i, slotContainer);
- var top = computeDateTop(stretchStart, dayStart);
- var bottom = computeDateTop(stretchEnd, dayStart);
-
- rect.top = top;
- rect.height = bottom - top;
- slotBind(
- renderOverlay(rect, slotContainer)
- );
- }
- }
- }
-
-
-
-
-
-
-
- coordinateGrid = new CoordinateGrid(function(rows, cols) {
- var e, n, p;
- dayHeadCells.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();
- if (opt('allDaySlot')) {
- e = allDayRow;
- n = e.offset().top;
- rows[0] = [n, n+e.outerHeight()];
- }
- var slotTableTop = slotContainer.offset().top;
- var slotScrollerTop = slotScroller.offset().top;
- var slotScrollerBottom = slotScrollerTop + slotScroller.outerHeight();
- function constrain(n) {
- return Math.max(slotScrollerTop, Math.min(slotScrollerBottom, n));
- }
- for (var i=0; i<slotCnt*snapRatio; i++) {
- rows.push([
- constrain(slotTableTop + snapHeight*i),
- constrain(slotTableTop + snapHeight*(i+1))
- ]);
- }
- });
-
-
- hoverListener = new HoverListener(coordinateGrid);
-
- colPositions = new HorizontalPositionCache(function(col) {
- return dayBodyCellInners.eq(col);
- });
-
- colContentPositions = new HorizontalPositionCache(function(col) {
- return dayBodyCellContentInners.eq(col);
- });
-
-
- function colLeft(col) {
- return colPositions.left(col);
- }
-
-
- function colContentLeft(col) {
- return colContentPositions.left(col);
- }
-
-
- function colRight(col) {
- return colPositions.right(col);
- }
-
-
- function colContentRight(col) {
- return colContentPositions.right(col);
- }
-
-
- function getIsCellAllDay(cell) {
- return opt('allDaySlot') && !cell.row;
- }
-
-
- function realCellToDate(cell) {
- var date = cellToDate(0, cell.col);
- var slotIndex = cell.row;
-
- if (opt('allDaySlot')) {
- slotIndex--;
- }
-
- if (slotIndex >= 0) {
- date.time(moment.duration(minTime + slotIndex * slotDuration));
- date = calendar.rezoneDate(date);
- }
-
- return date;
- }
-
-
- function computeDateTop(date, startOfDayDate) {
- return computeTimeTop(
- moment.duration(
- date.clone().stripZone() - startOfDayDate.clone().stripTime()
- )
- );
- }
-
-
- function computeTimeTop(time) {
-
- if (time < minTime) {
- return 0;
- }
- if (time >= maxTime) {
- return slotTable.height();
- }
-
- var slots = (time - minTime) / slotDuration;
- var slotIndex = Math.floor(slots);
- var slotPartial = slots - slotIndex;
- var slotTop = slotTopCache[slotIndex];
-
-
-
- if (slotTop === undefined) {
- slotTop = slotTopCache[slotIndex] =
- slotTable.find('tr').eq(slotIndex).find('td div')[0].offsetTop;
-
-
-
- }
-
- var top =
- slotTop - 1 +
- slotPartial * slotHeight;
-
- top = Math.max(top, 0);
-
- return top;
- }
-
-
-
-
-
-
-
- function defaultSelectionEnd(start) {
- if (start.hasTime()) {
- return start.clone().add(slotDuration);
- }
- else {
- return start.clone().add('days', 1);
- }
- }
-
-
- function renderSelection(start, end) {
- if (start.hasTime() || end.hasTime()) {
- renderSlotSelection(start, end);
- }
- else if (opt('allDaySlot')) {
- renderDayOverlay(start, end, true);
- }
- }
-
-
- function renderSlotSelection(startDate, endDate) {
- var helperOption = opt('selectHelper');
- coordinateGrid.build();
- if (helperOption) {
- var col = dateToCell(startDate).col;
- if (col >= 0 && col < colCnt) {
- var rect = coordinateGrid.rect(0, col, 0, col, slotContainer);
- var top = computeDateTop(startDate, startDate);
- var bottom = computeDateTop(endDate, startDate);
- if (bottom > top) {
- rect.top = top;
- rect.height = bottom - top;
- rect.left += 2;
- rect.width -= 5;
- if ($.isFunction(helperOption)) {
- var helperRes = helperOption(startDate, endDate);
- if (helperRes) {
- rect.position = 'absolute';
- selectionHelper = $(helperRes)
- .css(rect)
- .appendTo(slotContainer);
- }
- }else{
- rect.isStart = true;
- rect.isEnd = true;
- selectionHelper = $(slotSegHtml(
- {
- title: '',
- start: startDate,
- end: endDate,
- className: ['fc-select-helper'],
- editable: false
- },
- rect
- ));
- selectionHelper.css('opacity', opt('dragOpacity'));
- }
- if (selectionHelper) {
- slotBind(selectionHelper);
- slotContainer.append(selectionHelper);
- setOuterWidth(selectionHelper, rect.width, true);
- setOuterHeight(selectionHelper, rect.height, true);
- }
- }
- }
- }else{
- renderSlotOverlay(startDate, endDate);
- }
- }
-
-
- function clearSelection() {
- clearOverlays();
- if (selectionHelper) {
- selectionHelper.remove();
- selectionHelper = null;
- }
- }
-
-
- function slotSelectionMousedown(ev) {
- if (ev.which == 1 && opt('selectable')) {
- unselect(ev);
- var dates;
- hoverListener.start(function(cell, origCell) {
- clearSelection();
- if (cell && cell.col == origCell.col && !getIsCellAllDay(cell)) {
- var d1 = realCellToDate(origCell);
- var d2 = realCellToDate(cell);
- dates = [
- d1,
- d1.clone().add(snapDuration),
- d2,
- d2.clone().add(snapDuration)
- ].sort(dateCompare);
- renderSlotSelection(dates[0], dates[3]);
- }else{
- dates = null;
- }
- }, ev);
- $(document).one('mouseup', function(ev) {
- hoverListener.stop();
- if (dates) {
- if (+dates[0] == +dates[1]) {
- reportDayClick(dates[0], ev);
- }
- reportSelection(dates[0], dates[3], ev);
- }
- });
- }
- }
-
-
- function reportDayClick(date, ev) {
- trigger('dayClick', dayBodyCells[dateToCell(date).col], date, ev);
- }
-
-
-
-
-
-
-
- function dragStart(_dragElement, ev, ui) {
- hoverListener.start(function(cell) {
- clearOverlays();
- if (cell) {
- var d1 = realCellToDate(cell);
- var d2 = d1.clone();
- if (d1.hasTime()) {
- d2.add(calendar.defaultTimedEventDuration);
- renderSlotOverlay(d1, d2);
- }
- else {
- d2.add(calendar.defaultAllDayEventDuration);
- renderDayOverlay(d1, d2);
- }
- }
- }, ev);
- }
-
-
- function dragStop(_dragElement, ev, ui) {
- var cell = hoverListener.stop();
- clearOverlays();
- if (cell) {
- trigger(
- 'drop',
- _dragElement,
- realCellToDate(cell),
- ev,
- ui
- );
- }
- }
-
-
- }
-
- ;;
-
- function AgendaEventRenderer() {
- var t = this;
-
-
-
- t.renderEvents = renderEvents;
- t.clearEvents = clearEvents;
- t.slotSegHtml = slotSegHtml;
-
-
-
- DayEventRenderer.call(t);
- var opt = t.opt;
- var trigger = t.trigger;
- var isEventDraggable = t.isEventDraggable;
- var isEventResizable = t.isEventResizable;
- var eventElementHandlers = t.eventElementHandlers;
- var setHeight = t.setHeight;
- var getDaySegmentContainer = t.getDaySegmentContainer;
- var getSlotSegmentContainer = t.getSlotSegmentContainer;
- var getHoverListener = t.getHoverListener;
- var computeDateTop = t.computeDateTop;
- var getIsCellAllDay = t.getIsCellAllDay;
- var colContentLeft = t.colContentLeft;
- var colContentRight = t.colContentRight;
- var cellToDate = t.cellToDate;
- var getColCnt = t.getColCnt;
- var getColWidth = t.getColWidth;
- var getSnapHeight = t.getSnapHeight;
- var getSnapDuration = t.getSnapDuration;
- var getSlotHeight = t.getSlotHeight;
- var getSlotDuration = t.getSlotDuration;
- var getSlotContainer = t.getSlotContainer;
- var reportEventElement = t.reportEventElement;
- var showEvents = t.showEvents;
- var hideEvents = t.hideEvents;
- var eventDrop = t.eventDrop;
- var eventResize = t.eventResize;
- var renderDayOverlay = t.renderDayOverlay;
- var clearOverlays = t.clearOverlays;
- var renderDayEvents = t.renderDayEvents;
- var getMinTime = t.getMinTime;
- var getMaxTime = t.getMaxTime;
- var calendar = t.calendar;
- var formatDate = calendar.formatDate;
- var formatRange = calendar.formatRange;
- var getEventEnd = calendar.getEventEnd;
-
-
-
- t.draggableDayEvent = draggableDayEvent;
-
-
-
-
-
-
-
- function renderEvents(events, modifiedEventId) {
- var i, len=events.length,
- dayEvents=[],
- slotEvents=[];
- for (i=0; i<len; i++) {
- if (events[i].allDay) {
- dayEvents.push(events[i]);
- }else{
- slotEvents.push(events[i]);
- }
- }
-
- if (opt('allDaySlot')) {
- renderDayEvents(dayEvents, modifiedEventId);
- setHeight();
- }
-
- renderSlotSegs(compileSlotSegs(slotEvents), modifiedEventId);
- }
-
-
- function clearEvents() {
- getDaySegmentContainer().empty();
- getSlotSegmentContainer().empty();
- }
-
-
- function compileSlotSegs(events) {
- var colCnt = getColCnt(),
- minTime = getMinTime(),
- maxTime = getMaxTime(),
- cellDate,
- i,
- j, seg,
- colSegs,
- segs = [];
-
- for (i=0; i<colCnt; i++) {
- cellDate = cellToDate(0, i);
-
- colSegs = sliceSegs(
- events,
- cellDate.clone().time(minTime),
- cellDate.clone().time(maxTime)
- );
-
- colSegs = placeSlotSegs(colSegs);
-
- for (j=0; j<colSegs.length; j++) {
- seg = colSegs[j];
- seg.col = i;
- segs.push(seg);
- }
- }
-
- return segs;
- }
-
-
- function sliceSegs(events, rangeStart, rangeEnd) {
-
-
- rangeStart = rangeStart.clone().stripZone();
- rangeEnd = rangeEnd.clone().stripZone();
-
- var segs = [],
- i, len=events.length, event,
- eventStart, eventEnd,
- segStart, segEnd,
- isStart, isEnd;
- for (i=0; i<len; i++) {
-
- event = events[i];
-
-
- eventStart = event.start.clone().stripZone();
- eventEnd = getEventEnd(event).stripZone();
-
- if (eventEnd > rangeStart && eventStart < rangeEnd) {
-
- if (eventStart < rangeStart) {
- segStart = rangeStart.clone();
- isStart = false;
- }
- else {
- segStart = eventStart;
- isStart = true;
- }
-
- if (eventEnd > rangeEnd) {
- segEnd = rangeEnd.clone();
- isEnd = false;
- }
- else {
- segEnd = eventEnd;
- isEnd = true;
- }
-
- segs.push({
- event: event,
- start: segStart,
- end: segEnd,
- isStart: isStart,
- isEnd: isEnd
- });
- }
- }
-
- return segs.sort(compareSlotSegs);
- }
-
-
-
-
-
-
- function renderSlotSegs(segs, modifiedEventId) {
-
- var i, segCnt=segs.length, seg,
- event,
- top,
- bottom,
- columnLeft,
- columnRight,
- columnWidth,
- width,
- left,
- right,
- html = '',
- eventElements,
- eventElement,
- triggerRes,
- titleElement,
- height,
- slotSegmentContainer = getSlotSegmentContainer(),
- isRTL = opt('isRTL');
-
-
- for (i=0; i<segCnt; i++) {
- seg = segs[i];
- event = seg.event;
- top = computeDateTop(seg.start, seg.start);
- bottom = computeDateTop(seg.end, seg.start);
- columnLeft = colContentLeft(seg.col);
- columnRight = colContentRight(seg.col);
- columnWidth = columnRight - columnLeft;
-
-
-
- columnRight -= columnWidth * .025;
- columnWidth = columnRight - columnLeft;
-
- width = columnWidth * (seg.forwardCoord - seg.backwardCoord);
-
- if (opt('slotEventOverlap')) {
-
-
- width = Math.max(
- (width - (20/2)) * 2,
- width
-
- );
- }
-
- if (isRTL) {
- right = columnRight - seg.backwardCoord * columnWidth;
- left = right - width;
- }
- else {
- left = columnLeft + seg.backwardCoord * columnWidth;
- right = left + width;
- }
-
-
- left = Math.max(left, columnLeft);
- right = Math.min(right, columnRight);
- width = right - left;
-
- seg.top = top;
- seg.left = left;
- seg.outerWidth = width;
- seg.outerHeight = bottom - top;
- html += slotSegHtml(event, seg);
- }
-
- slotSegmentContainer[0].innerHTML = html;
- eventElements = slotSegmentContainer.children();
-
-
- for (i=0; i<segCnt; i++) {
- seg = segs[i];
- event = seg.event;
- eventElement = $(eventElements[i]);
- triggerRes = trigger('eventRender', event, event, eventElement);
- if (triggerRes === false) {
- eventElement.remove();
- }else{
- if (triggerRes && triggerRes !== true) {
- eventElement.remove();
- eventElement = $(triggerRes)
- .css({
- position: 'absolute',
- top: seg.top,
- left: seg.left
- })
- .appendTo(slotSegmentContainer);
- }
- seg.element = eventElement;
- if (event._id === modifiedEventId) {
- bindSlotSeg(event, eventElement, seg);
- }else{
- eventElement[0]._fci = i;
- }
- reportEventElement(event, eventElement);
- }
- }
-
- lazySegBind(slotSegmentContainer, segs, bindSlotSeg);
-
-
- for (i=0; i<segCnt; i++) {
- seg = segs[i];
- if ((eventElement = seg.element)) {
- seg.vsides = vsides(eventElement, true);
- seg.hsides = hsides(eventElement, true);
- titleElement = eventElement.find('.fc-event-title');
- if (titleElement.length) {
- seg.contentTop = titleElement[0].offsetTop;
- }
- }
- }
-
-
- for (i=0; i<segCnt; i++) {
- seg = segs[i];
- if ((eventElement = seg.element)) {
- eventElement[0].style.width = Math.max(0, seg.outerWidth - seg.hsides) + 'px';
- height = Math.max(0, seg.outerHeight - seg.vsides);
- eventElement[0].style.height = height + 'px';
- event = seg.event;
- if (seg.contentTop !== undefined && height - seg.contentTop < 10) {
-
- eventElement.find('div.fc-event-time')
- .text(
- formatDate(event.start, opt('timeFormat')) + ' - ' + event.title
- );
- eventElement.find('div.fc-event-title')
- .remove();
- }
- trigger('eventAfterRender', event, event, eventElement);
- }
- }
-
- }
-
-
- function slotSegHtml(event, seg) {
- var html = "<";
- var url = event.url;
- var skinCss = getSkinCss(event, opt);
- var classes = ['fc-event', 'fc-event-vert'];
- if (isEventDraggable(event)) {
- classes.push('fc-event-draggable');
- }
- if (seg.isStart) {
- classes.push('fc-event-start');
- }
- if (seg.isEnd) {
- classes.push('fc-event-end');
- }
- classes = classes.concat(event.className);
- if (event.source) {
- classes = classes.concat(event.source.className || []);
- }
- if (url) {
- html += "a href='" + htmlEscape(event.url) + "'";
- }else{
- html += "div";
- }
-
- html +=
- " class='" + classes.join(' ') + "'" +
- " style=" +
- "'" +
- "position:absolute;" +
- "top:" + seg.top + "px;" +
- "left:" + seg.left + "px;" +
- skinCss +
- "'" +
- ">" +
- "<div class='fc-event-inner'>" +
- "<div class='fc-event-time'>";
-
- if (event.end) {
- html += htmlEscape(formatRange(event.start, event.end, opt('timeFormat')));
- }else{
- html += htmlEscape(formatDate(event.start, opt('timeFormat')));
- }
-
- html +=
- "</div>" +
- "<div class='fc-event-title'>" +
- htmlEscape(event.title || '') +
- "</div>" +
- "</div>" +
- "<div class='fc-event-bg'></div>";
-
- if (seg.isEnd && isEventResizable(event)) {
- html +=
- "<div class='ui-resizable-handle ui-resizable-s'>=</div>";
- }
- html +=
- "</" + (url ? "a" : "div") + ">";
- return html;
- }
-
-
- function bindSlotSeg(event, eventElement, seg) {
- var timeElement = eventElement.find('div.fc-event-time');
- if (isEventDraggable(event)) {
- draggableSlotEvent(event, eventElement, timeElement);
- }
- if (seg.isEnd && isEventResizable(event)) {
- resizableSlotEvent(event, eventElement, timeElement);
- }
- eventElementHandlers(event, eventElement);
- }
-
-
-
-
-
-
-
-
-
-
-
- function draggableDayEvent(event, eventElement, seg) {
- var isStart = seg.isStart;
- var origWidth;
- var revert;
- var allDay = true;
- var dayDelta;
-
- var hoverListener = getHoverListener();
- var colWidth = getColWidth();
- var minTime = getMinTime();
- var slotDuration = getSlotDuration();
- var slotHeight = getSlotHeight();
- var snapDuration = getSnapDuration();
- var snapHeight = getSnapHeight();
-
- eventElement.draggable({
- opacity: opt('dragOpacity', 'month'),
- revertDuration: opt('dragRevertDuration'),
- start: function(ev, ui) {
-
- trigger('eventDragStart', eventElement, event, ev, ui);
- hideEvents(event, eventElement);
- origWidth = eventElement.width();
-
- hoverListener.start(function(cell, origCell) {
- clearOverlays();
- if (cell) {
- revert = false;
-
- var origDate = cellToDate(0, origCell.col);
- var date = cellToDate(0, cell.col);
- dayDelta = date.diff(origDate, 'days');
-
- if (!cell.row) {
-
- renderDayOverlay(
- event.start.clone().add('days', dayDelta),
- getEventEnd(event).add('days', dayDelta)
- );
-
- resetElement();
- }
- else {
-
- if (isStart) {
- if (allDay) {
-
- eventElement.width(colWidth - 10);
- setOuterHeight(eventElement, calendar.defaultTimedEventDuration / slotDuration * slotHeight);
- eventElement.draggable('option', 'grid', [ colWidth, 1 ]);
- allDay = false;
- }
- }
- else {
- revert = true;
- }
- }
-
- revert = revert || (allDay && !dayDelta);
- }
- else {
- resetElement();
- revert = true;
- }
-
- eventElement.draggable('option', 'revert', revert);
-
- }, ev, 'drag');
- },
- stop: function(ev, ui) {
- hoverListener.stop();
- clearOverlays();
- trigger('eventDragStop', eventElement, event, ev, ui);
-
- if (revert) {
-
- resetElement();
- eventElement.css('filter', '');
- showEvents(event, eventElement);
- }
- else {
-
- var eventStart = event.start.clone().add('days', dayDelta);
- var snapTime;
- var snapIndex;
- if (!allDay) {
- snapIndex = Math.round((eventElement.offset().top - getSlotContainer().offset().top) / snapHeight);
- snapTime = moment.duration(minTime + snapIndex * snapDuration);
- eventStart = calendar.rezoneDate(eventStart.clone().time(snapTime));
- }
-
- eventDrop(
- this,
- event,
- eventStart,
- ev,
- ui
- );
- }
- }
- });
- function resetElement() {
- if (!allDay) {
- eventElement
- .width(origWidth)
- .height('')
- .draggable('option', 'grid', null);
- allDay = true;
- }
- }
- }
-
-
-
-
- function draggableSlotEvent(event, eventElement, timeElement) {
- var coordinateGrid = t.getCoordinateGrid();
- var colCnt = getColCnt();
- var colWidth = getColWidth();
- var snapHeight = getSnapHeight();
- var snapDuration = getSnapDuration();
-
-
- var origPosition;
- var origCell;
- var isInBounds, prevIsInBounds;
- var isAllDay, prevIsAllDay;
- var colDelta, prevColDelta;
- var dayDelta;
- var snapDelta, prevSnapDelta;
-
-
- var eventStart, eventEnd;
-
- eventElement.draggable({
- scroll: false,
- grid: [ colWidth, snapHeight ],
- axis: colCnt==1 ? 'y' : false,
- opacity: opt('dragOpacity'),
- revertDuration: opt('dragRevertDuration'),
- start: function(ev, ui) {
-
- trigger('eventDragStart', eventElement, event, ev, ui);
- hideEvents(event, eventElement);
-
- coordinateGrid.build();
-
-
- origPosition = eventElement.position();
- origCell = coordinateGrid.cell(ev.pageX, ev.pageY);
- isInBounds = prevIsInBounds = true;
- isAllDay = prevIsAllDay = getIsCellAllDay(origCell);
- colDelta = prevColDelta = 0;
- dayDelta = 0;
- snapDelta = prevSnapDelta = 0;
-
- eventStart = null;
- eventEnd = null;
- },
- drag: function(ev, ui) {
-
-
-
-
-
-
-
- var cell = coordinateGrid.cell(ev.pageX, ev.pageY);
-
-
- isInBounds = !!cell;
- if (isInBounds) {
- isAllDay = getIsCellAllDay(cell);
-
-
- colDelta = Math.round((ui.position.left - origPosition.left) / colWidth);
- if (colDelta != prevColDelta) {
-
- var origDate = cellToDate(0, origCell.col);
- var col = origCell.col + colDelta;
- col = Math.max(0, col);
- col = Math.min(colCnt-1, col);
- var date = cellToDate(0, col);
- dayDelta = date.diff(origDate, 'days');
- }
-
-
- if (!isAllDay) {
- snapDelta = Math.round((ui.position.top - origPosition.top) / snapHeight);
- }
- }
-
-
- if (
- isInBounds != prevIsInBounds ||
- isAllDay != prevIsAllDay ||
- colDelta != prevColDelta ||
- snapDelta != prevSnapDelta
- ) {
-
-
- if (isAllDay) {
- eventStart = event.start.clone().stripTime().add('days', dayDelta);
- eventEnd = eventStart.clone().add(calendar.defaultAllDayEventDuration);
- }
- else {
- eventStart = event.start.clone().add(snapDelta * snapDuration).add('days', dayDelta);
- eventEnd = getEventEnd(event).add(snapDelta * snapDuration).add('days', dayDelta);
- }
-
- updateUI();
-
-
- prevIsInBounds = isInBounds;
- prevIsAllDay = isAllDay;
- prevColDelta = colDelta;
- prevSnapDelta = snapDelta;
- }
-
-
- eventElement.draggable('option', 'revert', !isInBounds);
-
- },
- stop: function(ev, ui) {
-
- clearOverlays();
- trigger('eventDragStop', eventElement, event, ev, ui);
-
- if (isInBounds && (isAllDay || dayDelta || snapDelta)) {
- eventDrop(
- this,
- event,
- eventStart,
- ev,
- ui
- );
- }
- else {
-
-
- isInBounds = true;
- isAllDay = false;
- colDelta = 0;
- dayDelta = 0;
- snapDelta = 0;
-
- updateUI();
- eventElement.css('filter', '');
-
-
-
-
- eventElement.css(origPosition);
-
- showEvents(event, eventElement);
- }
- }
- });
-
- function updateUI() {
- clearOverlays();
- if (isInBounds) {
- if (isAllDay) {
- timeElement.hide();
- eventElement.draggable('option', 'grid', null);
- renderDayOverlay(eventStart, eventEnd);
- }
- else {
- updateTimeText();
- timeElement.css('display', '');
- eventElement.draggable('option', 'grid', [colWidth, snapHeight]);
- }
- }
- }
-
- function updateTimeText() {
- var text;
- if (eventStart) {
- if (event.end) {
- text = formatRange(eventStart, eventEnd, opt('timeFormat'));
- }
- else {
- text = formatDate(eventStart, opt('timeFormat'));
- }
- timeElement.text(text);
- }
- }
-
- }
-
-
-
-
-
-
-
- function resizableSlotEvent(event, eventElement, timeElement) {
- var snapDelta, prevSnapDelta;
- var snapHeight = getSnapHeight();
- var snapDuration = getSnapDuration();
- var eventEnd;
-
- eventElement.resizable({
- handles: {
- s: '.ui-resizable-handle'
- },
- grid: snapHeight,
- start: function(ev, ui) {
- snapDelta = prevSnapDelta = 0;
- hideEvents(event, eventElement);
- trigger('eventResizeStart', this, event, ev, ui);
- },
- resize: function(ev, ui) {
-
- snapDelta = Math.round((Math.max(snapHeight, eventElement.height()) - ui.originalSize.height) / snapHeight);
- if (snapDelta != prevSnapDelta) {
- eventEnd = getEventEnd(event).add(snapDuration * snapDelta);
- var text;
- if (snapDelta || event.end) {
- text = formatRange(
- event.start,
- eventEnd,
- opt('timeFormat')
- );
- }
- else {
- text = formatDate(event.start, opt('timeFormat'));
- }
- timeElement.text(text);
- prevSnapDelta = snapDelta;
- }
- },
- stop: function(ev, ui) {
- trigger('eventResizeStop', this, event, ev, ui);
- if (snapDelta) {
- eventResize(
- this,
- event,
- eventEnd,
- ev,
- ui
- );
- }
- else {
- showEvents(event, eventElement);
-
- }
- }
- });
- }
-
-
- }
-
-
-
-
-
-
-
-
- function placeSlotSegs(segs) {
- var levels = buildSlotSegLevels(segs);
- var level0 = levels[0];
- var i;
-
- computeForwardSlotSegs(levels);
-
- if (level0) {
-
- for (i=0; i<level0.length; i++) {
- computeSlotSegPressures(level0[i]);
- }
-
- for (i=0; i<level0.length; i++) {
- computeSlotSegCoords(level0[i], 0, 0);
- }
- }
-
- return flattenSlotSegLevels(levels);
- }
-
-
-
-
- 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;
- }
- }
-
- (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 flattenSlotSegLevels(levels) {
- var segs = [];
- var i, level;
- var j;
-
- for (i=0; i<levels.length; i++) {
- level = levels[i];
-
- for (j=0; j<level.length; j++) {
- segs.push(level[j]);
- }
- }
-
- return segs;
- }
-
-
-
-
- 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.end > seg2.start && seg1.start < seg2.end;
- }
-
-
-
- function compareForwardSlotSegs(seg1, seg2) {
-
- return seg2.forwardPressure - seg1.forwardPressure ||
-
- (seg1.backwardCoord || 0) - (seg2.backwardCoord || 0) ||
-
- compareSlotSegs(seg1, seg2);
- }
-
-
-
-
- function compareSlotSegs(seg1, seg2) {
- return seg1.start - seg2.start ||
- (seg2.end - seg2.start) - (seg1.end - seg1.start) ||
- (seg1.event.title || '').localeCompare(seg2.event.title);
- }
-
-
- ;;
-
-
- function View(element, calendar, viewName) {
- var t = this;
-
-
-
- t.element = element;
- t.calendar = calendar;
- t.name = viewName;
- t.opt = opt;
- t.trigger = trigger;
- t.isEventDraggable = isEventDraggable;
- t.isEventResizable = isEventResizable;
- t.clearEventData = clearEventData;
- t.reportEventElement = reportEventElement;
- t.triggerEventDestroy = triggerEventDestroy;
- t.eventElementHandlers = eventElementHandlers;
- t.showEvents = showEvents;
- t.hideEvents = hideEvents;
- t.eventDrop = eventDrop;
- t.eventResize = eventResize;
-
-
-
-
-
- var reportEventChange = calendar.reportEventChange;
-
-
-
- var eventElementsByID = {};
- var eventElementCouples = [];
- var options = calendar.options;
- var nextDayThreshold = moment.duration(options.nextDayThreshold);
-
-
-
-
- function opt(name, viewNameOverride) {
- var v = options[name];
- if ($.isPlainObject(v) && !isForcedAtomicOption(name)) {
- return smartProperty(v, viewNameOverride || viewName);
- }
- 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')
- );
- }
-
-
-
-
-
-
-
- function clearEventData() {
- eventElementsByID = {};
- eventElementCouples = [];
- }
-
-
-
-
-
-
-
-
- function reportEventElement(event, element) {
- eventElementCouples.push({ event: event, element: element });
- if (eventElementsByID[event._id]) {
- eventElementsByID[event._id].push(element);
- }else{
- eventElementsByID[event._id] = [element];
- }
- }
-
-
- function triggerEventDestroy() {
- $.each(eventElementCouples, function(i, couple) {
- t.trigger('eventDestroy', couple.event, couple.event, couple.element);
- });
- }
-
-
-
- function eventElementHandlers(event, eventElement) {
- eventElement
- .click(function(ev) {
- if (!eventElement.hasClass('ui-draggable-dragging') &&
- !eventElement.hasClass('ui-resizable-resizing')) {
- return trigger('eventClick', this, event, ev);
- }
- })
- .hover(
- function(ev) {
- trigger('eventMouseover', this, event, ev);
- },
- function(ev) {
- trigger('eventMouseout', this, event, ev);
- }
- );
-
-
- }
-
-
- function showEvents(event, exceptElement) {
- eachEventElement(event, exceptElement, 'show');
- }
-
-
- function hideEvents(event, exceptElement) {
- eachEventElement(event, exceptElement, 'hide');
- }
-
-
- function eachEventElement(event, exceptElement, funcName) {
-
-
- var elements = eventElementsByID[event._id],
- i, len = elements.length;
- for (i=0; i<len; i++) {
- if (!exceptElement || elements[i][0] != exceptElement[0]) {
- elements[i][funcName]();
- }
- }
- }
-
-
-
-
-
-
-
- function eventDrop(el, event, newStart, ev, ui) {
- var undoMutation = calendar.mutateEvent(event, newStart, null);
-
- trigger(
- 'eventDrop',
- el,
- event,
- function() {
- undoMutation();
- reportEventChange(event._id);
- },
- ev,
- ui
- );
-
- reportEventChange(event._id);
- }
-
-
- function eventResize(el, event, newEnd, ev, ui) {
- var undoMutation = calendar.mutateEvent(event, null, newEnd);
-
- trigger(
- 'eventResize',
- el,
- event,
- function() {
- undoMutation();
- reportEventChange(event._id);
- },
- ev,
- ui
- );
-
- reportEventChange(event._id);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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;
-
-
-
- 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('days', inc);
- }
- 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.getColCnt();
-
-
- 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('days', dayOffset);
- }
-
-
-
-
-
-
-
- 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.getColCnt();
-
-
- 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.getRowCnt();
- var colCnt = t.getColCnt();
- var segments = [];
-
-
- var rangeDayOffsetStart = dateToDayOffset(start);
- var rangeDayOffsetEnd = dateToDayOffset(end);
- var endTimeMS = +end.time();
- if (endTimeMS && endTimeMS >= nextDayThreshold) {
- rangeDayOffsetEnd++;
- }
- rangeDayOffsetEnd = Math.max(rangeDayOffsetEnd, rangeDayOffsetStart + 1);
-
-
-
- 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 DayEventRenderer() {
- var t = this;
-
-
-
- t.renderDayEvents = renderDayEvents;
- t.draggableDayEvent = draggableDayEvent;
- t.resizableDayEvent = resizableDayEvent;
-
-
-
- var opt = t.opt;
- var trigger = t.trigger;
- var isEventDraggable = t.isEventDraggable;
- var isEventResizable = t.isEventResizable;
- var reportEventElement = t.reportEventElement;
- var eventElementHandlers = t.eventElementHandlers;
- var showEvents = t.showEvents;
- var hideEvents = t.hideEvents;
- var eventDrop = t.eventDrop;
- var eventResize = t.eventResize;
- var getRowCnt = t.getRowCnt;
- var getColCnt = t.getColCnt;
- var allDayRow = t.allDayRow;
- var colLeft = t.colLeft;
- var colRight = t.colRight;
- var colContentLeft = t.colContentLeft;
- var colContentRight = t.colContentRight;
- var getDaySegmentContainer = t.getDaySegmentContainer;
- var renderDayOverlay = t.renderDayOverlay;
- var clearOverlays = t.clearOverlays;
- var clearSelection = t.clearSelection;
- var getHoverListener = t.getHoverListener;
- var rangeToSegments = t.rangeToSegments;
- var cellToDate = t.cellToDate;
- var cellToCellOffset = t.cellToCellOffset;
- var cellOffsetToDayOffset = t.cellOffsetToDayOffset;
- var dateToDayOffset = t.dateToDayOffset;
- var dayOffsetToCellOffset = t.dayOffsetToCellOffset;
- var calendar = t.calendar;
- var getEventEnd = calendar.getEventEnd;
- var formatDate = calendar.formatDate;
-
-
-
-
-
- function renderDayEvents(events, modifiedEventId) {
-
-
- var segments = _renderDayEvents(
- events,
- false,
- true
- );
-
-
- segmentElementEach(segments, function(segment, element) {
- reportEventElement(segment.event, element);
- });
-
-
- attachHandlers(segments, modifiedEventId);
-
-
- segmentElementEach(segments, function(segment, element) {
- trigger('eventAfterRender', segment.event, segment.event, element);
- });
- }
-
-
-
-
-
-
-
- function renderTempDayEvent(event, adjustRow, adjustTop) {
-
-
-
- var segments = _renderDayEvents(
- [ event ],
- true,
- false
- );
-
- var elements = [];
-
-
- segmentElementEach(segments, function(segment, element) {
- if (segment.row === adjustRow) {
- element.css('top', adjustTop);
- }
- elements.push(element[0]);
- });
-
- return elements;
- }
-
-
-
-
-
-
- function _renderDayEvents(events, doAppend, doRowHeights) {
-
-
- var finalContainer = getDaySegmentContainer();
-
-
-
- var renderContainer = doAppend ? $("<div/>") : finalContainer;
-
- var segments = buildSegments(events);
- var html;
- var elements;
-
-
- calculateHorizontals(segments);
-
-
- html = buildHTML(segments);
-
-
- renderContainer[0].innerHTML = html;
-
-
- elements = renderContainer.children();
-
-
-
- if (doAppend) {
- finalContainer.append(elements);
- }
-
-
- resolveElements(segments, elements);
-
-
-
-
-
- segmentElementEach(segments, function(segment, element) {
- segment.hsides = hsides(element, true);
- });
-
-
- segmentElementEach(segments, function(segment, element) {
- element.width(
- Math.max(0, segment.outerWidth - segment.hsides)
- );
- });
-
-
-
- segmentElementEach(segments, function(segment, element) {
- segment.outerHeight = element.outerHeight(true);
- });
-
-
- setVerticals(segments, doRowHeights);
-
- return segments;
- }
-
-
-
- function buildSegments(events) {
- var segments = [];
- for (var i=0; i<events.length; i++) {
- var eventSegments = buildSegmentsForEvent(events[i]);
- segments.push.apply(segments, eventSegments);
- }
- return segments;
- }
-
-
-
-
-
- function buildSegmentsForEvent(event) {
- var segments = rangeToSegments(event.start, getEventEnd(event));
- for (var i=0; i<segments.length; i++) {
- segments[i].event = event;
- }
- return segments;
- }
-
-
-
-
- function calculateHorizontals(segments) {
- var isRTL = opt('isRTL');
- for (var i=0; i<segments.length; i++) {
- var segment = segments[i];
-
-
-
-
-
-
- var leftFunc = (isRTL ? segment.isEnd : segment.isStart) ? colContentLeft : colLeft;
- var rightFunc = (isRTL ? segment.isStart : segment.isEnd) ? colContentRight : colRight;
-
- var left = leftFunc(segment.leftCol);
- var right = rightFunc(segment.rightCol);
- segment.left = left;
- segment.outerWidth = right - left;
- }
- }
-
-
-
- function buildHTML(segments) {
- var html = '';
- for (var i=0; i<segments.length; i++) {
- html += buildHTMLForSegment(segments[i]);
- }
- return html;
- }
-
-
-
-
-
-
- function buildHTMLForSegment(segment) {
- var html = '';
- var isRTL = opt('isRTL');
- var event = segment.event;
- var url = event.url;
-
-
- var classNames = [ 'fc-event', 'fc-event-hori' ];
- if (isEventDraggable(event)) {
- classNames.push('fc-event-draggable');
- }
- if (segment.isStart) {
- classNames.push('fc-event-start');
- }
- if (segment.isEnd) {
- classNames.push('fc-event-end');
- }
-
-
- classNames = classNames.concat(event.className);
- if (event.source) {
-
- classNames = classNames.concat(event.source.className || []);
- }
-
-
-
- var skinCss = getSkinCss(event, opt);
-
- if (url) {
- html += "<a href='" + htmlEscape(url) + "'";
- }else{
- html += "<div";
- }
- html +=
- " class='" + classNames.join(' ') + "'" +
- " style=" +
- "'" +
- "position:absolute;" +
- "left:" + segment.left + "px;" +
- skinCss +
- "'" +
- ">" +
- "<div class='fc-event-inner'>";
- if (!event.allDay && segment.isStart) {
- html +=
- "<span class='fc-event-time'>" +
- htmlEscape(
- formatDate(event.start, opt('timeFormat'))
- ) +
- "</span>";
- }
- html +=
- "<span class='fc-event-title'>" +
- htmlEscape(event.title || '') +
- "</span>" +
- "</div>";
- if (event.allDay && segment.isEnd && isEventResizable(event)) {
- html +=
- "<div class='ui-resizable-handle ui-resizable-" + (isRTL ? 'w' : 'e') + "'>" +
- " " +
- "</div>";
- }
- html += "</" + (url ? "a" : "div") + ">";
-
-
-
-
-
-
- return html;
- }
-
-
-
-
-
-
- function resolveElements(segments, elements) {
- for (var i=0; i<segments.length; i++) {
- var segment = segments[i];
- var event = segment.event;
- var element = elements.eq(i);
-
-
- var triggerRes = trigger('eventRender', event, event, element);
-
- if (triggerRes === false) {
-
- element.remove();
- }
- else {
- if (triggerRes && triggerRes !== true) {
-
-
-
- triggerRes = $(triggerRes)
- .css({
- position: 'absolute',
- left: segment.left
- });
-
- element.replaceWith(triggerRes);
- element = triggerRes;
- }
-
- segment.element = element;
- }
- }
- }
-
-
-
-
-
-
-
-
-
-
- function setVerticals(segments, doRowHeights) {
- var rowContentHeights = calculateVerticals(segments);
- var rowContentElements = getRowContentElements();
- var rowContentTops = [];
- var i;
-
-
- if (doRowHeights) {
- for (i=0; i<rowContentElements.length; i++) {
- rowContentElements[i].height(rowContentHeights[i]);
- }
- }
-
-
-
- for (i=0; i<rowContentElements.length; i++) {
- rowContentTops.push(
- rowContentElements[i].position().top
- );
- }
-
-
-
- segmentElementEach(segments, function(segment, element) {
- element.css(
- 'top',
- rowContentTops[segment.row] + segment.top
- );
- });
- }
-
-
-
-
-
-
- function calculateVerticals(segments) {
- var rowCnt = getRowCnt();
- var colCnt = getColCnt();
- var rowContentHeights = [];
- var segmentRows = buildSegmentRows(segments);
- var colI;
-
- for (var rowI=0; rowI<rowCnt; rowI++) {
- var segmentRow = segmentRows[rowI];
-
-
-
- var colHeights = [];
- for (colI=0; colI<colCnt; colI++) {
- colHeights.push(0);
- }
-
-
- for (var segmentI=0; segmentI<segmentRow.length; segmentI++) {
- var segment = segmentRow[segmentI];
-
-
-
- segment.top = arrayMax(
- colHeights.slice(
- segment.leftCol,
- segment.rightCol + 1
- )
- );
-
-
- for (colI=segment.leftCol; colI<=segment.rightCol; colI++) {
- colHeights[colI] = segment.top + segment.outerHeight;
- }
- }
-
-
- rowContentHeights.push(arrayMax(colHeights));
- }
-
- return rowContentHeights;
- }
-
-
-
-
- function buildSegmentRows(segments) {
- var rowCnt = getRowCnt();
- var segmentRows = [];
- var segmentI;
- var segment;
- var rowI;
-
-
- for (segmentI=0; segmentI<segments.length; segmentI++) {
- segment = segments[segmentI];
- rowI = segment.row;
- if (segment.element) {
- if (segmentRows[rowI]) {
-
- segmentRows[rowI].push(segment);
- }
- else {
-
- segmentRows[rowI] = [ segment ];
- }
- }
- }
-
-
- for (rowI=0; rowI<rowCnt; rowI++) {
- segmentRows[rowI] = sortSegmentRow(
- segmentRows[rowI] || []
- );
- }
-
- return segmentRows;
- }
-
-
-
- function sortSegmentRow(segments) {
- var sortedSegments = [];
-
-
- var subrows = buildSegmentSubrows(segments);
-
-
- for (var i=0; i<subrows.length; i++) {
- sortedSegments.push.apply(sortedSegments, subrows[i]);
- }
-
- return sortedSegments;
- }
-
-
-
-
- function buildSegmentSubrows(segments) {
-
-
-
- segments.sort(compareDaySegments);
-
- var subrows = [];
- for (var i=0; i<segments.length; i++) {
- var segment = segments[i];
-
-
-
- for (var j=0; j<subrows.length; j++) {
- if (!isDaySegmentCollision(segment, subrows[j])) {
- break;
- }
- }
-
- if (subrows[j]) {
- subrows[j].push(segment);
- }
- else {
- subrows[j] = [ segment ];
- }
- }
-
- return subrows;
- }
-
-
-
-
-
- function getRowContentElements() {
- var i;
- var rowCnt = getRowCnt();
- var rowDivs = [];
- for (i=0; i<rowCnt; i++) {
- rowDivs[i] = allDayRow(i)
- .find('div.fc-day-content > div');
- }
- return rowDivs;
- }
-
-
-
-
-
-
-
-
- function attachHandlers(segments, modifiedEventId) {
- var segmentContainer = getDaySegmentContainer();
-
- segmentElementEach(segments, function(segment, element, i) {
- var event = segment.event;
- if (event._id === modifiedEventId) {
- bindDaySeg(event, element, segment);
- }else{
- element[0]._fci = i;
- }
- });
-
- lazySegBind(segmentContainer, segments, bindDaySeg);
- }
-
-
- function bindDaySeg(event, eventElement, segment) {
-
- if (isEventDraggable(event)) {
- t.draggableDayEvent(event, eventElement, segment);
- }
-
- if (
- event.allDay &&
- segment.isEnd &&
- isEventResizable(event)
- ) {
- t.resizableDayEvent(event, eventElement, segment);
- }
-
-
-
- eventElementHandlers(event, eventElement);
- }
-
-
- function draggableDayEvent(event, eventElement) {
- var hoverListener = getHoverListener();
- var dayDelta;
- var eventStart;
- eventElement.draggable({
- delay: 50,
- opacity: opt('dragOpacity'),
- revertDuration: opt('dragRevertDuration'),
- start: function(ev, ui) {
- trigger('eventDragStart', eventElement, event, ev, ui);
- hideEvents(event, eventElement);
- hoverListener.start(function(cell, origCell, rowDelta, colDelta) {
- eventElement.draggable('option', 'revert', !cell || !rowDelta && !colDelta);
- clearOverlays();
- if (cell) {
- var origCellDate = cellToDate(origCell);
- var cellDate = cellToDate(cell);
- dayDelta = cellDate.diff(origCellDate, 'days');
- eventStart = event.start.clone().add('days', dayDelta);
- renderDayOverlay(
- eventStart,
- getEventEnd(event).add('days', dayDelta)
- );
- }
- else {
- dayDelta = 0;
- }
- }, ev, 'drag');
- },
- stop: function(ev, ui) {
- hoverListener.stop();
- clearOverlays();
- trigger('eventDragStop', eventElement, event, ev, ui);
- if (dayDelta) {
- eventDrop(
- this,
- event,
- eventStart,
- ev,
- ui
- );
- }
- else {
- eventElement.css('filter', '');
- showEvents(event, eventElement);
- }
- }
- });
- }
-
-
- function resizableDayEvent(event, element, segment) {
- var isRTL = opt('isRTL');
- var direction = isRTL ? 'w' : 'e';
- var handle = element.find('.ui-resizable-' + direction);
- var isResizing = false;
-
-
- disableTextSelection(element);
- element
- .mousedown(function(ev) {
- ev.preventDefault();
- })
- .click(function(ev) {
- if (isResizing) {
- ev.preventDefault();
- ev.stopImmediatePropagation();
-
- }
- });
-
- handle.mousedown(function(ev) {
- if (ev.which != 1) {
- return;
- }
- isResizing = true;
- var hoverListener = getHoverListener();
- var elementTop = element.css('top');
- var dayDelta;
- var eventEnd;
- var helpers;
- var eventCopy = $.extend({}, event);
- var minCellOffset = dayOffsetToCellOffset(dateToDayOffset(event.start));
- clearSelection();
- $('body')
- .css('cursor', direction + '-resize')
- .one('mouseup', mouseup);
- trigger('eventResizeStart', this, event, ev);
- hoverListener.start(function(cell, origCell) {
- if (cell) {
-
- var origCellOffset = cellToCellOffset(origCell);
- var cellOffset = cellToCellOffset(cell);
-
-
- cellOffset = Math.max(cellOffset, minCellOffset);
-
- dayDelta =
- cellOffsetToDayOffset(cellOffset) -
- cellOffsetToDayOffset(origCellOffset);
-
- eventEnd = getEventEnd(event).add('days', dayDelta);
-
- if (dayDelta) {
- eventCopy.end = eventEnd;
- var oldHelpers = helpers;
- helpers = renderTempDayEvent(eventCopy, segment.row, elementTop);
- helpers = $(helpers);
- helpers.find('*').css('cursor', direction + '-resize');
- if (oldHelpers) {
- oldHelpers.remove();
- }
- hideEvents(event);
- }
- else {
- if (helpers) {
- showEvents(event);
- helpers.remove();
- helpers = null;
- }
- }
-
- clearOverlays();
- renderDayOverlay(
- event.start,
- eventEnd
-
-
- );
- }
- }, ev);
-
- function mouseup(ev) {
- trigger('eventResizeStop', this, event, ev);
- $('body').css('cursor', '');
- hoverListener.stop();
- clearOverlays();
-
- if (dayDelta) {
- eventResize(
- this,
- event,
- eventEnd,
- ev
- );
-
- }
-
-
- setTimeout(function() {
- isResizing = false;
- },0);
- }
- });
- }
-
-
- }
-
-
-
-
-
-
- function isDaySegmentCollision(segment, otherSegments) {
- for (var i=0; i<otherSegments.length; i++) {
- var otherSegment = otherSegments[i];
- if (
- otherSegment.leftCol <= segment.rightCol &&
- otherSegment.rightCol >= segment.leftCol
- ) {
- return true;
- }
- }
- return false;
- }
-
-
- function segmentElementEach(segments, callback) {
- for (var i=0; i<segments.length; i++) {
- var segment = segments[i];
- var element = segment.element;
- if (element) {
- callback(segment, element, i);
- }
- }
- }
-
-
-
- function compareDaySegments(a, b) {
- return (b.rightCol - b.leftCol) - (a.rightCol - a.leftCol) ||
- b.event.allDay - a.event.allDay ||
- a.event.start - b.event.start ||
- (a.event.title || '').localeCompare(b.event.title);
- }
-
-
- ;;
-
-
-
- function SelectionManager() {
- var t = this;
-
-
-
- t.select = select;
- t.unselect = unselect;
- t.reportSelection = reportSelection;
- t.daySelectionMousedown = daySelectionMousedown;
-
-
-
- var calendar = t.calendar;
- var opt = t.opt;
- var trigger = t.trigger;
- var defaultSelectionEnd = t.defaultSelectionEnd;
- var renderSelection = t.renderSelection;
- var clearSelection = t.clearSelection;
-
-
-
- var selected = false;
-
-
-
-
- if (opt('selectable') && opt('unselectAuto')) {
-
- $(document).mousedown(function(ev) {
- var ignore = opt('unselectCancel');
- if (ignore) {
- if ($(ev.target).parents(ignore).length) {
- return;
- }
- }
- unselect(ev);
- });
- }
-
-
- function select(start, end) {
- unselect();
-
- start = calendar.moment(start);
- if (end) {
- end = calendar.moment(end);
- }
- else {
- end = defaultSelectionEnd(start);
- }
-
- renderSelection(start, end);
- reportSelection(start, end);
- }
-
-
- function unselect(ev) {
- if (selected) {
- selected = false;
- clearSelection();
- trigger('unselect', null, ev);
- }
- }
-
-
- function reportSelection(start, end, ev) {
- selected = true;
- trigger('select', null, start, end, ev);
- }
-
-
- function daySelectionMousedown(ev) {
- var cellToDate = t.cellToDate;
- var getIsCellAllDay = t.getIsCellAllDay;
- var hoverListener = t.getHoverListener();
- var reportDayClick = t.reportDayClick;
-
- if (ev.which == 1 && opt('selectable')) {
- unselect(ev);
- var dates;
- hoverListener.start(function(cell, origCell) {
- clearSelection();
- if (cell && getIsCellAllDay(cell)) {
- dates = [ cellToDate(origCell), cellToDate(cell) ].sort(dateCompare);
- renderSelection(
- dates[0],
- dates[1].clone().add('days', 1)
- );
- }else{
- dates = null;
- }
- }, ev);
- $(document).one('mouseup', function(ev) {
- hoverListener.stop();
- if (dates) {
- if (+dates[0] == +dates[1]) {
- reportDayClick(dates[0], ev);
- }
- reportSelection(
- dates[0],
- dates[1].clone().add('days', 1),
- ev
- );
- }
- });
- }
- }
-
-
- }
-
- ;;
-
- function OverlayManager() {
- var t = this;
-
-
-
- t.renderOverlay = renderOverlay;
- t.clearOverlays = clearOverlays;
-
-
-
- var usedOverlays = [];
- var unusedOverlays = [];
-
-
- function renderOverlay(rect, parent) {
- var e = unusedOverlays.shift();
- if (!e) {
- e = $("<div class='fc-cell-overlay' style='position:absolute;z-index:3'/>");
- }
- if (e[0].parentNode != parent[0]) {
- e.appendTo(parent);
- }
- usedOverlays.push(e.css(rect).show());
- return e;
- }
-
-
- function clearOverlays() {
- var e;
- while ((e = usedOverlays.shift())) {
- unusedOverlays.push(e.hide().unbind());
- }
- }
-
-
- }
-
- ;;
-
- function CoordinateGrid(buildFunc) {
-
- var t = this;
- var rows;
- var cols;
-
-
- t.build = function() {
- rows = [];
- cols = [];
- buildFunc(rows, cols);
- };
-
-
- t.cell = function(x, y) {
- var rowCnt = rows.length;
- var colCnt = cols.length;
- var i, r=-1, c=-1;
- for (i=0; i<rowCnt; i++) {
- if (y >= rows[i][0] && y < rows[i][1]) {
- r = i;
- break;
- }
- }
- for (i=0; i<colCnt; i++) {
- if (x >= cols[i][0] && x < cols[i][1]) {
- c = i;
- break;
- }
- }
- return (r>=0 && c>=0) ? { row: r, col: c } : null;
- };
-
-
- t.rect = function(row0, col0, row1, col1, originElement) {
- var origin = originElement.offset();
- return {
- top: rows[row0][0] - origin.top,
- left: cols[col0][0] - origin.left,
- width: cols[col1][1] - cols[col0][0],
- height: rows[row1][1] - rows[row0][0]
- };
- };
-
- }
-
- ;;
-
- function HoverListener(coordinateGrid) {
-
-
- var t = this;
- var bindType;
- var change;
- var firstCell;
- var cell;
-
-
- t.start = function(_change, ev, _bindType) {
- change = _change;
- firstCell = cell = null;
- coordinateGrid.build();
- mouse(ev);
- bindType = _bindType || 'mousemove';
- $(document).bind(bindType, mouse);
- };
-
-
- function mouse(ev) {
- _fixUIEvent(ev);
- var newCell = coordinateGrid.cell(ev.pageX, ev.pageY);
- if (
- Boolean(newCell) !== Boolean(cell) ||
- newCell && (newCell.row != cell.row || newCell.col != cell.col)
- ) {
- if (newCell) {
- if (!firstCell) {
- firstCell = newCell;
- }
- change(newCell, firstCell, newCell.row-firstCell.row, newCell.col-firstCell.col);
- }else{
- change(newCell, firstCell);
- }
- cell = newCell;
- }
- }
-
-
- t.stop = function() {
- $(document).unbind(bindType, mouse);
- return cell;
- };
-
-
- }
-
-
-
-
-
-
-
-
- function _fixUIEvent(event) {
- if (event.pageX === undefined) {
- event.pageX = event.originalEvent.pageX;
- event.pageY = event.originalEvent.pageY;
- }
- }
- ;;
-
- function HorizontalPositionCache(getElement) {
-
- var t = this,
- elements = {},
- lefts = {},
- rights = {};
-
- function e(i) {
- return (elements[i] = (elements[i] || getElement(i)));
- }
-
- t.left = function(i) {
- return (lefts[i] = (lefts[i] === undefined ? e(i).position().left : lefts[i]));
- };
-
- t.right = function(i) {
- return (rights[i] = (rights[i] === undefined ? t.left(i) + e(i).width() : rights[i]));
- };
-
- t.clear = function() {
- elements = {};
- lefts = {};
- rights = {};
- };
-
- }
-
- ;;
-
- });
|