javascript - Show only one month name in FullCalendar when WeekView wraps two different months -


i developing using fullcalendar.js, , in week view, when week 2 different months (for example 27 july - 2 august) fullcalendar week view shows 2 months text. searching everywhere there no solution this. maybe stackoverflow users can me.

that's have:

that's have

and that's need:

that's need

i see date format mmmm yyyy, , returns 2 months or 1 automatically , seems impossible change this.

in calendar.defaults (aprox. line 8300 in non-minimized code) object can notice this:

titlerangeseparator: ' \u2014 ', // emphasized dash monthyearformat: 'mmmm yyyy', // required en. other languages rely on datepicker computable option 

as explained, monthyearformat seems 1 month, in specific moment merges titlerangeseparator become 2 months.

do know how solvable?

thank you.

edit

i found functions make complex string, used month , day views don't want change (i need week view). code next. how can modify code solve it?

// date range formatting // ------------------------------------------------------------------------------------------------- // todo: make work timezone offset  // using formatting string meant single date, generate range string, // "sep 2 - 9 2013", intelligently inserts separator dates differ. // if dates same far format string concerned, return single // rendering of 1 date, without separator. function formatrange(date1, date2, formatstr, separator, isrtl) {    var localedata;  date1 = fc.moment.parsezone(date1); date2 = fc.moment.parsezone(date2);  localedata = (date1.localedata || date1.lang).call(date1); // works moment-pre-2.8  // expand localized format strings, "ll" -> "mmmm d yyyy" formatstr = localedata.longdateformat(formatstr) || formatstr; // btw, not important `formatdate` because impossible put custom tokens // or non-zero areas in moment's localized format strings.  separator = separator || ' - ';  return formatrangewithchunks(     date1,     date2,     getformatstringchunks(formatstr),     separator,     isrtl ); } fc.formatrange = formatrange; // expose function formatrangewithchunks(date1, date2, chunks, separator, isrtl) { var chunkstr; // rendering of chunk var lefti; var leftstr = ''; var righti; var rightstr = ''; var middlei; var middlestr1 = ''; var middlestr2 = ''; var middlestr = '';  // start @ leftmost side of formatting string , continue until hit token // not same between dates. (lefti=0; lefti<chunks.length; lefti++) {     chunkstr = formatsimilarchunk(date1, date2, chunks[lefti]);     if (chunkstr === false) {         break;     }     leftstr += chunkstr; }  // similarly, start @ rightmost side of formatting string , move left (righti=chunks.length-1; righti>lefti; righti--) {     chunkstr = formatsimilarchunk(date1, date2, chunks[righti]);     if (chunkstr === false) {         break;     }     rightstr = chunkstr + rightstr; }  // area in middle different both of dates. // collect them distinctly can jam them later. (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; } 

this isn't directly supported unfortunately, there still better way modifying fc source (that get's messy patches , stuff).

there several render hooks available can use fix formatting after fact. viewrender doesn't work because it's called before title changes. can use eventafterallrender instead.

eventafterallrender:function(){     if(view.name!=="agendaweek")         return;     var $title = $("#calendar").find(".fc-toolbar h2"); //make sure right selector     var text = $title.text();     text = text.match(/.*? /)+text.match(/[0-9]+/);     $title.text(text); //replace text } 

jsfiddle - titleformat hack

not elegant thing in world, should work better modifying source. let me know if there issues.

edit:

also, if you're having problems flashing wrong dateformat before correct one, use css make title invisible. add class element in eventafterallrender makes visible again.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -