1/** 2 * @file Sets up the event bar javascript. 3 * This file should load after tribe events core and pro js and before any events view javascript. 4 * @version 3.0 5 */ 6 7/** 8 * @global 9 * @desc This global is used in various functions throughout the plugin to determine if the view is being changed. Its value will be set to 'change_view' when true. 10 */ 11 12var tribe_events_bar_action; 13var ITM_EVENT = window.ITM_EVENT || {}; 14ITM_EVENT.ITM_OneCmsEventLoad = false; 15ITM_EVENT.ITM_OneCmsEventLoad_Flag = ''; 16 17jQuery(document).ready(function( $ ){ 18 readyFn_EventAjax( jQuery, 'document.ready' ); 19 ITM_EVENT.ITM_OneCmsEventLoad_Flag = 'document.ready'; 20}); 21 22function readyFn_EventAjax( $, flagCheck = '') { 23 if (ITM_EVENT.ITM_OneCmsEventLoad) { 24 window.console.log('ITM_OneCmsEventLoad return : '+flagCheck); 25 window.console.log('ITM_OneCmsEventLoad_Flag : '+ITM_EVENT.ITM_OneCmsEventLoad_Flag); 26 return; 27 } 28 29 //we need to call only once. if pjax and or document.ready above. 30 ITM_EVENT.ITM_OneCmsEventLoad = true; 31 32//(function (window, document, $, td, te, tf, ts, tt, dbug) { 33 $ = jQuery 34 td = tribe_ev.data 35 te = tribe_ev.events 36 tf = tribe_ev.fn 37 ts = tribe_ev.state 38 tt = tribe_ev.tests 39 dbug = tribe_debug 40 41 42 //$(document).ready(function () { 43 44 if(dbug){ 45 if(!$().bootstrapDatepicker){ 46 debug.warn('TEC Debug: vendor bootstrapDatepicker was not loaded before its dependant file tribe-events-bar.js'); 47 } 48 if(!$().placeholder){ 49 debug.warn('TEC Debug: vendor placeholder was not loaded before its dependant file tribe-events-bar.js'); 50 } 51 } 52 53 var $tribebar = $('#tribe-bar-form'), 54 $tribedate = $('#tribe-bar-date'), 55 $tribe_events = $('#tribe-events'), 56 $tribebarselect = $('select[name=tribe-bar-view]'); 57 58 /** 59 * @function eventsBarWidth 60 * @desc eventsBarWidth applies responsive css classes to the bar to adjust its layout for smaller screens. 61 * @param {jQuery} $tribebar The event bar jquery object. 62 */ 63 function eventsBarWidth($tribebar) { 64 if ( $tribebar.parents('.tribe-bar-disabled').length ) 65 return; 66 67 var tribeBarWidth = $tribebar.width(); 68 69 if (tribeBarWidth > 800) { 70 $tribebar.removeClass('tribe-bar-mini tribe-bar-collapse').addClass('tribe-bar-full'); 71 } else { 72 $tribebar.removeClass('tribe-bar-full').addClass('tribe-bar-mini'); 73 } 74 if (tribeBarWidth < 728) { 75 $tribebar.removeClass('tribe-bar-mini').addClass('tribe-bar-collapse'); 76 } else { 77 $tribebar.removeClass('tribe-bar-collapse'); 78 } 79 } 80 81 eventsBarWidth($tribebar); 82 83 $tribebar.resize(function () { 84 eventsBarWidth($tribebar); 85 }); 86 87 if (!$('.tribe-events-week-grid').length) { 88 89 if (ts.view !== 'month') { 90 91 // begin display date formatting 92 93 var date_format = 'yyyy-mm-dd'; 94 95 if(ts.datepicker_format !== '0'){ 96 97 // we are not using the default query date format, lets grab it from the data array 98 99 date_format = td.datepicker_formats.main[ts.datepicker_format]; 100 101 var url_date = tf.get_url_param('tribe-bar-date'); 102 103 // if url date is set and datepicker format is different from query format 104 // we need to fix the input value to emulate that before kicking in the datepicker 105 106 if(url_date) 107 $tribedate.val(tribeDateFormat(url_date, ts.datepicker_format)); 108 else if(ts.view === 'day' && $tribedate.val().length !== 0) { 109 $tribedate.val(tribeDateFormat($tribedate.val(), ts.datepicker_format)); 110 } 111 } 112 113 dbug && debug.info('TEC Debug: bootstrapDatepicker was just initialized in "tribe-events-bar.js" on:', $tribedate); 114 115 td.datepicker_opts = { 116 format: date_format, 117 autoclose: true 118 }; 119 120 if($tribedate.length > 0) 121 $tribedate.bootstrapDatepicker(td.datepicker_opts); 122 } 123 } 124 125 $tribedate.blur(function () { 126 if ($tribedate.val() === '' && $('.datepicker.dropdown-menu').is(':hidden') && tt.live_ajax() && tt.pushstate) { 127 ts.date = td.cur_date; 128 td.cur_url = td.base_url; 129 $(te).trigger('tribe_ev_runAjax'); 130 } 131 }); 132 133 // Add some classes 134 if ($('.tribe-bar-settings').length) { 135 $('#tribe-events-bar').addClass('tribe-has-settings'); 136 } 137 if ($('#tribe-events-bar .hasDatepicker').length) { 138 $('#tribe-events-bar').addClass('tribe-has-datepicker'); 139 } 140 141 // Implement views links 142 function format(view) { 143 return '<span class="tribe-icon-' + $.trim(view.text.toLowerCase()) + '">' + view.text + '</span>'; 144 } 145 // Implement placeholder 146 $('input[name*="tribe-bar-"]').placeholder(); 147 148 $('.tribe-bar-views-list').remove(); //WPB-2679 149 150 // Create list 151 $('<ul class="tribe-bar-views-list" />').insertAfter( $tribebarselect ); 152 153 var $tribebarviews = $('.tribe-bar-views-list'); 154 //alert('here to create list ul li from select box through js code......'); 155 156 // Create list from select options 157 $tribebarselect.find('option').each(function(i){ 158 var $view = $(this); 159 displaying = $view.data('view'); 160 // build list items and append them 161 var unique_c = 'tribe-bar-views-option-' + $view.data('view'); 162 $('<li></li>', { 163 'class': 'tribe-bar-views-option ' + unique_c, 164 'data-tribe-bar-order': i, 165 'data-view': displaying 166 }).html([ 167 ' <a href="#">', 168 ' <span class="tribe-icon-' + displaying + '">' + $view.text() + '</span>', 169 '</a>'].join("") 170 ).appendTo( '.tribe-bar-views-list' ); 171 172 }); 173 174 //find the current view and select it in the bar 175 var currentview = $tribebarselect.find(':selected').data('view'), 176 $currentli = $tribebarviews.find('li[data-view='+ currentview +']'); 177 178 $currentli.prependTo($tribebarviews).addClass('tribe-bar-active'); 179 180 //WPB-2500 -- this file called from wp-content/themes/king-theme/inc/js/persistent-header.js 181 //need to hide original select box. during page load it will call tribe-events-bar.min.js file. 182 $tribebarselect.hide(); 183 184 // toggle the views dropdown 185 $tribebar.on('click', '#tribe-bar-views', function (e) { 186 e.stopPropagation(); 187 var $this = $(this); 188 $this.toggleClass('tribe-bar-views-open'); 189 }); 190 191 // change views 192 $tribebar.on('click', '.tribe-bar-views-option', function(e) { 193 e.preventDefault(); 194 var $this = $(this); 195 if ( !$this.is('.tribe-bar-active') ) { 196 197 var target = $this.data('view'); 198 199 ts.cur_url = $('option[data-view='+ target +']').val(); 200 ts.view_target = $('select[name=tribe-bar-view] option[value="' + ts.cur_url + '"]').data('view'); 201 tribe_events_bar_action = 'change_view'; 202 tribe_events_bar_change_view(); 203 204 } 205 }); 206
207 // change views with select (for skeleton styles) 208 $tribebar.on('change', '.tribe-bar-views-select', function(e) { 209 e.preventDefault(); 210 var $this = $("option:selected", this); 211 212 var target = $this.data('view'); 213 214 ts.cur_url = $('option[data-view='+ target +']').val(); 215 ts.view_target = $('select[name=tribe-bar-view] option[value="' + ts.cur_url + '"]').data('view'); 216 tribe_events_bar_action = 'change_view'; 217 tribe_events_bar_change_view(); 218 219 }); 220 221 $tribebar.on('click', '#tribe-bar-collapse-toggle', function () { 222 $(this).toggleClass('tribe-bar-filters-open'); 223 $('.tribe-bar-filters').slideToggle('fast'); 224 }); 225 226 // Wrap date inputs with a parent container 227 $('label[for="tribe-bar-date"], input[name="tribe-bar-date"]').wrapAll('<div id="tribe-bar-dates" />'); 228 229 // Add our date bits outside of our filter container 230 $('#tribe-bar-filters').before($('#tribe-bar-dates')); 231 232 $(te).on("tribe_ev_serializeBar", function () { 233 $('form#tribe-bar-form input, form#tribe-bar-form select, #tribeHideRecurrence').each(function () { 234 var $this = $(this); 235 if ($this.is('#tribe-bar-date')) { 236 if ($this.val().length) { 237 if(ts.view === 'month'){ 238 ts.params[$this.attr('name')] = tribeDateFormat(ts.mdate, "tribeMonthQuery"); 239 ts.url_params[$this.attr('name')] = tribeDateFormat(ts.mdate, "tribeMonthQuery"); 240 } else { 241 ts.params[$this.attr('name')] = tribeDateFormat($this.bootstrapDatepicker('getDate'), "tribeQuery"); 242 ts.url_params[$this.attr('name')] = tribeDateFormat($this.bootstrapDatepicker('getDate'), "tribeQuery"); 243 } 244 } else if($this.is('.placeholder') && $this.is('.bd-updated')){ 245 ts.url_params[$this.attr('name')] = $this.attr('data-oldDate'); 246 } else { 247 ts.date = td.cur_date; 248 } 249 } 250 251 if ($this.val().length && !$this.hasClass('tribe-no-param') && !$this.is('#tribe-bar-date')) { 252 if ($this.is(':checkbox')) { 253 if ($this.is(':checked')) { 254 ts.params[$this.attr('name')] = $this.val(); 255 if (ts.view !== 'map') 256 ts.url_params[$this.attr('name')] = $this.val(); 257 if (ts.view === 'month' || ts.view === 'day' || ts.view === 'week' || ts.recurrence) 258 ts.pushcount++; 259 } 260 } else { 261 ts.params[$this.attr('name')] = $this.val(); 262 if (ts.view !== 'map') 263 ts.url_params[$this.attr('name')] = $this.val(); 264 if (ts.view === 'month' || ts.view === 'day' || ts.view === 'week') 265 ts.pushcount++; 266 } 267 } 268 }); 269 }); 270 271 /** 272 * @function tribe_events_bar_change_view 273 * @desc tribe_events_bar_change_view handles switching views and collecting any params from the events bar. It also fires 2 custom actions that can be hooked into: 'tribe_ev_preCollectBarParams' and 'tribe_ev_postCollectBarParams'. 274 */ 275 276 function tribe_events_bar_change_view() { 277 278 tribe_events_bar_action = 'change_view'; 279 280 if (ts.view === 'month' && $tribedate.length) { 281 var dp_date = $tribedate.val(), 282 day = tf.get_day(); 283 284 if(ts.datepicker_format !== '0'){ 285 if(day.length){ 286 dp_date = tribeDateFormat($tribedate.bootstrapDatepicker('getDate'), 'tribeMonthQuery'); 287 $tribedate.val(dp_date + day); 288 } else { 289 $tribedate.val(''); 290 } 291 292 } else { 293 if (dp_date.length === 7) 294 $tribedate.val(dp_date + day); 295 } 296 297 } 298 299 ts.url_params = {}; 300 301 $(te).trigger('tribe_ev_preCollectBarParams'); 302 303 $('#tribe-bar-form input, #tribe-bar-form select').each(function () { 304 var $this = $(this); 305 if ($this.val().length && !$this.hasClass('tribe-no-param')) { 306 if (ts.view !== 'month' && ts.datepicker_format !== '0' && $this.is($tribedate)) { 307 308 ts.url_params[$this.attr('name')] = tribeDateFormat($this.bootstrapDatepicker('getDate'), 'tribeQuery'); 309 310 } else { 311 if ($this.is(':checkbox')) { 312 if ($this.is(':checked')) { 313 ts.url_params[$this.attr('name')] = $this.val(); 314 } 315 } else { 316 ts.url_params[$this.attr('name')] = $this.val(); 317 } 318 } 319 } 320 }); 321 322 ts.url_params = $.param(ts.url_params); 323 324 $(te).trigger('tribe_ev_postCollectBarParams'); 325 326 if (ts.url_params.length) 327 ts.cur_url += tt.starting_delim() + ts.url_params; 328 329 window.location.href = ts.cur_url; 330 } 331 332 // Implement simple toggle for filters at smaller size (and close if click outside of toggle area) 333 var $tribeDropToggle = $('#tribe-events-bar [class^="tribe-bar-button-"]'); 334 var $tribeDropToggleEl = $tribeDropToggle.next('.tribe-bar-drop-content'); 335 336 $tribeDropToggle.click(function () { 337 var $this = $(this); 338 $this.toggleClass('open'); 339 $this.next('.tribe-bar-drop-content').toggle(); 340 return false 341 }); 342 343 $(document).click(function () { 344 $('#tribe-bar-views').removeClass('tribe-bar-views-open'); 345 if ($tribeDropToggle.hasClass('open')) { 346 $tribeDropToggle.removeClass('open'); 347 $tribeDropToggleEl.hide(); 348 } 349 }); 350 351 $tribeDropToggleEl.click(function (e) { 352 e.stopPropagation(); 353 }); 354 dbug && debug.info('TEC Debug: tribe-events-bar.js successfully loaded'); 355 } 356 //}); 357 358//})(window, document, jQuery, tribe_ev.data, tribe_ev.events, tribe_ev.fn, tribe_ev.state, tribe_ev.tests, tribe_debug); 359
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.