Calendar Module ported to engine
|
@ -0,0 +1,7 @@
|
|||
.bundle/
|
||||
log/*.log
|
||||
pkg/
|
||||
test/dummy/db/*.sqlite3
|
||||
test/dummy/log/*.log
|
||||
test/dummy/tmp/
|
||||
test/dummy/.sass-cache
|
|
@ -0,0 +1,17 @@
|
|||
source "https://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 'debugger'
|
|
@ -0,0 +1,95 @@
|
|||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
calendar (0.0.1)
|
||||
rails (~> 3.2.16)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (3.2.16)
|
||||
actionpack (= 3.2.16)
|
||||
mail (~> 2.5.4)
|
||||
actionpack (3.2.16)
|
||||
activemodel (= 3.2.16)
|
||||
activesupport (= 3.2.16)
|
||||
builder (~> 3.0.0)
|
||||
erubis (~> 2.7.0)
|
||||
journey (~> 1.0.4)
|
||||
rack (~> 1.4.5)
|
||||
rack-cache (~> 1.2)
|
||||
rack-test (~> 0.6.1)
|
||||
sprockets (~> 2.2.1)
|
||||
activemodel (3.2.16)
|
||||
activesupport (= 3.2.16)
|
||||
builder (~> 3.0.0)
|
||||
activerecord (3.2.16)
|
||||
activemodel (= 3.2.16)
|
||||
activesupport (= 3.2.16)
|
||||
arel (~> 3.0.2)
|
||||
tzinfo (~> 0.3.29)
|
||||
activeresource (3.2.16)
|
||||
activemodel (= 3.2.16)
|
||||
activesupport (= 3.2.16)
|
||||
activesupport (3.2.16)
|
||||
i18n (~> 0.6, >= 0.6.4)
|
||||
multi_json (~> 1.0)
|
||||
arel (3.0.3)
|
||||
builder (3.0.4)
|
||||
erubis (2.7.0)
|
||||
hike (1.2.3)
|
||||
i18n (0.6.9)
|
||||
journey (1.0.4)
|
||||
jquery-rails (3.0.4)
|
||||
railties (>= 3.0, < 5.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
json (1.8.1)
|
||||
mail (2.5.4)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
mime-types (1.25.1)
|
||||
multi_json (1.8.4)
|
||||
polyglot (0.3.3)
|
||||
rack (1.4.5)
|
||||
rack-cache (1.2)
|
||||
rack (>= 0.4)
|
||||
rack-ssl (1.3.3)
|
||||
rack
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
rails (3.2.16)
|
||||
actionmailer (= 3.2.16)
|
||||
actionpack (= 3.2.16)
|
||||
activerecord (= 3.2.16)
|
||||
activeresource (= 3.2.16)
|
||||
activesupport (= 3.2.16)
|
||||
bundler (~> 1.0)
|
||||
railties (= 3.2.16)
|
||||
railties (3.2.16)
|
||||
actionpack (= 3.2.16)
|
||||
activesupport (= 3.2.16)
|
||||
rack-ssl (~> 1.3.2)
|
||||
rake (>= 0.8.7)
|
||||
rdoc (~> 3.4)
|
||||
thor (>= 0.14.6, < 2.0)
|
||||
rake (10.1.1)
|
||||
rdoc (3.12.2)
|
||||
json (~> 1.4)
|
||||
sprockets (2.2.2)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
thor (0.18.1)
|
||||
tilt (1.4.1)
|
||||
treetop (1.4.15)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.38)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
calendar!
|
||||
jquery-rails
|
|
@ -0,0 +1,20 @@
|
|||
Copyright 2014 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.
|
|
@ -0,0 +1,3 @@
|
|||
= Calendar
|
||||
|
||||
This project rocks and uses MIT-LICENSE.
|
|
@ -0,0 +1,38 @@
|
|||
#!/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
|
||||
|
||||
|
||||
|
||||
|
||||
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
|
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 264 B |
After Width: | Height: | Size: 260 B |
After Width: | Height: | Size: 387 B |
After Width: | Height: | Size: 259 B |
After Width: | Height: | Size: 314 B |
After Width: | Height: | Size: 314 B |
After Width: | Height: | Size: 384 B |
After Width: | Height: | Size: 332 B |
After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 6.7 KiB |
After Width: | Height: | Size: 6.7 KiB |
After Width: | Height: | Size: 4.3 KiB |
|
@ -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">×</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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
});
|
|
@ -0,0 +1,503 @@
|
|||
var Calendar = function(dom){
|
||||
|
||||
c = this;
|
||||
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.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 dview = (c.currentView == "agenda" ? "month" : c.currentView);
|
||||
c.calendar.fullCalendar({
|
||||
editable: false,
|
||||
selectable: false,
|
||||
events: "/panel/calendar_new/back_end/events/",
|
||||
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});
|
||||
}
|
||||
});
|
||||
|
||||
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;}
|
||||
|
||||
}
|
||||
|
||||
this.renderEvent = function(eventStick){
|
||||
if(eventStick.recurring == true)
|
||||
c.calendar.fullCalendar("refetchEvents");
|
||||
else
|
||||
c.calendar.fullCalendar("renderEvent",eventStick);
|
||||
}
|
||||
|
||||
|
||||
$(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">×</button><h3>'+ _event.title +'</h3></div><div class="modal-body"><div class="event_summary">'+ time_string +'</div>'+ _event.note +'</div><div class="modal-footer"></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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -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();
|
||||
});
|
||||
});
|
|
@ -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;
|
||||
}
|
|
@ -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
|
||||
*/
|
|
@ -0,0 +1,579 @@
|
|||
/*!
|
||||
* FullCalendar v1.6.1 Stylesheet
|
||||
* Docs & License: http://arshaw.com/fullcalendar/
|
||||
* (c) 2013 Adam Shaw
|
||||
*/
|
||||
|
||||
|
||||
.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, /* non-theme */
|
||||
.fc-header .ui-corner-right { /* theme */
|
||||
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 #ddd;
|
||||
}
|
||||
|
||||
.fc-state-highlight { /* <td> today cell */ /* TODO: add .fc-today to <th> */
|
||||
background: #fcf8e3;
|
||||
}
|
||||
|
||||
.fc-cell-overlay { /* semi-transparent rectangle while dragging */
|
||||
background: #bce8f1;
|
||||
opacity: .3;
|
||||
filter: alpha(opacity=30); /* for IE */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Buttons
|
||||
------------------------------------------------------------------------*/
|
||||
|
||||
.fc-button {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
padding: 0 .6em;
|
||||
overflow: hidden;
|
||||
height: 1.9em;
|
||||
line-height: 1.9em;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.fc-state-default { /* non-theme */
|
||||
border: 1px solid;
|
||||
}
|
||||
|
||||
.fc-state-default.fc-corner-left { /* non-theme */
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
}
|
||||
|
||||
.fc-state-default.fc-corner-right { /* non-theme */
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
|
||||
/*
|
||||
Our default prev/next buttons use HTML entities like ‹ › « »
|
||||
and we'll try to make them look good cross-browser.
|
||||
*/
|
||||
|
||||
.fc-text-arrow {
|
||||
margin: 0 .1em;
|
||||
font-size: 2em;
|
||||
font-family: "Courier New", Courier, monospace;
|
||||
vertical-align: baseline; /* for IE7 */
|
||||
}
|
||||
|
||||
.fc-button-prev .fc-text-arrow,
|
||||
.fc-button-next .fc-text-arrow { /* for ‹ › */
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* icon (for jquery ui) */
|
||||
|
||||
.fc-button .fc-icon-wrap {
|
||||
position: relative;
|
||||
float: left;
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
.fc-button .ui-icon {
|
||||
position: relative;
|
||||
float: left;
|
||||
margin-top: -50%;
|
||||
*margin-top: 0;
|
||||
*top: -50%;
|
||||
}
|
||||
|
||||
/*
|
||||
button states
|
||||
borrowed from twitter bootstrap (http://twitter.github.com/bootstrap/)
|
||||
*/
|
||||
|
||||
.fc-state-default {
|
||||
background-color: #f5f5f5;
|
||||
background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
|
||||
background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
|
||||
background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
|
||||
background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #e6e6e6 #e6e6e6 #bfbfbf;
|
||||
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
||||
color: #333;
|
||||
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.fc-state-hover,
|
||||
.fc-state-down,
|
||||
.fc-state-active,
|
||||
.fc-state-disabled {
|
||||
color: #333333;
|
||||
background-color: #e6e6e6;
|
||||
}
|
||||
|
||||
.fc-state-hover {
|
||||
color: #333333;
|
||||
text-decoration: none;
|
||||
background-position: 0 -15px;
|
||||
-webkit-transition: background-position 0.1s linear;
|
||||
-moz-transition: background-position 0.1s linear;
|
||||
-o-transition: background-position 0.1s linear;
|
||||
transition: background-position 0.1s linear;
|
||||
}
|
||||
|
||||
.fc-state-down,
|
||||
.fc-state-active {
|
||||
background-color: #cccccc;
|
||||
background-image: none;
|
||||
outline: 0;
|
||||
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.fc-state-disabled {
|
||||
cursor: default;
|
||||
background-image: none;
|
||||
opacity: 0.65;
|
||||
filter: alpha(opacity=65);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Global Event Styles
|
||||
------------------------------------------------------------------------*/
|
||||
|
||||
.fc-event {
|
||||
border: 1px solid #3a87ad; /* default BORDER color */
|
||||
background-color: #3a87ad; /* default BACKGROUND color */
|
||||
color: #fff; /* default TEXT color */
|
||||
font-size: .85em;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
a.fc-event {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.fc-event,
|
||||
.fc-event-draggable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.fc-rtl .fc-event {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.fc-event-inner {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.fc-event-time,
|
||||
.fc-event-title {
|
||||
padding: 0 1px;
|
||||
}
|
||||
|
||||
.fc .ui-resizable-handle {
|
||||
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;
|
||||
}
|
||||
|
||||
.fc-ltr .fc-event-hori.fc-event-start,
|
||||
.fc-rtl .fc-event-hori.fc-event-end {
|
||||
border-left-width: 1px;
|
||||
border-top-left-radius: 3px;
|
||||
border-bottom-left-radius: 3px;
|
||||
}
|
||||
|
||||
.fc-ltr .fc-event-hori.fc-event-end,
|
||||
.fc-rtl .fc-event-hori.fc-event-start {
|
||||
border-right-width: 1px;
|
||||
border-top-right-radius: 3px;
|
||||
border-bottom-right-radius: 3px;
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 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 .fc-week-number {
|
||||
width: 22px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.fc .fc-week-number div {
|
||||
padding: 0 2px;
|
||||
}
|
||||
|
||||
.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-week-number {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.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-start {
|
||||
border-top-width: 1px;
|
||||
border-top-left-radius: 3px;
|
||||
border-top-right-radius: 3px;
|
||||
}
|
||||
|
||||
.fc-event-vert.fc-event-end {
|
||||
border-bottom-width: 1px;
|
||||
border-bottom-left-radius: 3px;
|
||||
border-bottom-right-radius: 3px;
|
||||
}
|
||||
|
||||
.fc-event-vert .fc-event-time {
|
||||
white-space: nowrap;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.fc-event-vert .fc-event-inner {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.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: .25;
|
||||
filter: alpha(opacity=25);
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
class Panel::CalendarNew::BackEnd::EventCategoriesController < OrbitBackendController
|
||||
include AdminHelper
|
||||
|
||||
# GET /events
|
||||
# GET /events.json
|
||||
def index
|
||||
@module_app_id = @module_app.id rescue nil
|
||||
|
||||
@categories = get_categories_for_index
|
||||
@categories = @categories.page(params[:page]).per(10)
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @categories }
|
||||
end
|
||||
end
|
||||
|
||||
def list
|
||||
@module_app_id = @module_app.id rescue nil
|
||||
|
||||
@categories = get_categories_for_index
|
||||
@categories = @categories.page(params[:page]).per(10)
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,126 @@
|
|||
class Panel::CalendarNew::BackEnd::EventsController < OrbitBackendController
|
||||
open_for_visitor :only => [:index, :show]
|
||||
# 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
|
||||
@categories = get_categories_for_index
|
||||
@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
|
||||
|
||||
end
|
||||
|
||||
# GET /events/1/edit
|
||||
def edit
|
||||
@event = Event.find(params[:id])
|
||||
@categories = get_categories_for_index
|
||||
@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 @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
|
||||
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
class Panel::CalendarNew::FrontEnd::EventsController < OrbitWidgetController
|
||||
# GET /events
|
||||
# GET /events.json
|
||||
def initialize
|
||||
super
|
||||
@app_title = 'calendar'
|
||||
end
|
||||
|
||||
def index
|
||||
@item = Page.find(params[:page_id])
|
||||
@title = @item.title
|
||||
if !@item.frontend_data_count.blank?
|
||||
@page_num = @item.frontend_data_count
|
||||
else
|
||||
@page_num = 10
|
||||
end
|
||||
|
||||
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
|
||||
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
|
||||
end
|
|
@ -0,0 +1,114 @@
|
|||
require 'time'
|
||||
require 'date'
|
||||
|
||||
class Event
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include OrbitCategory::Categorizable
|
||||
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 :frequency
|
||||
field :period
|
||||
|
||||
attr_accessor :agenda_start, :agenda_end, :get_agenda_events
|
||||
|
||||
|
||||
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.category_id,
|
||||
:color => (Category.find(self.category_id).custom_value rescue nil),
|
||||
: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.category_id.to_s, :color => Category.find(re.category_id).custom_value, :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.category_id.to_s, :color => Category.find(re.category_id).custom_value, :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.category_id.to_s, :color => Category.find(re.category_id).custom_value, :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.category_id.to_s, :color => Category.find(re.category_id).custom_value, :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.category_id.to_s, :color => Category.find(re.category_id).custom_value, :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
|
|
@ -0,0 +1,11 @@
|
|||
class EventCategory
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include OrbitCategory::Categorizable
|
||||
|
||||
field :name, localize: true
|
||||
field :color
|
||||
|
||||
has_many :events, :dependent => :destroy
|
||||
validates_presence_of :name, :message => "Please fill the name of the Category"
|
||||
end
|
|
@ -0,0 +1,21 @@
|
|||
<tr class="<%= 'disable' if category.disable %>">
|
||||
<% @site_valid_locales.each_with_index do |locale, i| %>
|
||||
<td>
|
||||
<%= category.title_translations[locale] %>
|
||||
<% if i == 0 %>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills">
|
||||
<% if is_admin?%>
|
||||
<li><%= link_to t(:edit), '#', class: "open-slide", data: {title: t(:edit_category), id: category.id.to_s, module: @module_app_id.to_s, form: category.title_translations.merge(color: category.custom_value)} %></li>
|
||||
<li><%= link_to show_toggle_archive_btn(category), toggle_admin_module_app_category_path(@module_app_id, category), method: :post, remote: true, class: "archive_toggle" %></li>
|
||||
<% end %>
|
||||
<% if is_manager? || is_admin? %>
|
||||
<li><%= link_to t(:category_auth), admin_authorizations_path(@module_app.key, 'category_authorization', category.id) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
</td>
|
||||
<% end %>
|
||||
<td><span class="badge" style="background-color: <%= category.custom_value %>;"><%= category.custom_value %></span></td>
|
||||
</tr>
|
|
@ -0,0 +1,12 @@
|
|||
<%= flash_messages %>
|
||||
<%= f.error_messages %>
|
||||
<%= label_tag("color", t("calendar.color")) %>
|
||||
<div class="input-append">
|
||||
<%= f.text_field :custom_value, id: "color", :class => "color-picker miniColors input-small", :size => "7", :maxlength => "7", :autocomplete=>"off",:value=>"9100FF" %>
|
||||
</div>
|
||||
<%= f.fields_for :title_translations do |f| %>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<%= label_tag "name-#{locale}", "#{t(:name)} (#{I18nVariable.from_locale(locale)})" %>
|
||||
<%= f.text_field locale, :class => 'input-large', :value => (@category.title_translations[locale] rescue ''), placeholder: t(:name), id: locale %>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
<%= stylesheet_link_tag "jquery.miniColors" %>
|
||||
|
||||
<%= javascript_include_tag "jquery.miniColors.min" %>
|
||||
|
||||
<%= javascript_include_tag "admin/categories" %>
|
||||
|
||||
<div id="categories_index">
|
||||
<table class="table main-list">
|
||||
<thead>
|
||||
<tr class="sort-header">
|
||||
<% @site_valid_locales.each_with_index do |locale, i| %>
|
||||
<th class="<%= 'span5' if i <= 1 %>"><a href="#"><%= t(:_locale, :locale => locale) %></a></th>
|
||||
<% end %>
|
||||
<th class="span2"><a href="#"><%= t('event_category.color') %></a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%= render partial: 'category', collection: @categories %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="bottomnav clearfix">
|
||||
<div class="action pull-right">
|
||||
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t(:add_category), id: 'new', module: @module_app_id.to_s } %>
|
||||
</div>
|
||||
<div class="pagination pagination-centered">
|
||||
<%= paginate @categories unless @categories.blank? %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="pageslide">
|
||||
<div class="page-title clearfix">
|
||||
<a class="pull-right" href="javascript:$.pageslide.close()">
|
||||
<i class="icons-arrow-left-2"></i>
|
||||
</a>
|
||||
<span></span>
|
||||
</div>
|
||||
<div class="view-page">
|
||||
<div class="nano">
|
||||
<div class="content">
|
||||
<%= form_for :category, url: nil, html:{:id=>"color"}, remote: true do |f| %>
|
||||
<fieldset>
|
||||
<%= render :partial => "form", :locals => { :f => f } %>
|
||||
<div class="form-actions">
|
||||
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
|
||||
<%= f.submit t(:submit), class: 'btn btn-primary btn-small' %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
if($('.color-picker').length > 0){
|
||||
$('.color-picker').miniColors(); // just in category view
|
||||
$('.miniColors-trigger').addClass('btn');
|
||||
}
|
||||
$("form#color").bind("ajax:complete",function(){
|
||||
$.get("<%= panel_calendar_new_back_end_event_categories_list_path %>",function(data){
|
||||
$("#categories_index").html(data);
|
||||
openSlide();
|
||||
})
|
||||
})
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
<table class="table main-list">
|
||||
<thead>
|
||||
<tr class="sort-header">
|
||||
<% @site_valid_locales.each_with_index do |locale, i| %>
|
||||
<th class="<%= 'span5' if i <= 1 %>"><a href="#"><%= t(:_locale, :locale => locale) %></a></th>
|
||||
<% end %>
|
||||
<th class="span2"><a href="#"><%= t('event_category.color') %></a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%= render partial: 'category', collection: @categories %>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="bottomnav clearfix">
|
||||
<div class="action pull-right">
|
||||
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t(:add_category), id: 'new', module: @module_app_id.to_s } %>
|
||||
</div>
|
||||
<div class="pagination pagination-centered">
|
||||
<%= paginate @categories unless @categories.blank? %>
|
||||
</div>
|
||||
</div>
|
|
@ -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>
|
|
@ -0,0 +1,3 @@
|
|||
<%=@event_category.name%>
|
||||
|
||||
<%=@event_category.color%>
|
|
@ -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;
|
||||
}
|
|
@ -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.select :category_id, @categories.collect{|t| [ t.title, t.id ]} %>
|
||||
</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>
|
|
@ -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;
|
||||
}
|
|
@ -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>
|
|
@ -0,0 +1,71 @@
|
|||
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
|
||||
<%= javascript_include_tag 'fullcalendar' %>
|
||||
<%= javascript_include_tag 'calendar' %>
|
||||
<%= javascript_include_tag 'bootstrap-datetimepicker' %>
|
||||
|
||||
<%= stylesheet_link_tag "fullcalendar"%>
|
||||
<%= stylesheet_link_tag "calendar"%>
|
||||
|
||||
<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">
|
||||
<i class="icon-chevron-left"></i>
|
||||
</button>
|
||||
<button class="btn" id="next_month_btn">
|
||||
<i class="icon-chevron-right"></i>
|
||||
</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">
|
||||
<i class="icons-cycle"></i>
|
||||
</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>
|
||||
<%if is_manager?%>
|
||||
<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>
|
||||
<%end%>
|
|
@ -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>
|
|
@ -0,0 +1,20 @@
|
|||
<div class="modal-header">
|
||||
<button type="button" class="close event-close-btn" data-dismiss="modal" aria-hidden="true">×</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>
|
||||
<%if user_signed_in? && is_manager?%>
|
||||
<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>
|
||||
<% end %>
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
|
||||
<%= javascript_include_tag 'fullcalendar' %>
|
||||
<%= javascript_include_tag 'calendar_frontend' %>
|
||||
<%= javascript_include_tag 'bootstrap-datetimepicker' %>
|
||||
|
||||
<%= stylesheet_link_tag "fullcalendar"%>
|
||||
<%= stylesheet_link_tag "calendar"%>
|
||||
|
||||
<div id="orbit_calendar">
|
||||
<div id='sec1' class="cal-fn">
|
||||
<div class="btn-toolbar" id="navigation">
|
||||
<div id="calendar-nav">
|
||||
<button class="btn" id="today_btn">Today</button>
|
||||
<div class="btn-group">
|
||||
<button class="btn" id="prev_month_btn">
|
||||
<i class="icon-chevron-left"></i>
|
||||
</button>
|
||||
<button class="btn" id="next_month_btn">
|
||||
<i class="icon-chevron-right"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-inline" id="range_selection"></div>
|
||||
</div>
|
||||
<div id='sec3' class="btn-toolbar">
|
||||
<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>
|
||||
<button id="refresh_btn" class="btn">
|
||||
<i class="icons-cycle"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div id="view_holder">
|
||||
<h3 id="current_title" class="current_day_title"></h3>
|
||||
<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="calendar-loading">Loading...</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var calendar = new Calendar("#calendar");
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
$:.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"
|
||||
s.version = Calendar::VERSION
|
||||
s.authors = ["Harry Bomrah, Saurabh Bhatia"]
|
||||
s.email = ["harry@rulingcom.com, saurabh@rulingcom.com"]
|
||||
s.homepage = "http://www.rulingcom.com"
|
||||
s.summary = "Calendar Module for Orbit."
|
||||
s.description = "A module to display events on a Calendar"
|
||||
|
||||
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
|
||||
s.test_files = Dir["test/**/*"]
|
||||
|
||||
s.add_dependency "rails", "~> 3.2.16"
|
||||
# s.add_dependency "jquery-rails"
|
||||
end
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
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'
|
||||
|
||||
authorizable
|
||||
categorizable
|
||||
taggable
|
||||
|
||||
front_end do
|
||||
app_page 'events' do
|
||||
frontend_i18n "calendar_new.frontend.events"
|
||||
end
|
||||
end
|
||||
|
||||
side_bar do
|
||||
head_label_i18n 'calendar.calendar',:icon_class=>"icons-calendar"
|
||||
available_for [:admin,:guest,:manager,:sub_manager]
|
||||
active_for_controllers ({:private=>['events','event_categories'],:public=>['panel/calendar_new/back_end/tags']})
|
||||
|
||||
|
||||
head_link_path "panel_calendar_new_back_end_events_path"
|
||||
|
||||
# context_link 'calendar.categories',
|
||||
# :link_path=>"admin_module_app_categories_path(get_module_app)" ,
|
||||
# :priority=>2,
|
||||
# :active_for_category => 'CalendarNew',
|
||||
# :available_for => [:manager]
|
||||
context_link 'tags',
|
||||
:link_path=>"admin_module_tags_path(module_app_id: get_module_app)" ,
|
||||
:priority=>4,
|
||||
:active_for_tag => 'CalendarNew',
|
||||
:available_for => [:manager]
|
||||
|
||||
context_link 'calendar.categories',
|
||||
:link_path=>"panel_calendar_new_back_end_event_categories_path" ,
|
||||
:priority=>3,
|
||||
:active_for_category => 'CalendarNew',
|
||||
:available_for => [:manager]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
en:
|
||||
calendar:
|
||||
all: All
|
||||
calendar: Calendar
|
||||
calendars: Calendars
|
||||
color: Color
|
||||
name: Name
|
||||
save: Save
|
||||
select_calendar: "Select Calendar"
|
||||
categories: Categories
|
||||
new_category: New Category
|
|
@ -0,0 +1,9 @@
|
|||
zh_tw:
|
||||
calendar:
|
||||
calendar: 行事曆
|
||||
calendars: 我的行事曆
|
||||
color: 顏色
|
||||
name: 名稱
|
||||
save: 儲存
|
||||
select_calendar: 選取行事曆
|
||||
categories: 類別
|
|
@ -0,0 +1,17 @@
|
|||
Rails.application.routes.draw do
|
||||
namespace :panel do
|
||||
namespace :calendar_new do
|
||||
namespace :back_end do
|
||||
match 'event_categories/list' => "event_categories#list"
|
||||
resources :event_categories
|
||||
match 'events/agenda' => 'events#agenda', :as => :agenda
|
||||
|
||||
resources :events
|
||||
end
|
||||
namespace :front_end do
|
||||
match 'events/agenda' => 'events#agenda', :as => :agenda
|
||||
resources :events, except: [:new, :edit, :update, :destroy]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
require "calendar/engine"
|
||||
|
||||
module Calendar
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
module Calendar
|
||||
class Engine < ::Rails::Engine
|
||||
end
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
module Calendar
|
||||
VERSION = "0.0.1"
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
# desc "Explaining what the task does"
|
||||
# task :calendar do
|
||||
# # Task goes here
|
||||
# end
|
|
@ -0,0 +1,8 @@
|
|||
#!/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_ROOT = File.expand_path('../..', __FILE__)
|
||||
ENGINE_PATH = File.expand_path('../../lib/calendar/engine', __FILE__)
|
||||
|
||||
require 'rails/all'
|
||||
require 'rails/engine/commands'
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class CalendarTest < ActiveSupport::TestCase
|
||||
test "truth" do
|
||||
assert_kind_of Module, Calendar
|
||||
end
|
||||
end
|
|
@ -0,0 +1,261 @@
|
|||
== Welcome to Rails
|
||||
|
||||
Rails is a web-application framework that includes everything needed to create
|
||||
database-backed web applications according to the Model-View-Control pattern.
|
||||
|
||||
This pattern splits the view (also called the presentation) into "dumb"
|
||||
templates that are primarily responsible for inserting pre-built data in between
|
||||
HTML tags. The model contains the "smart" domain objects (such as Account,
|
||||
Product, Person, Post) that holds all the business logic and knows how to
|
||||
persist themselves to a database. The controller handles the incoming requests
|
||||
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
||||
and directing data to the view.
|
||||
|
||||
In Rails, the model is handled by what's called an object-relational mapping
|
||||
layer entitled Active Record. This layer allows you to present the data from
|
||||
database rows as objects and embellish these data objects with business logic
|
||||
methods. You can read more about Active Record in
|
||||
link:files/vendor/rails/activerecord/README.html.
|
||||
|
||||
The controller and view are handled by the Action Pack, which handles both
|
||||
layers by its two parts: Action View and Action Controller. These two layers
|
||||
are bundled in a single package due to their heavy interdependence. This is
|
||||
unlike the relationship between the Active Record and Action Pack that is much
|
||||
more separate. Each of these packages can be used independently outside of
|
||||
Rails. You can read more about Action Pack in
|
||||
link:files/vendor/rails/actionpack/README.html.
|
||||
|
||||
|
||||
== Getting Started
|
||||
|
||||
1. At the command prompt, create a new Rails application:
|
||||
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
|
||||
|
||||
2. Change directory to <tt>myapp</tt> and start the web server:
|
||||
<tt>cd myapp; rails server</tt> (run with --help for options)
|
||||
|
||||
3. Go to http://localhost:3000/ and you'll see:
|
||||
"Welcome aboard: You're riding Ruby on Rails!"
|
||||
|
||||
4. Follow the guidelines to start developing your application. You can find
|
||||
the following resources handy:
|
||||
|
||||
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
|
||||
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
|
||||
|
||||
|
||||
== Debugging Rails
|
||||
|
||||
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
||||
will help you debug it and get it back on the rails.
|
||||
|
||||
First area to check is the application log files. Have "tail -f" commands
|
||||
running on the server.log and development.log. Rails will automatically display
|
||||
debugging and runtime information to these files. Debugging info will also be
|
||||
shown in the browser on requests from 127.0.0.1.
|
||||
|
||||
You can also log your own messages directly into the log file from your code
|
||||
using the Ruby logger class from inside your controllers. Example:
|
||||
|
||||
class WeblogController < ActionController::Base
|
||||
def destroy
|
||||
@weblog = Weblog.find(params[:id])
|
||||
@weblog.destroy
|
||||
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
|
||||
end
|
||||
end
|
||||
|
||||
The result will be a message in your log file along the lines of:
|
||||
|
||||
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
||||
|
||||
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
||||
|
||||
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
||||
several books available online as well:
|
||||
|
||||
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
||||
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
||||
|
||||
These two books will bring you up to speed on the Ruby language and also on
|
||||
programming in general.
|
||||
|
||||
|
||||
== Debugger
|
||||
|
||||
Debugger support is available through the debugger command when you start your
|
||||
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
||||
execution at any point in the code, investigate and change the model, and then,
|
||||
resume execution! You need to install ruby-debug to run the server in debugging
|
||||
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
||||
|
||||
class WeblogController < ActionController::Base
|
||||
def index
|
||||
@posts = Post.all
|
||||
debugger
|
||||
end
|
||||
end
|
||||
|
||||
So the controller will accept the action, run the first line, then present you
|
||||
with a IRB prompt in the server window. Here you can do things like:
|
||||
|
||||
>> @posts.inspect
|
||||
=> "[#<Post:0x14a6be8
|
||||
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
||||
#<Post:0x14a6620
|
||||
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
||||
>> @posts.first.title = "hello from a debugger"
|
||||
=> "hello from a debugger"
|
||||
|
||||
...and even better, you can examine how your runtime objects actually work:
|
||||
|
||||
>> f = @posts.first
|
||||
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
||||
>> f.
|
||||
Display all 152 possibilities? (y or n)
|
||||
|
||||
Finally, when you're ready to resume execution, you can enter "cont".
|
||||
|
||||
|
||||
== Console
|
||||
|
||||
The console is a Ruby shell, which allows you to interact with your
|
||||
application's domain model. Here you'll have all parts of the application
|
||||
configured, just like it is when the application is running. You can inspect
|
||||
domain models, change values, and save to the database. Starting the script
|
||||
without arguments will launch it in the development environment.
|
||||
|
||||
To start the console, run <tt>rails console</tt> from the application
|
||||
directory.
|
||||
|
||||
Options:
|
||||
|
||||
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
||||
made to the database.
|
||||
* Passing an environment name as an argument will load the corresponding
|
||||
environment. Example: <tt>rails console production</tt>.
|
||||
|
||||
To reload your controllers and models after launching the console run
|
||||
<tt>reload!</tt>
|
||||
|
||||
More information about irb can be found at:
|
||||
link:http://www.rubycentral.org/pickaxe/irb.html
|
||||
|
||||
|
||||
== dbconsole
|
||||
|
||||
You can go to the command line of your database directly through <tt>rails
|
||||
dbconsole</tt>. You would be connected to the database with the credentials
|
||||
defined in database.yml. Starting the script without arguments will connect you
|
||||
to the development database. Passing an argument will connect you to a different
|
||||
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
||||
PostgreSQL and SQLite 3.
|
||||
|
||||
== Description of Contents
|
||||
|
||||
The default directory structure of a generated Ruby on Rails application:
|
||||
|
||||
|-- app
|
||||
| |-- assets
|
||||
| | |-- images
|
||||
| | |-- javascripts
|
||||
| | `-- stylesheets
|
||||
| |-- controllers
|
||||
| |-- helpers
|
||||
| |-- mailers
|
||||
| |-- models
|
||||
| `-- views
|
||||
| `-- layouts
|
||||
|-- config
|
||||
| |-- environments
|
||||
| |-- initializers
|
||||
| `-- locales
|
||||
|-- db
|
||||
|-- doc
|
||||
|-- lib
|
||||
| |-- assets
|
||||
| `-- tasks
|
||||
|-- log
|
||||
|-- public
|
||||
|-- script
|
||||
|-- test
|
||||
| |-- fixtures
|
||||
| |-- functional
|
||||
| |-- integration
|
||||
| |-- performance
|
||||
| `-- unit
|
||||
|-- tmp
|
||||
| `-- cache
|
||||
| `-- assets
|
||||
`-- vendor
|
||||
|-- assets
|
||||
| |-- javascripts
|
||||
| `-- stylesheets
|
||||
`-- plugins
|
||||
|
||||
app
|
||||
Holds all the code that's specific to this particular application.
|
||||
|
||||
app/assets
|
||||
Contains subdirectories for images, stylesheets, and JavaScript files.
|
||||
|
||||
app/controllers
|
||||
Holds controllers that should be named like weblogs_controller.rb for
|
||||
automated URL mapping. All controllers should descend from
|
||||
ApplicationController which itself descends from ActionController::Base.
|
||||
|
||||
app/models
|
||||
Holds models that should be named like post.rb. Models descend from
|
||||
ActiveRecord::Base by default.
|
||||
|
||||
app/views
|
||||
Holds the template files for the view that should be named like
|
||||
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
||||
eRuby syntax by default.
|
||||
|
||||
app/views/layouts
|
||||
Holds the template files for layouts to be used with views. This models the
|
||||
common header/footer method of wrapping views. In your views, define a layout
|
||||
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
||||
Inside default.html.erb, call <% yield %> to render the view using this
|
||||
layout.
|
||||
|
||||
app/helpers
|
||||
Holds view helpers that should be named like weblogs_helper.rb. These are
|
||||
generated for you automatically when using generators for controllers.
|
||||
Helpers can be used to wrap functionality for your views into methods.
|
||||
|
||||
config
|
||||
Configuration files for the Rails environment, the routing map, the database,
|
||||
and other dependencies.
|
||||
|
||||
db
|
||||
Contains the database schema in schema.rb. db/migrate contains all the
|
||||
sequence of Migrations for your schema.
|
||||
|
||||
doc
|
||||
This directory is where your application documentation will be stored when
|
||||
generated using <tt>rake doc:app</tt>
|
||||
|
||||
lib
|
||||
Application specific libraries. Basically, any kind of custom code that
|
||||
doesn't belong under controllers, models, or helpers. This directory is in
|
||||
the load path.
|
||||
|
||||
public
|
||||
The directory available for the web server. Also contains the dispatchers and the
|
||||
default HTML files. This should be set as the DOCUMENT_ROOT of your web
|
||||
server.
|
||||
|
||||
script
|
||||
Helper scripts for automation and generation.
|
||||
|
||||
test
|
||||
Unit and functional tests along with fixtures. When using the rails generate
|
||||
command, template test files will be generated for you and placed in this
|
||||
directory.
|
||||
|
||||
vendor
|
||||
External libraries that the application depends on. Also includes the plugins
|
||||
subdirectory. If the app has frozen rails, those gems also go here, under
|
||||
vendor/rails/. This directory is in the load path.
|
|
@ -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
|
|
@ -0,0 +1,15 @@
|
|||
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
||||
// listed below.
|
||||
//
|
||||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
||||
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
||||
//
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// the compiled file.
|
||||
//
|
||||
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
||||
// GO AFTER THE REQUIRES BELOW.
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require_tree .
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||
* listed below.
|
||||
*
|
||||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
||||
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
||||
*
|
||||
* 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 .
|
||||
*/
|
|
@ -0,0 +1,3 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module ApplicationHelper
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Dummy</title>
|
||||
<%= stylesheet_link_tag "application", :media => "all" %>
|
||||
<%= javascript_include_tag "application" %>
|
||||
<%= csrf_meta_tags %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%= yield %>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -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
|
|
@ -0,0 +1,65 @@
|
|||
require File.expand_path('../boot', __FILE__)
|
||||
|
||||
# Pick the frameworks you want:
|
||||
# require "active_record/railtie"
|
||||
require "action_controller/railtie"
|
||||
require "action_mailer/railtie"
|
||||
require "active_resource/railtie"
|
||||
require "sprockets/railtie"
|
||||
require "rails/test_unit/railtie"
|
||||
|
||||
Bundler.require(*Rails.groups)
|
||||
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 escaping HTML in JSON.
|
||||
config.active_support.escape_html_entities_in_json = true
|
||||
|
||||
# Use SQL instead of Active Record's schema dumper when creating the 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
|
||||
|
||||
# Enforce whitelist mode for mass assignment.
|
||||
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
||||
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
||||
# parameters by using an attr_accessible or attr_protected declaration.
|
||||
# config.active_record.whitelist_attributes = true
|
||||
|
||||
# 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
|
||||
|
|
@ -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__)
|
|
@ -0,0 +1,5 @@
|
|||
# Load the rails application
|
||||
require File.expand_path('../application', __FILE__)
|
||||
|
||||
# Initialize the rails application
|
||||
Dummy::Application.initialize!
|
|
@ -0,0 +1,31 @@
|
|||
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
|
|
@ -0,0 +1,64 @@
|
|||
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 nil and saved in location specified by config.assets.prefix
|
||||
# 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
|
||||
|
||||
# Prepend all log lines with the following tags
|
||||
# config.log_tags = [ :subdomain, :uuid ]
|
||||
|
||||
# Use a different logger for distributed setups
|
||||
# config.logger = ActiveSupport::TaggedLogging.new(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
|
|
@ -0,0 +1,35 @@
|
|||
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
|
||||
|
||||
|
||||
# Print deprecation notices to the stderr
|
||||
config.active_support.deprecation = :stderr
|
||||
end
|
|
@ -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!
|
|
@ -0,0 +1,15 @@
|
|||
# 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
|
||||
#
|
||||
# These inflection rules are supported but not enabled by default:
|
||||
# ActiveSupport::Inflector.inflections do |inflect|
|
||||
# inflect.acronym 'RESTful'
|
||||
# end
|
|
@ -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
|
|
@ -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 = '235c60b779abd1ac3a6403222fb5542e37a86c6271f934d35a5a3eaad3f1ca3e7e0248a42a221699f26408da30ff5e2b455e68f06a0586a0ac8bba7b9e21b265'
|
|
@ -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
|
|
@ -0,0 +1,10 @@
|
|||
# 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
|
||||
|
|
@ -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"
|
|
@ -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
|
|
@ -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>
|