diff --git a/app/assets/stylesheets/orbitTimeline.css b/app/assets/stylesheets/orbitTimeline111.css similarity index 100% rename from app/assets/stylesheets/orbitTimeline.css rename to app/assets/stylesheets/orbitTimeline111.css diff --git a/vendor/built_in_modules/calendar/app/assets/javascripts/calendarAPI.js.erb b/vendor/built_in_modules/calendar/app/assets/javascripts/calendarAPI.js.erb index 41c2fc12..d023a0fa 100644 --- a/vendor/built_in_modules/calendar/app/assets/javascripts/calendarAPI.js.erb +++ b/vendor/built_in_modules/calendar/app/assets/javascripts/calendarAPI.js.erb @@ -27,6 +27,13 @@ Date.prototype.getWeek = function (dowOffset) { return weeknum; }; +Date.prototype.daysInMonth = function(){ + var daysArray = [31,28,31,30,31,30,31,31,30,31,30,31]; + if(this.getFullYear()%4 == 0) + daysArray[1] = 29; + + return daysArray[this.getMonth()]; +} var calendarAPI = function(){ c = this; @@ -36,17 +43,20 @@ var calendarAPI = function(){ this.cur_month = c.today.getMonth()+1; this.cur_year = c.today.getFullYear(); this.cur_week = c.today.getWeek(); + this.cur_date = c.today.getDate(); this.view = null; this.monthlist = ["","January","February","March","April","May","June","July","August","September","October","November","December"]; this.initialize = function(){ $(window).load(function(){ // c.loadMonthView(c.cur_month,c.cur_year); - c.loadWeekView(c.cur_week,c.cur_year); + // c.loadWeekView(c.cur_week,c.cur_year); + c.loadDayView(c.cur_date,c.cur_month,c.cur_year); bindHandlers(); }) var bindHandlers = function(){ - $(".event").live("click",function(){ - c.displayEvent($(this)); + $(".event").live("click",function(e){ + var pos = {"x":e.clientX,"y":e.clientY}; + c.displayEvent($(this),pos); }) $("#create_event_btn").click(function(){ @@ -73,7 +83,7 @@ var calendarAPI = function(){ c.loadWeekView(c.cur_week,c.cur_year); break; case 'day': - c.loadDayView(); + c.loadDayView(c.cur_date,c.cur_month,c.cur_year); break; case 'agenda': c.loadAgendaView(); @@ -104,6 +114,22 @@ var calendarAPI = function(){ } c.loadWeekView(w,y); break; + case "day": + var d,w,y; + d = c.cur_date - 1; + m = c.cur_month; + y = c.cur_year; + if(d == 0){ + var dx = new Date(c.cur_year,c.cur_month-2); + d = dx.daysInMonth(); + m--; + } + if(m == 0){ + m = 12; + y = y - 1; + } + c.loadDayView(d,m,y); + break; } }) @@ -132,6 +158,26 @@ var calendarAPI = function(){ } c.loadWeekView(w,y); break; + case "day": + var d,w,y; + var dx = new Date(c.cur_year,c.cur_month-1); + if(c.cur_date == dx.daysInMonth()){ + d = 1; + m = c.cur_month + 1; + }else{ + d = c.cur_date + 1; + m = c.cur_month; + } + + if(m == 13){ + m = 1; + y = c.cur_year + 1; + }else{ + y = c.cur_year; + } + + c.loadDayView(d,m,y); + break; } }) $("button#today_btn").click(function(){ @@ -142,6 +188,9 @@ var calendarAPI = function(){ case "month": c.loadMonthView(); break; + case "day": + c.loadDayView(); + break; } }) } @@ -222,6 +271,8 @@ var calendarAPI = function(){ var recordcurdate = true; if(allow){ + if(evnt.title=="Navratri") + console.log(pos); if(pos == 1){ var colspan = 0; if(evnt.total_days>7){ @@ -238,7 +289,7 @@ var calendarAPI = function(){ $eventrow.html('
'+evnt.title+'
'); }else{ if($eventrow.html()==""){ - $eventrow.append(''); + $eventrow.append(''); }else{ if((lastno+1)!=thisno){ var inposition = parseInt($eventrow.find("td.main_td:last").attr("pos")); @@ -304,19 +355,69 @@ var calendarAPI = function(){ } this.getEventsForWeek = function(week,year){ $.getJSON("cals/getWeekEvents",{"week":week,"year":year},function(events){ + var height = 15; + var full_day_count = 0; + var rowcount = 7; + var tr = $(""); + var pre = true; $.each(events,function(i,evnt){ + // console.log("rowcount: "+rowcount); + // console.log("start:"+evnt.start); + if(rowcount >= (7 - evnt.total_days)){ + if(tr.html()!=""){ + if(rowcount != 7){ + tr.append(""); + } + $("table.all_day_event_holder").append(tr); + } + tr = null; + tr = $(''); + pre = true; + } + if(evnt.all_day){ - $(".week_day_header[date="+evnt.start_date+"]").append('
'+evnt.title+'
'); + full_day_count++; + + var precountspan = 7 - evnt.total_days; + if(pre){ + height+=20; + $(".head_event_wrapper").height(height); + $(".head_event_wrapper table").eq(0).height(height); + tr.append(' '); + if(precountspan != 0){ + tr.append(''); + pre = false; + } + } + var colcount = evnt.total_days; + if(evnt.colcount != 0){ + colcount = evnt.colcount; + } + + rowcount = precountspan + colcount; + + tr.append('
'+evnt.title+'
'); + + // $(".week_day_header[date="+evnt.start_date+"]").append('
'+evnt.title+'
'); }else{ + var starttime,endtime,displaystarttime,displayendtime; - if(evnt.start_am_pm == "AM") + if(evnt.start_am_pm == "AM"){ starttime = evnt.start_time; - else + if(starttime == 12) + starttime = 0; + if(starttime == 12.5) + starttime = 0.5; + }else starttime = evnt.start_time + 12; - if(evnt.end_am_pm == "AM") + if(evnt.end_am_pm == "AM"){ endtime = evnt.end_time; - else + if(endtime == 12) + endtime = 0; + if(endtime == 12.5) + endtime = 0.5; + }else endtime = evnt.end_time + 12; var temp = parseInt(evnt.start_time); @@ -333,17 +434,99 @@ var calendarAPI = function(){ else displayendtime = temp + ":00 " + evnt.end_am_pm; - var toppx = ((starttime * 2) * 19) + starttime; - var eventdom = $('
'+displaystarttime+' - '+displayendtime+'
'+evnt.title+'
'); + var toppx = ((starttime * 2) * 20) + 1; + var h = endtime - starttime; + var halfhour = ""; + if(h == 0.5) + halfhour = "half"; + h = 17 + 20 + (((h-1) * 2) * 20) + 1; + var eventdom = $('
'+displaystarttime+' - '+displayendtime+'
'+evnt.title+'
'); $(".week_day_body[date="+evnt.start_date+"] .inner").append(eventdom); } + if(full_day_count == 0){ + tr.append(''); + $("table.all_day_event_holder").append(tr); + } }) + if(tr.html()!=""){ + if(rowcount != 7){ + tr.append(""); + } + $("table.all_day_event_holder").append(tr); + } }) } - this.loadDayView = function(){ - $('#view_holder').load("cals/day_view", function() { - $('.current_day_title').text('September 2, 2012'); + this.loadDayView = function(day,month,year){ + c.view = "day"; + if(!day){ + var dt = new Date(); + week = dt.getWeek(); + year = dt.getFullYear(); + day = dt.getDate(); + month = dt.getMonth()+1; + } + + c.cur_date = day; + c.cur_month = month; + c.cur_year = year; + + $('#view_holder').load("cals/day_view?date="+day+"&month="+month+"&year="+year, function() { + $('.current_day_title').text($("#day_header").text()); + c.getEventsForDay(day,month,year); + }) + } + this.getEventsForDay = function(day,month,year){ + $.getJSON("cals/getDayEvents",{"date":day,"month":month,"year":year},function(events){ + $.each(events,function(i,evnt){ + if(evnt.all_day){ + $(".all_day_event").append('
'+evnt.title+'
') + }else{ + var starttime,endtime,displaystarttime,displayendtime; + if(evnt.start_am_pm == "AM"){ + starttime = evnt.start_time; + if(starttime == 12) + starttime = 0; + if(starttime == 12.5) + starttime = 0.5; + }else + starttime = evnt.start_time + 12; + + if(evnt.end_am_pm == "AM"){ + endtime = evnt.end_time; + if(endtime == 12) + endtime = 0; + if(endtime == 12.5) + endtime = 0.5; + }else + endtime = evnt.end_time + 12; + + var temp = parseInt(evnt.start_time); + + if (evnt.start_time > temp) + displaystarttime = temp + ":30 " + evnt.start_am_pm; + else + displaystarttime = temp + ":00 " + evnt.start_am_pm; + + temp = parseInt(evnt.end_time); + + if (evnt.end_time > temp) + displayendtime = temp + ":30 " + evnt.end_am_pm; + else + displayendtime = temp + ":00 " + evnt.end_am_pm; + + var toppx = ((starttime * 2) * 20) + 1; + var h = endtime - starttime; + var halfhour = ""; + if(h == 0.5) + halfhour = "half"; + h = 17 + 20 + (((h-1) * 2) * 20) + 1; + var eventdom = $('
'+displaystarttime+' - '+displayendtime+'
'+evnt.title+'
'); + $(".event_holder").append(eventdom); + } + + }) + }) } this.loadAgendaView = function(){ @@ -379,11 +562,27 @@ var calendarAPI = function(){ var domfor = $(this).attr("data-content"); $("tr[for="+domfor+"]").remove(); }) + $(".btn-edit-a").live("ajax:success",function(evt,form){ + $("#edit_area_" + $(this).attr("for")).html(form).slideDown(); + $("#edit_area_" + $(this).attr("for")).find(".color-picker").miniColors(); + }) + $(".bt-cancel").live("click",function(){ + $("#edit_area_" + $(this).attr("for")).html("").slideUp(); + }) } - this.displayEvent = function(dom){ + this.displayEvent = function(dom,pos){ var url = dom.attr("link"); c.event_quick_view_div.load(url,function(){ - c.event_quick_view_div.show() + var x = pos.x; + var y = pos.y; + var winheight = $(window).height() + if((x+c.event_quick_view_div.width()) > $(window).width()){ + x = x - c.event_quick_view_div.width(); + } + if((y+c.event_quick_view_div.height()) > winheight){ + y = y - c.event_quick_view_div.height(); + } + c.event_quick_view_div.css({"left":x+"px","top":y+"px"}).show() c.event_quick_view_div.find(".event-close-btn").click(function(){ c.event_quick_view_div.empty().hide(); }) diff --git a/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css b/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css index 86df5516..874904a5 100644 --- a/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css +++ b/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css @@ -32,6 +32,7 @@ border-radius: 3px; cursor: pointer; padding: 1px 3px; + font-weight: bold; box-shadow: inset 0 0 1px black; -webkit-box-shadow: inset 0 0 1px black; -moz-box-shadow: inset 0 0 1px black; diff --git a/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/cals_controller.rb b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/cals_controller.rb index 8e67117b..fdf712aa 100644 --- a/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/cals_controller.rb +++ b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/cals_controller.rb @@ -11,6 +11,19 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController @calendars = Cal.all end + def edit + @calendar = Cal.find(params[:id]) + render :layout=>false + end + + def update + @calendar = Cal.find(params[:id]) + @calendar.update_attributes(params[:cal]) + respond_to do |h| + h.js + end + end + def create @calendar = Cal.new(params[:cal]) @calendar.save! @@ -26,7 +39,12 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController end def day_view - render :layout => false + date = params[:date].to_i + month = params[:month].to_i + year = params[:year].to_i + @cur_day = getDayName(date,month,year) + " " + month.to_s + "/" + date.to_s + " - " + year.to_s + @hours = getHours(12) + render :layout => false end def week_view @@ -70,38 +88,84 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController end def get_month_events - month = params[:month] - year = params[:year] - month = month.to_i - year = year.to_i - events = Event.where(:start_month.lt => month).and(:start_year => year).and(:end_month.gte => month).asc(:start_date).desc(:total_days) + month = params[:month].to_i + year = params[:year].to_i + + # events = Event.where(:start_month.lt => month).and(:start_year => year).and(:end_month.gte => month).asc(:start_date).desc(:total_days) @events = Array.new no_of_days_in_month = getMonthDays(year) - events.each_with_index do |event,i| - no_of_days = event.total_days + # events.each_with_index do |event,i| + # no_of_days = event.total_days - if event.end_month > month - no_of_days = no_of_days_in_month[month] - elsif event.end_month == month - no_of_days = event.end_date - end + # if event.end_month > month + # no_of_days = no_of_days_in_month[month] + # elsif event.end_month == month + # no_of_days = event.end_date + # end - no_of_days = no_of_days.to_i + # no_of_days = no_of_days.to_i - color = Cal.find(event.cal_id).color - @events << {"id"=>event.id,"index"=>i,"start_date"=>"1", "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event)} - end - events = Event.where(:start_month => month).and(:start_year => year).asc(:start_date).desc(:total_days) + # color = Cal.find(event.cal_id).color + # @events << {"id"=>event.id,"index"=>i,"start_date"=>"1", "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event)} + # end + # events = Event.where(:start_month => month).and(:start_year => year).asc(:start_date).desc(:total_days) + # events.each_with_index do |event,i| + # # @temp = Array.new + # no_of_days = event.total_days + # if event.end_month > month + # no_of_days = no_of_days_in_month[month] - event.start_date + # end + # no_of_days = no_of_days.to_i + # no_of_days += 1 + + # color = Cal.find(event.cal_id).color + # @events << {"id"=>event.id,"index"=>i,"start_date"=>event.start_date, "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event)} + # end + events = Event.all.asc(:start_date).desc(:total_days) events.each_with_index do |event,i| # @temp = Array.new - no_of_days = event.total_days - if event.end_month > month - no_of_days = no_of_days_in_month[month] - event.start_date - end - no_of_days = no_of_days.to_i - no_of_days += 1 - color = Cal.find(event.cal_id).color - @events << {"id"=>event.id,"index"=>i,"start_date"=>event.start_date, "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event)} + startdt = Date.new(event.start_year,event.start_month) + enddt = Date.new(event.end_year,event.end_month) + range = startdt..enddt + + dt = Date.new(year,month) + if range === dt + no_of_days = event.total_days + start_date = event.start_date + + if event.start_year < year + no_of_days = no_of_days_in_month[month] - event.start_date + no_of_days += 1 + temp = month + 12 + if event.start_month < temp + start_date = 1 + end + end + if event.end_year > year + no_of_days = no_of_days_in_month[month] - event.start_date + no_of_days += 1 + temp = month + 12 + end + if event.end_month > month + no_of_days = no_of_days_in_month[month] - event.start_date + no_of_days += 1 + elsif event.end_month == month + no_of_days = event.end_date + end + + if event.start_month == month && event.end_month == month + no_of_days = event.total_days + no_of_days += 1 + end + + if event.start_month < month + start_date = 1 + end + + color = Cal.find(event.cal_id).color + @events << {"start_year"=>event.start_year, "id"=>event.id,"index"=>i,"start_date"=>start_date, "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event)} + end + end render :json => @events.to_json @@ -111,26 +175,83 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController week = params[:week].to_i year = params[:year].to_i @d = getWeekDataSet(week,year) - events = Event.where(:start_week.lte => week).and(:start_year => year).and(:end_week.gte => week).and(:start_year => year) + events = Event.where(:start_week.lte => week).and(:start_year => year).and(:end_week.gte => week).and(:start_year => year).asc(:start_week).asc(:start_date) @events = Array.new events.each_with_index do |event,i| # @temp = Array.new - no_of_days = event.total_days + days = event.total_days.to_i + 1 + colcount = 0 startdt = event.start_date - if event.start_week < week - startdt = @d[0].to_i - event.all_day = true - end - no_of_days = no_of_days.to_i - no_of_days += 1 all_day = event.all_day - if no_of_days > 1 + + if days > 1 all_day = true end + if event.end_week > week && event.start_week < week + days = 7 + end + + if event.end_week == week + days = @d.index(event.end_date.to_s).to_i + end + + if event.start_week == week + days = 7 - @d.index(event.start_date.to_s).to_i + end + + + if event.start_week == week && event.end_week == week + x = @d.index(event.end_date.to_s).to_i + y = @d.index(event.start_date.to_s).to_i + colcount = x - y + colcount+=1 + + end + + if event.start_week < week + startdt = @d[0].to_i + event.all_day = true + if event.end_week == week + colcount = 7 - @d.index(event.end_date.to_s).to_i + days = 7; + startdt = event.start_date + end + end + color = Cal.find(event.cal_id).color - @events << {"id"=>event.id,"index"=>i,"start_date"=>startdt,"all_day"=>all_day, "start_week" => event.start_week, "end_week" => event.end_week, "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event),"start_time"=>event.start_time,"end_time"=>event.end_time,"start_am_pm"=>event.start_am_pm,"end_am_pm"=>event.end_am_pm} + @events << {"id"=>event.id,"index"=>i,"start_date"=>startdt,"end_date"=>event.end_date ,"all_day"=>all_day, "start_week" => event.start_week, "end_week" => event.end_week, "total_days" => days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event),"start_time"=>event.start_time,"end_time"=>event.end_time,"start_am_pm"=>event.start_am_pm,"end_am_pm"=>event.end_am_pm,"colcount"=>colcount} + end + render :json => @events.to_json + end + + def get_day_events + day = params[:date].to_i + month = params[:month].to_i + year = params[:year].to_i + dt = Date.new(year,month,day) + week = dt.strftime("%U") + events = Event.where(:start_month.lte => month).and(:start_year => year).and(:end_month.gte => month) + @events = Array.new + events.each_with_index do |event,i| + days = event.total_days.to_i + 1 + colcount = 0 + + all_day = event.all_day + + if days > 1 + all_day = true + end + startdt = Date.new(event.start_year,event.start_month,event.start_date) + enddt = Date.new(event.end_year,event.end_month,event.end_date) + + range = startdt..enddt + + if range === dt + color = Cal.find(event.cal_id).color + @events << {"id"=>event.id,"index"=>i,"start_date"=>event.start_date,"end_date"=>event.end_date ,"all_day"=>all_day, "start_week" => event.start_week, "end_week" => event.end_week, "total_days" => days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event),"start_time"=>event.start_time,"end_time"=>event.end_time,"start_am_pm"=>event.start_am_pm,"end_am_pm"=>event.end_am_pm} + end end render :json => @events.to_json end diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/_calendar.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/_calendar.html.erb index 9accb75a..c03b0d18 100644 --- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/_calendar.html.erb +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/_calendar.html.erb @@ -1,10 +1,12 @@ +
+
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/agenda_view.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/agenda_view.html.erb index 98d716c1..57bb1bf9 100644 --- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/agenda_view.html.erb +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/agenda_view.html.erb @@ -1,4 +1,4 @@ - -
+
+ \ No newline at end of file diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/day_view.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/day_view.html.erb index 46fc0a16..709437c7 100644 --- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/day_view.html.erb +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/day_view.html.erb @@ -3,14 +3,14 @@ -

Sunday 9/2

+ -
event1
-
event2
+ @@ -18,107 +18,25 @@ diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/edit.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/edit.html.erb new file mode 100644 index 00000000..9cf6b355 --- /dev/null +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/edit.html.erb @@ -0,0 +1,26 @@ +<%= form_for @calendar, :url => panel_calendar_back_end_cal_path(@calendar), :remote => true do |f| %> +

Edit

+
+
+ <%= label_tag("color", t("calendar.color")) %> + <%= f.text_field :color, :class => "color-picker miniColors", :size => "5", :maxlength => "5", :autocomplete=>"off",:value=>@calendar.color %> +
+
+ +
+ <%= f.fields_for :name_translations do |name| %> + <% @site_valid_locales.each_with_index do |locale, i| %> +
+ <%= label_tag(locale, t("calendar.name")+"-"+I18nVariable.from_locale(locale)) %> +
+ <%= name.text_field locale, :class => "input-xxlarge", :size=>"30", :value=>@calendar.name_translations[locale] %> +
+
+ <% end %> + <% end %> +
+
+ <%= f.submit t("calendar.save"), :class=>"btn btn-primary" %> + +
+<% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/index.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/index.html.erb index 96701aaf..791cfe19 100644 --- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/index.html.erb +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/index.html.erb @@ -64,7 +64,7 @@ - +
-
12am
-
1am
-
2am
-
3am
-
4am
-
5am
-
6am
-
7am
-
8am
-
9am
-
10am
-
11am
-
12am
-
1pm
-
2pm
-
3pm
-
4pm
-
5pm
-
6pm
-
7pm
-
8pm
-
9pm
-
10pm
-
11pm
+ <% @hours.each do |hour| %> +
<%= hour %>am
+ <% end %> + <% @hours.each do |hour| %> +
<%= hour %>pm
+ <% end %>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ <% @hours.each do |hour| %> +
+
+
+
+
+
+ <% end %>
-
+