Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
21627 kshitij.so 1
var Script = function () {
2
 
3
 
4
    /* initialize the external events
5
     -----------------------------------------------------------------*/
6
 
7
    $('#external-events div.external-event').each(function() {
8
 
9
        // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
10
        // it doesn't need to have a start or end
11
        var eventObject = {
12
            title: $.trim($(this).text()) // use the element's text as the event title
13
        };
14
 
15
        // store the Event Object in the DOM element so we can get to it later
16
        $(this).data('eventObject', eventObject);
17
 
18
        // make the event draggable using jQuery UI
19
        $(this).draggable({
20
            zIndex: 999,
21
            revert: true,      // will cause the event to go back to its
22
            revertDuration: 0  //  original position after the drag
23
        });
24
 
25
    });
26
 
27
 
28
    /* initialize the calendar
29
     -----------------------------------------------------------------*/
30
 
31
    var date = new Date();
32
    var d = date.getDate();
33
    var m = date.getMonth();
34
    var y = date.getFullYear();
35
 
36
    $('#calendar').fullCalendar({
37
        header: {
38
            left: 'prev,next today',
39
            center: 'title',
40
            right: 'month,basicWeek,basicDay'
41
        },
42
        editable: true,
43
        droppable: true, // this allows things to be dropped onto the calendar !!!
44
        drop: function(date, allDay) { // this function is called when something is dropped
45
 
46
            // retrieve the dropped element's stored Event Object
47
            var originalEventObject = $(this).data('eventObject');
48
 
49
            // we need to copy it, so that multiple events don't have a reference to the same object
50
            var copiedEventObject = $.extend({}, originalEventObject);
51
 
52
            // assign it the date that was reported
53
            copiedEventObject.start = date;
54
            copiedEventObject.allDay = allDay;
55
 
56
            // render the event on the calendar
57
            // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
58
            $('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
59
 
60
            // is the "remove after drop" checkbox checked?
61
            if ($('#drop-remove').is(':checked')) {
62
                // if so, remove the element from the "Draggable Events" list
63
                $(this).remove();
64
            }
65
 
66
        },
67
        events: [
68
            {
69
                title: 'All Day Event',
70
                start: new Date(y, m, 1)
71
            },
72
            {
73
                title: 'Long Event',
74
                start: new Date(y, m, d-5),
75
                end: new Date(y, m, d-2)
76
            },
77
            {
78
                id: 999,
79
                title: 'Repeating Event',
80
                start: new Date(y, m, d-3, 16, 0),
81
                allDay: false
82
            },
83
            {
84
                id: 999,
85
                title: 'Repeating Event',
86
                start: new Date(y, m, d+4, 16, 0),
87
                allDay: false
88
            },
89
            {
90
                title: 'Meeting',
91
                start: new Date(y, m, d, 10, 30),
92
                allDay: false
93
            },
94
            {
95
                title: 'Lunch',
96
                start: new Date(y, m, d, 12, 0),
97
                end: new Date(y, m, d, 14, 0),
98
                allDay: false
99
            },
100
            {
101
                title: 'Birthday Party',
102
                start: new Date(y, m, d+1, 19, 0),
103
                end: new Date(y, m, d+1, 22, 30),
104
                allDay: false
105
            },
106
            {
107
                title: 'Click for Google',
108
                start: new Date(y, m, 28),
109
                end: new Date(y, m, 29),
110
                url: 'http://google.com/'
111
            }
112
        ]
113
    });
114
 
115
}();