lot of updates

This commit is contained in:
Harry Bomrah 2012-10-26 19:04:51 +08:00 committed by chris
parent 58d4554b0b
commit 513671e498
15 changed files with 471 additions and 97 deletions

View File

@ -6,8 +6,7 @@ Date.prototype.getWeek = function (dowOffset) {
var newYear = new Date(this.getFullYear(),0,1); var newYear = new Date(this.getFullYear(),0,1);
var day = newYear.getDay() - dowOffset; //the day of week the year begins on var day = newYear.getDay() - dowOffset; //the day of week the year begins on
day = (day >= 0 ? day : day + 7); day = (day >= 0 ? day : day + 7);
var daynum = Math.floor((this.getTime() - newYear.getTime() - var daynum = Math.floor((this.getTime() - newYear.getTime() - (this.getTimezoneOffset()-newYear.getTimezoneOffset())*60000)/86400000) + 1;
(this.getTimezoneOffset()-newYear.getTimezoneOffset())*60000)/86400000) + 1;
var weeknum; var weeknum;
//if the year starts before the middle of a week //if the year starts before the middle of a week
if(day < 4) { if(day < 4) {
@ -49,8 +48,8 @@ var calendarAPI = function(){
this.initialize = function(){ this.initialize = function(){
$(window).load(function(){ $(window).load(function(){
// c.loadMonthView(c.cur_month,c.cur_year); // 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); // c.loadDayView(c.cur_date,c.cur_month,c.cur_year);
bindHandlers(); bindHandlers();
}) })
var bindHandlers = function(){ var bindHandlers = function(){
@ -61,16 +60,46 @@ var calendarAPI = function(){
$("#create_event_btn").click(function(){ $("#create_event_btn").click(function(){
if(!$(this).hasClass("active")){ 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{ }else{
c.event_create_div.hide().empty(); c.event_create_div.hide().empty();
} }
$(this).toggleClass("active"); $(this).toggleClass("active");
return false; return false;
}) })
$("td.click_event").live("click",function(){ $(".click_event").live("click",function(e){
c.newEvent($(this).attr("link"),$(this).attr("ref"),$(this).attr("date"),c.cur_month,c.cur_year); 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"); $("#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(){ $('.mode_switch').click(function(){
@ -262,7 +291,7 @@ var calendarAPI = function(){
curparent.append($eventrow); curparent.append($eventrow);
} }
$eventrow = null; $eventrow = null;
$eventrow = $("<tr class='event_row'></tr>"); $eventrow = $("<tr class='event_row destroy'></tr>");
allow = true; allow = true;
}else if(evnt.start_date > curdate){ }else if(evnt.start_date > curdate){
allow = true; allow = true;
@ -358,7 +387,7 @@ var calendarAPI = function(){
var height = 15; var height = 15;
var full_day_count = 0; var full_day_count = 0;
var rowcount = 7; var rowcount = 7;
var tr = $("<tr></tr>"); var tr = $("<tr class='destroy'></tr>");
var pre = true; var pre = true;
$.each(events,function(i,evnt){ $.each(events,function(i,evnt){
// console.log("rowcount: "+rowcount); // console.log("rowcount: "+rowcount);
@ -371,7 +400,7 @@ var calendarAPI = function(){
$("table.all_day_event_holder").append(tr); $("table.all_day_event_holder").append(tr);
} }
tr = null; tr = null;
tr = $('<tr></tr>'); tr = $('<tr class="destroy"></tr>');
pre = true; pre = true;
} }
@ -440,7 +469,7 @@ var calendarAPI = function(){
if(h == 0.5) if(h == 0.5)
halfhour = "half"; halfhour = "half";
h = 17 + 20 + (((h-1) * 2) * 20) + 1; h = 17 + 20 + (((h-1) * 2) * 20) + 1;
var eventdom = $('<div class="event '+halfhour+'" link="'+evnt.show_link+'" style="background-color: '+evnt.color+';color:#fff; top:'+toppx+'px; height:'+h+'px;"><dl><dt>'+displaystarttime+' - '+displayendtime+'</dt><dd>'+evnt.title+'</dd></dl></div>'); var eventdom = $('<div class="event '+halfhour+' destroy" link="'+evnt.show_link+'" style="background-color: '+evnt.color+';color:#fff; top:'+toppx+'px; height:'+h+'px;"><dl><dt>'+displaystarttime+' - '+displayendtime+'</dt><dd>'+evnt.title+'</dd></dl></div>');
$(".week_day_body[date="+evnt.start_date+"] .inner").append(eventdom); $(".week_day_body[date="+evnt.start_date+"] .inner").append(eventdom);
} }
if(full_day_count == 0){ if(full_day_count == 0){
@ -480,7 +509,7 @@ var calendarAPI = function(){
$.getJSON("cals/getDayEvents",{"date":day,"month":month,"year":year},function(events){ $.getJSON("cals/getDayEvents",{"date":day,"month":month,"year":year},function(events){
$.each(events,function(i,evnt){ $.each(events,function(i,evnt){
if(evnt.all_day){ if(evnt.all_day){
$(".all_day_event").append('<div class="event" link="'+evnt.show_link+'" style="background-color: '+evnt.color+';color:#fff;">'+evnt.title+'</div>') $(".all_day_event").append('<div class="event destroy" link="'+evnt.show_link+'" style="background-color: '+evnt.color+';color:#fff;">'+evnt.title+'</div>')
}else{ }else{
var starttime,endtime,displaystarttime,displayendtime; var starttime,endtime,displaystarttime,displayendtime;
if(evnt.start_am_pm == "AM"){ if(evnt.start_am_pm == "AM"){
@ -521,7 +550,7 @@ var calendarAPI = function(){
if(h == 0.5) if(h == 0.5)
halfhour = "half"; halfhour = "half";
h = 17 + 20 + (((h-1) * 2) * 20) + 1; h = 17 + 20 + (((h-1) * 2) * 20) + 1;
var eventdom = $('<div class="inner"><div class="event '+halfhour+'" link="'+evnt.show_link+'" style="background-color: '+evnt.color+';color:#fff; top:'+toppx+'px; height:'+h+'px;"><dl><dt>'+displaystarttime+' - '+displayendtime+'</dt><dd>'+evnt.title+'</dd></dl></div></div>'); var eventdom = $('<div class="inner"><div class="event '+halfhour+' destroy" link="'+evnt.show_link+'" style="background-color: '+evnt.color+';color:#fff; top:'+toppx+'px; height:'+h+'px;"><dl><dt>'+displaystarttime+' - '+displayendtime+'</dt><dd>'+evnt.title+'</dd></dl></div></div>');
$(".event_holder").append(eventdom); $(".event_holder").append(eventdom);
} }
@ -534,7 +563,7 @@ var calendarAPI = function(){
$('.current_day_title').text('September 2, 2012'); $('.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(){ var bindHandlers = function(){
c.event_create_div.find("button.btn-close").click(function(){ c.event_create_div.find("button.btn-close").click(function(){
c.event_create_div.hide().empty(); c.event_create_div.hide().empty();
@ -546,14 +575,67 @@ var calendarAPI = function(){
else else
c.event_create_div.find("#non_all_day").show() 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(); c.event_create_div.show();
bindHandlers(); 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(){ this.newCalendars = function(){
if($('.color-picker').length > 0){ if($('.color-picker').length > 0){
$('.color-picker').miniColors(); // just in category view $('.color-picker').miniColors(); // just in category view
@ -586,7 +668,25 @@ var calendarAPI = function(){
c.event_quick_view_div.find(".event-close-btn").click(function(){ c.event_quick_view_div.find(".event-close-btn").click(function(){
c.event_quick_view_div.empty().hide(); 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(); c.initialize();

View File

@ -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

View File

@ -71,7 +71,7 @@
} }
#calendar_day .event_holder { #calendar_day .event_holder {
width: 100%; width: 100%;
height: 100%; /*height: 100%;*/
position: absolute; position: absolute;
top: 0; top: 0;
z-index: 1; z-index: 1;

View File

@ -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
*/

View File

@ -39,10 +39,10 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController
end end
def day_view def day_view
date = params[:date].to_i @date = params[:date].to_i
month = params[:month].to_i month = params[:month].to_i
year = params[:year].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) @hours = getHours(12)
render :layout => false render :layout => false
end end

View File

@ -8,10 +8,47 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController
else else
@all_day_disabled = false @all_day_disabled = false
end 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 render :layout => false
end end
def create def create
title = params[:event][:title] title = params[:event][:title]
note = params[:event][:note] note = params[:event][:note]
@ -21,14 +58,14 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController
$endtime = params[:end_time] $endtime = params[:end_time]
temp = $start.split("/") temp = $start.split("/")
start_date = temp[0] start_month = temp[0]
start_month = temp[1] start_date = temp[1]
start_year = temp[2] start_year = temp[2]
@m = start_month @m = start_month
@y = start_year @y = start_year
temp = $end.split("/") temp = $end.split("/")
end_date = temp[0] end_month = temp[0]
end_month = temp[1] end_date = temp[1]
end_year = temp[2] end_year = temp[2]
start_am_pm = params[:start_am_pm] start_am_pm = params[:start_am_pm]
@ -81,6 +118,78 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController
h.js h.js
end end
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 def show
@event = Event.find(params[:id]) @event = Event.find(params[:id])
@start_month_name = Date::ABBR_MONTHNAMES[@event.start_month] @start_month_name = Date::ABBR_MONTHNAMES[@event.start_month]

View File

@ -180,6 +180,15 @@ module Panel::Calendar::BackEnd::CalsHelper
end end
hours hours
end 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 end

View File

@ -28,11 +28,13 @@
<td> <td>
<div class="event_list_wrapper"> <div class="event_list_wrapper">
<% @hours.each do |hour| %> <% @hours.each do |hour| %>
<div class="cell"> <div class="cell click_event" time="<%= hour.to_s+".5" %>" ref="add-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @date.to_s %>" ses="AM">
<div class="divide"></div> <div class="divide click_event" time="<%= hour %>" ref="add-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @date.to_s %>" ses="AM"></div>
</div> </div>
<div class="cell"> <% end %>
<div class="divide"></div> <% @hours.each do |hour| %>
<div class="cell click_event" time="<%= hour.to_s+".5" %>" ref="add-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @date.to_s %>" ses="PM">
<div class="divide click_event" time="<%= hour %>" ref="add-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @date.to_s %>" ses="PM"></div>
</div> </div>
<% end %> <% end %>
<div class="event_holder"> <div class="event_holder">

View File

@ -1,10 +1,8 @@
<%= stylesheet_link_tag "font-awesome" %> <%= stylesheet_link_tag "font-awesome" %>
<%= stylesheet_link_tag "calendar" %> <%= stylesheet_link_tag "calendar" %>
<%= stylesheet_link_tag "bootstrap-responsive" %> <%= stylesheet_link_tag "bootstrap-responsive" %>
<% content_for :page_specific_javascript do %> <%= javascript_include_tag "cals" %>
<%= javascript_include_tag "calendarAPI" %> <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.0/themes/cupertino/jquery-ui.css">
<% end %>
<div id="filter" class="subnav"> <div id="filter" class="subnav">
<ul class="nav nav-pills filter"> <ul class="nav nav-pills filter">
<li class="accordion-group"> <li class="accordion-group">
@ -43,12 +41,16 @@
<h4 class="current_day_title"></h4> <h4 class="current_day_title"></h4>
</div> </div>
<div class="span4"> <div class="span4">
<div class="btn-group pull-right">
<button id="refresh_btn" class="btn icon-refresh"></button>
</div>
<div class="btn-group calendar_mode" data-toggle="buttons-radio"> <div class="btn-group calendar_mode" data-toggle="buttons-radio">
<button class="btn mode_switch">day</button> <button class="btn mode_switch">day</button>
<button class="btn mode_switch">week</button> <button class="btn mode_switch">week</button>
<button class="btn active mode_switch">month</button> <button class="btn active mode_switch">month</button>
<button class="btn mode_switch">agenda</button> <button class="btn mode_switch">agenda</button>
</div> </div>
</div> </div>
</div> </div>
<div id="view_holder"></div> <div id="view_holder"></div>

View File

@ -62,11 +62,13 @@
<div class="event_list_wrapper"> <div class="event_list_wrapper">
<div class="cell_wrapper"> <div class="cell_wrapper">
<% @hours.each do |hour| %> <% @hours.each do |hour| %>
<div class="cell"> <div class="cell click_event" time="<%= hour.to_s+".5" %>" ref="add-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @date.to_s %>" ses="AM">
<div class="divide"></div> <div class="divide click_event" time="<%= hour %>" ref="add-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @date.to_s %>" ses="AM"></div>
</div> </div>
<div class="cell"> <% end %>
<div class="divide"></div> <% @hours.each do |hour| %>
<div class="cell click_event" time="<%= hour.to_s+".5" %>" ref="add-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @date.to_s %>" ses="PM">
<div class="divide click_event" time="<%= hour %>" ref="add-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @date.to_s %>" ses="PM"></div>
</div> </div>
<% end %> <% end %>
</div> </div>

View File

@ -1,4 +1,14 @@
$("#event_create").empty().hide(); $("#event_create").empty().hide();
$("#create_event_btn").removeClass("active"); $("#create_event_btn").removeClass("active");
$("#calendar_month tr.event_row").remove(); $(".destroy").remove();
calendar.getEventsForMonth(<%= @m %>,<%= @y %>); 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;
}

View File

@ -0,0 +1,133 @@
<div class="modal-body">
<div class="event_controller">
<!-- <form class="form-horizontal"> -->
<%= form_for @event, :url =>panel_calendar_back_end_event_path(@event), :class=>"form-horizontal", :remote => true do |f| %>
<div class="row-fluid">
<button type="button" class="close btn-close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="row-fluid">
<%= f.text_field :title, :class=>"span12", :placeholder => "Event Name",:value=>@event.title %>
</div>
<div class="row-fluid">
<label class="checkbox inline">
<input type="checkbox" name="all_day" for="all_day" <%= @event.all_day == true ? "checked='checked'" : "" %> > All day
</label>
<label class="checkbox inline">
<input type="checkbox"> Repeat
</label>
</div>
<% if !@event.all_day %>
<div id="non_all_day">
<div class="row-fluid">
<label class="control-label span3">From</label>
<div class="row-fluid span9">
<input class="span5" id="dpfrom" type="text" value="<%= @event.start_month.to_s + "/" + @event.start_date.to_s + "/" + @event.start_year.to_s %>" name="start_date">
<select name="start_time" class="span4">
<% @hours.each_with_index do |hour,i| %>
<% if hour['val'] == @event.start_time %>
<option value="<%= hour['val'] %>" selected="selected"><%= hour['title'] %></option>
<% else %>
<option value="<%= hour['val'] %>" ><%= hour['title'] %></option>
<% end %>
<% end %>
</select>
<select name="start_am_pm" class="span3">
<% @ampm.each do |a| %>
<% if @event.start_am_pm == a %>
<option value="<%= a %>" selected="selected"><%= a %></option>
<% else %>
<option value="<%= a %>"><%= a %></option>
<% end %>
<% end %>
</select>
</div>
</div>
<div class="row-fluid">
<label class="control-label span3">To</label>
<div class="row-fluid span9">
<input class="span5" id="dpto" type="text" value="<%= @event.end_month.to_s + "/" + @event.end_date.to_s + "/" + @event.end_year.to_s %>" name="end_date">
<select name="end_time" class="span4">
<% @hours.each_with_index do |hour,i| %>
<% if hour['val'] == @event.end_time %>
<option value="<%= hour['val'] %>" selected="selected"><%= hour['title'] %></option>
<% else %>
<option value="<%= hour['val'] %>" ><%= hour['title'] %></option>
<% end %>
<% end %>
</select>
<select name="end_am_pm" class="span3">
<% @ampm.each do |a| %>
<% if @event.end_am_pm == a %>
<option value="<%= a %>" selected="selected"><%= a %></option>
<% else %>
<option value="<%= a %>"><%= a %></option>
<% end %>
<% end %>
</select>
</div>
</div>
</div>
<% else %>
<div id="non_all_day" style="display:none;">
<div class="row-fluid">
<label class="control-label span3">From</label>
<div class="row-fluid span9">
<input class="span5" id="dpfrom" type="text" value="" name="start_date">
<select name="start_time" class="span4">
<% @hours.each_with_index do |hour,i| %>
<% if i == 16 %>
<option value="<%= hour['val'] %>" selected="selected"><%= hour['title'] %></option>
<% else %>
<option value="<%= hour['val'] %>" ><%= hour['title'] %></option>
<% end %>
<% end %>
</select>
<select name="start_am_pm" class="span3">
<option value="AM">AM</option>
<option value="PM">PM</option>
</select>
</div>
</div>
<div class="row-fluid">
<label class="control-label span3">To</label>
<div class="row-fluid span9">
<input class="span5" id="dpto" type="text" name="end_date" value="<%= @placeholder %>" placeholder="<%= @placeholder %>">
<select name="start_time" class="span4">
<% @hours.each_with_index do |hour,i| %>
<% if i == 18 %>
<option value="<%= hour['val'] %>" selected="selected"><%= hour['title'] %></option>
<% else %>
<option value="<%= hour['val'] %>" ><%= hour['title'] %></option>
<% end %>
<% end %>
</select>
<select name="end_am_pm" class="span3">
<option value="AM">AM</option>
<option value="PM">PM</option>
</select>
</div>
</div>
</div>
<% end %>
<div class="row-fluid">
<label for="" class="control-label span3">Calendars</label>
<div class="row-fluid span9">
<%= f.select(:cal_id, Cal.all.collect {|p| [ p.name, p.id ] },{:prompt => t("calendar.select_calendar")},:class => "validate", :selected => @event.cal_id) %>
</div>
</div>
<div class="row-fluid">
<label for="" class="control-label span3">Note</label>
<div class="row-fluid span9">
<%= f.text_area :note, :class=>"span12", :cols=>"30", :rows=>"3", :value => @event.note %>
</div>
</div>
<div class="row-fluid">
<div class="span9 offset3">
<button class="btn btn-close">Cancel</button>
<%= f.submit t("calendar.save"), :class=>"btn" %>
</div>
</div>
<% end %>
<!-- </form> -->
</div>
</div>

View File

@ -22,72 +22,48 @@
<div class="row-fluid"> <div class="row-fluid">
<label class="control-label span3">From</label> <label class="control-label span3">From</label>
<div class="row-fluid span9"> <div class="row-fluid span9">
<input class="span5" type="text" value="<%= @placeholder %>" name="start_date" placeholder="<%= @placeholder %>"> <input class="span5" id="dpfrom" type="text" value="<%= @placeholder %>" name="start_date" placeholder="<%= @placeholder %>">
<select name="start_time" class="span4"> <select name="start_time" class="span4">
<option value="1.00">1:00</option> <% @hours.each_with_index do |hour,i| %>
<option value="1.50">1:30</option> <% if i == @sindex %>
<option value="2.00">2:00</option> <option value="<%= hour['val'] %>" selected="selected"><%= hour['title'] %></option>
<option value="2.50">2:30</option> <% else %>
<option value="3.00">3:00</option> <option value="<%= hour['val'] %>" ><%= hour['title'] %></option>
<option value="3.50">3:30</option> <% end %>
<option value="4.00">4:00</option> <% end %>
<option value="4.50">4:30</option>
<option value="5.00">5:00</option>
<option value="5.50">5:30</option>
<option value="6.00">6:00</option>
<option value="6.50">6:30</option>
<option value="7.00">7:00</option>
<option value="7.50">7:30</option>
<option value="8.00">8:00</option>
<option value="8.50">8:30</option>
<option value="9.00">9:00</option>
<option value="9.50">9:30</option>
<option value="10.00">10:00</option>
<option value="10.50">10:30</option>
<option value="11.00">11:00</option>
<option value="11.50">11:30</option>
<option value="12.00">12:00</option>
<option value="12.50">12:30</option>
</select> </select>
<select name="start_am_pm" class="span3"> <select name="start_am_pm" class="span3">
<option value="AM">AM</option> <% @ampm.each do |a| %>
<option value="PM">PM</option> <% if @sampm == a %>
<option value="<%= a %>" selected="selected"><%= a %></option>
<% else %>
<option value="<%= a %>"><%= a %></option>
<% end %>
<% end %>
</select> </select>
</div> </div>
</div> </div>
<div class="row-fluid"> <div class="row-fluid">
<label class="control-label span3">To</label> <label class="control-label span3">To</label>
<div class="row-fluid span9"> <div class="row-fluid span9">
<input class="span5" type="text" name="end_date" value="<%= @placeholder %>" placeholder="<%= @placeholder %>"> <input class="span5" id="dpto" type="text" name="end_date" value="<%= @placeholder %>" placeholder="<%= @placeholder %>">
<select name="end_time" class="span4"> <select name="end_time" class="span4">
<option value="1.00">1:00</option> <% @hours.each_with_index do |hour,i| %>
<option value="1.50">1:30</option> <% if i == @eindex %>
<option value="2.00">2:00</option> <option value="<%= hour['val'] %>" selected="selected"><%= hour['title'] %></option>
<option value="2.50">2:30</option> <% else %>
<option value="3.00">3:00</option> <option value="<%= hour['val'] %>" ><%= hour['title'] %></option>
<option value="3.50">3:30</option> <% end %>
<option value="4.00">4:00</option> <% end %>
<option value="4.50">4:30</option>
<option value="5.00">5:00</option>
<option value="5.50">5:30</option>
<option value="6.00">6:00</option>
<option value="6.50">6:30</option>
<option value="7.00">7:00</option>
<option value="7.50">7:30</option>
<option value="8.00">8:00</option>
<option value="8.50">8:30</option>
<option value="9.00">9:00</option>
<option value="9.50">9:30</option>
<option value="10.00">10:00</option>
<option value="10.50">10:30</option>
<option value="11.00">11:00</option>
<option value="11.50">11:30</option>
<option value="12.00">12:00</option>
<option value="12.50">12:30</option>
</select> </select>
<select name="end_am_pm" class="span3"> <select name="end_am_pm" class="span3">
<option value="AM">AM</option> <% @ampm.each do |a| %>
<option value="PM">PM</option> <% if @eampm == a %>
<option value="<%= a %>" selected="selected"><%= a %></option>
<% else %>
<option value="<%= a %>"><%= a %></option>
<% end %>
<% end %>
</select> </select>
</div> </div>
</div> </div>

View File

@ -13,6 +13,6 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<%= link_to "Delete", panel_calendar_back_end_event_path(@event),:class => "btn", :method => :delete, :remote => true %> <%= link_to t("calendar.delete"), panel_calendar_back_end_event_path(@event),:class => "btn bt-del", :method => :delete, :remote => true %>
<a href="#" class="btn btn-primary">Edit</a> <%= link_to t("calendar.edit"), edit_panel_calendar_back_end_event_path(@event),:class => "btn btn-primary",:id=>"edit_event_btn" ,:remote => true %>
</div> </div>

View File

@ -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;
}