(function ($) { Drupal.behaviors.iFrameSearch = { attached: false, $$searchIFrame: null, onResize: function(){ var $$ = parent.$ || parent.jQuery; this.$$searchIFrame = this.$$searchIFrame || $$( '#search-frame' ); //this.$$searchIFrame.height( document.documentElement.scrollHeight ); $dis = this; setTimeout(function() { $dis.$$searchIFrame.height( $('#main-container').height() ); }, 400); }, retargetLinks: function(){ $('a').each( function(){ var $a = $( this ); if ( $a.hasClass( 'target-processed' ) ) return; var target = $a.attr( 'target' ); if ( !target ) $a.attr( 'target', '_top' ); $a.addClass( 'target-processed' ); }); }, toggleAreaFilter: function(){ $('.area-filter').scrollTop('0px'); $('.area-filter').click(function() { $(this).toggleClass('expanded'); }); $('.area-filter .pane-content').addClass('container-fluid'); $('.area-filter .pane-content > ul').addClass('row'); $('.area-filter .pane-content > ul > li').addClass('col-sm-6 col-md-4'); }, retargetLeafletLinks: function(){ if ( typeof Drupal.settings.leaflet === 'undefined' ) return; for( var l = 0; l < Drupal.settings.leaflet.length; l++ ) { if ( typeof Drupal.settings.leaflet[ l ].lMap === 'object' ) Drupal.settings.leaflet[ l ].lMap.on( 'popupopen', this.retargetLinks.bind( this ) ); else setTimeout( this.retargetLeafletLinks.bind( this ), 500 ); } }, inIFrame: function() { try { return window.self !== window.top; } catch (e) { return true; } }, attach: function (context, settings) { var inIFrame = this.inIFrame(); // If in an iFrame and not attached, listen to resize if ( inIFrame && !this.attached ) { $( parent ).resize( this.onResize.bind( this ) ); var _this = this; $( 'img' ).on( 'load.imgload', function(){ var $img = $(this); _this.onResize.call( _this ) $img.off( 'load.imgload' ); }); this.onResize.call( this ) } if ( inIFrame && !this.attached ) { this.retargetLeafletLinks(); } // Convert all links to target _top if ( inIFrame ) { this.retargetLinks() } this.toggleAreaFilter(); this.attached = true; } }; Drupal.behaviors.adminToggle = { once: false, keyUp: function( e ){ var keyCode = e.keyCode || 0; if ( keyCode != 192 ) return; $('body').toggleClass( 'a-menu' ); }, attach: function (context, settings) { if ( this.once ) return; var $btn = $('.admin-btn'); if ( !$btn.length ) return; window.addEventListener( 'keyup', this.keyUp ); this.once = true; } } Drupal.behaviors.typesDurationDefaults = { attach: function (context, settings) { $('[name$="[standard_duration][period]"], [name$="[minimum_duration][period]"]').each(function(){ var $this = $(this); if ( $this.hasClass('defaulted') ) return; $this.val('hour').addClass('defaulted'); }) $('[name$="[maximum_duration][period]"]').each(function(){ var $this = $(this); if ( $this.hasClass('defaulted') ) return; $this.val('month').addClass('defaulted'); }); } } }(jQuery));