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 77faba8a..94a9fcb9 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 @@ -4,6 +4,10 @@ var calendarAPI = function(){ c = this; this.event_create_div = $("#event_create"); this.event_quick_view_div = $("#event_quick_view"); + this.cur_month = null; + this.cur_year = null; + this.today = new Date(); + this.monthlist = ["","January","February","March","April","May","June","July","August","September","October","November","December"]; this.initialize = function(){ $(window).load(function(){ c.loadMonthView(); @@ -24,7 +28,7 @@ var calendarAPI = function(){ var target = $(this).text(); switch(target){ case 'month': - c.loadMonthView(); + c.loadMonthView(c.cur_month,c.cur_year); break; case 'week': c.loadWeekView(); @@ -36,12 +40,46 @@ var calendarAPI = function(){ c.loadAgendaView(); break; } - }); + }) + $("button#prev_month_btn").click(function(){ + var m,y; + if(c.cur_month == 1){ + m = 12; + y = c.cur_year-1; + }else{ + m = c.cur_month-1; + y = c.cur_year; + } + c.loadMonthView(m,y); + }) + $("button#next_month_btn").click(function(){ + var m,y; + if(c.cur_month == 12){ + m = 1; + y = c.cur_year+1; + }else{ + m = c.cur_month+1; + y = c.cur_year; + } + c.loadMonthView(m,y); + }) + $("button#today_btn").click(function(){ + c.loadMonthView(); + }) } } - this.loadMonthView = function(){ - $('#view_holder').load("cals/month_view", function() { - $('.current_day_title').text('September 2012'); + this.loadMonthView = function(month,year){ + if(!month){ + var dt = new Date(); + month = dt.getMonth()+1; + year = dt.getFullYear(); + } + // month = 2; + // year = 2008; + c.cur_month = month; + c.cur_year = year; + $('#view_holder').load("cals/month_view?month="+month+"&year="+year, function() { + $('.current_day_title').text(c.monthlist[c.cur_month]+" "+c.cur_year); if($('#calendar_month').length > 0){ var $c_table = $('#calendar_month'); var sum_h = 0; @@ -106,6 +144,10 @@ var calendarAPI = function(){ if($('.color-picker').length > 0){ $('.color-picker').miniColors(); // just in category view } + $(".btn-del-a").live("ajax:success",function(){ + var domfor = $(this).attr("data-content"); + $("tr[for="+domfor+"]").remove(); + }) } this.displayEvent = function(){ 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 86764157..27a0f484 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 @@ -1,5 +1,6 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController include AdminHelper + include Panel::Calendar::BackEnd::CalsHelper def index @@ -8,13 +9,20 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController def new @calendar = Cal.new @calendars = Cal.all - debugger end def create - debugger - calendar = Cal.new(params[:cal]) - render :json => calendar.to_json + @calendar = Cal.new(params[:cal]) + @calendar.save! + respond_to do |h| + h.js + end + end + + def destroy + calendar = Cal.find(params[:id]) + calendar.delete + render :json => {"success"=>"true"}.to_json end def day_view @@ -26,6 +34,20 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController end def month_view + month = params[:month].to_i + year = params[:year].to_i + t = Time.now + startday = monthStartDay(month,year) + @pre_disabled_days = startday - 1 + if t.month == month && t.year == year + @today = @pre_disabled_days + t.day + else + @today = 50 + end + cur_month_days = getMonthDays(year) + @post_disabled_days = @pre_disabled_days + cur_month_days[month] + @dateset = getDateSet(month,year) + 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 1b459f48..6900480e 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 @@ -1,6 +1,7 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController def new + @calendars = Cal.all render :layout => false end end \ No newline at end of file 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 new file mode 100644 index 00000000..60a14ffa --- /dev/null +++ b/vendor/built_in_modules/calendar/app/helpers/panel/calendar/back_end/cals_helper.rb @@ -0,0 +1,65 @@ +module Panel::Calendar::BackEnd::CalsHelper + + def monthStartDay(month,year) + dt = Date.new(year,month,1) + startday = dt.wday + 1 + return startday + end + + def getDateSet(month,year) + dateset = Array.new + startday = monthStartDay(month,year) + monthsdays = getMonthDays(year) + + cur_month_days = monthsdays[month] + next_month_days = monthsdays[month+1] + prev_month_days = monthsdays[month-1] + + prev_month_days_to_add = startday - 1 + + i = prev_month_days_to_add + while i > 0 do + i -= 1 + dateset << prev_month_days - i + end + + i = 0 + while i < cur_month_days do + dateset << i + 1 + i += 1 + end + + next_month_days_to_add = 42 - (prev_month_days_to_add + cur_month_days) + + i = 0 + while i < next_month_days_to_add do + dateset << i + 1 + i += 1 + end + + return dateset + end + + def getMonthDays(year) + monthsdays = Array.new + monthsdays << 0 + monthsdays << 31 + if Date.new(year).leap? + monthsdays << 29 + else + monthsdays << 28 + end + monthsdays << 31 + monthsdays << 30 + monthsdays << 31 + monthsdays << 30 + monthsdays << 31 + monthsdays << 31 + monthsdays << 30 + monthsdays << 31 + monthsdays << 30 + monthsdays << 31 + return monthsdays + end + +end \ No newline at end of file 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 new file mode 100644 index 00000000..9accb75a --- /dev/null +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/_calendar.html.erb @@ -0,0 +1,16 @@ + + + +
+ +
+ + <% @site_valid_locales.each do |locale| %> + + <%= calendar.name_translations[locale] %> + + <% end %> + \ No newline at end of file diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/create.js.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/create.js.erb new file mode 100644 index 00000000..4e52c64c --- /dev/null +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/create.js.erb @@ -0,0 +1 @@ +$("#calendar_list").prepend("<%= j render :partial=>'calendar', :object=>@calendar %>"); \ 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 0a81c50e..1ebf08b2 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 @@ -31,16 +31,16 @@
- +
- - + +
-

Semptember 2012

+

diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/month_view.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/month_view.html.erb index 6b9b4470..8416b967 100644 --- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/month_view.html.erb +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/month_view.html.erb @@ -12,55 +12,50 @@
-
- - - - - - - - - - -
- - - - - - - - - - -
Aug 262728293031Sep 1
-
-
- - - - - - - - - - -
- - - - - - - - - - -
2345678
-
-
+ + <% i = 0 %> + <% day_count_for_title = 0 %> + <% day_count_for_space = 0 %> + <% while i < 6 %> +
+ + + <% x = 0 %> + <% while x < 7 %> + <% if day_count_for_space < @pre_disabled_days %> + + <% elsif day_count_for_space >= @post_disabled_days %> + + <% elsif day_count_for_space == @today-1 %> + + <% else %> + + <% end %> + <% day_count_for_space += 1 %> + <% x += 1 %> + <% end %> + +
+ + + <% x = 0 %> + <% while x < 7 %> + <% if day_count_for_title < @pre_disabled_days %> + + <% elsif day_count_for_title >= @post_disabled_days %> + + <% else %> + + <% end %> + <% day_count_for_title += 1 %> + <% x += 1 %> + <% end %> + +
<%= @dateset[day_count_for_title] %><%= @dateset[day_count_for_title] %><%= @dateset[day_count_for_title] %>
+
+ <% i += 1 %> + <% end %> +
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/new.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/new.html.erb index ec40e887..80de4ed2 100644 --- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/new.html.erb +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/new.html.erb @@ -12,47 +12,25 @@ - - + - +
KeyColorColor EnglishChinessChinese
- - - +
- - - <% @calendars.each do |calendar| %> - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - <% end %> + + <%= render :partial => "calendar", :collection => @calendars %>
- - - - <% calendar.name_translations[locale] %> -
@@ -63,7 +41,7 @@
<%= label_tag("color", t("calendar.color")) %> - <%= f.text_field :color, :class => "color-picker miniColors span5", :size => "7", :maxlength => "7", :autocomplete=>"off",:value=>"FFCC00" %> + <%= f.text_field :color, :class => "color-picker miniColors span5", :size => "7", :maxlength => "7", :autocomplete=>"off",:value=>"9100FF" %>
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 ca9778eb..9515c57e 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 @@ -95,11 +95,12 @@
-