1/** 2 * Funcionalidad JavaScript asociada a las redes sociales 3 */ 4(function( $ ) { 5 'use strict'; 6 7 var navigation = { 8 9 /** 10 * Acciones a realizar al cargar la página. 11 */ 12 'init_footer' : function() { 13 this.toggle_menu.init(); 14 this.toggle_menu.tabs.init(); 15 this.set_device_used(); // Guarda que se han ejecutado todos los scripts para el dispositivo actual. 16 }, 17 18 /** 19 * Acciones a realizar al terminar de cargar los recursos de la página. 20 * @todo Ejecutar sólo en Safari, ya que otros navegadores no necesitan ejecutar esto on load. 21 */ 22 'on_load' : function() { 23 if( golsmedia_viewport.current_device != 'mobile' ) { 24 this.main_menu.submenus.align_dropdown(); 25 this.main_menu.submenus.append_to_header(); 26 } 27 this.main_menu.tablet_scroll.on_load(); 28 }, 29 30 /** 31 * Acciones a realizar al cargar la página. 32 */ 33 'on_resize_footer' : function() { 34 this.toggle_menu.on_resize(); 35 this.toggle_menu.tabs.on_resize(); 36 this.set_device_used(); // Guarda que se han ejecutado todos los scripts para el dispositivo actual. 37 }, 38 39 /** 40 * Acciones a realizar al cargar anuncios. 41 */ 42 'on_ads_loaded' : function() { 43 this.main_menu.submenus.on_ads_loaded(); 44 this.toggle_menu.on_ads_loaded(); 45 }, 46 47 /** 48 * Menu desplegable. 49 */ 50 'toggle_menu' : { 51 52 /** 53 * @var jQuery Botón que abre y cierra el menú desplegable. 54 */ 55 '$button' : false, 56 57 /** 58 * @var jQuery Contenedor del menú desplegable. 59 */ 60 '$menu' : false, 61 62 /** 63 * @var jQuery Uno de los menús que hay dentro del contenedor: menú por pestañas y columnas. 64 */ 65 '$tabs_menu' : false, 66 67 /** 68 * @var jQuery Uno de los menús que hay dentro del contenedor: menú horizontal. 69 */ 70 '$inline_menu' : false, 71 72 /** 73 * @var jQuery Elemento que contiene la sombra en la parte inferior del menú. 74 * Debemos ocultarla al abrir el menú desplegable ya que si no se posiciona sobre 75 * elementos del menú e impide hacer click. 76 */ 77 '$header_gradient' : false, 78 79 /** 80 * Acciones a realizar al cargar la página. 81 */ 82 'init' : function() { 83 84 if( golsmedia_viewport.current_device != 'mobile' && !golsmedia_navigation.has_device_been_used(['desktop','portrait','landscape']) ) { 85 86 this.$button = golsmedia_navigation.$header.find( '#golsmedia-toggle-menu-button' ); 87 this.$menu = $( '#golsmedia-toggle-menu' ); 88 this.$header_gradient = golsmedia_navigation.$header.find( '.td-header-gradient' ); 89 this.$tabs_menu = this.$menu.find( '.golsmedia-toggle-columns > ul' ); 90 this.$inline_menu = this.$menu.find( '.golsmedia-toggle-horizontal > ul' ); 91 92 this.enable_scroll(); 93 this.on_click_button(); 94 this.on_click_outside(); 95 96 } 97 98 }, 99 100 /** 101 * Acciones a realizar al cargar la página. 102 */ 103 'on_resize' : function() { 104 105 this.init(); 106 if( golsmedia_viewport.current_device != 'mobile' ) { 107 this.append_to_header(); 108 } 109 110 }, 111 112 /** 113 * Acciones a realizar al cargar anuncios. 114 */ 115 'on_ads_loaded' : function() { 116 117 if( golsmedia_viewport.current_device != 'mobile' ) { 118 // Reposicionar menú desplegable tras cargar el anuncio de la cabecera. 119 this.append_to_header(); 120 } 121 122 }, 123 124 /** 125 * Acciones a realizar al hacer click en el botón de menú desplegable. 126 */ 127 'on_click_button' : function() { 128 129 var _this = this; 130 131 this.$button.click( function() { 132 if( _this.$button.hasClass( 'is-active' ) ) { 133 _this.close_menu(); 134 } else { 135 _this.open_menu(); 136 } 137 }); 138 139 }, 140 141 /** 142 * Acciones a realizar al hacer click fuera del menú. 143 */ 144 'on_click_outside' : function() { 145 146 var _this = this; 147 148 $( document ).click( function( event ) { 149 150 if( _this.$button.hasClass( 'is-active' ) ) { 151 var $target = $( event.target ); 152 if( !$target.closest( '.toggle-menu__wrapper' ).length && !$target.is( $( '.toggle-menu__wrapper' ) ) && 153 !$target.closest( '.toggle-menu' ).length && !$target.is( _this.$menu ) ) { 154 _this.close_menu(); 155 } 156 } 157 158 }); 159 160 }, 161 162 /** 163 * Abrir menú desplegable. 164 */ 165 'open_menu' : function() { 166 var _this = this; 167 168 this.$button.addClass( 'is-active' ); 169 golsmedia_body_scroll.lock(); 170 this.$header_gradient.addClass( 'hide-gradient' ); 171 172 this.append_to_header(); 173 this.$menu.slideDown( 400, function(){ 174 _this.redo_scroll(); 175 }); 176 177 }, 178 179 /** 180 * Cerrar menú desplegable. 181 */ 182 'close_menu' : function() { 183 this.$button.removeClass( 'is-active' ); 184 this.$menu.slideUp(); 185 golsmedia_body_scroll.unlock(); 186 this.$header_gradient.removeClass( 'hide-gradient' ); 187 }, 188 189 /** 190 * Colocar menú debajo de la cabecera. 191 */ 192 'append_to_header' : function() { 193 if( this.$button.hasClass( 'is-active' ) ) {
194 this.$menu.css( 'top', golsmedia_navigation.get_offset_top() ); 195 this.$tabs_menu.parent().css( 'height', $( window ).height() - golsmedia_navigation.get_offset_top() - 90 ); 196 } 197 }, 198 199 /** 200 * Habilitar scroll. 201 */ 202 'enable_scroll' : function() { 203 204 this.$tabs_menu.parent().niceScroll({ 205 cursorcolor : '#3F3F3E', 206 cursorwidth : '8px', 207 cursorborder : 0, 208 autohidemode : false 209 }); 210 211 }, 212 213 /** 214 * Recargar scroll. 215 */ 216 'redo_scroll' : function() { 217 this.$tabs_menu.parent().getNiceScroll().resize(); 218 }, 219 220 /** 221 * Navegación por pestañas del menú desplegable 222 */ 223 'tabs' : { 224 225 /** 226 * @var jQuery Elementos del menú considerados pestañas. 227 */ 228 '$tabs' : null, 229 230 /** 231 * Acciones a realizar al cargar la página. 232 */ 233 'init' : function() { 234 if( golsmedia_viewport.current_device != 'mobile' && !golsmedia_navigation.has_device_been_used(['desktop','portrait','landscape']) ) { 235 this.$tabs = golsmedia_navigation.toggle_menu.$tabs_menu.find( '> li' ); 236 this.align_dropdown(); 237 this.on_hover(); 238 this.on_click(); 239 } 240 }, 241 242 /** 243 * Acciones a modificar el tamaño de la ventana. 244 */ 245 'on_resize' : function() { 246 247 this.init(); 248 if( golsmedia_viewport.current_device != 'mobile' ) { 249 this.align_dropdown(); 250 } 251 252 }, 253 254 /** 255 * Acciones a realizar al pasar el cursor por encima de una tab. 256 */ 257 'on_hover' : function() { 258 259 var _this = this; 260 261 this.$tabs.on( 'mouseenter mouseleave', function( event ) { 262 263 var $tab = $( this ); 264 265 if( event.type === 'mouseleave' ) { 266 _this.hide_tab( $tab ); 267 } else { 268 _this.show_tab( $tab ); 269 } 270 271 golsmedia_navigation.toggle_menu.redo_scroll(); 272 273 }); 274 275 }, 276 277 /** 278 * Al hacer click sobre una pestaña. 279 */ 280 'on_click' : function() { 281 282 var _this = this; 283 284 this.$tabs.find( '> a' ).on( 'click', function( event ) { 285 286 var $tab = $( this ).parent(); 287 event.preventDefault(); 288 _this.show_tab( $tab ); 289 _this.freeze_tab( $tab ); 290 golsmedia_navigation.toggle_menu.redo_scroll(); 291 292 }); 293 294 }, 295 296 /** 297 * Mostrar pestaña. 298 * @param jQuery $tab Pestaña a mostrar. 299 */ 300 'show_tab' : function( $tab ) { 301 this.$tabs.removeClass( 'golsmedia-menu-tab--selected' ); 302 $tab.addClass( 'golsmedia-menu-tab--selected' ); 303 }, 304 305 /** 306 * Ocultar pestaña. 307 * @param jQuery $tab Pestaña a mostrar. 308 */ 309 'hide_tab' : function( $tab ) { 310 $tab.removeClass( 'golsmedia-menu-tab--selected' ); 311 this.$tabs.filter( '.golsmedia-menu-tab--original' ).addClass( 'golsmedia-menu-tab--selected' ); 312 }, 313 314 /** 315 * Dejar pestaña seleccionada. 316 * @param jQuery $tab Pestaña a mostrar. 317 * @param jQuery $tab_holder Grupo de pestañas al que pertenece $tab. 318 */ 319 'freeze_tab' : function( $tab ) { 320 this.$tabs.removeClass( 'golsmedia-menu-tab--original' ); 321 $tab.addClass( 'golsmedia-menu-tab--original' ); 322 }, 323 324 /** 325 * Alinear submenús a la pestaña que los contiene. 326 */ 327 'align_dropdown' : function() { 328 329 var _this = this, 330 $tab_menus = this.$tabs.find( '> ul' ); 331 332 if( !golsmedia_navigation.toggle_menu.$button.hasClass( 'is-active' ) ) { 333 golsmedia_navigation.toggle_menu.$menu.addClass( 'allow-check' ); 334 } 335 336 $tab_menus.addClass( 'allow-check' ); 337 338 $tab_menus.each( function( index ) { 339 340 var $tab_menu = $( this ), 341 tab_menu_height = $tab_menu.outerHeight(), 342 $tab_button = $tab_menu.parent(), 343 tab_button_bottom_border = $tab_button.position().top + $tab_button.outerHeight(); 344 345 if( tab_menu_height < ( tab_button_bottom_border + 24 ) ) { 346 $tab_menu.css( 'margin-top', tab_button_bottom_border - tab_menu_height ); 347 } 348 349 });
350 351 golsmedia_navigation.toggle_menu.$menu.removeClass( 'allow-check' ); 352 $tab_menus.removeClass( 'allow-check' ); 353 354 } 355 356 } 357 358 } 359 360 } 361 362 window.golsmedia_navigation = $.extend( true, {}, window.golsmedia_navigation, navigation ); 363 364})( jQuery );
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.