new ui for calendar fixed.

This commit is contained in:
Harry Bomrah 2013-07-15 17:54:15 +08:00 committed by saurabhbhatia
parent 0d0f85e7ad
commit 4ff5724379
99 changed files with 9807 additions and 0 deletions

View File

@ -0,0 +1,6 @@
.bundle/
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/log/*.log
test/dummy/tmp/

View File

@ -0,0 +1,18 @@
source "http://rubygems.org"
# Declare your gem's dependencies in calendar.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
# jquery-rails is used by the dummy application
gem "jquery-rails"
# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
gem "time_difference"

View File

@ -0,0 +1,20 @@
Copyright 2012 YOURNAME
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,3 @@
= Calendar
This project rocks and uses MIT-LICENSE.

View File

@ -0,0 +1,39 @@
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
begin
require 'rdoc/task'
rescue LoadError
require 'rdoc/rdoc'
require 'rake/rdoctask'
RDoc::Task = Rake::RDocTask
end
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'Calendar'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
task :default => :test

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,688 @@
var Calendar = function(dom){
c = this;
this.create_event_btn = $("#create_event_btn");
this.event_create_space = $("#event_create_space");
this.title = $("#current_title");
this.calendar = $(dom);
this.nextBtn = $("#next_month_btn");
this.prevBtn = $("#prev_month_btn");
this.todayBtn = $("#today_btn");
this.modeBtns = $(".calendar_mode button");
this.refreshBtn = $("#refresh_btn");
this.dialog = new EventDialog(c);
this.loading = $('#calendar-loading');
this.success_event = null;
this.agenda_space = $("#calendar_agenda");
this.currentView = "month";
this.navigation = $("#navigation");
this.rangeSelection = $("#range_selection");
var agendaView = new AgendaView(c);
var loadeventsonviewchange = false;
this.initialize = function(){
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var change_event = function(_event, delta) {
_event.end = (_event.end ? _event.end : _event.start);
var s = $.fullCalendar.parseDate(c.calendar.find(".fc-view table tbody td:first").data("date"));
var e = $.fullCalendar.parseDate(c.calendar.find(".fc-view table tbody td:first").data("date"));
$.ajax({
url: "/panel/calendar_new/back_end/events/"+_event.id+'.json',
data: {event:{id:_event.id,start:_event.start,end: _event.end,_s:Math.round(+s / 1000), _e:Math.round(+e / 1000)}},
type: 'put' ,
datatype: 'JSON',
error: function(jqXHR, textStatus, errorThrown) {},
success: function(data) {
console.log('event was success updated');
}
});
}
var success_event = function(data,allDay,type){
c.event_create_space.html(data).show();
var dtpick = $('.datetimepick');
var pickers = new Array();
var checked = ($("#all_day_check").is(":checked") ? true : false);
var checked_function = function(c){
if(c){
for(i in pickers){
var input = pickers[i].find("input");
input.val(input.val().split(" ")[0]);
}
}else{
for(i in pickers){
var d = new Date();
var input = pickers[i].find("input");
if(input.val())
input.val(input.val() + " " + d.getHours() + ":" + d.getMinutes());
}
}
}
var repeat_function = function(){
if(c.event_create_space.find("#event_period").val() == c.event_create_space.find("#event_period option:eq(0)").val()){
c.event_create_space.find("#event_frequency").attr("disabled","disabled");
}else{
c.event_create_space.find("#event_frequency").removeAttr("disabled");
}
}
dtpick.each(function() {
var $data = $(this).data();
var options = {
format: $data.dateFormat,
pickTime: $data.picktime,
language: $data.language,
place: "top"
}
pickers.push(
$(this).datetimepicker(options)
);
});
$("a.btn-close").one("click",function(){
c.event_create_space.html("").hide();
return false;
});
$("#all_day_check").click(function(){
if($(this).is(":checked")){
checked = true;
}else{
checked = false;
}
checked_function(checked);
});
$("#recurring_checkbox").click(function(){
if($(this).is(":checked"))
$("#recurring_panel").show();
else
$("#recurring_panel").hide();
})
$('form[data-remote]').bind("ajax:success",function(evt, data, status){
c.event_create_space.html("").hide();
if(type == "new")
c.renderEvent(data);
if(type == "edit")
c.calendar.fullCalendar("refetchEvents");
});
c.event_create_space.find("#event_period").change(function(){
repeat_function();
})
for(i in pickers){
pickers[i].on("changeDate",function(e){
if(checked){
var input = $(this).find("input");
input.val(input.val().split(" ")[0]);
}
})
}
repeat_function();
if(allDay)
checked_function(checked);
}
c.success_event = success_event;
var dview = (c.currentView == "agenda" ? "month" : c.currentView);
c.calendar.fullCalendar({
editable: true,
selectable: true,
events: "/panel/calendar_new/back_end/events/",
eventResize: change_event,
eventDrop: change_event ,
header: false,
default: dview,
height: $("body").height() - 141,
loading: function(bool) {
if (bool) c.loading.css("left",($(window).width()/2 - 60) + "px").show();
else c.loading.hide();
},
windowResize : function(view){
view.setHeight($("body").height() - 141);
c.calendar.fullCalendar("refetchEvents");
},
viewDisplay: function(view) {
c.title.html(view.title);
},
eventClick: function(calEvent, e, view) {
c.dialog.dismiss();
c.dialog.inflate(calEvent);
c.dialog.show({"x":e.originalEvent.clientX,"y":e.originalEvent.clientY});
},
select : function(startDate, endDate, allDay, jsEvent, view){
var start = new Date(startDate),
end = new Date(endDate),
startString = start.getFullYear() + "/"+ (start.getMonth() + 1 > 9 ? start.getMonth() + 1 : "0" + (start.getMonth() + 1)) + "/" + (start.getDate() > 9 ? start.getDate() : "0" + start.getDate()),
endString = end.getFullYear() + "/" + (end.getMonth() + 1 > 9 ? end.getMonth() + 1 : "0" + (end.getMonth() + 1)) + "/" + (end.getDate() > 9 ? end.getDate() : "0" + end.getDate());
if(!allDay){
startString += " " + (start.getHours() > 9 ? start.getHours() : "0" + start.getHours()) + ":" + (start.getMinutes() > 9 ? start.getMinutes() : "0" + start.getMinutes());
endString += " " + (end.getHours() > 9 ? end.getHours() : "0" + end.getHours()) + ":" + (end.getMinutes() > 9 ? end.getMinutes() : "0" + end.getMinutes());
}else{
startString += " " + start.getHours() + ":" + start.getMinutes();
endString += " " + end.getMinutes() + ":" + end.getMinutes();
}
$.ajax({
type : "get",
url : c.create_event_btn.attr("href"),
data : {"startDate":startString,"endDate":endString,"allDay":allDay},
success : function(data){
success_event(data,allDay,"new");
}
})
}
});
c.create_event_btn.click(function(){
if(!c.isFormVisible()){
$.ajax({
type : "get",
url : $(this).attr("href"),
success : function(data){
success_event(data,false,"new");
}
})
}
return false;
});
c.nextBtn.click(function(){
c.dialog.dismiss();
c.calendar.fullCalendar('next');
});
c.prevBtn.click(function(){
c.dialog.dismiss();
c.calendar.fullCalendar('prev');
});
c.todayBtn.click(function(){
c.dialog.dismiss();
c.calendar.fullCalendar('today');
});
c.modeBtns.click(function(){
c.dialog.dismiss();
toggleViews($(this).data("mode"));
});
c.refreshBtn.click(function(){
c.dialog.dismiss();
if(c.currentView == "agenda")
agendaView.refresh();
else
c.calendar.fullCalendar("refetchEvents");
});
var toggleViews = function(view){
c.modeBtns.removeClass("active");
c.modeBtns.each(function(){
if ($(this).data("mode") == view)
$(this).addClass("active");
})
if(view != "agenda"){
if(c.currentView == "agenda"){
$("#sec1").addClass("span3").removeClass("span7");
$("#sec2").show();
$("#sec3").addClass("span4").removeClass("span5");
agendaView.hide();
}
c.calendar.fullCalendar('changeView',view);
}else{
$("#sec1").addClass("span7").removeClass("span3");
$("#sec2").hide();
$("#sec3").addClass("span5").removeClass("span4");
agendaView.inflate();
}
c.currentView = view;
if(loadeventsonviewchange){
c.calendar.fullCalendar("refetchEvents");
loadeventsonviewchange = false;
}
}
if(c.currentView == "agenda"){toggleViews("agenda");loadeventsonviewchange = true;}
$(document).on("DOMMouseScroll mousewheel", function(e){
if(c.calendar.fullCalendar("getView").name == "month"){
if(!c.isFormVisible()){
c.dialog.dismiss();
if(/Firefox/i.test(navigator.userAgent)){
if(e.originalEvent.detail == 1){
c.calendar.fullCalendar('next');
}else if(e.originalEvent.detail == -1){
c.calendar.fullCalendar('prev');
}
}else{
if(e.originalEvent.wheelDelta /120 > 0)
c.calendar.fullCalendar('prev');
else
c.calendar.fullCalendar('next');
}
}
}
});
}
this.isFormVisible = function(){
return (c.event_create_space.html() == "" ? false : true);
}
this.renderEvent = function(eventStick){
if(eventStick.recurring == true)
c.calendar.fullCalendar("refetchEvents");
else
c.calendar.fullCalendar("renderEvent",eventStick);
}
this.updateEvent = function(eventStick){
c.calendar.fullCalendar("updateEvent",eventStick);
}
this.deleteEvent = function(delete_url,_id){
$.ajax({
type : "delete",
url : delete_url,
success : function(){
c.calendar.fullCalendar("removeEvents",[_id]);
c.dialog.dismiss();
}
})
}
this.editEvent = function(edit_url,allDay){
console.log(edit_url);
$.ajax({
type : "get",
url : edit_url,
success : function(data){
c.success_event(data,allDay,"edit");
c.dialog.dismiss();
}
})
}
$(document).ready(function() {
c.initialize();
});
}
var EventDialog = function(calendar,event){
_t = this;
var event_quick_view = null;
var template = "";
var _this_event = null;
this.inflate = function(_event){
if(!_event) throw new UserException("EventStick can't be null!");
_this_event = _event;
var start_time = "",
end_time = "",
time_string = null;
if(_event.allDay){
start_time = (/00:00:00/i.test(_event._start.toLocaleString()) ? $.fullCalendar.formatDate(_event._start,"ddd MMM dd, yyyy") : $.fullCalendar.formatDate(_event._start,"ddd MMM dd, yyyy hh:mm"));
if(_event._end)
end_time = (/00:00:00/i.test(_event._end.toLocaleString()) ? $.fullCalendar.formatDate(_event._end,"ddd MMM dd, yyyy") : $.fullCalendar.formatDate(_event._end,"ddd MMM dd, yyyy hh:mm"));
time_string = (_event._start === _event._end || !_event._end ? start_time : start_time + " - " + end_time);
}else{
var reg = new RegExp(/ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/),
stime = _event._start.toLocaleString().match(reg).toString(),
etime = _event._end.toLocaleString().match(reg).toString();
start_time = _event._start.toLocaleString().replace(stime,",");
end_time = _event._end.toLocaleString().replace(etime,",");
stime = stime.substr(0,stime.length - 3);
etime = etime.substr(0,etime.length - 3);
time_string = (start_time === end_time ? start_time + " " + stime + " - " + etime : start_time + " " + stime + " - " + end_time + " " +etime );
}
event_quick_view = $('<div class="modal" style="width: 300px; display:none; margin:0 0 0 0;"></div>');
template = '<div class="modal-header"><button type="button" class="close event-close-btn" data-dismiss="modal" aria-hidden="true">&times;</button><h3>'+ _event.title +'</h3></div><div class="modal-body"><div class="event_summary">'+ time_string +'</div>'+ _event.note +'</div><div class="modal-footer"><a href="'+ _event.delete_url +'" class="delete btn btn-primary">Delete</a><a href="'+ _event.edit_url +'" class="edit btn btn-primary" >Edit</a></div>';
}
this.show = function(pos){
if(pos){
var pos = getPosition(pos);
event_quick_view.css({"left":pos.x+"px","top":pos.y+"px"});
}
event_quick_view.html(template).appendTo("body").show();
event_quick_view.find(".event-close-btn").one("click",function(){_t.dismiss();});
event_quick_view.find("a.delete").one("click",function(){calendar.deleteEvent(_this_event.delete_url,_this_event._id);return false;});
event_quick_view.find("a.edit").one("click",function(){calendar.editEvent(_this_event.edit_url,_this_event.allDay);return false;});
}
this.dismiss = function(){
if(event_quick_view)
event_quick_view.remove();
}
var getPosition = function(pos){
var x = pos.x,
y = pos.y,
winheight = $(window).height();
if((x + event_quick_view.width()) > $(window).width()){
x = x - event_quick_view.width();
}
if((y + event_quick_view.height()) > winheight){
y = y - event_quick_view.height();
}
return {"x":x,"y":y};
}
if(event)
_t.inflate(event);
}
var UserException = function(message) {
this.message = message;
this.name = "UserException";
this.toString = function(){
return this.message;
}
}
var AgendaView = function(calendar){
var av = this;
var _calendar = calendar;
var agenda_space = _calendar.agenda_space;
var today = new Date();
var minDifference = 6;
var start_month = today.getMonth();
var start_year = today.getFullYear();
var end_month = ((start_month + minDifference) > 11 ? (start_month + minDifference) - 11 : start_month + minDifference);
var end_year = ((start_month + minDifference) > 11 ? start_year+1 : start_year);
var monthNames = ['January','February','March','April','May','June','July','August','September','October','November','December'];
var month_template = '<div class="span4"><h4></h4><div class="tiny_calendar"><table class="table"><tbody><tr><th class="week_title">Sun</th><th class="week_title">Mon</th><th class="week_title">Tue</th><th class="week_title">Wed</th><th class="week_title">Thu</th><th class="week_title">Fri</th><th class="week_title">Sat</th></tr></tbody></table></div></div>';
var event_list_template = '<div class="span8"><table class="table event_list"><thead><tr height="0"><th class="span3"></th><th class="span2"></th><th class=""></th></tr></thead><tbody><tr><td colspan="3" class="no_events">No events for this month.</td></tr></tbody></table></div>';
var head_template = '<div><label>From</label> <select name="start_month" class="input-small"></select><select name="start_year" class="input-small"></select><label>To</label> <select name="end_month" class="input-small"></select><select name="end_year" class="input-small"></select><button id="show_events" class="btn bt-filter">Show Events</button></div>';
var event_template = "<tr><th></th><td class='event_time'></td><td><div class='event'></div></td></tr>";
var cache = false;
var show_event_clicked = false;
this.refresh = function(){
av.inflate(true);
}
this.inflate = function(forceInflation){
loading(true);
_calendar.calendar.hide();
_calendar.navigation.hide();
if(!forceInflation){
if(cache){
av.show();
loading(false);
return;
}
}
agenda_space.empty();
if(!show_event_clicked){
_calendar.rangeSelection.empty();
_calendar.rangeSelection.append(renderHead().html()).show();
_calendar.rangeSelection.find("button#show_events").click(function(){
show_event_clicked = true;
start_month = parseInt($("select[name=start_month]").val());
end_month = parseInt($("select[name=end_month]").val());
start_year = parseInt($("select[name=start_year]").val());
end_year = parseInt($("select[name=end_year]").val());
av.inflate(true);
})
}
show_event_clicked = false;
eventsManager();
var s = start_month,
e = end_month
y = start_year;
e = (e > s && start_year == end_year? e : e + 11);
if(end_year > start_year)
e = e + ((end_year - start_year -1) * 12);
else e--;
for(var i = s;i <= e+1; i++){
var m = new Month(s,y);
s++;
if(s > 11){
s = 0;
y++;
}
if(e == 0)
agenda_space.text("Invalid Range of Dates.")
else
agenda_space.append(m.monthDom);
}
loading(false);
}
this.hide = function(){
cache = true;
_calendar.rangeSelection.hide();
agenda_space.hide();
_calendar.navigation.show();
_calendar.calendar.show();
}
this.show = function(){
_calendar.rangeSelection.show();
agenda_space.show();
}
var copyObject = function(x){
return x.clone();
}
var eventsManager = function(){
var url = "/panel/calendar_new/back_end/events/agenda",
sd = new Date(start_year,start_month,1),
ed = new Date(end_year,end_month+1,0);
$.ajax({
type : "get",
url : url,
data : {"agenda_start":sd.toLocaleString(),"agenda_end":ed.toLocaleString()},
success : function(events){
$.each(events,function(i,e){
var ed = eventDom(e),
s = new Date(e.start),
e = new Date(e.end),
e_m = ((e.getMonth() > s.getMonth() || s.getMonth() == e.getMonth()) && s.getFullYear() == e.getFullYear() ? e.getMonth() : e.getMonth() + 12)
s_m = s.getMonth(),
s_y = s.getFullYear();
if(e.getFullYear() > s.getFullYear())
e_m = e_m + ((e.getFullYear() - s.getFullYear() -1) * 12);
for(var i = s_m; i < e_m + 1; i++){
var temp_ed = copyObject(ed);
var list = agenda_space.find("div[data-month="+s_m+"][data-year="+s_y+"] table.event_list tbody");
list.append(temp_ed);
s_m++;
if(s_m > 11){
s_m = 0;
s_y++;
}
}
if(s.getDate() == e.getDate() && s.getMonth() == s.getMonth() && e.getFullYear() == e.getFullYear()){
var td = agenda_space.find("td[data-date-node="+s.getDate()+"-"+s.getMonth()+"-"+s.getFullYear()+"]");
td.addClass("has_event");
}else{
var timeDiff = Math.abs(e.getTime() - s.getTime()),
diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24)),
c_m = s.getMonth(),
c_d = s.getDate(),
c_y = s.getFullYear(),
end_of_c_month = new Date(s.getFullYear(),s.getMonth()+1,0).getDate();
for(var i = 0; i <= diffDays; i++){
var td = agenda_space.find("td[data-date-node="+c_d+"-"+c_m+"-"+c_y+"]");
td.addClass("has_event");
c_d++;
if(c_d > end_of_c_month){
c_d = 1;
c_m++;
if(c_m > 11){
c_m = 0;
c_y++;
}
}
}
}
})
agenda_space.find("table.event_list tbody").each(function(){
if($(this).find("tr").length > 1)
$(this).find("td.no_events").parent().remove();
})
}
})
var eventDom = function(event){
var e_t = $(event_template),
s = new Date(event.start),
e = new Date(event.end),
dateFormat = "";
if(s.getDate() == e.getDate() && s.getMonth() == s.getMonth() && e.getFullYear() == e.getFullYear())
dateFormat = $.fullCalendar.formatDate(s, "ddd dd");
else
dateFormat = $.fullCalendar.formatDates(s, e, "ddd dd, MMM - {ddd dd, MMM}");
e_t.find("th").text(dateFormat);
e_t.find("td.event_time").text((event.allDay ? "All Day" : $.fullCalendar.formatDate(s, "hh:mm")));
e_t.find("div.event").text(event.title).css("color",event.color);
return e_t;
}
}
var loading = function(bool) {
if (bool) _calendar.loading.css("left",($(window).width()/2 - 60) + "px").show();
else _calendar.loading.hide();
}
var renderHead = function(){
var head = $(head_template);
var start_month_select = head.find("select[name=start_month]");
for(var i = 0; i < 12; i++){
var option = $("<option value='"+i+"'>"+monthNames[i]+"</option>");
if(i == start_month)
option.attr("selected","selected");
start_month_select.append(option);
}
var end_month_select = head.find("select[name=end_month]");
for(var i = 0; i < 12; i++){
var option = $("<option value='"+i+"'>"+monthNames[i]+"</option>");
if(i == end_month)
option.attr("selected","selected");
end_month_select.append(option);
}
var start_year_select = head.find("select[name=start_year]");
var y = start_year - 5;
for(var i = 0; i < 10; i++){
var option = $("<option value='"+y+"'>"+y+"</option>");
if(y == start_year)
option.attr("selected","selected");
start_year_select.append(option);
y++;
}
var end_year_select = head.find("select[name=end_year]");
y = start_year - 5;
for(var i = 0; i < 10; i++){
var option = $("<option value='"+y+"'>"+y+"</option>");
if(y == end_year)
option.attr("selected","selected");
end_year_select.append(option);
y++;
}
return head;
}
var Month = function(month,year){
_this = this;
this.monthDom = $("<div class='row-fluid' data-year='"+year+"' data-month='"+month+"'></div>");
var template = $(month_template);
var list_template = $(event_list_template);
var firstDay = new Date(year,month,1);
var lastDay = new Date(year,month+1,0);
var last_inserted_date = 1;
var renderMonth = function(){
for(var i = 0; i < 5; i++){
var tr = null;
if(i == 0)
tr = makeRow("first");
else if(i == 4){
tr = makeRow("last");
}else{
tr = makeRow("middle");
}
template.find("table.table tbody").append(tr);
template.find("h4").text(monthNames[firstDay.getMonth()] + " - " + firstDay.getFullYear());
}
_this.monthDom.append(template);
_this.monthDom.append(list_template);
}
var makeRow = function(position){
var row = $("<tr></tr>");
switch (position){
case "first":
for(var i = 0;i < 7;i++){
var td = $("<td></td>");
if(i >= firstDay.getDay()){
td.text(last_inserted_date);
td.attr("data-date-node",last_inserted_date+"-"+firstDay.getMonth()+"-"+firstDay.getFullYear());
last_inserted_date++;
}
row.append(td);
}
break;
case "middle":
for(var i = 0;i < 7;i++){
var td = $("<td></td>");
td.text(last_inserted_date);
td.attr("data-date-node",last_inserted_date+"-"+firstDay.getMonth()+"-"+firstDay.getFullYear());
last_inserted_date++;
row.append(td);
}
break;
case "last":
for(var i = 0;i < 7;i++){
var td = $("<td></td>");
if(i <= lastDay.getDay()){
td.text(last_inserted_date);
td.attr("data-date-node",last_inserted_date+"-"+firstDay.getMonth()+"-"+firstDay.getFullYear());
last_inserted_date++;
}
row.append(td);
}
break;
}
return row;
}
renderMonth();
}
}

View File

@ -0,0 +1,42 @@
//= require_tree .
//= require fullcalendar
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
change_event = function(_event, delta) {
console.log("evento" + _event.id);
$.ajax({
url: "events/"+_event.id+'.json',
data: {event:{id:_event.id,start:_event.start,end: _event.end}},
method: 'PUT' ,
datatype: 'JSON',
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus);
},
success: function(data) {
console.log('event was success updated');
}
});
}
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
events: "events/",
eventResize: change_event,
eventDrop: change_event ,
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}
});
});

View File

@ -0,0 +1,17 @@
!function ($) {
$.fn.datetimepick = function() {
var $this = this,
$data = $this.data();
$this.datetimepicker({
format: $data.dateFormat,
pickTime: $data.picktime,
language: $data.language,
});
}
}(window.jQuery);
$(function(){
$('.datetimepick').each(function() {
$(this).datetimepick();
});
});

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,394 @@
/* orbit calendar */
#orbit_calendar {
padding: 10px 8px;
min-width: 960px;
transition: all 0.3s ease;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
}
.calendar_color_tag {
display: inline-block;
width: 18px;
height: 18px;
margin-right: 4px;
vertical-align: bottom;
}
.current_day_title {
text-align: center;
line-height: 28px;
}
.calendar_mode {
z-index: 2;
}
.mode_switch {
text-transform: capitalize;
}
.today {
background-color: #D9EDF7;
}
.event {
font-size: 12px;
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;
}
.modal-body {
max-height: 515px;
}
.event_list_wrapper {
position: relative;
}
.event_list .cell {
height: 39px;
border: solid 1px #ddd;
border-top: 0;
}
.event_list .divide {
height: 19px;
margin-bottom: 18px;
border-bottom: solid 1px #eee;
}
.event_list .day_time {
height: 31px;
border-bottom: solid 1px #ddd;
border-left: solid 1px #ddd;
text-align: right;
padding: 4px;
}
.event dl, .event dt, .event dd {
margin: 0;
padding: 0;
}
.event dl {
padding: 3px;
}
.event dt {
font-size: 11px;
font-weight: normal;
line-height: 12px;
}
#calendar_day .event_holder {
width: 100%;
/*height: 100%;*/
position: absolute;
top: 0;
z-index: 1;
}
.event_holder .inner {
position: relative;
margin: 0 16px 0 2px;
}
.event_holder .event {
padding: 0px;
position: absolute;
width: 100%;
}
.event_holder .event.half {
}
.event_holder .event.over {
border: solid 1px #fff;
}
/* month view */
#calendar_month {
border-bottom: solid 1px #ddd;
}
#calendar_month .month_row {
position: relative;
border: solid 1px #ddd;
border-bottom: 0;
height: 60px;
overflow: hidden;
}
#calendar_month .month_row .table {
table-layout: fixed;
margin-bottom: 0;
width: 100%;
position: absolute;
}
#calendar_month .month_row .table td {
border: 0;
border-left: solid 1px #ddd;
padding: 2px 4px 0 4px;
}
#calendar_month .month_row .table td:first-child {
border-left: 0;
}
#calendar_month .month_row.header {
height: 28px;
border: 0;
}
#calendar_month .month_row.header th {
font-size: 12px;
padding: 4px;
border: 0;
}
#calendar_month .month_row .month_table {
height: 100%;
}
#calendar_month .month_row .month_date {
color: #666;
font-size: 11px;
cursor: pointer;
}
#calendar_month .month_row .month_date td {
border-left: 0
}
#calendar_month .month_row .month_date .day_title:hover {
text-decoration: underline;
}
#calendar_month .month_row td.today {
border-bottom: solid 1px #fff;
border-top: solid 1px #fff;
}
#calendar_month .month_row .event {
margin: 0 -2px;
position: relative;
color: #000;
}
#calendar_month .month_row .month_date .event:hover {
text-decoration: none !important;
}
#calendar_month .month_row td.disable {
background-color: #f6f6f6;
color: #ccc;
border-left: solid 1px #ddd;
}
#calendar_month .event.single {
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
/* agenda view */
#calendar_agenda {
margin-top: 20px;
}
#calendar_agenda .table {
margin-bottom: 0;
}
#calendar_agenda .tiny_calendar {
border: solid 1px #eee;
}
#calendar_agenda .tiny_calendar .table th {
border-top: 0;
}
#calendar_agenda .tiny_calendar .table td {
text-align: center;
}
#calendar_agenda .event {
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
#calendar_agenda .row-fluid {
margin-top: 20px;
padding-top: 20px;
border-top: dashed 1px #ddd;
}
#calendar_agenda .row-fluid:first-child {
border-top: 0;
padding-top: 0;
margin-top: 0;
}
#calendar_agenda .table.event_list .span2, #calendar_agenda .table.event_list thead th {
min-height: 0 !important;
height: 0 !important;
line-height: 0;
padding: 0;
}
.event_time {
font-family: Tahoma, sans-serif;
}
.has_event {
background-color: #08c;
color: #fff;
}
/* day view */
#calendar_day .header {
margin-bottom: 10px;
}
#calendar_day .header th {
text-align: center;
}
#calendar_day td {
border: 0;
}
#calendar_day .event {
margin-bottom: 2px;
}
#calendar_day .all_day_event {
background: #eee;
border: solid 1px #ddd;
}
#calendar_day .event_list .table {
border-top: solid 1px #ddd;
}
#calendar_day .event_list td {
padding: 0;
}
/* week view */
#calendar_week {
}
#calendar_week .cell_wrapper {
position: absolute;
width: 100%;
}
#calendar_week td {
padding: 0;
}
#calendar_week .table {
margin-bottom: 0;
}
#calendar_week .header {
margin-bottom: 12px;
border-top: 0;
table-layout: fixed;
}
#calendar_week .header th {
text-align: center;
font-size: 12px;
}
#calendar_week .header td {
border: solid 1px #ddd;
/*background-color: #eee;*/
}
#calendar_week .week_day {
padding: 0 2px;
border: solid 1px #ddd;
}
#calendar_week .header .week_day {
padding: 2px 4px 0px 2px;
}
#calendar_week .event_list .event {
position: absolute;
width: 100%;
margin-bottom: 2px;
}
#calendar_week .cell_map {
margin-bottom: 18px;
}
#calendar_week .cell_map td {
border-top: 0;
border-bottom: 0;
}
#calendar_week .cell_map tr:first-child td {
border-top: solid 1px #ddd;
}
#calendar_week .event_holder .inner {
margin: 0 8px 0 0;
}
#calendar_week .all_day_event_holder {
position: relative;
width: 100%;
table-layout: fixed;
}
#calendar_week .all_day_event_holder td {
border: 0;
background-color: transparent;
}
#calendar_week .all_day_event {
background: #eee;
}
/* calendars(category) */
.calendars_color_tag {
width: 20px;
height: 20px;
display: inline-block;
border-radius: 3px;
box-shadow: inset 0 -1px 0 rgba(0,0,0,0.2);
}
/* Event Controller */
.event_controller {
width: 350px;
}
.event_controller .row-fluid {
margin-bottom: 6px;
}
.event_controller .row-fluid .control-label {
line-height: 30px;
}
.close {
border: 0;
background: none;
}
/* miniColors tweak */
.miniColors-trigger {
width: 20px;
height: 20px;
margin-bottom: 10px;
margin-left: 10px;
border-color: #f1f1f1;
}
.miniColors-selector {
float: none;
margin: 4px 0 0 0;
}
/* category edit */
.edit_cal {
margin: -8px;
background-color: whitesmoke;
}
.edit_cal .table td, .edit_cal .table {
border: 0 !important;
background-color: transparent !important;
margin: 0 !important;
}
.main-list td {
border-top: solid 1px #ddd;
}
/* create / edit event panel */
#tags_panel {
top: auto;
bottom: 34px;
width: 258px;
height: 170px;
padding: 8px 0;
overflow: hidden;
position: absolute;
clear: none;
}
#tags_panel .viewport {
height: 170px;
}
#tags_panel .scrollbar {
top: 8px;
}
#tags_list {
padding: 8px;
}
.bootstrap-datetimepicker-widget.dropdown-menu {
z-index: 1051;
}
#main-wrap{
padding-bottom: 0;
}
.fc-other-month{
background-color: #F6F6F6;
}
#calendar-loading{
display: none;
background-color: red;
padding: 0 5px;
position: absolute;
top: 31px;
width: 60px;
z-index: 10;
}

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

