[2.0] demo file updates; new timezone and language demos

This commit is contained in:
Adam Shaw
2014-01-24 22:53:18 -08:00
parent 05ab0a7cf8
commit cfc7087f99
15 changed files with 706 additions and 256 deletions
+23 -30
View File
@@ -1,19 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='../build/out/fullcalendar.css' rel='stylesheet' />
<link href='../build/out/fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='../lib/moment/moment.js'></script>
<script src='../lib/jquery/jquery.js'></script>
<script src='../lib/jquery-ui/ui/jquery-ui.js'></script>
<script src='../build/out/fullcalendar.js'></script>
<script>
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
header: {
@@ -21,51 +18,45 @@
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2014-01-12',
editable: true,
events: [
{
title: 'All Day Event',
start: new Date(y, m, 1)
start: '2014-01-01'
},
{
title: 'Long Event',
start: new Date(y, m, d-5),
end: new Date(y, m, d-2)
start: '2014-01-07',
end: '2014-01-10'
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d-3, 16, 0),
allDay: false
start: '2014-01-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d+4, 16, 0),
allDay: false
start: '2014-01-16T16:00:00'
},
{
title: 'Meeting',
start: new Date(y, m, d, 10, 30),
allDay: false
start: '2014-01-12T10:30:00',
end: '2014-01-12T12:30:00'
},
{
title: 'Lunch',
start: new Date(y, m, d, 12, 0),
end: new Date(y, m, d, 14, 0),
allDay: false
start: '2014-01-12T12:00:00'
},
{
title: 'Birthday Party',
start: new Date(y, m, d+1, 19, 0),
end: new Date(y, m, d+1, 22, 30),
allDay: false
start: '2014-01-13T07:00:00'
},
{
title: 'Click for Google',
start: new Date(y, m, 28),
end: new Date(y, m, 29),
url: 'http://google.com/'
url: 'http://google.com/',
start: '2014-01-28'
}
]
});
@@ -76,20 +67,22 @@
<style>
body {
margin-top: 40px;
text-align: center;
font-size: 14px;
margin: 0;
padding: 0;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
font-size: 14px;
}
#calendar {
width: 900px;
margin: 0 auto;
}
margin: 40px auto;
}
</style>
</head>
<body>
<div id='calendar'></div>
<div id='calendar'></div>
</body>
</html>
+23 -30
View File
@@ -1,19 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='../build/out/fullcalendar.css' rel='stylesheet' />
<link href='../build/out/fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='../lib/moment/moment.js'></script>
<script src='../lib/jquery/jquery.js'></script>
<script src='../lib/jquery-ui/ui/jquery-ui.js'></script>
<script src='../build/out/fullcalendar.js'></script>
<script>
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
header: {
@@ -21,51 +18,45 @@
center: 'title',
right: 'month,basicWeek,basicDay'
},
defaultDate: '2014-01-12',
editable: true,
events: [
{
title: 'All Day Event',
start: new Date(y, m, 1)
start: '2014-01-01'
},
{
title: 'Long Event',
start: new Date(y, m, d-5),
end: new Date(y, m, d-2)
start: '2014-01-07',
end: '2014-01-10'
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d-3, 16, 0),
allDay: false
start: '2014-01-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d+4, 16, 0),
allDay: false
start: '2014-01-16T16:00:00'
},
{
title: 'Meeting',
start: new Date(y, m, d, 10, 30),
allDay: false
start: '2014-01-12T10:30:00',
end: '2014-01-12T12:30:00'
},
{
title: 'Lunch',
start: new Date(y, m, d, 12, 0),
end: new Date(y, m, d, 14, 0),
allDay: false
start: '2014-01-12T12:00:00'
},
{
title: 'Birthday Party',
start: new Date(y, m, d+1, 19, 0),
end: new Date(y, m, d+1, 22, 30),
allDay: false
start: '2014-01-13T07:00:00'
},
{
title: 'Click for Google',
start: new Date(y, m, 28),
end: new Date(y, m, 29),
url: 'http://google.com/'
url: 'http://google.com/',
start: '2014-01-28'
}
]
});
@@ -76,20 +67,22 @@
<style>
body {
margin-top: 40px;
text-align: center;
font-size: 14px;
margin: 0;
padding: 0;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
font-size: 14px;
}
#calendar {
width: 900px;
margin: 0 auto;
}
margin: 40px auto;
}
</style>
</head>
<body>
<div id='calendar'></div>
<div id='calendar'></div>
</body>
</html>
+24 -31
View File
@@ -1,66 +1,57 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='../build/out/fullcalendar.css' rel='stylesheet' />
<link href='../build/out/fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='../lib/moment/moment.js'></script>
<script src='../lib/jquery/jquery.js'></script>
<script src='../lib/jquery-ui/ui/jquery-ui.js'></script>
<script src='../build/out/fullcalendar.js'></script>
<script>
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
defaultDate: '2014-01-12',
editable: true,
events: [
{
title: 'All Day Event',
start: new Date(y, m, 1)
start: '2014-01-01'
},
{
title: 'Long Event',
start: new Date(y, m, d-5),
end: new Date(y, m, d-2)
start: '2014-01-07',
end: '2014-01-10'
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d-3, 16, 0),
allDay: false
start: '2014-01-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d+4, 16, 0),
allDay: false
start: '2014-01-16T16:00:00'
},
{
title: 'Meeting',
start: new Date(y, m, d, 10, 30),
allDay: false
start: '2014-01-12T10:30:00',
end: '2014-01-12T12:30:00'
},
{
title: 'Lunch',
start: new Date(y, m, d, 12, 0),
end: new Date(y, m, d, 14, 0),
allDay: false
start: '2014-01-12T12:00:00'
},
{
title: 'Birthday Party',
start: new Date(y, m, d+1, 19, 0),
end: new Date(y, m, d+1, 22, 30),
allDay: false
start: '2014-01-13T07:00:00'
},
{
title: 'Click for Google',
start: new Date(y, m, 28),
end: new Date(y, m, 29),
url: 'http://google.com/'
url: 'http://google.com/',
start: '2014-01-28'
}
]
});
@@ -71,20 +62,22 @@
<style>
body {
margin-top: 40px;
text-align: center;
font-size: 14px;
margin: 0;
padding: 0;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
font-size: 14px;
}
#calendar {
width: 900px;
margin: 0 auto;
}
margin: 40px auto;
}
</style>
</head>
<body>
<div id='calendar'></div>
<div id='calendar'></div>
</body>
</html>
+28 -25
View File
@@ -1,8 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='../build/out/fullcalendar.css' rel='stylesheet' />
<link href='../build/out/fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='../lib/moment/moment.js'></script>
<script src='../lib/jquery/jquery.js'></script>
<script src='../lib/jquery-ui/ui/jquery-ui.js'></script>
<script src='../build/out/fullcalendar.js'></script>
@@ -46,7 +48,7 @@
},
editable: true,
droppable: true, // this allows things to be dropped onto the calendar !!!
drop: function(date, allDay) { // this function is called when something is dropped
drop: function(date) { // this function is called when something is dropped
// retrieve the dropped element's stored Event Object
var originalEventObject = $(this).data('eventObject');
@@ -56,7 +58,6 @@
// assign it the date that was reported
copiedEventObject.start = date;
copiedEventObject.allDay = allDay;
// render the event on the calendar
// the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
@@ -82,12 +83,12 @@
text-align: center;
font-size: 14px;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
}
#wrap {
width: 1100px;
margin: 0 auto;
}
}
#external-events {
float: left;
@@ -96,13 +97,13 @@
border: 1px solid #ccc;
background: #eee;
text-align: left;
}
}
#external-events h4 {
font-size: 16px;
margin-top: 0;
padding-top: 1em;
}
}
.external-event { /* try to mimick the look of a real event */
margin: 10px 0;
@@ -111,44 +112,46 @@
color: #fff;
font-size: .85em;
cursor: pointer;
}
}
#external-events p {
margin: 1.5em 0;
font-size: 11px;
color: #666;
}
}
#external-events p input {
margin: 0;
vertical-align: middle;
}
}
#calendar {
float: right;
width: 900px;
}
}
</style>
</head>
<body>
<div id='wrap'>
<div id='wrap'>
<div id='external-events'>
<h4>Draggable Events</h4>
<div class='external-event'>My Event 1</div>
<div class='external-event'>My Event 2</div>
<div class='external-event'>My Event 3</div>
<div class='external-event'>My Event 4</div>
<div class='external-event'>My Event 5</div>
<p>
<input type='checkbox' id='drop-remove' /> <label for='drop-remove'>remove after drop</label>
</p>
</div>
<div id='external-events'>
<h4>Draggable Events</h4>
<div class='external-event'>My Event 1</div>
<div class='external-event'>My Event 2</div>
<div class='external-event'>My Event 3</div>
<div class='external-event'>My Event 4</div>
<div class='external-event'>My Event 5</div>
<p>
<input type='checkbox' id='drop-remove' />
<label for='drop-remove'>remove after drop</label>
</p>
</div>
<div id='calendar'></div>
<div id='calendar'></div>
<div style='clear:both'></div>
</div>
<div style='clear:both'></div>
</div>
</body>
</html>
+18 -17
View File
@@ -1,10 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='../build/out/fullcalendar.css' rel='stylesheet' />
<link href='../build/out/fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='../lib/moment/moment.js'></script>
<script src='../lib/jquery/jquery.js'></script>
<script src='../lib/jquery-ui/ui/jquery-ui.js'></script>
<script src='../build/out/fullcalendar.js'></script>
<script src='../build/out/gcal.js'></script>
<script>
@@ -23,11 +24,7 @@
},
loading: function(bool) {
if (bool) {
$('#loading').show();
}else{
$('#loading').hide();
}
$('#loading').toggle(bool);
}
});
@@ -38,27 +35,31 @@
<style>
body {
margin-top: 40px;
text-align: center;
font-size: 14px;
margin: 0;
padding: 0;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
font-size: 14px;
}
#loading {
display: none;
position: absolute;
top: 5px;
right: 5px;
}
top: 10px;
right: 10px;
}
#calendar {
width: 900px;
margin: 0 auto;
}
margin: 40px auto;
}
</style>
</head>
<body>
<div id='loading' style='display:none'>loading...</div>
<div id='calendar'></div>
<div id='loading'>loading...</div>
<div id='calendar'></div>
</body>
</html>
-25
View File
@@ -1,25 +0,0 @@
<?php
$year = date('Y');
$month = date('m');
echo json_encode(array(
array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-10",
'url' => "http://yahoo.com/"
),
array(
'id' => 222,
'title' => "Event2",
'start' => "$year-$month-20",
'end' => "$year-$month-22",
'url' => "http://yahoo.com/"
)
));
?>
+47 -25
View File
@@ -1,8 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='../build/out/fullcalendar.css' rel='stylesheet' />
<link href='../build/out/fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='../lib/moment/moment.js'></script>
<script src='../lib/jquery/jquery.js'></script>
<script src='../lib/jquery-ui/ui/jquery-ui.js'></script>
<script src='../build/out/fullcalendar.js'></script>
@@ -11,21 +13,22 @@
$(document).ready(function() {
$('#calendar').fullCalendar({
editable: true,
events: "json-events.php",
eventDrop: function(event, delta) {
alert(event.title + ' was moved ' + delta + ' days\n' +
'(should probably update your database)');
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2014-01-12',
editable: true,
events: {
url: 'php/get-events.php',
error: function() {
$('#script-warning').show();
}
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
$('#loading').toggle(bool);
}
});
});
@@ -34,28 +37,47 @@
<style>
body {
margin-top: 40px;
text-align: center;
font-size: 14px;
margin: 0;
padding: 0;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
font-size: 14px;
}
#script-warning {
display: none;
background: #eee;
border-bottom: 1px solid #ddd;
padding: 0 10px;
line-height: 40px;
text-align: center;
font-weight: bold;
font-size: 12px;
color: red;
}
#loading {
display: none;
position: absolute;
top: 5px;
right: 5px;
}
top: 10px;
right: 10px;
}
#calendar {
width: 900px;
margin: 0 auto;
}
margin: 40px auto;
}
</style>
</head>
<body>
<div id='loading' style='display:none'>loading...</div>
<div id='calendar'></div>
<p>json-events.php needs to be running in the same directory.</p>
<div id='script-warning'>
<code>php/get-events.php</code> must be running.
</div>
<div id='loading'>loading...</div>
<div id='calendar'></div>
</body>
</html>
+39
View File
@@ -0,0 +1,39 @@
[
{
"title": "All Day Event",
"start": "2014-01-01"
},
{
"title": "Long Event",
"start": "2014-01-07",
"end": "2014-01-10"
},
{
"id": "999",
"title": "Repeating Event",
"start": "2014-01-09T16:00:00-05:00"
},
{
"id": "999",
"title": "Repeating Event",
"start": "2014-01-16T16:00:00-05:00"
},
{
"title": "Meeting",
"start": "2014-01-12T10:30:00-05:00",
"end": "2014-01-12T12:30:00-05:00"
},
{
"title": "Lunch",
"start": "2014-01-12T12:00:00-05:00"
},
{
"title": "Birthday Party",
"start": "2014-01-13T07:00:00-05:00"
},
{
"title": "Click for Google",
"url": "http://google.com/",
"start": "2014-01-28"
}
]
+131
View File
@@ -0,0 +1,131 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link rel='stylesheet' href='../lib/jquery-ui/themes/cupertino/jquery-ui.min.css' />
<link href='../build/out/fullcalendar.css' rel='stylesheet' />
<link href='../build/out/fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='../lib/moment/moment.js'></script>
<script src='../lib/jquery/jquery.js'></script>
<script src='../lib/jquery-ui/ui/jquery-ui.js'></script>
<script src='../build/out/fullcalendar.js'></script>
<script src='../build/out/lang/all.js'></script>
<script>
$(document).ready(function() {
var currentLangCode = 'en';
// build the language selector's options
$.each($.fullCalendar.langs, function(langCode) {
$('#lang-selector').append(
$('<option/>')
.attr('value', langCode)
.prop('selected', langCode == currentLangCode)
.text(langCode)
);
});
// rerender the calendar when the selected option changes
$('#lang-selector').on('change', function() {
if (this.value) {
currentLangCode = this.value;
$('#calendar').fullCalendar('destroy');
renderCalendar();
}
});
function renderCalendar() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2014-01-12',
lang: currentLangCode,
buttonIcons: false, // show the prev/next text
weekNumbers: true,
editable: true,
events: [
{
title: 'All Day Event',
start: '2014-01-01'
},
{
title: 'Long Event',
start: '2014-01-07',
end: '2014-01-10'
},
{
id: 999,
title: 'Repeating Event',
start: '2014-01-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: '2014-01-16T16:00:00'
},
{
title: 'Meeting',
start: '2014-01-12T10:30:00',
end: '2014-01-12T12:30:00'
},
{
title: 'Lunch',
start: '2014-01-12T12:00:00'
},
{
title: 'Birthday Party',
start: '2014-01-13T07:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2014-01-28'
}
]
});
}
renderCalendar();
});
</script>
<style>
body {
margin: 0;
padding: 0;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
font-size: 14px;
}
#top {
background: #eee;
border-bottom: 1px solid #ddd;
padding: 0 10px;
line-height: 40px;
font-size: 12px;
}
#calendar {
width: 900px;
margin: 40px auto;
}
</style>
</head>
<body>
<div id='top'>
Language:
<select id='lang-selector'></select>
</div>
<div id='calendar'></div>
</body>
</html>
+50
View File
@@ -0,0 +1,50 @@
<?php
//--------------------------------------------------------------------------------------------------
// This script reads event data from a JSON file and outputs those events which are within the range
// supplied by the "start" and "end" GET parameters.
//
// An optional "timezone" GET parameter will force all ISO8601 date stings to a given timezone.
//
// Requires PHP 5.3.0 or higher.
//--------------------------------------------------------------------------------------------------
// Require our Event class and datetime utilities
require __DIR__ . '/utils.php';
// Short-circuit if the client did not give us a date range.
if (!isset($_GET['start']) || !isset($_GET['end'])) {
die("Please provide a date range.");
}
// Parse the start/end parameters.
// These are assumed to be ISO8601 strings with no time nor timezone, like "2013-12-29".
// Since no timezone will be present, they will parsed as UTC.
$range_start = parseDateTime($_GET['start']);
$range_end = parseDateTime($_GET['end']);
// Parse the timezone parameter if it is present.
$timezone = null;
if (isset($_GET['timezone'])) {
$timezone = new DateTimeZone($_GET['timezone']);
}
// Read and parse our events JSON file into an array of event data arrays.
$json = file_get_contents(__DIR__ . '/../json/events.json');
$input_arrays = json_decode($json, true);
// Accumulate an output array of event data arrays.
$output_arrays = array();
foreach ($input_arrays as $array) {
// Convert the input array into a useful Event object
$event = new Event($array, $timezone);
// If the event is in-bounds, add it to the output
if ($event->isWithinDayRange($range_start, $range_end)) {
$output_arrays[] = $event->toArray();
}
}
// Send JSON to the client.
echo json_encode($output_arrays);
+9
View File
@@ -0,0 +1,9 @@
<?php
//--------------------------------------------------------------------------------------------------
// This script outputs a JSON array of all timezones (like "America/Chicago") that PHP supports.
//
// Requires PHP 5.3.0 or higher.
//--------------------------------------------------------------------------------------------------
echo json_encode(DateTimeZone::listIdentifiers());
+130
View File
@@ -0,0 +1,130 @@
<?php
//--------------------------------------------------------------------------------------------------
// Utilities for our event-fetching scripts.
//
// Requires PHP 5.3.0 or higher.
//--------------------------------------------------------------------------------------------------
// PHP will fatal error if we attempt to use the DateTime class without this being set.
date_default_timezone_set('UTC');
class Event {
// Tests whether the given ISO8601 string has a time-of-day or not
const ALL_DAY_REGEX = '/^\d{4}-\d\d-\d\d$/'; // matches strings like "2013-12-29"
public $title;
public $allDay; // a boolean
public $start; // a DateTime
public $end; // a DateTime, or null
public $properties = array(); // an array of other misc properties
// Constructs an Event object from the given array of key=>values.
// You can optionally force the timezone of the parsed dates.
public function __construct($array, $timezone=null) {
$this->title = $array['title'];
if (isset($array['allDay'])) {
// allDay has been explicitly specified
$this->allDay = (bool)$array['allDay'];
}
else {
// Guess allDay based off of ISO8601 date strings
$this->allDay = preg_match(self::ALL_DAY_REGEX, $array['start']) &&
(!isset($array['end']) || preg_match(self::ALL_DAY_REGEX, $array['end']));
}
if ($this->allDay) {
// If dates are allDay, we want to parse them in UTC to avoid DST issues.
$timezone = null;
}
// Parse dates
$this->start = parseDateTime($array['start'], $timezone);
$this->end = isset($array['end']) ? parseDateTime($array['end'], $timezone) : null;
// Record misc properties
foreach ($array as $name => $value) {
if (!in_array($name, array('title', 'allDay', 'start', 'end'))) {
$this->properties[$name] = $value;
}
}
}
// Returns whether the date range of our event intersects with the given all-day range.
// $rangeStart and $rangeEnd are assumed to be dates in UTC with 00:00:00 time.
public function isWithinDayRange($rangeStart, $rangeEnd) {
// Normalize our event's dates for comparison with the all-day range.
$eventStart = stripTime($this->start);
$eventEnd = isset($this->end) ? stripTime($this->end) : null;
if (!$eventEnd) {
// No end time? Only check if the start is within range.
return $eventStart < $rangeEnd && $eventStart >= $rangeStart;
}
else {
// Check if the two ranges intersect.
return $eventStart < $rangeEnd && $eventEnd > $rangeStart;
}
}
// Converts this Event object back to a plain data array, to be used for generating JSON
public function toArray() {
// Start with the misc properties (don't worry, PHP won't affect the original array)
$array = $this->properties;
$array['title'] = $this->title;
// Figure out the date format. This essentially encodes allDay into the date string.
if ($this->allDay) {
$format = 'Y-m-d'; // output like "2013-12-29"
}
else {
$format = 'c'; // full ISO8601 output, like "2013-12-29T09:00:00+08:00"
}
// Serialize dates into strings
$array['start'] = $this->start->format($format);
if (isset($this->end)) {
$array['end'] = $this->end->format($format);
}
return $array;
}
}
// Date Utilities
//----------------------------------------------------------------------------------------------
// Parses a string into a DateTime object, optionally forced into the given timezone.
function parseDateTime($string, $timezone=null) {
$date = new DateTime(
$string,
$timezone ?: new DateTimeZone('UTC')
// Used only when the string is ambiguous.
// Ignored if string has a timezone offset in it.
);
if ($timezone) {
// If our timezone was ignore above, force it.
$date->setTimezone($timezone);
}
return $date;
}
// Takes the year/month/date values of the given DateTime and converts them to a new DateTime,
// but in UTC.
function stripTime($datetime) {
return new DateTime($datetime->format('Y-m-d'));
}
+33 -42
View File
@@ -1,88 +1,77 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='../build/out/fullcalendar.css' rel='stylesheet' />
<link href='../build/out/fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='../lib/moment/moment.js'></script>
<script src='../lib/jquery/jquery.js'></script>
<script src='../lib/jquery-ui/ui/jquery-ui.js'></script>
<script src='../build/out/fullcalendar.js'></script>
<script>
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2014-01-12',
selectable: true,
selectHelper: true,
select: function(start, end, allDay) {
select: function(start, end) {
var title = prompt('Event Title:');
var eventData;
if (title) {
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end,
allDay: allDay
},
true // make the event "stick"
);
eventData = {
title: title,
start: start,
end: end
};
$('#calendar').fullCalendar('renderEvent', eventData, true); // stick? = true
}
calendar.fullCalendar('unselect');
$('#calendar').fullCalendar('unselect');
},
editable: true,
events: [
{
title: 'All Day Event',
start: new Date(y, m, 1)
start: '2014-01-01'
},
{
title: 'Long Event',
start: new Date(y, m, d-5),
end: new Date(y, m, d-2)
start: '2014-01-07',
end: '2014-01-10'
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d-3, 16, 0),
allDay: false
start: '2014-01-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d+4, 16, 0),
allDay: false
start: '2014-01-16T16:00:00'
},
{
title: 'Meeting',
start: new Date(y, m, d, 10, 30),
allDay: false
start: '2014-01-12T10:30:00',
end: '2014-01-12T12:30:00'
},
{
title: 'Lunch',
start: new Date(y, m, d, 12, 0),
end: new Date(y, m, d, 14, 0),
allDay: false
start: '2014-01-12T12:00:00'
},
{
title: 'Birthday Party',
start: new Date(y, m, d+1, 19, 0),
end: new Date(y, m, d+1, 22, 30),
allDay: false
start: '2014-01-13T07:00:00'
},
{
title: 'Click for Google',
start: new Date(y, m, 28),
end: new Date(y, m, 29),
url: 'http://google.com/'
url: 'http://google.com/',
start: '2014-01-28'
}
]
});
@@ -93,20 +82,22 @@
<style>
body {
margin-top: 40px;
text-align: center;
font-size: 14px;
margin: 0;
padding: 0;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
font-size: 14px;
}
#calendar {
width: 900px;
margin: 0 auto;
}
margin: 40px auto;
}
</style>
</head>
<body>
<div id='calendar'></div>
<div id='calendar'></div>
</body>
</html>
+24 -31
View File
@@ -1,21 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link rel='stylesheet' href='../lib/jquery-ui/themes/cupertino/jquery-ui.min.css' />
<link href='../build/out/fullcalendar.css' rel='stylesheet' />
<link href='../build/out/fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='../lib/moment/moment.js'></script>
<script src='../lib/jquery/jquery.js'></script>
<script src='../lib/jquery-ui/ui/jquery-ui.js'></script>
<script src='../build/out/fullcalendar.js'></script>
<script>
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
theme: true,
header: {
@@ -23,51 +20,45 @@
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2014-01-12',
editable: true,
events: [
{
title: 'All Day Event',
start: new Date(y, m, 1)
start: '2014-01-01'
},
{
title: 'Long Event',
start: new Date(y, m, d-5),
end: new Date(y, m, d-2)
start: '2014-01-07',
end: '2014-01-10'
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d-3, 16, 0),
allDay: false
start: '2014-01-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d+4, 16, 0),
allDay: false
start: '2014-01-16T16:00:00'
},
{
title: 'Meeting',
start: new Date(y, m, d, 10, 30),
allDay: false
start: '2014-01-12T10:30:00',
end: '2014-01-12T12:30:00'
},
{
title: 'Lunch',
start: new Date(y, m, d, 12, 0),
end: new Date(y, m, d, 14, 0),
allDay: false
start: '2014-01-12T12:00:00'
},
{
title: 'Birthday Party',
start: new Date(y, m, d+1, 19, 0),
end: new Date(y, m, d+1, 22, 30),
allDay: false
start: '2014-01-13T07:00:00'
},
{
title: 'Click for Google',
start: new Date(y, m, 28),
end: new Date(y, m, 29),
url: 'http://google.com/'
url: 'http://google.com/',
start: '2014-01-28'
}
]
});
@@ -78,20 +69,22 @@
<style>
body {
margin-top: 40px;
text-align: center;
font-size: 13px;
margin: 0;
padding: 0;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
font-size: 14px;
}
#calendar {
width: 900px;
margin: 0 auto;
}
margin: 40px auto;
}
</style>
</head>
<body>
<div id='calendar'></div>
<div id='calendar'></div>
</body>
</html>
+127
View File
@@ -0,0 +1,127 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='../build/out/fullcalendar.css' rel='stylesheet' />
<link href='../build/out/fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='../lib/moment/moment.js'></script>
<script src='../lib/jquery/jquery.js'></script>
<script src='../lib/jquery-ui/ui/jquery-ui.js'></script>
<script src='../build/out/fullcalendar.js'></script>
<script>
$(document).ready(function() {
var currentTimezone = false;
// load the list of available timezones
$.getJSON('php/get-timezones.php', function(timezones) {
$.each(timezones, function(i, timezone) {
if (timezone != 'UTC') { // UTC is already in the list
$('#timezone-selector').append(
$("<option/>").text(timezone).attr('value', timezone)
);
}
});
});
// when the timezone selector changes, rerender the calendar
$('#timezone-selector').on('change', function() {
currentTimezone = this.value || false;
$('#calendar').fullCalendar('destroy');
renderCalendar();
});
function renderCalendar() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2014-01-12',
timezone: currentTimezone,
editable: true,
events: {
url: 'php/get-events.php',
error: function() {
$('#script-warning').show();
}
},
loading: function(bool) {
$('#loading').toggle(bool);
},
eventRender: function(event, el) {
// render the timezone offset below the event title
if (event.start.hasZone()) {
el.find('.fc-event-title').after(
$('<div class="tzo"/>').text(event.start.format('Z'))
);
}
}
});
}
renderCalendar();
});
</script>
<style>
body {
margin: 0;
padding: 0;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
font-size: 14px;
}
#top {
background: #eee;
border-bottom: 1px solid #ddd;
padding: 0 10px;
line-height: 40px;
font-size: 12px;
}
.left { float: left }
.right { float: right }
.clear { clear: both }
#script-warning, #loading { display: none }
#script-warning { font-weight: bold; color: red }
#calendar {
width: 900px;
margin: 40px auto;
}
.tzo {
color: #000;
}
</style>
</head>
<body>
<div id='top'>
<div class='left'>
Timezone:
<select id='timezone-selector'>
<option value='' selected>none</option>
<option value='local'>local</option>
<option value='UTC'>UTC</option>
</select>
</div>
<div class='right'>
<span id='loading'>loading...</span>
<span id='script-warning'><code>php/get-events.php</code> must be running.</span>
</div>
<div class='clear'></div>
</div>
<div id='calendar'></div>
</body>
</html>