diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 0aa6a930..8a67b0c8 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -112,7 +112,7 @@ <%#= content_tag :li, link_to(t('admin.ad.all_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %> <%#= content_tag :li, link_to(t('admin.ad.new_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %> <%#= content_tag :li, link_to(t('admin.ad.new_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %> - <%= content_tag :li, link_to((t('calendar.calendars') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_calendar_back_end_calendar_categories_path), :class => active_for_action('calendar_categories','index') %> + <%= content_tag :li, link_to((t('calendar.calendars') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_panel_calendar_back_end_cal_path), :class => active_for_action('cals','new') %> <%#= content_tag :li, link_to(t('gallery.tags'), panel_gallery_back_end_tags_path), :class => active_for_action('/panel/gallery/back_end/tags', 'index') %> <%#= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "gallery"}))), :class => active_for_app_auth('gallery') if (is_admin? rescue nil) %> <% end -%> 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 d5999917..77faba8a 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 @@ -1,83 +1,122 @@ -$(window).load(function(){ - if($('.color-picker').length > 0){ - $('.color-picker').miniColors(); // just in category view - } +//created on sep 14 2012 - var view_url = 'http://localhost:3000/panel/calendar/back_end/cals/'; - - // below calendar start - - $.get(view_url+'month_view', function(data) { - $('#view_holder').html(data); - month_fn(); - }); - $.get(view_url+'new', function(data) { - $('#create .modal-body').html(data); - }); - - // view switch (for view test) - $('.mode_switch').click(function(){ - var target = $(this).text(); - $.get(view_url+target+'_view', function(data) { - $('#view_holder').html(data); - switch(target){ - case 'month': - month_fn(); - break; - case 'week': - week_fn(); - break; - case 'day': - day_fn(); - break; - case 'agenda': - agenda_fn(); - break; - } - }); - }); - - // month fn - var month_fn = function(){ - $('.current_day_title').text('September 2012'); - - // month view - if($('#calendar_month').length > 0){ - var $c_table = $('#calendar_month'); - var sum_h = 0; - var context_h = $('#main-sidebar').outerHeight(); - $('#main-wrap > *').not('#orbit_calendar, .modal').each(function(){ - sum_h += $(this).outerHeight(); - }); - - $c_table - // .height(context_h-sum_h-64) - .find('.month_row') - .not('.month_row.header') - .height((context_h-sum_h-92) / 6); +var calendarAPI = function(){ + c = this; + this.event_create_div = $("#event_create"); + this.event_quick_view_div = $("#event_quick_view"); + this.initialize = function(){ + $(window).load(function(){ + c.loadMonthView(); + bindHandlers(); + }) + var bindHandlers = function(){ + $(".event").live("click",function(){ + c.displayEvent(); + }) - $(window).resize(function(){ - $c_table - .find('.month_row') - .not('.month_row.header') - .height(($('#main-sidebar').outerHeight()-sum_h-92) / 6); + $("#create_event_btn").click(function(){ + c.newEvent($(this)); + $(this).toggleClass("active"); + return false; + }) + + $('.mode_switch').click(function(){ + var target = $(this).text(); + switch(target){ + case 'month': + c.loadMonthView(); + break; + case 'week': + c.loadWeekView(); + break; + case 'day': + c.loadDayView(); + break; + case 'agenda': + c.loadAgendaView(); + break; + } }); } - }; - - // week fn - var week_fn = function(){ - $('.current_day_title').text('September 2 - 8, 2012'); } + this.loadMonthView = function(){ + $('#view_holder').load("cals/month_view", function() { + $('.current_day_title').text('September 2012'); + if($('#calendar_month').length > 0){ + var $c_table = $('#calendar_month'); + var sum_h = 0; + var context_h = $('#main-sidebar').outerHeight(); + $('#main-wrap > *').not('#orbit_calendar, .modal').each(function(){ + sum_h += $(this).outerHeight(); + }); - // day fn - var day_fn = function(){ - $('.current_day_title').text('September 2, 2012'); + $c_table + // .height(context_h-sum_h-64) + .find('.month_row') + .not('.month_row.header') + .height((context_h-sum_h-92) / 6); + + $(window).resize(function(){ + $c_table + .find('.month_row') + .not('.month_row.header') + .height(($('#main-sidebar').outerHeight()-sum_h-92) / 6); + }); + } + }) } - - // agenda fn - var agenda_fn = function(){ - $('.current_day_title').text('September 2, 2012'); + this.loadWeekView = function(){ + $('#view_holder').load("cals/week_view", function() { + $('.current_day_title').text('September 2 - 8, 2012'); + }) } + this.loadDayView = function(){ + $('#view_holder').load("cals/day_view", function() { + $('.current_day_title').text('September 2, 2012'); + }) + } + this.loadAgendaView = function(){ + $('#view_holder').load("cals/week_view", function() { + $('.current_day_title').text('September 2, 2012'); + }) + } + this.newEvent = function(dom){ + var bindHandlers = function(){ + c.event_create_div.find("button.btn-close").click(function(){ + c.event_create_div.hide().empty(); + dom.removeClass("active"); + }) + 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() + }) + } + if(!dom.hasClass("active")){ + c.event_create_div.load(dom.attr("href"),function(){ + c.event_create_div.show(); + bindHandlers(); + }) + }else{ + c.event_create_div.hide().empty(); + } + } + this.newCalendars = function(){ + if($('.color-picker').length > 0){ + $('.color-picker').miniColors(); // just in category view + } + } + this.displayEvent = function(){ + + c.event_quick_view_div.show() + } + c.initialize(); +} + + + + + + -}); \ 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 e8bc4a96..421f8334 100644 --- a/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css +++ b/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css @@ -19,6 +19,7 @@ } .calendar_mode { float: right; + z-index: 2; } .mode_switch { text-transform: capitalize; @@ -69,6 +70,7 @@ height: 100%; position: absolute; top: 0; + z-index: 1; } .event_holder .inner { position: relative; diff --git a/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/calendar_categories_controller.rb b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/calendar_categories_controller.rb deleted file mode 100644 index 7c368659..00000000 --- a/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/calendar_categories_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Panel::Calendar::BackEnd::CalendarCategoriesController < OrbitBackendController - - def index - - end - -end \ 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 b55f5a35..86764157 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 @@ -6,7 +6,15 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController end def new - render :layout => false + @calendar = Cal.new + @calendars = Cal.all + debugger + end + + def create + debugger + calendar = Cal.new(params[:cal]) + render :json => calendar.to_json end def day_view 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 new file mode 100644 index 00000000..1b459f48 --- /dev/null +++ b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/events_controller.rb @@ -0,0 +1,6 @@ +class Panel::Calendar::BackEnd::EventsController < OrbitBackendController + + def new + render :layout => false + end +end \ No newline at end of file diff --git a/vendor/built_in_modules/calendar/app/models/cal.rb b/vendor/built_in_modules/calendar/app/models/cal.rb new file mode 100644 index 00000000..a1e8c6ab --- /dev/null +++ b/vendor/built_in_modules/calendar/app/models/cal.rb @@ -0,0 +1,9 @@ +class Cal + include Mongoid::Document + include Mongoid::Timestamps + + field :name, localize: true + field :color + has_many :events, :autosave => true, :dependent => :destroy + accepts_nested_attributes_for :events, :allow_destroy => true +end \ No newline at end of file diff --git a/vendor/built_in_modules/calendar/app/models/event.rb b/vendor/built_in_modules/calendar/app/models/event.rb new file mode 100644 index 00000000..eb6f218d --- /dev/null +++ b/vendor/built_in_modules/calendar/app/models/event.rb @@ -0,0 +1,16 @@ +class Event + include Mongoid::Document + include Mongoid::Timestamps + + field :title + field :description + field :start_year + field :end_year + field :start_month + field :end_month + field :start_date + field :end_date + + belongs_to :cal + +end \ No newline at end of file diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/calendar_categories/index.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/calendar_categories/index.html.erb deleted file mode 100644 index db939b74..00000000 --- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/calendar_categories/index.html.erb +++ /dev/null @@ -1,91 +0,0 @@ -<%= stylesheet_link_tag "jquery.miniColors" %> -<%= stylesheet_link_tag "calendar" %> -<%= javascript_include_tag "jquery.miniColors.min" %> -<% content_for :page_specific_javascript do %> - <%= javascript_include_tag "calendarAPI" %> -<% end %> - - -
- - -- | - | - | - |
---|---|---|---|
- key_name
-
-
-
- |
- - - | -English_title | -Chinese_title | -