@ -0,0 +1,619 @@
/*
* FullCalendar v1.5.4 Stylesheet
*
* Copyright (c) 2011 Adam Shaw
* Dual licensed under the MIT and GPL licenses, located in
* MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
*
* Date: Tue Sep 4 23:38:33 2012 -0700
*
*/
.fc {
direction: ltr;
text-align: left;
}
.fc table {
border-collapse: collapse;
border-spacing: 0;
}
html .fc,
.fc table {
font-size: 1em;
}
.fc td,
.fc th {
padding: 0;
vertical-align: top;
}
/* Header
------------------------------------------------------------------------*/
.fc-header td {
white-space: nowrap;
}
.fc-header-left {
width: 25%;
text-align: left;
}
.fc-header-center {
text-align: center;
}
.fc-header-right {
width: 25%;
text-align: right;
}
.fc-header-title {
display: inline-block;
vertical-align: top;
}
.fc-header-title h2 {
margin-top: 0;
white-space: nowrap;
}
.fc .fc-header-space {
padding-left: 10px;
}
.fc-header .fc-button {
margin-bottom: 1em;
vertical-align: top;
}
/* buttons edges butting together */
.fc-header .fc-button {
margin-right: -1px;
}
.fc-header .fc-corner-right {
margin-right: 1px; /* back to normal */
}
.fc-header .ui-corner-right {
margin-right: 0; /* back to normal */
}
/* button layering (for border precedence) */
.fc-header .fc-state-hover,
.fc-header .ui-state-hover {
z-index: 2;
}
.fc-header .fc-state-down {
z-index: 3;
}
.fc-header .fc-state-active,
.fc-header .ui-state-active {
z-index: 4;
}
/* Content
------------------------------------------------------------------------*/
.fc-content {
clear: both;
}
.fc-view {
width: 100%; /* needed for view switching (when view is absolute) */
overflow: hidden;
}
/* Cell Styles
------------------------------------------------------------------------*/
.fc-widget-header, /* <th>, usually */
.fc-widget-content { /* <td>, usually */
border: 1px solid #ccc;
}
.fc-state-highlight { /* <td> today cell */ /* TODO: add .fc-today to <th> */
background: #ffc;
}
.fc-cell-overlay { /* semi-transparent rectangle while dragging */
background: #9cf;
opacity: .2;
filter: alpha(opacity=20); /* for IE */
}
/* Buttons
------------------------------------------------------------------------*/
.fc-button {
position: relative;
display: inline-block;
cursor: pointer;
}
.fc-state-default { /* non-theme */
border-style: solid;
border-width: 1px 0;
}
.fc-button-inner {
position: relative;
float: left;
overflow: hidden;
}
.fc-state-default .fc-button-inner { /* non-theme */
border-style: solid;
border-width: 0 1px;
}
.fc-button-content {
position: relative;
float: left;
height: 1.9em;
line-height: 1.9em;
padding: 0 .6em;
white-space: nowrap;
}
/* icon (for jquery ui) */
.fc-button-content .fc-icon-wrap {
position: relative;
float: left;
top: 50%;
}
.fc-button-content .ui-icon {
position: relative;
float: left;
margin-top: -50%;
*margin-top: 0;
*top: -50%;
}
/* gloss effect */
.fc-state-default .fc-button-effect {
position: absolute;
top: 50%;
left: 0;
}
.fc-state-default .fc-button-effect span {
position: absolute;
top: -100px;
left: 0;
width: 500px;
height: 100px;
border-width: 100px 0 0 1px;
border-style: solid;
border-color: #fff;
background: #444;
opacity: .09;
filter: alpha(opacity=9);
}
/* button states (determines colors) */
.fc-state-default,
.fc-state-default .fc-button-inner {
border-style: solid;
border-color: #ccc #bbb #aaa;
background: #F3F3F3;
color: #000;
}
.fc-state-hover,
.fc-state-hover .fc-button-inner {
border-color: #999;
}
.fc-state-down,
.fc-state-down .fc-button-inner {
border-color: #555;
background: #777;
}
.fc-state-active,
.fc-state-active .fc-button-inner {
border-color: #555;
background: #777;
color: #fff;
}
.fc-state-disabled,
.fc-state-disabled .fc-button-inner {
color: #999;
border-color: #ddd;
}
.fc-state-disabled {
cursor: default;
}
.fc-state-disabled .fc-button-effect {
display: none;
}
/* Global Event Styles
------------------------------------------------------------------------*/
.fc-event {
border-style: solid;
border-width: 0;
font-size: .85em;
cursor: default;
}
a.fc-event,
.fc-event-draggable {
cursor: pointer;
}
a.fc-event {
text-decoration: none;
}
.fc-rtl .fc-event {
text-align: right;
}
.fc-event-skin {
border-color: #36c; /* default BORDER color */
background-color: #36c; /* default BACKGROUND color */
color: #fff; /* default TEXT color */
}
.fc-event-inner {
position: relative;
width: 100%;
height: 100%;
border-style: solid;
border-width: 0;
overflow: hidden;
}
.fc-event-time,
.fc-event-title {
padding: 3px 1px;
background-color: #eee;
}
.fc .ui-resizable-handle { /*** TODO: don't use ui-resizable anymore, change class ***/
display: block;
position: absolute;
z-index: 99999;
overflow: hidden; /* hacky spaces (IE6/7) */
font-size: 300%; /* */
line-height: 50%; /* */
}
/* Horizontal Events
------------------------------------------------------------------------*/
.fc-event-hori {
border-width: 1px 0;
margin-bottom: 1px;
}
/* resizable */
.fc-event-hori .ui-resizable-e {
top: 0 !important; /* importants override pre jquery ui 1.7 styles */
right: -3px !important;
width: 7px !important;
height: 100% !important;
cursor: e-resize;
}
.fc-event-hori .ui-resizable-w {
top: 0 !important;
left: -3px !important;
width: 7px !important;
height: 100% !important;
cursor: w-resize;
}
.fc-event-hori .ui-resizable-handle {
_padding-bottom: 14px; /* IE6 had 0 height */
}
/* Fake Rounded Corners (for buttons and events)
------------------------------------------------------------*/
.fc-corner-left {
margin-left: 1px;
}
.fc-corner-left .fc-button-inner,
.fc-corner-left .fc-event-inner {
margin-left: -1px;
}
.fc-corner-right {
margin-right: 1px;
}
.fc-corner-right .fc-button-inner,
.fc-corner-right .fc-event-inner {
margin-right: -1px;
}
.fc-corner-top {
margin-top: 1px;
}
.fc-corner-top .fc-event-inner {
margin-top: -1px;
}
.fc-corner-bottom {
margin-bottom: 1px;
}
.fc-corner-bottom .fc-event-inner {
margin-bottom: -1px;
}
/* Fake Rounded Corners SPECIFICALLY FOR EVENTS
-----------------------------------------------------------------*/
.fc-corner-left .fc-event-inner {
border-left-width: 1px;
}
.fc-corner-right .fc-event-inner {
border-right-width: 1px;
}
.fc-corner-top .fc-event-inner {
border-top-width: 1px;
}
.fc-corner-bottom .fc-event-inner {
border-bottom-width: 1px;
}
/* Reusable Separate-border Table
------------------------------------------------------------*/
table.fc-border-separate {
border-collapse: separate;
}
.fc-border-separate th,
.fc-border-separate td {
border-width: 1px 0 0 1px;
}
.fc-border-separate th.fc-last,
.fc-border-separate td.fc-last {
border-right-width: 1px;
}
.fc-border-separate tr.fc-last th,
.fc-border-separate tr.fc-last td {
border-bottom-width: 1px;
}
.fc-border-separate tbody tr.fc-first td,
.fc-border-separate tbody tr.fc-first th {
border-top-width: 0;
}
/* Month View, Basic Week View, Basic Day View
------------------------------------------------------------------------*/
.fc-grid th {
text-align: center;
}
.fc-grid .fc-day-number {
float: right;
padding: 0 2px;
}
.fc-grid .fc-other-month .fc-day-number {
opacity: 0.3;
filter: alpha(opacity=30); /* for IE */
/* opacity with small font can sometimes look too faded
might want to set the 'color' property instead
making day-numbers bold also fixes the problem */
}
.fc-grid .fc-day-content {
clear: both;
padding: 2px 2px 1px; /* distance between events and day edges */
}
/* event styles */
.fc-grid .fc-event-time {
font-weight: bold;
}
/* right-to-left */
.fc-rtl .fc-grid .fc-day-number {
float: left;
}
.fc-rtl .fc-grid .fc-event-time {
float: right;
}
/* Agenda Week View, Agenda Day View
------------------------------------------------------------------------*/
.fc-agenda table {
border-collapse: separate;
}
.fc-agenda-days th {
text-align: center;
}
.fc-agenda .fc-agenda-axis {
width: 50px;
padding: 0 4px;
vertical-align: middle;
text-align: right;
white-space: nowrap;
font-weight: normal;
}
.fc-agenda .fc-day-content {
padding: 2px 2px 1px;
}
/* make axis border take precedence */
.fc-agenda-days .fc-agenda-axis {
border-right-width: 1px;
}
.fc-agenda-days .fc-col0 {
border-left-width: 0;
}
/* all-day area */
.fc-agenda-allday th {
border-width: 0 1px;
}
.fc-agenda-allday .fc-day-content {
min-height: 34px; /* TODO: doesnt work well in quirksmode */
_height: 34px;
}
/* divider (between all-day and slots) */
.fc-agenda-divider-inner {
height: 2px;
overflow: hidden;
}
.fc-widget-header .fc-agenda-divider-inner {
background: #eee;
}
/* slot rows */
.fc-agenda-slots th {
border-width: 1px 1px 0;
}
.fc-agenda-slots td {
border-width: 1px 0 0;
background: none;
}
.fc-agenda-slots td div {
height: 20px;
}
.fc-agenda-slots tr.fc-slot0 th,
.fc-agenda-slots tr.fc-slot0 td {
border-top-width: 0;
}
.fc-agenda-slots tr.fc-minor th,
.fc-agenda-slots tr.fc-minor td {
border-top-style: dotted;
}
.fc-agenda-slots tr.fc-minor th.ui-widget-header {
*border-top-style: solid; /* doesn't work with background in IE6/7 */
}
/* Vertical Events
------------------------------------------------------------------------*/
.fc-event-vert {
border-width: 0 1px;
}
.fc-event-vert .fc-event-head,
.fc-event-vert .fc-event-content {
position: relative;
z-index: 2;
width: 100%;
overflow: hidden;
}
.fc-event-vert .fc-event-time {
white-space: nowrap;
font-size: 10px;
}
.fc-event-vert .fc-event-bg { /* makes the event lighter w/ a semi-transparent overlay */
position: absolute;
z-index: 1;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #fff;
opacity: .3;
filter: alpha(opacity=30);
}
.fc .ui-draggable-dragging .fc-event-bg, /* TODO: something nicer like .fc-opacity */
.fc-select-helper .fc-event-bg {
display: none\9; /* for IE6/7/8. nested opacity filters while dragging don't work */
}
/* resizable */
.fc-event-vert .ui-resizable-s {
bottom: 0 !important; /* importants override pre jquery ui 1.7 styles */
width: 100% !important;
height: 8px !important;
overflow: hidden !important;
line-height: 8px !important;
font-size: 11px !important;
font-family: monospace;
text-align: center;
cursor: s-resize;
}
.fc-agenda .ui-resizable-resizing { /* TODO: better selector */
_overflow: hidden;
}

