| 21627 |
kshitij.so |
1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
|
2 |
<html>
|
|
|
3 |
<head>
|
|
|
4 |
<link rel='stylesheet' type='text/css' href='../fullcalendar/fullcalendar.css' />
|
|
|
5 |
<link rel='stylesheet' type='text/css' href='../fullcalendar/fullcalendar.print.css' media='print' />
|
|
|
6 |
<script type='text/javascript' src='../jquery/jquery-1.8.1.min.js'></script>
|
|
|
7 |
<script type='text/javascript' src='../jquery/jquery-ui-1.8.23.custom.min.js'></script>
|
|
|
8 |
<script type='text/javascript' src='../fullcalendar/fullcalendar.min.js'></script>
|
|
|
9 |
<script type='text/javascript'>
|
|
|
10 |
|
|
|
11 |
$(document).ready(function() {
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
/* initialize the external events
|
|
|
15 |
-----------------------------------------------------------------*/
|
|
|
16 |
|
|
|
17 |
$('#external-events div.external-event').each(function() {
|
|
|
18 |
|
|
|
19 |
// create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
|
|
|
20 |
// it doesn't need to have a start or end
|
|
|
21 |
var eventObject = {
|
|
|
22 |
title: $.trim($(this).text()) // use the element's text as the event title
|
|
|
23 |
};
|
|
|
24 |
|
|
|
25 |
// store the Event Object in the DOM element so we can get to it later
|
|
|
26 |
$(this).data('eventObject', eventObject);
|
|
|
27 |
|
|
|
28 |
// make the event draggable using jQuery UI
|
|
|
29 |
$(this).draggable({
|
|
|
30 |
zIndex: 999,
|
|
|
31 |
revert: true, // will cause the event to go back to its
|
|
|
32 |
revertDuration: 0 // original position after the drag
|
|
|
33 |
});
|
|
|
34 |
|
|
|
35 |
});
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
/* initialize the calendar
|
|
|
39 |
-----------------------------------------------------------------*/
|
|
|
40 |
|
|
|
41 |
$('#calendar').fullCalendar({
|
|
|
42 |
header: {
|
|
|
43 |
left: 'prev,next today',
|
|
|
44 |
center: 'title',
|
|
|
45 |
right: 'month,agendaWeek,agendaDay'
|
|
|
46 |
},
|
|
|
47 |
editable: true,
|
|
|
48 |
droppable: true, // this allows things to be dropped onto the calendar !!!
|
|
|
49 |
drop: function(date, allDay) { // this function is called when something is dropped
|
|
|
50 |
|
|
|
51 |
// retrieve the dropped element's stored Event Object
|
|
|
52 |
var originalEventObject = $(this).data('eventObject');
|
|
|
53 |
|
|
|
54 |
// we need to copy it, so that multiple events don't have a reference to the same object
|
|
|
55 |
var copiedEventObject = $.extend({}, originalEventObject);
|
|
|
56 |
|
|
|
57 |
// assign it the date that was reported
|
|
|
58 |
copiedEventObject.start = date;
|
|
|
59 |
copiedEventObject.allDay = allDay;
|
|
|
60 |
|
|
|
61 |
// render the event on the calendar
|
|
|
62 |
// the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
|
|
|
63 |
$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
|
|
|
64 |
|
|
|
65 |
// is the "remove after drop" checkbox checked?
|
|
|
66 |
if ($('#drop-remove').is(':checked')) {
|
|
|
67 |
// if so, remove the element from the "Draggable Events" list
|
|
|
68 |
$(this).remove();
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
}
|
|
|
72 |
});
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
});
|
|
|
76 |
|
|
|
77 |
</script>
|
|
|
78 |
<style type='text/css'>
|
|
|
79 |
|
|
|
80 |
body {
|
|
|
81 |
margin-top: 40px;
|
|
|
82 |
text-align: center;
|
|
|
83 |
font-size: 14px;
|
|
|
84 |
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
#wrap {
|
|
|
88 |
width: 1100px;
|
|
|
89 |
margin: 0 auto;
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
#external-events {
|
|
|
93 |
float: left;
|
|
|
94 |
width: 150px;
|
|
|
95 |
padding: 0 10px;
|
|
|
96 |
border: 1px solid #ccc;
|
|
|
97 |
background: #eee;
|
|
|
98 |
text-align: left;
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
#external-events h4 {
|
|
|
102 |
font-size: 16px;
|
|
|
103 |
margin-top: 0;
|
|
|
104 |
padding-top: 1em;
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
.external-event { /* try to mimick the look of a real event */
|
|
|
108 |
margin: 10px 0;
|
|
|
109 |
padding: 2px 4px;
|
|
|
110 |
background: #3366CC;
|
|
|
111 |
color: #fff;
|
|
|
112 |
font-size: .85em;
|
|
|
113 |
cursor: pointer;
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
#external-events p {
|
|
|
117 |
margin: 1.5em 0;
|
|
|
118 |
font-size: 11px;
|
|
|
119 |
color: #666;
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
#external-events p input {
|
|
|
123 |
margin: 0;
|
|
|
124 |
vertical-align: middle;
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
#calendar {
|
|
|
128 |
float: right;
|
|
|
129 |
width: 900px;
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
</style>
|
|
|
133 |
</head>
|
|
|
134 |
<body>
|
|
|
135 |
<div id='wrap'>
|
|
|
136 |
|
|
|
137 |
<div id='external-events'>
|
|
|
138 |
<h4>Draggable Events</h4>
|
|
|
139 |
<div class='external-event'>My Event 1</div>
|
|
|
140 |
<div class='external-event'>My Event 2</div>
|
|
|
141 |
<div class='external-event'>My Event 3</div>
|
|
|
142 |
<div class='external-event'>My Event 4</div>
|
|
|
143 |
<div class='external-event'>My Event 5</div>
|
|
|
144 |
<p>
|
|
|
145 |
<input type='checkbox' id='drop-remove' /> <label for='drop-remove'>remove after drop</label>
|
|
|
146 |
</p>
|
|
|
147 |
</div>
|
|
|
148 |
|
|
|
149 |
<div id='calendar'></div>
|
|
|
150 |
|
|
|
151 |
<div style='clear:both'></div>
|
|
|
152 |
</div>
|
|
|
153 |
</body>
|
|
|
154 |
</html>
|