diff --git a/app/assets/images/loading1.gif b/app/assets/images/loading1.gif new file mode 100644 index 0000000..e092d81 Binary files /dev/null and b/app/assets/images/loading1.gif differ diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index 3b3447d..b4f7767 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -45,6 +45,7 @@ var Calendar = function(dom){ var success_event = function(data,allDay,type,addbtn){ c.dialog.dismiss(); + $('.bootstrap-datetimepicker-widget').remove(); c.event_create_space.html(data); var create_space_height = c.event_create_space.height(), create_space_width = c.event_create_space.width(); @@ -107,6 +108,7 @@ var Calendar = function(dom){ }); $("a.btn-close").one("click",function(){ c.event_create_space.html("").hide(); + $('.bootstrap-datetimepicker-widget').remove(); return false; }); @@ -245,16 +247,16 @@ var Calendar = function(dom){ }) if(view != "agenda"){ if(c.currentView == "agenda"){ - $("#sec1").addClass("span3").removeClass("span7"); + // $("#sec1").addClass("span3").removeClass("span7"); $("#sec2").show(); - $("#sec3").addClass("span4").removeClass("span5"); + // $("#sec3").addClass("span4").removeClass("span5"); agendaView.hide(); } c.calendar.fullCalendar('changeView',view); }else{ - $("#sec1").addClass("span7").removeClass("span3"); + // $("#sec1").addClass("span7").removeClass("span3"); $("#sec2").hide(); - $("#sec3").addClass("span5").removeClass("span4"); + // $("#sec3").addClass("span5").removeClass("span4"); agendaView.inflate(); } c.currentView = view; @@ -264,7 +266,7 @@ var Calendar = function(dom){ } } if(c.currentView == "agenda"){toggleViews("agenda");loadeventsonviewchange = true;} - $(document).on("DOMMouseScroll mousewheel", function(e){ + c.calendar.on("DOMMouseScroll mousewheel", function(e){ if(c.calendar.fullCalendar("getView").name == "month"){ if(!c.isFormVisible()){ c.dialog.dismiss(); @@ -334,35 +336,48 @@ var EventDialog = function(calendar,event){ var event_quick_view = null; var template = ""; var _this_event = null; + var month_names = ["Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec"]; this.inflate = function(_event){ if(!_event) throw new UserException("EventStick can't be null!"); _this_event = _event; var start_time = "", - end_time = "", - time_string = null; + end_time = "", + time_string = null; - if(_event.allDay){ - start_time = (/00:00:00/i.test(_event._start.toLocaleString()) ? $.fullCalendar.formatDate(_event._start,"ddd MMM dd, yyyy") : $.fullCalendar.formatDate(_event._start,"ddd MMM dd, yyyy hh:mm")); + if(_event.allDay) { + start_time = $.fullCalendar.formatDate(_event._start,"MMM dd, yyyy"); if(_event._end) - end_time = (/00:00:00/i.test(_event._end.toLocaleString()) ? $.fullCalendar.formatDate(_event._end,"ddd MMM dd, yyyy") : $.fullCalendar.formatDate(_event._end,"ddd MMM dd, yyyy hh:mm")); - time_string = (_event._start === _event._end || !_event._end ? start_time : start_time + " - " + end_time); - }else{ - var reg = new RegExp(/ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/), - stime = _event._start.toLocaleString().split(",")[1], - etime = _event._end.toLocaleString().split(",")[1]; + end_time = $.fullCalendar.formatDate(_event._end,"MMM dd, yyyy"); + time_string = (_event._start === _event._end || !_event._end ? "

" + start_time + "

" : " " + start_time + " " + end_time + ""); + } else { + var sh = _event._start.getHours() > 12 ? _event._start.getHours() - 12 : _event._start.getHours(), + eh = _event._end.getHours() > 12 ? _event._end.getHours() - 12 : _event._end.getHours(), + sm = _event._start.getMinutes() < 10 ? '0' + _event._start.getMinutes() : _event._start.getMinutes(), + em = _event._end.getMinutes() < 10 ? '0' + _event._end.getMinutes() : _event._end.getMinutes(), + stime = _event._start.getHours() > 12 ? sh + ':' + sm + " PM" : sh + ':' + sm + " AM", + etime = _event._end.getHours() > 12 ? eh + ':' + em + " PM" : eh + ':' + em + " AM", + same = (_event._start.getDate() == _event._end.getDate() && _event._start.getMonth() == _event._end.getMonth() && _event._start.getFullYear() == _event._end.getFullYear()); + start_time = month_names[_event._start.getMonth()] + " " + _event._start.getDate() + ", " + _event._start.getFullYear(); + end_time = month_names[_event._end.getMonth()] + " " + _event._end.getDate() + ", " + _event._end.getFullYear(); - start_time = _event._start.toLocaleString().replace(stime,""); - end_time = _event._end.toLocaleString().replace(etime,""); - - stime = stime.substr(0,stime.length - 3); - etime = etime.substr(0,etime.length - 3); - - time_string = (start_time === end_time ? start_time + " " + stime + " - " + etime : start_time + " " + stime + " - " + end_time + " " +etime ); + time_string = (same ? "

" + start_time + "

" + stime + " " + etime : "

" + start_time + "" + stime + "

" + end_time + "" + etime + "

"); } - event_quick_view = $(''); - template = ''; + event_quick_view = $(''); + template = '' + + ''; if(_event.can_edit){ - template+=''; + template += ''; } } @@ -386,6 +401,7 @@ var EventDialog = function(calendar,event){ var x = pos.x, y = pos.y, winheight = $(window).height(); + console.log(event_quick_view.width()) if((x + event_quick_view.width()) > $(window).width()){ x = x - event_quick_view.width(); } @@ -418,13 +434,59 @@ var AgendaView = function(calendar){ var end_month = ((start_month + minDifference) > 11 ? (start_month + minDifference) - 11 : start_month + minDifference); var end_year = ((start_month + minDifference) > 11 ? start_year+1 : start_year); var monthNames = ['January','February','March','April','May','June','July','August','September','October','November','December']; - var month_template = '

SunMonTueWedThuFriSat
'; + var month_template = '
' + + '

' + + '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
SunMonTueWedThuFriSat
' + + '
' + + '
'; - var event_list_template = '
No events for this month.
'; + var event_list_template = '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
DateTimeEvents
No events for this month.
' + + '
'; - var head_template = '
'; + var head_template = '
' + + '' + + '' + + '' + + '' + + '' + + '
'; - var event_template = "
"; + var event_template = '' + + '' + + '' + + '' + + '
' + + '' + + ''; var cache = false; var show_event_clicked = false; @@ -570,7 +632,7 @@ var AgendaView = function(calendar){ dateFormat = $.fullCalendar.formatDate(s, "ddd dd"); else dateFormat = $.fullCalendar.formatDates(s, e, "ddd dd, MMM - {ddd dd, MMM}"); - e_t.find("th").text(dateFormat); + e_t.find("td:first").text(dateFormat); e_t.find("td.event_time").text((event.allDay ? "All Day" : $.fullCalendar.formatDate(s, "hh:mm"))); e_t.find("div.event").text(event.title).css("color",event.color); return e_t; diff --git a/app/assets/javascripts/calendar_frontend.js b/app/assets/javascripts/calendar_frontend.js index a5980b8..31de1d6 100644 --- a/app/assets/javascripts/calendar_frontend.js +++ b/app/assets/javascripts/calendar_frontend.js @@ -80,16 +80,16 @@ var Calendar = function(dom,page_id){ }) if(view != "agenda"){ if(c.currentView == "agenda"){ - $("#sec1").addClass("span3").removeClass("span7"); + // $("#sec1").addClass("span3").removeClass("span7"); $("#sec2").show(); - $("#sec3").addClass("span4").removeClass("span5"); + // $("#sec3").addClass("span4").removeClass("span5"); agendaView.hide(); } c.calendar.fullCalendar('changeView',view); }else{ - $("#sec1").addClass("span7").removeClass("span3"); + // $("#sec1").addClass("span7").removeClass("span3"); $("#sec2").hide(); - $("#sec3").addClass("span5").removeClass("span4"); + // $("#sec3").addClass("span5").removeClass("span4"); agendaView.inflate(); } c.currentView = view; @@ -120,35 +120,47 @@ var EventDialog = function(calendar,event){ var event_quick_view = null; var template = ""; var _this_event = null; + var month_names = ["Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec"]; this.inflate = function(_event){ if(!_event) throw new UserException("EventStick can't be null!"); _this_event = _event; var start_time = "", - end_time = "", - time_string = null; + end_time = "", + time_string = null; - if(_event.allDay){ - start_time = (/00:00:00/i.test(_event._start.toLocaleString()) ? $.fullCalendar.formatDate(_event._start,"ddd MMM dd, yyyy") : $.fullCalendar.formatDate(_event._start,"ddd MMM dd, yyyy hh:mm")); + if(_event.allDay) { + start_time = $.fullCalendar.formatDate(_event._start,"MMM dd, yyyy"); if(_event._end) - end_time = (/00:00:00/i.test(_event._end.toLocaleString()) ? $.fullCalendar.formatDate(_event._end,"ddd MMM dd, yyyy") : $.fullCalendar.formatDate(_event._end,"ddd MMM dd, yyyy hh:mm")); - time_string = (_event._start === _event._end || !_event._end ? start_time : start_time + " - " + end_time); - }else{ - var reg = new RegExp(/ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/), - stime = _event._start.toLocaleString().split(",")[1], - etime = _event._end.toLocaleString().split(",")[1]; + end_time = $.fullCalendar.formatDate(_event._end,"MMM dd, yyyy"); + time_string = (_event._start === _event._end || !_event._end ? "

" + start_time + "

" : " " + start_time + " " + end_time + ""); + } else { + var sh = _event._start.getHours() > 12 ? _event._start.getHours() - 12 : _event._start.getHours(), + eh = _event._end.getHours() > 12 ? _event._end.getHours() - 12 : _event._end.getHours(), + sm = _event._start.getMinutes() < 10 ? '0' + _event._start.getMinutes() : _event._start.getMinutes(), + em = _event._end.getMinutes() < 10 ? '0' + _event._end.getMinutes() : _event._end.getMinutes(), + stime = _event._start.getHours() > 12 ? sh + ':' + sm + " PM" : sh + ':' + sm + " AM", + etime = _event._end.getHours() > 12 ? eh + ':' + em + " PM" : eh + ':' + em + " AM", + same = (_event._start.getDate() == _event._end.getDate() && _event._start.getMonth() == _event._end.getMonth() && _event._start.getFullYear() == _event._end.getFullYear()); + start_time = month_names[_event._start.getMonth()] + " " + _event._start.getDate() + ", " + _event._start.getFullYear(); + end_time = month_names[_event._end.getMonth()] + " " + _event._end.getDate() + ", " + _event._end.getFullYear(); - start_time = _event._start.toLocaleString().replace(stime,","); - end_time = _event._end.toLocaleString().replace(etime,","); - - stime = stime.substr(0,stime.length - 3); - etime = etime.substr(0,etime.length - 3); - - time_string = (start_time === end_time ? start_time + " " + stime + " - " + etime : start_time + " " + stime + " - " + end_time + " " +etime ); + time_string = (same ? "

" + start_time + "

" + stime + " " + etime : "

" + start_time + "" + stime + "

" + end_time + "" + etime + "

"); } - event_quick_view = $(''); - template = ''; + event_quick_view = $(''); + template = '