1/** 2 * Handle: init_show_calendar 3 * Version: 1.0 4 * Deps: jQuery 5 * Enqueue: true 6 */ 7 8jQuery(document).ready(function ($) { 9 var toUnixDate = function (date) { 10 return $.fullCalendar.formatDate(date, 'yyyy-MM-dd HH:mm:ss'); // unix datetime 11 }, 12 js_n = function (arr, quantity, singular, plural, min) { // javascript _n method 13 if (undefined === min) { 14 min = 0; 15 } 16 if (quantity > 0) { 17 var out = [], 18 output = []; 19 if (quantity > min) { 20 out.push(quantity); 21 } 22 out.push((quantity != 1) ? plural : singular); 23 output = out.join(' '); 24 arr.push(output); 25 } 26 return; 27 }, 28 calcDuration = function (from, to, allDay, frequency, interval, until) { 29 var mills = new Date(to).getTime() - new Date(from).getTime(), 30 diff = {}, 31 out = []; 32 diff.weeks = Math.floor(mills / 604800000); 33 mills -= diff.weeks * 604800000; 34 diff.days = Math.floor(mills / 86400000); 35 mills -= diff.days * 86400000; 36 diff.hours = Math.floor(mills / 3600000); 37 mills -= diff.hours * 3600000; 38 diff.minutes = Math.floor(mills / 60000); 39 40 // format output 41 if (allDay == 1) { 42 diff.days += 1; 43 } 44 js_n(out, diff.weeks, custom.week, custom.weeks); 45 js_n(out, diff.days, custom.day, custom.days); 46 if (allDay == 0) { 47 js_n(out, diff.hours, custom.hour, custom.hours); 48 js_n(out, diff.minutes, custom.minute, custom.minutes); 49 } 50 output = out.join(' '); 51 52 if (frequency > 0) { 53 reps = []; 54 reps.push(' '); 55 reps.push('('); 56 reps.push(custom.repeats_every); 57 reps.push(' '); 58 if (interval == 0) { js_n(reps, frequency, custom.day, custom.days, 1); } 59 if (interval == 1) { js_n(reps, frequency, custom.week, custom.weeks, 1); } 60 if (interval == 2) { js_n(reps, frequency, custom.month, custom.months, 1); } 61 if (interval == 3) { js_n(reps, frequency, custom.year, custom.years, 1); } 62 reps.push(' '); 63 reps.push(custom.until); 64 reps.push(' '); 65 reps.push(until); 66 reps.push(')'); 67 output += reps.join(''); 68 } 69 70 return output; 71 }, 72 eventDialog = function (e) { 73 // adjusts modal top for WordPress admin bar 74 var wpadminbar = $('#wpadminbar'), 75 wpadminbar_height = (wpadminbar.length > 0) ? wpadminbar.height() : '0', 76 modal = '<div id="aec-modal"><div class="aec-title"></div><div class="aec-content"></div></div>'; 77 78 // check for modal html structure, if not present add it to the DOM 79 if ($('#aec-modal').length === 0) { 80 $('body').prepend(modal); 81 } 82 $('#aec-modal').modal({ 83 overlayId: 'aec-modal-overlay', 84 containerId: 'aec-modal-container', 85 closeHTML: '<div class="close"><a href="#" class="simplemodal-close" title="' + custom.close_event_form + '">x</a></div>', 86 minHeight: 35, 87 opacity: 65, 88 zIndex: 10000, 89 position: [wpadminbar_height, ], 90 overlayClose: true, 91 onOpen: function (d) { 92 var modal = this; 93 modal.container = d.container[0]; 94 d.overlay.fadeIn(150, function () { 95 $('#aec-modal', modal.container).show(); 96 var title = $('div.aec-title', modal.container), 97 content = $('div.aec-content', modal.container), 98 closebtn = $('div.close', modal.container); 99 title.html(custom.loading_event_form).show(); 100 d.container.slideDown(150, function () { 101 $.post(custom.ajaxurl, { action: 'get_event', 'id': e.id, 'start': toUnixDate(e.start), 'end': toUnixDate(e.end)}, function (data) { 102 title.html(data.title); 103 content.html(data.content); 104 var h = content.height() + title.height() + 40; 105 d.container.animate({ height: h }, 150, function () { 106 closebtn.show(); 107 content.show(); 108 $('.duration').html(calcDuration(data.start, data.end, data.allDay, data.repeat_f, data.repeat_i, data.repeat_e)); 109 });
110 }, 'json'); 111 }); 112 }); 113 }, 114 onClose: function (d) { 115 var modal = this; 116 d.container.animate({ top: '-' + (d.container.height() + 20) }, 250, function () { 117 $('.time-picker').remove(); 118 modal.close(); 119 }); 120 } 121 }); 122 }, 123 calendarInit = function () { 124 calendar = $('#aec-calendar').fullCalendar({ 125 isRTL: custom.is_rtl, 126 monthNames: [custom.january, custom.february, custom.march, custom.april, custom.may, custom.june, custom.july, 127 custom.august, custom.september, custom.october, custom.november, custom.december], 128 monthNamesShort: [custom.jan, custom.feb, custom.mar, custom.apr, custom.may_short, custom.jun, custom.jul, custom.aug, 129 custom.sep, custom.oct, custom.nov, custom.dec], 130 dayNames: [custom.sunday, custom.monday, custom.tuesday, custom.wednesday, custom.thursday, custom.friday, custom.saturday], 131 dayNamesShort: [custom.sun, custom.mon, custom.tue, custom.wed, custom.thu, custom.fri, custom.sat], 132 buttonIcons: false, 133 buttonText: { 134 today: custom.today, 135 month: custom.month, 136 week: custom.week, 137 day: custom.day, 138 prev: ' ◄ ', // left triangle 139 next: ' ► ' // right triangle 140 }, 141 allDayText: custom.all_day, 142 timeFormat: { 143 agenda: custom.agenda_time_format,
144 '': custom.other_time_format 145 }, 146 columnFormat: { 147 week: 'ddd d', 148 month: 'ddd' 149 }, 150 axisFormat: custom.axis_time_format, 151 firstDay: custom.start_of_week, 152 firstHour: 8, 153 weekMode: 'liquid', 154 weekends: (custom.show_weekends === '1') ? true : false, 155 events: { 156 url: custom.ajaxurl, 157 data: { action: 'get_events', 158 'readonly': true, 159 'categories': shortcode.categories, 160 'excluded': shortcode.excluded 161 }, 162 type: 'POST' 163 }, 164 header: { 165 left: shortcode.nav, 166 center: (shortcode.mini) ? '' : 'title', 167 right: shortcode.views 168 }, 169 height: shortcode.height, 170 defaultView: shortcode.view, 171 month: shortcode.month, 172 year: shortcode.year, 173 editable: custom.editable, 174 selectable: custom.editable, 175 selectHelper: custom.editable, 176 loading: function (b) { 177 if (b) { 178 $.jGrowl(custom.loading, {sticky: true}); 179 } else { 180 $('#jGrowl').jGrowl('close'); 181 } 182 }, 183 //eventMouseover: function (e, js, view) { 184 //}, 185 eventClick: function (e) { 186 eventDialog(e); 187 }, 188 eventRender: function (e, element) { 189 // check if filter is active 190 if (isFilter) { 191 var filter = $('#aec-filter li.active').children(); 192 // if filter is not "all", hide all category types other than the selected 193 if (!filter.hasClass('all') && !filter.hasClass(e.className[0])) { 194 element.hide(); 195 } 196 } 197 if (shortcode.mini) { 198 element.html(' ').attr('title', e.title); 199 } 200 } 201 }); 202 }, 203 filter = function (active) { 204 $('#aec-filter li').next().fadeTo(0, 0.5).removeClass('active'); 205 $(active).parent().fadeTo(250, 1).addClass('active'); 206 calendar.fullCalendar('rerenderEvents'); 207 }, 208 eventHandlers = function () { 209 if (isFilter) { 210 // category filter 211 filter($('#aec-filter .' + shortcode.filter)); 212 $('#aec-filter li a').click(function () { 213 filter(this); 214 }); 215 } 216 if (shortcode.nav) { 217 // quick navigation 218 if ($('#aec-quickselect').length === 0) { 219 $('.fc-button-prev', '.fc-header').after('<div id="aec-quickselect"></div>'); 220 } 221 var quickSelect = $('#aec-quickselect').datepicker({ 222 changeMonth: true, 223 changeYear: true, 224 onChangeMonthYear: function (year, month, inst) { 225 calendar.fullCalendar('gotoDate', year, month - 1); 226 } 227 }), 228 date = calendar.fullCalendar('getDate'); 229 quickSelect.datepicker("setDate", date); 230 $('.fc-button-prev, .fc-button-next, .fc-button-today', '.fc-header').click(function () { 231 var date = calendar.fullCalendar('getDate'); 232 quickSelect.datepicker("setDate", date); 233 }); 234 } 235 if (shortcode.scroll) { 236 // mousewheel navigation 237 $('#aec-calendar').mousewheel(function (e, delta) { 238 var scroll = (delta > 0) ? -1 : 1, 239 view = calendar.fullCalendar('getView'); 240 switch (view.name) { 241 case 'month': 242 calendar.fullCalendar('incrementDate', 0, scroll, 0); 243 break; 244 case 'basicWeek': 245 calendar.fullCalendar('incrementDate', 0, 0, scroll * 7); 246 break; 247 case 'basicDay': 248 calendar.fullCalendar('incrementDate', 0, 0, scroll); 249 break; 250 case 'agendaDay': 251 case 'agendaWeek': 252 return; 253 break; 254 } 255 quickSelect.datepicker("setDate", calendar.fullCalendar('getDate')); 256 return false; 257 }); 258 } 259 }, 260 aec_init = function () { 261 $.jGrowl.defaults.closerTemplate = '<div>' + custom.hide_all_notifications + '</div>'; 262 $.jGrowl.defaults.position = (custom.is_rtl === '1') ? 'bottom-left' : 'bottom-right'; 263 isFilter = ($('#aec-filter li a').length > 0); 264 if ($('#aec-calendar').length > 0) { 265 calendarInit(); 266 eventHandlers(); 267 } 268 }; 269 270 aec_init(); 271 272 // public method for sidebar widget access 273 $.aecDialog = function (e) { 274 e.start = $.fullCalendar.parseDate(e.start); 275 e.end = $.fullCalendar.parseDate(e.end); 276 eventDialog(e); 277 }; 278});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.