View File

@ -0,0 +1,61 @@
/*
* FullCalendar v1.5.4 Print Stylesheet
*
* Include this stylesheet on your page to get a more printer-friendly calendar.
* When including this stylesheet, use the media='print' attribute of the <link> tag.
* Make sure to include this stylesheet IN ADDITION to the regular fullcalendar.css.
*
* Copyright (c) 2011 Adam Shaw
* Dual licensed under the MIT and GPL licenses, located in
* MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
*
* Date: Tue Sep 4 23:38:33 2012 -0700
*
*/
/* Events
-----------------------------------------------------*/
.fc-event-skin {
background: none !important;
color: #000 !important;
}
/* horizontal events */
.fc-event-hori {
border-width: 0 0 1px 0 !important;
border-bottom-style: dotted !important;
border-bottom-color: #000 !important;
padding: 1px 0 0 0 !important;
}
.fc-event-hori .fc-event-inner {
border-width: 0 !important;
padding: 0 1px !important;
}
/* vertical events */
.fc-event-vert {
border-width: 0 0 0 1px !important;
border-left-style: dotted !important;
border-left-color: #000 !important;
padding: 0 1px 0 0 !important;
}
.fc-event-vert .fc-event-inner {
border-width: 0 !important;
padding: 1px 0 !important;
}
.fc-event-bg {
display: none !important;
}
.fc-event .ui-resizable-handle {
display: none !important;
}

