1/** 2 * Makes sure we have all the required levels on the Tribe Object 3 * 4 * @since 4.7.9 5 * 6 * @type {PlainObject} 7 */ 8tribe.events = tribe.events || {}; 9tribe.events.views = tribe.events.views || {}; 10 11/** 12 * Configures Map No Venue Modal Object in the Global Tribe variable 13 * 14 * @since 4.7.9 15 * 16 * @type {PlainObject} 17 */ 18tribe.events.views.mapNoVenueModal = {}; 19 20/** 21 * Initializes in a Strict env the code that manages the Event Views 22 * 23 * @since 4.7.9 24 * 25 * @param {PlainObject} $ jQuery 26 * @param {PlainObject} obj tribe.events.views.manager 27 * 28 * @return {void} 29 */ 30( function( $, obj ) { 31 'use strict'; 32 var $document = $( document ); 33 34 /** 35 * Selectors used for configuration and setup 36 * 37 * @since 4.7.9 38 * 39 * @type {PlainObject} 40 */ 41 obj.selectors = { 42 noVenueModal: '[data-js="tribe-events-pro-map-no-venue-modal"]', 43 noVenueModalClose: '[data-js="tribe-events-pro-map-no-venue-modal-close"]', 44 noVenueModalLink: '[data-js="tribe-events-pro-map-no-venue-modal-link"]', 45 tribeCommonA11yHiddenClass: '.tribe-common-a11y-hidden', 46 }; 47 48 /** 49 * Open no venue modal. 50 * 51 * @since 4.7.9 52 * 53 * @param {Event} event event object for `openNoVenueModal.tribeEvents` event 54 * 55 * @return {void} 56 */ 57 obj.openNoVenueModal = function( event ) { 58 var $modal = event.data.modal; 59 60 $modal.removeClass( obj.selectors.tribeCommonA11yHiddenClass.className() ); 61 }; 62 63 /** 64 * Close no venue modal. 65 * 66 * @since 4.7.9 67 * 68 * @param {Event} event event object for `closeNoVenueModal.tribeEvents` or `click` event 69 * 70 * @return {void} 71 */ 72 obj.closeNoVenueModal = function( event ) { 73 var $modal = event.data.modal; 74 75 $modal.addClass( obj.selectors.tribeCommonA11yHiddenClass.className() ); 76 }; 77 78 /** 79 * Set no venue modal link. 80 * 81 * @since 4.7.9 82 * 83 * @param {Event} event event object for `setNoVenueModalLink.tribeEvents` event 84 * @param {string} link URL of link to be set 85 * 86 * @return {void} 87 */ 88 obj.setNoVenueModalLink = function( event, link ) { 89 var $modal = event.data.modal; 90 91 $modal 92 .find( obj.selectors.noVenueModalLink ) 93 .attr( 'href', link ); 94 } 95 96 /** 97 * Unbind events for map no venue modal. 98 * 99 * @since 4.7.9 100 * 101 * @param {jQuery} $container jQuery object of view container. 102 * 103 * @return {void} 104 */ 105 obj.unbindEvents = function( $container ) { 106 $container 107 .off( 'openNoVenueModal.tribeEvents', obj.openNoVenueModal ) 108 .off( 'closeNoVenueModal.tribeEvents', obj.closeNoVenueModal ) 109 .off( 'setNoVenueModalLink.tribeEvents', obj.setNoVenueModalLink ) 110 .find( obj.selectors.noVenueModalClose ) 111 .off( 'click', obj.closeNoVenueModal ); 112 }; 113 114 /** 115 * Bind events for map no venue modal. 116 * 117 * @since 4.7.9 118 * 119 * @param {jQuery} $container jQuery object of view container. 120 * 121 * @return {void} 122 */ 123 obj.bindEvents = function( $container ) { 124 var $modal = $container.find( obj.selectors.noVenueModal ); 125 126 $container 127 .on( 'openNoVenueModal.tribeEvents', { container: $container, modal: $modal }, obj.openNoVenueModal ) 128 .on( 'closeNoVenueModal.tribeEvents', { container: $container, modal: $modal }, obj.closeNoVenueModal ) 129 .on( 'setNoVenueModalLink.tribeEvents', { container: $container, modal: $modal }, obj.setNoVenueModalLink ) 130 .find( obj.selectors.noVenueModalClose ) 131 .on( 'click', { container: $container, modal: $modal }, obj.closeNoVenueModal ); 132 }; 133 134 /** 135 * Deinitialize map no venue modal. 136 * 137 * @since 4.7.9 138 * 139 * @param {Event} event event object for 'afterSetup.tribeEvents' event 140 * @param {jqXHR} jqXHR Request object 141 * @param {PlainObject} settings Settings that this request was made with 142 * 143 * @return {void} 144 */ 145 obj.deinit = function( event, jqXHR, settings ) { 146 var $container = event.data.container; 147 obj.unbindEvents( $container ); 148 $container.off( 'beforeAjaxSuccess.tribeEvents', obj.deinit ); 149 }; 150 151 /** 152 * Initialize map no venue modal. 153 * 154 * @since 4.7.9 155 * 156 * @param {Event} event JS event triggered. 157 * @param {integer} index jQuery.each index param from 'afterSetup.tribeEvents' event. 158 * @param {jQuery} $container jQuery object of view container. 159 * @param {object} data data object passed from 'afterSetup.tribeEvents' event. 160 * 161 * @return {void} 162 */ 163 obj.init = function( event, index, $container, data ) { 164 if ( 'map' !== data.slug ) { 165 return; 166 } 167 168 obj.bindEvents( $container ); 169 $container.on( 'beforeAjaxSuccess.tribeEvents', { container: $container }, obj.deinit ); 170 }; 171 172 /** 173 * Handles the initialization of the map no venue modal when Document is ready 174 * 175 * @since 4.7.9 176 * 177 * @return {void} 178 */ 179 obj.ready = function() { 180 $document.on( 'afterSetup.tribeEvents', tribe.events.views.manager.selectors.container, obj.init ); 181 }; 182 183 // Configure on document ready 184 $document.ready( obj.ready ); 185} )( jQuery, tribe.events.views.mapNoVenueModal );
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.