1dpjQuery(document).ready( 2 function() { 3 4 // Parsing the hash 5 var today = new Date(); 6 dpcalendarOptions['year'] = today.getFullYear(); 7 dpcalendarOptions['month'] = today.getMonth(); 8 dpcalendarOptions['day'] = today.getDate(); 9 var vars = window.location.hash.replace(/&/gi, "&").split("&"); 10 for (var i = 0; i < vars.length; i++) { 11 if (vars[i].match("^#year")) 12 dpcalendarOptions['year'] = vars[i].substring(6); 13 if (vars[i].match("^month")) 14 dpcalendarOptions['month'] = vars[i].substring(6) - 1; 15 if (vars[i].match("^day")) 16 dpcalendarOptions['date'] = vars[i].substring(4); 17 if (vars[i].match("^view")) 18 dpcalendarOptions['defaultView'] = vars[i].substring(5); 19 } 20 21 // Loading the list view when we have a small screen 22 if (dpjQuery(document).width() < 500) { 23 dpcalendarOptions['defaultView'] = 'list'; 24 } 25 26 // Some default options 27 if (!('header' in dpcalendarOptions)) { 28 dpcalendarOptions['header'] = { 29 left : 'prev,next ', 30 center : 'title', 31 right : 'month,agendaWeek,agendaDay,list' 32 }; 33 } 34 dpcalendarOptions['weekNumberTitle'] = ''; 35 dpcalendarOptions['theme'] = false; 36 dpcalendarOptions['startParam'] = 'date-start'; 37 dpcalendarOptions['endParam'] = 'date-end'; 38 dpcalendarOptions['columnFormat'] = { 39 month : 'ddd', 40 week : 'ddd d', 41 day : 'dddd d' 42 }; 43 dpcalendarOptions['listSections'] = 'smart'; 44 dpcalendarOptions['listRange'] = 365; 45 dpcalendarOptions['listPage'] = 365; 46 47 // Translations 48 dpcalendarOptions['allDayText'] = Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_ALL_DAY', true); 49 dpcalendarOptions['buttonText'] = { 50 today : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_TOOLBAR_TODAY', true), 51 month : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_VIEW_MONTH', true), 52 week : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_VIEW_WEEK', true), 53 day : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_VIEW_DAY', true), 54 list : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_VIEW_LIST', true) 55 }; 56 57 dpcalendarOptions['listTexts'] = { 58 until : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_VIEW_TEXTS_UNTIL', true), 59 past : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_VIEW_TEXTS_PAST', true), 60 today : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_VIEW_TEXTS_TODAY', true), 61 tomorrow : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_VIEW_TEXTS_TOMORROW', true), 62 thisWeek : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_VIEW_TEXTS_THIS_WEEK', true), 63 nextWeek : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_VIEW_TEXTS_NEXT_WEEK', true), 64 thisMonth : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_VIEW_TEXTS_THIS_MONTH', true), 65 nextMonth : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_VIEW_TEXTS_NEXT_MONTH', true), 66 future : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_VIEW_TEXTS_FUTURE', true), 67 week : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_VIEW_TEXTS_WEEK', true) 68 }; 69 70 var hasMap = dpjQuery('#dpcalendar_component_map').length > 0; 71 72 dpcalendarOptions['viewRender'] = function(view) { 73 // Setting the hash based on the actual view 74 var d = dpjQuery('#dpcalendar_component').fullCalendar('getDate'); 75 var newHash = 'year=' + d.getFullYear() + '&month=' + (d.getMonth() + 1) + '&day=' + d.getDate() + '&view=' + view.name; 76 if (window.location.hash.replace(/&/gi, "&") != newHash) { 77 window.location.hash = newHash; 78 } 79 if (hasMap) { 80 // Clearing the map 81 if (dpcalendarMapMarkers != null) { 82 for (var i = 0; i < dpcalendarMapMarkers.length; i++) { 83 dpcalendarMapMarkers[i].setMap(null); 84 } 85 } 86 dpcalendarMapMarkers = []; 87 } 88 }; 89 dpcalendarOptions['eventRender'] = function(event, element) { 90 if (event.description && typeof (element.tooltip) == "function") { 91 // Adding the tooltip 92 element.tooltip({ 93 html : true, 94 title : dpEncode(event.description), 95 delay : { 96 show : 100, 97 hide : event.description.indexOf('task=event.edit') > -1 || event.description.indexOf('task=event.delete') > -1 ? 1500 98 : 200 99 }, 100 container : '#dpcalendar_component' 101 }); 102 } 103 104 if (hasMap) { 105 var chartUrl = 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|'; 106 if (document.location.protocol == 'https:') { 107 chartUrl = 'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|'; 108 } 109 110 // Adding the locations to the map 111 dpjQuery.each(event.location, function(i, loc) { 112 if (loc.location == undefined || loc.location == '' || loc.location == null) 113 return; 114 var l = new google.maps.LatLng(loc.latitude, loc.longitude); 115 116 var pinImage = new google.maps.MarkerImage(chartUrl + event.color.replace('#', ''), new google.maps.Size(2
1161, 34), 117 new google.maps.Point(0, 0), new google.maps.Point(10, 34)); 118 119 var marker = new google.maps.Marker({ 120 position : l, 121 map : dpcalendarMap, 122 title : loc.location, 123 icon : pinImage 124 }); 125 dpcalendarMapMarkers.push(marker); 126 var infowindow = new google.maps.InfoWindow({ 127 content : event.description 128 }); 129 google.maps.event.addListener(marker, 'click', function() { 130 infowindow.open(dpcalendarMap, marker); 131 }); 132 dpcalendarMapBounds.extend(l); 133 dpcalendarMap.setCenter(dpcalendarMapBounds.getCenter()); 134 }); 135 } 136 }; 137 138 // Handling the messages in the returned data 139 dpcalendarOptions['eventDataTransform'] = function(events) { 140 if (events.messages != null && dpjQuery('#system-message-container').length) { 141 Joomla.renderMessages(events.messages); 142 } 143 if (events.data != null) { 144 return events.data; 145 } 146 return events; 147 }; 148 149 // Drag and drop support 150 dpcalendarOptions['eventDrop'] = function(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) { 151 dpjQuery('#dpcalendar_component_loading').show(); 152 dpjQuery(jsEvent.target).tooltip('hide'); 153 dpjQuery.ajax({ 154 type : 'POST', 155 url : 'index.php?option=com_dpcalendar&task=event.move', 156 data : { 157 id : event.id, 158 days : dayDelta, 159 minutes : minuteDelta, 160 allDay : allDay 161 }, 162 success : function(data) { 163 dpjQuery('#dpcalendar_component_loading').hide(); 164 var json = dpjQuery.parseJSON(data); 165 if (json.data.url) 166 event.url = json.data.url; 167 Joomla.renderMessages(json.messages); 168 } 169 }); 170 }; 171 172 // Resize support 173 dpcalendarOptions['eventResize'] = function(event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view) { 174 dpjQuery('#dpcalendar_component_loading').show(); 175 dpjQuery(jsEvent.target).tooltip('hide'); 176 dpjQuery.ajax({ 177 type : 'POST', 178 url : 'index.php?option=com_dpcalendar&task=event.move', 179 data : { 180 id : event.id, 181 days : dayDelta, 182 minutes : minuteDelta, 183 allDay : false, 184 onlyEnd : true 185 }, 186 success : function(data) { 187 dpjQuery('#dpcalendar_component_loading').hide(); 188 var json = dpjQuery.parseJSON(data); 189 if (json.data.url) 190 event.url = json.data.url; 191 Joomla.renderMessages(json.messages); 192 } 193 }); 194 }; 195 196 // Handling clicking on an event 197 dpcalendarOptions['eventClick'] = function(event, jsEvent, view) { 198 jsEvent.stopPropagation(); 199 200 // If we are on a small screen navigate to the page 201 if (dpjQuery(window).width() < 600) { 202 window.location = dpEncode(event.url); 203 return false; 204 } 205 206 if (dpcalendarOptions['show_event_as_popup'] == 1) { 207 // Opening a BS modal dialog 208 dpjQuery('#dpc-event-view').on('show', function() { 209 var url = new Url(event.url); 210 url.query.tmpl = 'component'; 211 dpjQuery('#dpc-event-view iframe').attr('src', url.toString()); 212 }); 213 dpjQuery('#dpc-event-view').on('hide', function() { 214 if (dpjQuery('#dpc-event-view iframe').contents().find('#system-message').children().length > 0) { 215 dpjQuery('#dpcalendar_component').fullCalendar('refetchEvents'); 216 } 217 dpjQuery('#dpc-event-view iframe').removeAttr('src'); 218 }); 219 var modal = dpjQuery('#dpc-event-view').modal(); 220 if (dpjQuery(window).width() < modal.width()) { 221 modal.css({ 222 width : dpjQuery(window).width() - 100 + 'px' 223 }); 224 } else { 225 modal.css({ 226 'margin-left' : '-' + modal.width() / 2 + 'px' 227 }); 228 } 229 } else if (dpcalendarOptions['show_event_as_popup'] == 3) { 230 // Opening the Joomal modal box 231 var modal = dpjQuery('#dpc-event-view'); 232 var width = dpjQuery(window).width(); 233 var url = new Url(event.url); 234 url.query.tmpl = 'component'; 235 SqueezeBox.open(url.toString(), { 236 handler : 'iframe', 237 size : { 238 x : (width < 650 ? width - (width * 0.10) : modal.width()), 239 y : modal.height() 240 } 241 }); 242 } else { 243 // Just navigate to the event 244 window.location = dpEncode(event.url); 245 } 246 return false;
247 }; 248 249 dpcalendarOptions['dayClick'] = function(date, allDay, jsEvent, view) { 250 if (dpjQuery('#editEventFormComponent').length > 0) { 251 // On small screens open the edit page directly 252 if (dpjQuery(window).width() < 600) { 253 dpjQuery('#editEventFormComponent #task').val(''); 254 dpjQuery('#editEventFormComponent').submit(); 255 return false; 256 } 257 jsEvent.stopPropagation(); 258 259 // Setting some defaults on the quick add popup form 260 if (view.name == 'month') 261 date.setHours(8); 262 dpjQuery('#editEventFormComponent #jform_start_date').datepicker('setDate', date); 263 dpjQuery('#editEventFormComponent #jform_start_date_time').timepicker('setTime', date); 264 dpjQuery('#editEventFormComponent #jform_end_date').datepicker('setDate', date); 265 date.setHours(date.getHours() + 1); 266 dpjQuery('#editEventFormComponent #jform_end_date_time').timepicker('setTime', date); 267 var p = dpjQuery('#dpcalendar_component').parents().filter(function() { 268 var parent = dpjQuery(this); 269 return parent.is('body') || parent.css('position') == 'relative'; 270 }).slice(0, 1).offset(); 271 272 if (dpcalendarOptions['event_edit_popup'] == 1) { 273 // Show the quick add popup 274 dpjQuery('#editEventFormComponent').css({ 275 top : jsEvent.pageY - p.top, 276 left : jsEvent.pageX - 160 - p.left 277 }).show(); 278 dpjQuery('#editEventFormComponent #jform_title').focus(); 279 } else { 280 // Open the edit page 281 dpjQuery('#editEventFormComponent #task').val(''); 282 dpjQuery('#editEventFormComponent').submit(); 283 } 284 } else { 285 // The edit form is not loaded, navigate to the day 286 dpjQuery('#dpcalendar_component').fullCalendar('gotoDate', date).fullCalendar('changeView', 'agendaDay'); 287 } 288 }; 289 290 // Spinner handling 291 dpcalendarOptions['loading'] = function(bool) { 292 if (bool) { 293 dpjQuery('#dpcalendar_component_loading').show(); 294 } else { 295 dpjQuery('#dpcalendar_component_loading').hide(); 296 } 297 }; 298 299 // Loading the calendar 300 dpjQuery('#dpcalendar_component').fullCalendar(dpcalendarOptions); 301 302 if (hasMap) { 303 var dpcalendarMap = new google.maps.Map(document.getElementById('dpcalendar_component_map'), { 304 zoom : dpcalendarOptions['map_zoom'], 305 mapTypeId : google.maps.MapTypeId.ROADMAP, 306 center : new google.maps.LatLng(dpcalendarOptions['map_lat'], dpcalendarOptions['map_long']) 307 }); 308 var dpcalendarMapBounds = new google.maps.LatLngBounds(); 309 var dpcalendarMapMarkers = []; 310 } 311 // Adding the custom buttons 312 var custom_buttons = '<span class="fc-button fc-button-datepicker fc-state-default fc-corner-left fc-corner-right">' 313 + '<span class="fc-button-inner"><span class="fc-button-content" id="dpcalendar_component_date_picker_button">' 314 + '<input type="hidden" id="dpcalendar_component_date_picker" value="">' + '<i class="icon-calendar" title="' 315 + Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_SHOW_DATEPICKER') + '"></i>' + '</span></span></span>'; 316 custom_buttons += '<span class="hidden-phone fc-button fc-button-print fc-state-default fc-corner-left fc-corner-right">' 317 + '<span class="fc-button-inner"><span class="fc-button-content" id="dpcalendar_component_print_button">' 318 + '<i class="icon-print" title="' + Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_TOOLBAR_PRINT') + '"></i>' 319 + '</span></span></span>'; 320 dpjQuery('span.fc-header-space').after(custom_buttons); 321 322 // Initializing the datepicker 323 dpjQuery("#dpcalendar_component_date_picker").datepicker({ 324 dateFormat : 'dd-mm-yy', 325 changeYear : true, 326 dayNames : dpcalendarOptions['dayNames'], 327 dayNamesShort : dpcalendarOptions['dayNamesShort'], 328 dayNamesMin : dpcalendarOptions['dayNamesMin'], 329 monthNames : dpcalendarOptions['monthNames'], 330 monthNamesShort : dpcalendarOptions['monthNamesShort'], 331 firstDay : dpcalendarOptions['firstDay'], 332 showButtonPanel : true, 333 closeText : Joomla.JText._('JCANCEL', true), 334 currentText : Joomla.JText._('COM_DPCALENDAR_VIEW_CALENDAR_TOOLBAR_TODAY', true), 335 onSelect : function(dateText, inst) { 336 var d = dpjQuery('#dpcalendar_component_date_picker').datepicker('getDate'); 337 var view = dpjQuery('#dpcalendar_component').fullCalendar('getView').name; 338 dpjQuery('#dpcalendar_component').fullCalendar('gotoDate', d); 339 } 340 }); 341 dpjQuery('.ui-widget-overlay').on('click', function() { 342 dpjQuery('#dpcalendar-dialog').dialog('close'); 343 }); 344 345 // Listening for hash/url changes 346 dpjQuery(window).bind('hashchange', function() { 347 var today = new Date(); 348 var tmpYear = today.getFullYear(); 349 var tmpMonth = today.getMonth(); 350 var tmpDay = today.getDate(); 351 var tmpView = dpcalendarOptions['defaultView']; 352 var vars = window.location.hash.replace(/&/gi, "&").split("&"); 353 for (var i = 0; i < vars.length; i++) { 354 if (vars[i].match("^#year")) 355 tmpYear = vars[i].substring(6); 356 if (vars[i].match("^month")) 357 tmpMonth = vars[i].substring(6) - 1; 358 if (vars[i].match("^day")) 359 tmpDay = vars[i].substring(4); 360 if (vars[i].match("^view")) 361 tmpView = vars[i].substring(5); 362 } 363 var date = new Date(tmpYear, tmpMonth, tmpDay, 0, 0, 0); 364 var d = dpjQuery('#dpcalendar_component').fullCalendar('getDate'); 365 var view = dpjQuery('#dpcalendar_component').fullCalendar('getView'); 366 if (date.getFullYear() != d.getFullYear() || date.getMonth() != d.getMonth() || date.getDate() != d.getDate()) 367 dpjQuery('#dpcalendar_component').fullCalendar('gotoDate', date); 368 if (view.name != tmpView) 369 dpjQuery('#dpcalendar_component').fullCalendar('changeView', tmpView); 370 }); 371 372 if (dpjQuery('table').disableSelection) 373 dpjQuery('div.fc-button-today').closest('table.fc-header').disableSelection(); 374 375 // Showing the date picker 376 dpjQuery(document).on('click', '#dpcalendar_component_date_picker_button', function(e) { 377 dpjQuery('#dpcalendar_component_date_picker').datepicker('show'); 378 }); 379 380 // Go to the print page 381 dpjQuery(document).on('click', '#dpcalendar_component_print_button', function(e) { 382 var loc = document.location.href.replace(/\?/, "\?layout=print&format=raw\&"); 383 if (loc == document.location.href) 384 loc = document.location.href.replace(/#/, "\?layout=print&format=raw#"); 385 var printWindow = window.open(loc); 386 printWindow.focus(); 387 }); 388 389 // Toggle the list of calendars 390 dpjQuery('#dpcalendar_view_toggle_status').bind('click', function(e) { 391 dpjQuery('#dpcalendar_view_list').slideToggle('slow', function() { 392 var iconClass = 'icon-arrow-up'; 393 if (!dpjQuery('#dpcalendar_view_list').is(":visible")) 394 iconClass = 'icon-arrow-down'; 395 396 dpjQuery('#dpcalendar_view_toggle_status').attr('class', iconClass); 397 }); 398 }); 399 }); 400 401function updateDPCalendarFrame(calendar) { 402 if (calendar.checked) { 403 dpjQuery('#dpcalendar_component').fullCalendar('addEventSource', calendar.value); 404 } else { 405 dpjQuery('#dpcalendar_component').fullCalendar('removeEventSource', calendar.value); 406 } 407}
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.