View File

@ -0,0 +1,82 @@
class Panel::CalendarNew::BackEnd::EventCategoriesController < OrbitBackendController
include AdminHelper
# GET /events
# GET /events.json
def index
@event_categories = EventCategory.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @event_categories }
end
end
# GET /events/1
# GET /events/1.json
def show
@event_category = EventCategory.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @event_category }
end
end
# GET /events/new
# GET /events/new.json
def new
@event_category = EventCategory.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @event_category }
end
end
# GET /events/1/edit
def edit
@event_category = EventCategory.find(params[:id])
end
def create
@event_category = EventCategory.new(params[:event_category])
respond_to do |format|
if @event_category.save
format.html { redirect_to panel_calendar_new_back_end_event_categories_path, notice: 'Category was successfully created.' }
format.json { render json: @event_category, status: :created, location: @event_category }
else
format.html { render action: "new" }
format.json { render json: @event_category.errors, status: :unprocessable_entity }
end
end
end
def update
@event_category = EventCategory.find(params[:id])
respond_to do |format|
if @event_category.update_attributes(params[:event_category])
format.html { redirect_to panel_calendar_new_back_end_event_categories_path, notice: 'Category was successfully updated.' }
format.json { head :no_content }
#format.js
else
format.html { render action: "edit" }
format.json { render json: @event_category.errors, status: :unprocessable_entity }
#format.js
end
end
end
def destroy
@event_category = EventCategory.find(params[:id])
@event_category.destroy
respond_to do |format|
format.html { redirect_to panel_calendar_new_back_end_event_categories_path }
format.json { head :no_content }
end
end
end

