source: src/main/resources/static/js/homepage.js@ 9050790

Last change on this file since 9050790 was cc52b09, checked in by Gjoko Kostadinov <gjoko.kostadinov@…>, 17 months ago

Add search button functionality

  • Property mode set to 100644
File size: 5.3 KB
Line 
1$(document).ready(function() {
2 var date = new Date();
3 var d = date.getDate();
4 var m = date.getMonth();
5 var y = date.getFullYear();
6
7 /* className colors
8
9 className: default(transparent), important(red), chill(pink), success(green), info(blue)
10
11 */
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 var calendar = $('#calendar').fullCalendar({
42 header: {
43 left: 'title',
44 center: 'agendaWeek',
45 right: 'prev,next today'
46 },
47 editable: false,
48 edit: function (start, end, allDay) {
49
50 },
51 firstDay: 1, // 1(Monday) this can be changed to 0(Sunday) for the USA system
52 selectable: false,
53 defaultView: 'agendaWeek',
54
55 axisFormat: 'h:mm',
56 columnFormat: {
57 month: 'ddd', // Mon
58 week: 'ddd d', // Mon 7
59 day: 'dddd M/d', // Monday 9/7
60 agendaDay: 'dddd d'
61 },
62 titleFormat: {
63 month: 'MMMM yyyy', // September 2009
64 week: "MMMM yyyy", // September 2009
65 day: 'MMMM yyyy' // Tuesday, Sep 8, 2009
66 },
67 allDaySlot: false,
68 selectHelper: true,
69 select: function(start, end, allDay) {
70 var title = prompt('Event Title:');
71 if (title) {
72 calendar.fullCalendar('renderEvent',
73 {
74 title: title,
75 start: start,
76 end: end,
77 allDay: allDay
78 },
79 true // make the event "stick"
80 );
81 }
82 calendar.fullCalendar('unselect');
83 },
84 droppable: false, // this allows things to be dropped onto the calendar !!!
85 drop: function(date, allDay) { // this function is called when something is dropped
86
87 // retrieve the dropped element's stored Event Object
88 var originalEventObject = $(this).data('eventObject');
89
90 // we need to copy it, so that multiple events don't have a reference to the same object
91 var copiedEventObject = $.extend({}, originalEventObject);
92
93 // assign it the date that was reported
94 copiedEventObject.start = date;
95 copiedEventObject.allDay = allDay;
96
97 // render the event on the calendar
98 // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
99 $('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
100
101 // is the "remove after drop" checkbox checked?
102 if ($('#drop-remove').is(':checked')) {
103 // if so, remove the element from the "Draggable Events" list
104 $(this).remove();
105 }
106 console.log('dropped');
107
108 },
109
110 events: [
111 {
112 title: 'All Day Event',
113 start: new Date(y, m, 1)
114 },
115 {
116 id: 999,
117 title: 'Repeating Event',
118 start: new Date(y, m, d-3, 16, 0),
119 allDay: false,
120 className: 'info'
121 },
122 {
123 id: 999,
124 title: 'Repeating Event',
125 start: new Date(y, m, d+4, 16, 0),
126 allDay: false,
127 className: 'info'
128 },
129 {
130 title: 'Meeting',
131 start: new Date(y, m, d, 10, 30),
132 allDay: false,
133 className: 'important'
134 },
135 {
136 title: 'Lunch',
137 start: new Date(y, m, d, 12, 0),
138 end: new Date(y, m, d, 14, 0),
139 allDay: false,
140 className: 'important'
141 },
142 {
143 title: 'Birthday Party',
144 start: new Date(y, m, d+1, 19, 0),
145 end: new Date(y, m, d+1, 22, 30),
146 allDay: false,
147 },
148 {
149 title: 'Click for Google',
150 start: new Date(y, m, 28),
151 end: new Date(y, m, 29),
152 url: 'http://google.com/',
153 className: 'success'
154 }
155 ],
156 });
157 $("#search").click(function () {
158 alert("qweqew");
159
160 $.ajax({
161 url: "http://localhost:8080/events"
162 }).then(function(data) {
163 console.log(data);
164 });
165 });
166
167});
168
169function search() {
170
171}
Note: See TracBrowser for help on using the repository browser.