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 d023a0fa..09ef0195 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 @@ -6,8 +6,7 @@ Date.prototype.getWeek = function (dowOffset) { var newYear = new Date(this.getFullYear(),0,1); var day = newYear.getDay() - dowOffset; //the day of week the year begins on day = (day >= 0 ? day : day + 7); - var daynum = Math.floor((this.getTime() - newYear.getTime() - - (this.getTimezoneOffset()-newYear.getTimezoneOffset())*60000)/86400000) + 1; + var daynum = Math.floor((this.getTime() - newYear.getTime() - (this.getTimezoneOffset()-newYear.getTimezoneOffset())*60000)/86400000) + 1; var weeknum; //if the year starts before the middle of a week if(day < 4) { @@ -49,8 +48,8 @@ var calendarAPI = function(){ this.initialize = function(){ $(window).load(function(){ // c.loadMonthView(c.cur_month,c.cur_year); - // c.loadWeekView(c.cur_week,c.cur_year); - c.loadDayView(c.cur_date,c.cur_month,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(){ @@ -61,16 +60,46 @@ var calendarAPI = function(){ $("#create_event_btn").click(function(){ if(!$(this).hasClass("active")){ - c.newEvent($(this).attr("href"),$(this).attr("ref"),c.today.getDate(),c.today.getMonth()+1,c.today.getFullYear()); + c.newEvent($(this).attr("href"),$(this).attr("ref"),c.today.getDate(),c.today.getMonth()+1,c.today.getFullYear(),10.5,"AM"); }else{ c.event_create_div.hide().empty(); } $(this).toggleClass("active"); return false; }) - $("td.click_event").live("click",function(){ - c.newEvent($(this).attr("link"),$(this).attr("ref"),$(this).attr("date"),c.cur_month,c.cur_year); + $(".click_event").live("click",function(e){ + var dt = $(this).attr("date"); + if(!dt){ + var w = $("td.week_day_body").width(); + var parentOffset = $("table.cell_map").offset(); + var relX = e.pageX - parentOffset.left; + var t = 60; + for (var i = 0; i <= 6; i++) { + if(relX > t && relX < (t + w)){ + console.log(i); + dt = $("td.week_day_body").eq(i).attr("date"); + break; + } + t = t + w; + }; + } + var time = $(this).attr("time"); + var ses = $(this).attr("ses"); + if (!time) + time = 10.5; + if(!ses) + ses = "AM"; + + c.newEvent($(this).attr("link"),$(this).attr("ref"),dt,c.cur_month,c.cur_year,time,ses); $("#create_event_btn").toggleClass("active"); + e.stopPropagation(); + }) + $("#edit_event_btn").live("ajax:success",function(evt,form){ + c.event_quick_view_div.empty().hide(); + c.updateEvent(form); + }) + $("#refresh_btn").click(function(){ + c.refresh(); }) $('.mode_switch').click(function(){ @@ -262,7 +291,7 @@ var calendarAPI = function(){ curparent.append($eventrow); } $eventrow = null; - $eventrow = $(""); + $eventrow = $(""); allow = true; }else if(evnt.start_date > curdate){ allow = true; @@ -358,7 +387,7 @@ var calendarAPI = function(){ var height = 15; var full_day_count = 0; var rowcount = 7; - var tr = $(""); + var tr = $(""); var pre = true; $.each(events,function(i,evnt){ // console.log("rowcount: "+rowcount); @@ -371,7 +400,7 @@ var calendarAPI = function(){ $("table.all_day_event_holder").append(tr); } tr = null; - tr = $(''); + tr = $(''); pre = true; } @@ -440,7 +469,7 @@ var calendarAPI = function(){ if(h == 0.5) halfhour = "half"; h = 17 + 20 + (((h-1) * 2) * 20) + 1; - var eventdom = $('
'+displaystarttime+' - '+displayendtime+'
'+evnt.title+'
'); + var eventdom = $('
'+displaystarttime+' - '+displayendtime+'
'+evnt.title+'
'); $(".week_day_body[date="+evnt.start_date+"] .inner").append(eventdom); } if(full_day_count == 0){ @@ -480,7 +509,7 @@ var calendarAPI = function(){ $.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+'
') + $(".all_day_event").append('
'+evnt.title+'
') }else{ var starttime,endtime,displaystarttime,displayendtime; if(evnt.start_am_pm == "AM"){ @@ -521,7 +550,7 @@ var calendarAPI = function(){ if(h == 0.5) halfhour = "half"; h = 17 + 20 + (((h-1) * 2) * 20) + 1; - var eventdom = $('
'+displaystarttime+' - '+displayendtime+'
'+evnt.title+'
'); + var eventdom = $('
'+displaystarttime+' - '+displayendtime+'
'+evnt.title+'
'); $(".event_holder").append(eventdom); } @@ -534,7 +563,7 @@ var calendarAPI = function(){ $('.current_day_title').text('September 2, 2012'); }) } - this.newEvent = function(url,ref,date,month,year){ + this.newEvent = function(url,ref,date,month,year,time,ses){ var bindHandlers = function(){ c.event_create_div.find("button.btn-close").click(function(){ c.event_create_div.hide().empty(); @@ -546,14 +575,67 @@ var calendarAPI = function(){ else c.event_create_div.find("#non_all_day").show() }) + $( "#dpfrom" ).datepicker({ + defaultDate: "+1w", + changeMonth: true, + numberOfMonths: 3, + onSelect: function( selectedDate ) { + $( "#dpto" ).datepicker( "option", "minDate", selectedDate ); + } + }); + $( "#dpto" ).datepicker({ + defaultDate: "+1w", + changeMonth: true, + numberOfMonths: 3, + onSelect: function( selectedDate ) { + $( "#dpfrom" ).datepicker( "option", "maxDate", selectedDate ); + } + }); } - c.event_create_div.load(url+"?ref="+ref+"&date="+date+"&month="+month+"&year="+year,function(){ + c.event_create_div.load(url+"?ref="+ref+"&date="+date+"&month="+month+"&year="+year+"&time="+time+"&ses="+ses,function(){ c.event_create_div.show(); bindHandlers(); }) } + + this.updateEvent = function(form){ + var bindHandlers = function(){ + c.event_create_div.find("button.btn-close").click(function(){ + c.event_create_div.hide().empty(); + $("#create_event_btn").removeClass("active"); + $("#create_event_btn").show(); + }) + c.event_create_div.find("input[for=all_day][type=checkbox]").click(function(){ + if($(this).is(":checked")) + c.event_create_div.find("#non_all_day").hide() + else + c.event_create_div.find("#non_all_day").show() + }) + $( "#dpfrom" ).datepicker({ + defaultDate: "+1w", + changeMonth: true, + numberOfMonths: 3, + onSelect: function( selectedDate ) { + $( "#dpto" ).datepicker( "option", "minDate", selectedDate ); + } + }); + $( "#dpto" ).datepicker({ + defaultDate: "+1w", + changeMonth: true, + numberOfMonths: 3, + onSelect: function( selectedDate ) { + $( "#dpfrom" ).datepicker( "option", "maxDate", selectedDate ); + } + }); + } + c.event_create_div.html(form); + $("#create_event_btn").hide(); + c.event_create_div.show(); + bindHandlers(); + } + this.newCalendars = function(){ if($('.color-picker').length > 0){ $('.color-picker').miniColors(); // just in category view @@ -586,8 +668,26 @@ var calendarAPI = function(){ c.event_quick_view_div.find(".event-close-btn").click(function(){ c.event_quick_view_div.empty().hide(); }) + c.event_quick_view_div.find(".bt-del").bind("ajax:success",function(){ + c.event_quick_view_div.empty().hide(); + dom.remove(); + }) }) } + this.refresh = function(){ + $(".destroy").remove(); + switch (c.view){ + case "week": + c.loadWeekView(c.cur_week,c.cur_year); + break; + case "month": + c.loadMonthView(c.cur_month,c.cur_year); + break; + case "day": + c.loadDayView(c.cur_date,c.cur_month,c.cur_year); + break; + } + } c.initialize(); } diff --git a/vendor/built_in_modules/calendar/app/assets/javascripts/cals.js b/vendor/built_in_modules/calendar/app/assets/javascripts/cals.js new file mode 100644 index 00000000..0443e53a --- /dev/null +++ b/vendor/built_in_modules/calendar/app/assets/javascripts/cals.js @@ -0,0 +1,8 @@ +// This is a manifest file that'll be compiled into including all the files listed below. +// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically +// be included in the compiled file accessible from http://example.com/assets/application.js +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +//= require jquery-ui +//= require calendarAPI \ No newline at end of file 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 686cd600..24bb9062 100644 --- a/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css +++ b/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css @@ -71,7 +71,7 @@ } #calendar_day .event_holder { width: 100%; - height: 100%; + /*height: 100%;*/ position: absolute; top: 0; z-index: 1; diff --git a/vendor/built_in_modules/calendar/app/assets/stylesheets/cals.css b/vendor/built_in_modules/calendar/app/assets/stylesheets/cals.css new file mode 100644 index 00000000..f07975b5 --- /dev/null +++ b/vendor/built_in_modules/calendar/app/assets/stylesheets/cals.css @@ -0,0 +1,8 @@ +/* + *This is a manifest file that'll automatically include all the stylesheets available in this directory + *and any sub-directories. You're free to add application-wide styles to this file and they'll appear at + *the top of the compiled file, but it's generally better to create a new file per style scope. + *= font-awesome + *= calendar + *= bootstrap-responsive +*/ \ No newline at end of file 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 fdf712aa..33cb286d 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 @@ -39,10 +39,10 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController end def day_view - date = params[:date].to_i + @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 + @cur_day = getDayName(@date,month,year) + " " + month.to_s + "/" + @date.to_s + " - " + year.to_s @hours = getHours(12) render :layout => false end diff --git a/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/events_controller.rb b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/events_controller.rb index 41ffa151..4e477ded 100644 --- a/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/events_controller.rb +++ b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/events_controller.rb @@ -8,10 +8,47 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController else @all_day_disabled = false end - @placeholder = params[:date]+"/"+params[:month]+"/"+params[:year] + @hours = getHoursForForm + if params[:time] + + @hours.each_with_index do |h,i| + if h['val'].to_s == params[:time].to_s + @sindex = i + @eindex = i + 2 + break + end + end + else + @sindex = 16 + @eindex = 18 + end + @ampm = Array.new + @ampm << "AM" + @ampm << "PM" + if params[:ses] + @sampm = params[:ses] + @eampm = params[:ses] + if @eindex >= 22 + @eampm = "PM" + end + end + @placeholder = params[:month]+"/"+params[:date]+"/"+params[:year] render :layout => false end - + def edit + @calendars = Cal.all + @event = Event.find(params[:id]) + if @event.all_day + @all_day_disabled = true + else + @all_day_disabled = false + end + @hours = getHoursForForm + @ampm = Array.new + @ampm << "AM" + @ampm << "PM" + render :layout => false + end def create title = params[:event][:title] note = params[:event][:note] @@ -21,14 +58,14 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController $endtime = params[:end_time] temp = $start.split("/") - start_date = temp[0] - start_month = temp[1] + start_month = temp[0] + start_date = temp[1] start_year = temp[2] @m = start_month @y = start_year temp = $end.split("/") - end_date = temp[0] - end_month = temp[1] + end_month = temp[0] + end_date = temp[1] end_year = temp[2] start_am_pm = params[:start_am_pm] @@ -81,6 +118,78 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController h.js end end + + def update + + title = params[:event][:title] + note = params[:event][:note] + $start = params[:start_date] + $end = params[:end_date] + $starttime = params[:start_time] + $endtime = params[:end_time] + + temp = $start.split("/") + start_month = temp[0] + start_date = temp[1] + start_year = temp[2] + @m = start_month + @y = start_year + temp = $end.split("/") + end_month = temp[0] + end_date = temp[1] + end_year = temp[2] + + start_am_pm = params[:start_am_pm] + end_am_pm = params[:end_am_pm] + + cal_id = params[:event][:cal_id] + + # if start_am_pm == "PM" + # temp_start_time = $starttime + 12 + # end + # if end_am_pm == "PM" + # temp_end_time = $endtime + 12 + # end + if params[:all_day] + all_day = true + $starttime = 0 + $endtime = 0 + else + all_day = false + end + + final_start_time = Date.new(start_year.to_i,start_month.to_i,start_date.to_i) + final_end_time = Date.new(end_year.to_i,end_month.to_i,end_date.to_i) + start_week = final_start_time.strftime("%U") + end_week = final_end_time.strftime("%U") + total_days = final_end_time - final_start_time + @event = Event.find(params[:id]) + @event.title = title + @event.note = note + @event.start_year = start_year + @event.end_year = end_year + @event.start_month = start_month + @event.end_month = end_month + @event.start_date = start_date + @event.end_date = end_date + @event.start_time = $starttime + @event.start_am_pm = start_am_pm + @event.end_time = $endtime + @event.end_am_pm = end_am_pm + @event.cal_id = cal_id + @event.final_start_time = final_start_time + @event.final_end_time = final_end_time + @event.total_days = total_days + @event.start_week = start_week + @event.end_week = end_week + @event.all_day = all_day + @event.save! + + respond_to do |h| + h.js + end + end + def show @event = Event.find(params[:id]) @start_month_name = Date::ABBR_MONTHNAMES[@event.start_month] diff --git a/vendor/built_in_modules/calendar/app/helpers/panel/calendar/back_end/cals_helper.rb b/vendor/built_in_modules/calendar/app/helpers/panel/calendar/back_end/cals_helper.rb index fc349ecd..6377debb 100644 --- a/vendor/built_in_modules/calendar/app/helpers/panel/calendar/back_end/cals_helper.rb +++ b/vendor/built_in_modules/calendar/app/helpers/panel/calendar/back_end/cals_helper.rb @@ -180,6 +180,15 @@ module Panel::Calendar::BackEnd::CalsHelper end hours end + + def getHoursForForm + hours = Array.new + for i in 1..12 + hours << {"val"=>i,"title"=>i.to_s+":00"} + hours << {"val"=>i+0.5,"title"=>i.to_s+":30"} + end + hours + end end 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 709437c7..2edd9e7c 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 @@ -28,11 +28,13 @@
<% @hours.each do |hour| %> -
-
+
" ref="add-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @date.to_s %>" ses="AM"> +
-
-
+ <% end %> + <% @hours.each do |hour| %> +
" ref="add-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @date.to_s %>" ses="PM"> +
<% end %>
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 7c708f81..1cc46655 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 @@ -1,10 +1,9 @@ <%= stylesheet_link_tag "font-awesome" %> <%= stylesheet_link_tag "bootstrap-responsive" %> <%= stylesheet_link_tag "calendar" %> -<% content_for :page_specific_javascript do %> - <%= javascript_include_tag "calendarAPI" %> -<% end %> - +<%= javascript_include_tag "cals" %> + +>>>>>>> gallery_orbit
+
+ +
+
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/week_view.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/week_view.html.erb index 62b28113..a7287ba5 100644 --- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/week_view.html.erb +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/week_view.html.erb @@ -62,13 +62,15 @@
<% @hours.each do |hour| %> -
-
-
-
-
-
- <% end %> +
" ref="add-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @date.to_s %>" ses="AM"> +
+
+ <% end %> + <% @hours.each do |hour| %> +
" ref="add-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @date.to_s %>" ses="PM"> +
+
+ <% end %>
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/create.js.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/create.js.erb index 98703270..a07068ca 100644 --- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/create.js.erb +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/create.js.erb @@ -1,4 +1,14 @@ $("#event_create").empty().hide(); $("#create_event_btn").removeClass("active"); -$("#calendar_month tr.event_row").remove(); -calendar.getEventsForMonth(<%= @m %>,<%= @y %>); \ No newline at end of file +$(".destroy").remove(); +switch (c.view){ + case "week": + c.loadWeekView(c.cur_week,c.cur_year); + break; + case "month": + c.loadMonthView(c.cur_month,c.cur_year); + break; + case "day": + c.loadDayView(c.cur_date,c.cur_month,c.cur_year); + break; +} diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/edit.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/edit.html.erb new file mode 100644 index 00000000..3db09901 --- /dev/null +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/edit.html.erb @@ -0,0 +1,133 @@ + \ No newline at end of file diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/new.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/new.html.erb index 5fd5870e..df23e2bf 100644 --- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/new.html.erb +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/new.html.erb @@ -22,72 +22,48 @@
- +
- +
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/show.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/show.html.erb index 6f731784..a52b9f35 100644 --- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/show.html.erb +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/show.html.erb @@ -13,6 +13,6 @@
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/update.js.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/update.js.erb new file mode 100644 index 00000000..8875d214 --- /dev/null +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/update.js.erb @@ -0,0 +1,15 @@ +$("#event_create").empty().hide(); +$("#create_event_btn").removeClass("active"); +$(".destroy").remove(); +$("#create_event_btn").show(); +switch (c.view){ + case "week": + c.loadWeekView(c.cur_week,c.cur_year); + break; + case "month": + c.loadMonthView(c.cur_month,c.cur_year); + break; + case "day": + c.loadDayView(c.cur_date,c.cur_month,c.cur_year); + break; +}