View File

@ -0,0 +1,129 @@
class Panel::CalendarNew::BackEnd::EventsController < OrbitBackendController
# GET /events
# GET /events.json
def index
if params[:start].present? && params[:end].present?
sdt = Time.at(params[:start].to_i)
edt = Time.at(params[:end].to_i)
@monthly_events = Event.monthly_event(sdt,edt)
@re = Event.recurring_event(sdt,edt)
@events = @monthly_events.inject(@re, :<<)
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @events }
end
end
# GET /events/1
# GET /events/1.json
def show
@event = Event.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @event }
end
end
def agenda
agenda_start = Date.parse(params[:agenda_start])
agenda_end = Date.parse(params[:agenda_end])
@events = Event.agenda_events(agenda_start,agenda_end)
render :json=>@events.to_json
end
# GET /events/new
# GET /events/new.json
def new
@event = Event.new
@end_d_t = ""
@start_d_t = ""
@all_day = false;
@recurring = false;
if params
case params[:allDay]
when "true"
@all_day = true
when "false"
@all_day = false
case params[:recurring]
when "true"
@recurring = true
when "false"
@recurring = false
end
end
@end_d_t = params[:endDate]
@start_d_t = params[:startDate]
end
render :layout => false
#respond_to do |format|
# format.html # new.html.erb
# format.json { render json: @event }
#end
end
# GET /events/1/edit
def edit
@event = Event.find(params[:id])
@end_d_t = @event.end.strftime("%Y/%m/%d %H:%M").to_s
@start_d_t = @event.start.strftime("%Y/%m/%d %H:%M").to_s
@all_day = @event.all_day
@recurring = @event.recurring
render :layout => false
end
# POST /events
# POST /events.json
def create
@event = Event.new(params[:event])
# if params[:event][:period] == "Does not repeat"
#else
# @event_recurring = EventRecurring.new(params[:event])
#end
if @event.present? && @event.save
render json: @event.to_json
else
respond_to do |format|
format.html { render action: "new" }
format.json { render json: @event.errors, status: :unprocessable_entity }
end
end
end
# PUT /events/1
# PUT /events/1.json
def update
@event = Event.find(params[:id])
if @event.update_attributes(params[:event])
render json: @event.to_json
else
respond_to do |format|
format.html { render action: "edit" }
format.json { render json: @event.errors, status: :unprocessable_entity }
#format.js
end
end
end
# DELETE /events/1
# DELETE /events/1.json
def destroy
@event = Event.find(params[:id])
@event.destroy
render :json => {"success"=>true}.to_json
# respond_to do |format|
# format.html { redirect_to events }
# format.json { head :no_content }
# end
end
end

View File

@ -0,0 +1,115 @@
require 'time'
require 'date'
class Event
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes
field :title
field :note
field :start, type: DateTime
field :end, type: DateTime
field :all_day, type: Boolean
field :recurring, type: Boolean
field :event_category_id
field :frequency
field :period
attr_accessor :agenda_start, :agenda_end, :get_agenda_events
belongs_to :event_category
validates_presence_of :title, :message => "Please fill the title of the Event"
def self.format_date(date_time)
Time.at(date_time.to_i).to_formatted_s(:db)
end
REPEATS = [
"Daily" ,
"Weekly" ,
"Monthly" ,
"Yearly"
]
def as_json(options = {})
{
:id => self.id,
:title => self.title,
:note => self.note || "",
:start => self.start.rfc822,
:end => self.end.rfc822,
:allDay => self.all_day,
:recurring => self.recurring,
:calendar => self.event_category_id,
:color => EventCategory.find(self.event_category_id).color,
:edit_url => Rails.application.routes.url_helpers.edit_panel_calendar_new_back_end_event_path(self.id),
:delete_url => Rails.application.routes.url_helpers.panel_calendar_new_back_end_event_path(self.id)
}
end
def self.monthly_event(start_date,end_date)
self.any_of(:start.gte => start_date, :end.gte => start_date).and(:start.lte => end_date).asc(:start)
end
def self.recurring_event(start_date,end_date)
@recurring_events = self.where(:recurring => true)
@recurring = []
@recurring_events.each do |re|
case re.period
when 'Daily'
if (start_date..end_date).cover?(re.start)
@i = TimeDifference.between(re.start,end_date).in_days.to_i
(1..@i).each do |i|
@start_date = re.start + i
@recurring << {:id => re.id, :title=>re.title, :note=>re.note, :start=>@start_date, :end => @start_date, :allDay => re.all_day, :recurring => re.recurring, :calendar => re.event_category_id.to_s, :color => EventCategory.find(re.event_category_id).color, :edit_url => Rails.application.routes.url_helpers.edit_panel_calendar_new_back_end_event_path(re.id), :delete_url => Rails.application.routes.url_helpers.panel_calendar_new_back_end_event_path(re.id)}
end
elsif re.start < start_date
@i = TimeDifference.between(start_date,end_date).in_days.to_i
(0..@i-1).each do |i|
@start_date = start_date.to_date + i
@recurring << {:id => re.id, :title=>re.title, :note=>re.note, :start=>@start_date, :end => @start_date, :allDay => re.all_day, :recurring => re.recurring, :calendar => re.event_category_id.to_s, :color => EventCategory.find(re.event_category_id).color, :edit_url => Rails.application.routes.url_helpers.edit_panel_calendar_new_back_end_event_path(re.id), :delete_url => Rails.application.routes.url_helpers.panel_calendar_new_back_end_event_path(re.id)}
end
end
when "Weekly"
@start_date = re.start
@end_date = re.end
@i = TimeDifference.between(re.start,end_date).in_weeks.to_i
(1..@i).each do |i|
@start_date += (7*re.frequency.to_i)
@end_date += (7*re.frequency.to_i)
@recurring << {:id => re.id, :title=>re.title, :note=>re.note, :start=>@start_date, :end => @end_date, :allDay => re.all_day, :recurring => re.recurring, :calendar => re.event_category_id.to_s, :color => EventCategory.find(re.event_category_id).color, :edit_url => Rails.application.routes.url_helpers.edit_panel_calendar_new_back_end_event_path(re.id), :delete_url => Rails.application.routes.url_helpers.panel_calendar_new_back_end_event_path(re.id)}
end
when "Monthly"
if !(start_date..end_date).cover?(re.start)
sd = re.start
ed = re.end
@i = TimeDifference.between(re.start,end_date).in_months.to_i
@start_date = sd
sd = sd >> @i*re.frequency.to_i
ed = ed >> @i*re.frequency.to_i
@recurring << {:id => re.id, :title=>re.title, :note=>re.note, :start=>sd, :end => ed, :allDay => re.all_day, :recurring => re.recurring, :calendar => re.event_category_id.to_s, :color => EventCategory.find(re.event_category_id).color, :edit_url => Rails.application.routes.url_helpers.edit_panel_calendar_new_back_end_event_path(re.id), :delete_url => Rails.application.routes.url_helpers.panel_calendar_new_back_end_event_path(re.id)}
end
when "Yearly"
if !(start_date..end_date).cover?(re.start)
sd = re.start
ed = re.end
@i = TimeDifference.between(re.start,end_date).in_years.to_i
@start_date = sd
sd = sd >> 12 * @i*re.frequency.to_i
ed = ed >> 12 * @i*re.frequency.to_i
@recurring << {:id => re.id, :title=>re.title, :note=>re.note, :start=>sd, :end => ed, :allDay => re.all_day, :recurring => re.recurring, :calendar => re.event_category_id.to_s, :color => EventCategory.find(re.event_category_id).color, :edit_url => Rails.application.routes.url_helpers.edit_panel_calendar_new_back_end_event_path(re.id), :delete_url => Rails.application.routes.url_helpers.panel_calendar_new_back_end_event_path(re.id)}
end
end
end
@recurring
end
def self.agenda_events(agenda_start, agenda_end)
@all_events = self.any_of(:start.gte => agenda_start, :end.gte => agenda_start).and(:start.lte => agenda_end).asc(:start)
end
end

View File

@ -0,0 +1,10 @@
class EventCategory
include Mongoid::Document
include Mongoid::Timestamps
field :name, localize: true
field :color
has_many :events, :dependent => :destroy
validates_presence_of :name, :message => "Please fill the name of the Category"
end

View File

@ -0,0 +1,14 @@
$("#event_create").empty().hide();
$("#create_event_btn").removeClass("active");
$(".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;
}

View File

@ -0,0 +1,9 @@
<h3>Event Categories</h3>
<% @event_categories.each do |ec|%>
<ul>
<li><%= ec.name%> <%= ec.color%> <%= link_to 'Show', panel_calendar_new_back_end_event_category_path(ec)%> <%= link_to 'Destroy', panel_calendar_new_back_end_event_category_path(ec), method: :delete, data: { confirm: 'Are you sure?' }%></li>
</ul>
<%end%>
<p>
<%= link_to "add new category", new_panel_calendar_new_back_end_event_category_path %>
</p>

View File

@ -0,0 +1,35 @@
<%= stylesheet_link_tag "jquery.miniColors" %>
<%= javascript_include_tag "jquery.miniColors.min" %>
<div id="form">
<%= form_for @event_category, :url=> panel_calendar_new_back_end_event_categories_path(@event_category) do |f| %>
<h2>Add</h2>
<div class="row-fluid">
<div class="span2">
<%= label_tag("color", t("calendar.color")) %>
<%= f.text_field :color, :class => "color-picker miniColors span5", :size => "7", :maxlength => "7", :autocomplete=>"off",:value=>"9100FF" %>
</div>
</div>
<div>
<%= f.fields_for :name_translations do |name| %>
<% @site_valid_locales.each_with_index do |locale, i| %>
<div class="control-group">
<%= label_tag(locale, t("calendar.name")+"-"+I18nVariable.from_locale(locale)) %>
<div class="controls">
<%= name.text_field locale, :class => "input-xxlarge", :size=>"30" %>
</div>
</div>
<% end %>
<% end %>
</div>
<div class="form-actions form-fixed pagination-right">
<%= f.submit t("calendar.save"), :class=>"btn btn-primary" %>
</div>
<% end %>
</div>
<script type="text/javascript">
if($('.color-picker').length > 0){
$('.color-picker').miniColors(); // just in category view
}
</script>

View File

@ -0,0 +1,3 @@
<%=@event_category.name%>
<%=@event_category.color%>

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

View File

@ -0,0 +1,80 @@
<% if @event.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@event.errors.count, "error") %> prohibited this event from being saved:</h2>
<ul>
<% @event.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="row-fluid">
<%= f.label :title, :class=>"control-label span3" %>
<%= f.text_field :title %>
</div>
<div class="row-fluid">
<%= f.label :note, :class=>"control-label span3" %>
<%= f.text_area :note, :rows => 3 %>
</div>
<div class="row-fluid">
<label class="checkbox inline"><%= f.check_box :all_day,:id=>"all_day_check", :checked => @all_day %> All Day</label>
</div>
<div class="row-fluid">
<%= f.label :start, :class=>"control-label span3" %>
<%#= f.datetime_select :start %>
<div data-date-format="yyyy/MM/dd hh:mm" data-language="en" data-picktime="true" class="input-append datetimepick">
<%= f.text_field :start, :class => "input-large", :placeholder => 'YYYY/MM/DD',:value => @start_d_t %>
<span class="add-on clearDate">
<i class="icons-cross-3"></i>
</span>
<span class="add-on iconbtn">
<i data-time-icon="icons-clock" data-date-icon="icons-calendar"></i>
</span>
</div>
</div>
<div class="row-fluid">
<%= f.label :end, :class=>"control-label span3" %>
<%#= f.datetime_select :end %>
<div data-date-format="yyyy/MM/dd hh:mm" data-language="en" data-picktime="true" class="input-append datetimepick">
<%= f.text_field :end, :class => "input-large", :placeholder => 'YYYY/MM/DD', :value => @end_d_t %>
<!-- <input type="text" placeholder="YYYY/MM/DD" class="input-large" name="event[end]"></input> -->
<span class="add-on clearDate">
<i class="icons-cross-3"></i>
</span>
<span class="add-on iconbtn">
<i data-time-icon="icons-clock" data-date-icon="icons-calendar"></i>
</span>
</div>
</div>
<div class="row-fluid">
<%= f.label "Calendar", :class=>"control-label span3" %>
<%= f.collection_select :event_category_id, EventCategory.all, :id, :name%>
</div>
<div class="row-fluid">
<label class="checkbox inline"><%= f.check_box :recurring,:id=>"recurring_checkbox", :checked => @recurring %> Recurring</label>
</div>
<div id="recurring_panel" <%= (@recurring ? '' : "style=display:none;") %> >
<div class="row-fluid">
<%=f.label :period, "Repeats",:class=>"control-label span3" %>
<%=f.select :period, Event::REPEATS,{},:class=>"span5" %>
</div>
<div class="row-fluid">
<%=f.label :frequency, "Every",:class=>"control-label span3" %>
<%=f.select :frequency, (1..30).to_a,{},:class=>"span2" %>
</div>
</div>
<div class="row-fluid">
<div class="span9 offset3">
<% if action_name == "edit" %>
<%= f.submit t("calendar.save"), :class=>"btn btn-primary" %>
<% else %>
<%= f.submit t(:create_), :class=>"btn btn-primary" %>
<% end %>
<a href="" class="btn btn-close">Cancel</a>
</div>
</div>

View File

@ -0,0 +1,14 @@
$("#event_create").empty().hide();
$("#create_event_btn").removeClass("active");
$(".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;
}

View File

@ -0,0 +1,7 @@
<div class="modal-body">
<div class="event_controller">
<%= form_for @event, url: {action: "update"}, :remote=>true do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
</div>
</div>

View File

@ -0,0 +1,61 @@
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<%= stylesheet_link_tag 'fullcalendar'%>
<%= stylesheet_link_tag 'calendar'%>
<%= javascript_include_tag 'fullcalendar' %>
<%= javascript_include_tag 'calendar' %>
<%= javascript_include_tag 'bootstrap-datetimepicker' %>
<div id="orbit_calendar" class="month_view">
<div class="row-fluid cal-fn">
<div class="span3" id='sec1'>
<div class="btn-toolbar" id="navigation" style="margin:0;">
<div id="calendar-nav">
<div class="btn-group">
<button class="btn" id="today_btn">Today</button>
</div>
<div class="btn-group">
<button class="btn" id="prev_month_btn"><span class="icon-chevron-left"></span></button>
<button class="btn" id="next_month_btn"><span class="icon-chevron-right"></span></button>
</div>
</div>
</div>
<div class="form-inline" id="range_selection" style="display:none;margin:0;">
</div>
</div>
<div class="span5" id='sec2'>
<h3 id="current_title" class="current_day_title"></h4>
</div>
<div class="span4" id='sec3'>
<div class="btn-toolbar" style="margin:0; text-align:right;">
<div class="btn-group calendar_mode">
<button class="btn mode_switch" data-mode="agendaDay" >day</button>
<button class="btn mode_switch" data-mode="agendaWeek" >week</button>
<button class="btn active mode_switch" data-mode="month" >month</button>
<button class="btn mode_switch" data-mode="agenda" >agenda</button>
</div>
<div class="btn-group">
<button id="refresh_btn" class="btn icon-refresh"></button>
</div>
</div>
</div>
</div>
<div id="view_holder">
<div id="calendar"></div>
<div id="calendar_agenda"></div>
</div>
</div>
<div id="event_quick_view" class="modal" style="width: 300px; display:none; margin:0 0 0 0;"></div>
<div id="event_create_space" class="modal" style="right: 8px; bottom: 50px; left: auto; top: auto; width: 400px; margin: 0;display:none;"></div>
<div id="calendar-loading">Loading...</div>
<div class="form-actions form-fixed">
<div class="row-fluid">
<div class="span8">
</div>
<div class="span4">
<%= link_to "Add", new_panel_calendar_new_back_end_event_path, :class => "btn btn-primary pull-right", :id=>"create_event_btn", :ref=>"add-btn" %>
</div>
</div>
</div>
<script type="text/javascript">
var calendar = new Calendar("#calendar");
</script>

View File

@ -0,0 +1,7 @@
<div class="modal-body">
<div class="event_controller">
<%= form_for @event, :url=> panel_calendar_new_back_end_events_path(@event), :remote=>true do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
</div>
</div>

View File

@ -0,0 +1,18 @@
<div class="modal-header">
<button type="button" class="close event-close-btn" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3><%= @event.title %></h3>
</div>
<div class="modal-body">
<div class="event_summary">
<!-- Thu, September 13 -->
<% if @event.start_date == @event.end_date %>
<%= @start_day_name+", "+@event.start_date.to_s+"-"+@start_month_name %>
<% else %>
<%= @start_day_name+", "+@event.start_date.to_s+"-"+@start_month_name %> to <%= @end_day_name+", "+@event.end_date.to_s + "-" + @end_month_name %>
<% end %>
</div>
</div>
<div class="modal-footer">
<%= link_to t(:delete_), panel_calendar_new_back_end_event_path(@event),:class => "btn bt-del", :method => :delete, :remote => true %>
<%= link_to t(:edit), edit_panel_calendar_new_back_end_event_path(@event),:class => "btn btn-primary",:id=>"edit_event_btn" ,:remote => true %>
</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;
}

View File

@ -0,0 +1,23 @@
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "calendar/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "calendar_new"
s.version = CalendarNew::VERSION
s.authors = ["TODO: Your name"]
s.email = ["TODO: Your email"]
s.homepage = "TODO"
s.summary = "TODO: Summary of Calendar."
s.description = "TODO: Description of Calendar."
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]
s.add_dependency "rails", "~> 3.1.4"
# s.add_dependency "jquery-rails"
s.add_development_dependency "sqlite3"
end

View File

@ -0,0 +1,14 @@
{
"title": "calendar_new",
"version": "0.1",
"organization": "Rulingcom",
"author": "Visual dep",
"intro": "A simple and amazing calendar",
"update_info": "Some info",
"create_date": "11-08-2012",
"app_pages": ["calendar"],
"widgets": [],
"category": [],
"widget_fields":[],
"enable_frontend": true
}

View File

@ -0,0 +1,10 @@
en:
calendar:
calendar: Calendar
calendars: Calendars
color: Color
name: Name
save: Save
select_calendar: "Select Calendar"
categories: Categories
new_category: New Category

View File

@ -0,0 +1,9 @@
zh_tw:
calendar:
calendar: 行事曆
calendars: 我的行事曆
color: 顏色
name: 名稱
save: 儲存
select_calendar: 選取行事曆
categories: 類別

View File

@ -0,0 +1,11 @@
Rails.application.routes.draw do
namespace :panel do
namespace :calendar_new do
namespace :back_end do
resources :event_categories
match 'events/agenda' => 'events#agenda', :as => :agenda
resources :events
end
end
end
end

View File

@ -0,0 +1,34 @@
module CalendarNew
OrbitApp.registration "CalendarNew",:type=> 'ModuleApp' do
module_label 'calendar.calendar'
base_url File.expand_path File.dirname(__FILE__)
# personal_plugin :enable => true,:path=>"panel/calendar/plugin/profile",:i18n=>'admin.calendar'
version "0.1"
organization "Rulingcom"
author "RD dep"
intro "I am intro"
update_info 'some update_info'
side_bar do
head_label_i18n 'calendar.calendar',:icon_class=>"icons-calendar"
available_for [:admin,:guest,:manager,:sub_manager]
active_for_controllers ({:private=>['events'],:public=>['panel/calendar_new/back_end/tags']})
head_link_path "panel_calendar_new_back_end_events_path"
context_link 'calendar.new_category',
:link_path=>"new_panel_calendar_new_back_end_event_category_path" ,
:priority=>3,
:active_for_action=>{:event_categories=>:new},
:available_for => [:manager]
context_link 'calendar.categories',
:link_path=>"panel_calendar_new_back_end_event_categories_path" ,
:priority=>2,
:active_for_action=>{:event_categories=>:index},
:available_for => [:manager]
end
end
end

View File

@ -0,0 +1,4 @@
require "calendar_new/engine"
module CalendarNew
end

View File

@ -0,0 +1,4 @@
module CalendarNew
class Engine < Rails::Engine
end
end

View File

@ -0,0 +1,3 @@
module CalendarNew
VERSION = "0.0.1"
end

View File

@ -0,0 +1,4 @@
# desc "Explaining what the task does"
# task :calendar do
# # Task goes here
# end

View File

@ -0,0 +1,6 @@
#!/usr/bin/env ruby
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
ENGINE_PATH = File.expand_path('../..', __FILE__)
load File.expand_path('../../test/dummy/script/rails', __FILE__)

View File

@ -0,0 +1,7 @@
require 'test_helper'
class CalendarTest < ActiveSupport::TestCase
test "truth" do
assert_kind_of Module, Calendar
end
end

View File

@ -0,0 +1,7 @@
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Dummy::Application.load_tasks

View File

@ -0,0 +1,9 @@
// 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
//= require jquery_ujs
//= require_tree .

View File

@ -0,0 +1,7 @@
/*
* 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.
*= require_self
*= require_tree .
*/

View File

@ -0,0 +1,3 @@
class ApplicationController < ActionController::Base
protect_from_forgery
end

View File

@ -0,0 +1,2 @@
module ApplicationHelper
end

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>

View File

@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Dummy::Application

View File

@ -0,0 +1,45 @@
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require
require "calendar"
module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
end
end

View File

@ -0,0 +1,10 @@
require 'rubygems'
gemfile = File.expand_path('../../../../Gemfile', __FILE__)
if File.exist?(gemfile)
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
end
$:.unshift File.expand_path('../../../../lib', __FILE__)

View File

@ -0,0 +1,25 @@
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000

View File

@ -0,0 +1,5 @@
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Dummy::Application.initialize!

View File

@ -0,0 +1,30 @@
Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true
end

View File

@ -0,0 +1,60 @@
Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
# Compress JavaScripts and CSS
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
# Generate digests for assets URLs
config.assets.digest = true
# Defaults to Rails.root.join("public/assets")
# config.assets.manifest = YOUR_PATH
# Specifies the header that your server uses for sending files
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# See everything in the log (default is :info)
# config.log_level = :debug
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Use a different cache store in production
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
# config.assets.precompile += %w( search.js )
# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false
# Enable threaded mode
# config.threadsafe!
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
end

View File

@ -0,0 +1,39 @@
Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
# Log error messages when you accidentally call methods on nil
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
end

View File

@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!

View File

@ -0,0 +1,10 @@
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end

View File

@ -0,0 +1,5 @@
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone

View File

@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
Dummy::Application.config.secret_token = '51389313d40e5a40269583258f5a6734ca9764cd65e633594119a8cb165b4058f032d11407e10634acd50965e156a9c7f894b9e617526afe373506699bf6c2ee'

View File

@ -0,0 +1,8 @@
# Be sure to restart your server when you modify this file.
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
# Dummy::Application.config.session_store :active_record_store

View File

@ -0,0 +1,14 @@
# Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json]
end
# Disable root element in JSON by default.
ActiveSupport.on_load(:active_record) do
self.include_root_in_json = false
end

View File

@ -0,0 +1,5 @@
# Sample localization file for English. Add more files in this directory for other locales.
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
hello: "Hello world"

View File

@ -0,0 +1,58 @@
Dummy::Application.routes.draw do
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Sample resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Sample resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Sample resource route with more complex sub-resources
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', :on => :collection
# end
# end
# Sample resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
# root :to => 'welcome#index'
# See how all your routes lay out with "rake routes"
# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id(.:format)))'
end

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>The page you were looking for doesn't exist (404)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>
<body>
<!-- This file lives in public/404.html -->
<div class="dialog">
<h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p>
</div>
</body>
</html>

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>The change you wanted was rejected (422)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>
<body>
<!-- This file lives in public/422.html -->
<div class="dialog">
<h1>The change you wanted was rejected.</h1>
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
</body>
</html>

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>We're sorry, but something went wrong (500)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>
<body>
<!-- This file lives in public/500.html -->
<div class="dialog">
<h1>We're sorry, but something went wrong.</h1>
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
</div>
</body>
</html>

View File

@ -0,0 +1,6 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'

View File

@ -0,0 +1,10 @@
require 'test_helper'
class NavigationTest < ActionDispatch::IntegrationTest
fixtures :all
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,10 @@
# Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require "rails/test_help"
Rails.backtrace_cleaner.remove_silencers!
# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }