1 2// Scripts used by the theme 3 4 5 6// Noconflict 7var $str = jQuery.noConflict(); 8 9// Variables 10var $bento_isocontainer = $str('.items-container'); 11var bento_lastwindowPos = $str(window).scrollTop(); 12var bento_adminbarHeight = 0; 13if ( $str('#wpadminbar').outerHeight(true) > 0 ) { 14 bento_adminbarHeight = $str('#wpadminbar').outerHeight(true); 15} 16 17// Check if an iOS device 18function bentoCheckDevice() { 19 var iDevices = [ 20 'iPad Simulator', 21 'iPhone Simulator', 22 'iPod Simulator', 23 'iPad', 24 'iPhone', 25 'iPod', 26 'Mac68K', 27 'MacPPC', 28 'MacIntel' 29 ]; 30 if ( !!navigator.platform ) { 31 while ( iDevices.length ) { 32 if ( navigator.platform === iDevices.pop() ) { 33 return true; 34 } 35 } 36 } 37 return false; 38} 39 40// Generate em values 41function bentoEmValue(input) { 42 var emSize = parseFloat( $str('html').css('font-size') ); 43 var output = emSize * 1.6 * input; 44 return output; 45} 46 47// Handle same-page menu links 48function bentoOnePage() { 49 var headerHeight = 0; 50 if ( bentoThemeVars.fixed_menu == 1 ) { 51 headerHeight = $str('.site-header').outerHeight(true); 52 } 53 var menuitems = new Object(); 54 $str('.primary-menu a').each(function() { 55 var itemclasses = 0; 56 itemclasses = $str(this).parent('li').attr('class').split(" "); 57 var itemid = itemclasses.slice(-1).pop(); 58 var itemPosition = 0; 59 if ( $str(this).attr('href') && $str(this).attr('href').indexOf("#") != -1 ) { 60 hash = $str(this).attr('href').substring($str(this).attr('href').indexOf('#')+1); 61 if ( $str('#' + hash).length ) { 62 itemPosition = $str('#' + hash).offset().top - headerHeight - 10; 63 menuitems[itemid] = itemPosition; 64 } 65 } 66 }); 67 return menuitems; 68} 69 70// Set side menu width for boxed layout 71function bentoSideMenuWidth() { 72 if ( bentoThemeVars.menu_config == 3 ) { 73 var $header = $str('.header-side .site-header'); 74 if ( $str(window).width() < bentoEmValue(48) ) { 75 $header.css('width',''); 76 } else { 77 var wrapwidth = $str('.site-wrapper').outerWidth(); 78 var sidewidth = wrapwidth * 0.2; 79 var widthstyle = 'width:'+sidewidth+'px !important;'; 80 if ( $header.attr('style') ) { 81 $header.css('width',''); 82 $header.attr('style', widthstyle + $header.attr('style')); 83 } else { 84 $header.attr('style', widthstyle); 85 } 86 } 87 } 88} 89 90 91$str(document).ready(function() { 92 93 94 // Fixed header 95 if ( bentoThemeVars.fixed_menu == 1 && bentoThemeVars.menu_config != 3 && $str(window).width() > bentoEmValue(64) ) { 96 var topbar = 0; 97 if ( $str('.bnt-topbar').length ) { 98 topbar = $str('.bnt-topbar').outerHeight(true); 99 } 100 if ( $str(window).scrollTop() > topbar ) { 101 if ( ! $str('.fixed-header').length ) { 102 var $bento_headerClone = $str('.site-header > .bnt-container').clone(); 103 $str('.site-wrapper').append('<header class="site-header fixed-header"></header>'); 104 $str('.fixed-header').html($bento_headerClone); 105 } 106 } 107 } 108 109 110 // Submenu animations 111 if ( bentoThemeVars.menu_config < 2 ) { 112 $str('.site-wrapper').on( 'mouseenter mouseleave', '.primary-menu .menu-item-has-children', function(ev) { 113 var parentMenu = $str(this); 114 var submPos = parentMenu.offset().left; 115 var windowWidth = $str(window).width(); 116 if ( parentMenu.parents('.menu-item-has-children').length ) { 117 var subsubOff = submPos + 400; // 200 for each submenu width 118 if ( subsubOff > windowWidth ) { 119 parentMenu.children('.sub-menu').css({'left':'auto','right':'100%'}); 120 } 121 } else { 122 var subsubOff = submPos + 200; // 200 is the submenu width 123 if ( subsubOff > windowWidth ) { 124 parentMenu.children('.sub-menu').css({'right':'0'}); 125 } 126 } 127 if ( ev.type === 'mouseenter' ) { 128 $str(this).children('.sub-menu').fadeIn(200); 129 } else { 130 $str(this).children('.sub-menu').fadeOut(200); 131 } 132 }); 133 } else if ( bentoThemeVars.menu_config == 2 ) { 134 $str('.ham-menu-trigger-container').click(function() { 135 $str('.header-menu, .ham-menu-close-container').fadeIn(200, function() { 136 $str('body').addClass('mobile-menu-open'); 137 }); 138 var $menu = $str('#nav-primary'); 139 var menuHeight = 0; 140 if ( $menu.outerHeight(false) > 0 ) { 141 menuHeight = $menu.outerHeight(false); 142 } 143 var menuMargin = ( $str(window).height() - menuHeight ) / 2; 144 $menu.css('margin-top',menuMargin+'px'); 145 }); 146 $str('.ham-menu-close-container').click(function() { 147 $str('.header-menu, .ham-menu-close-container').fadeOut(200, function() { 148 $str('body').removeClass('mobile-menu-open'); 149 }); 150 }); 151 } else if ( bentoThemeVars.menu_config == 3 ) { 152 $str('.primary-menu .menu-item-has-children > a').toggle(function(e) { 153 if ( ! $str(this).hasClass('opened-side-menu') ) { 154 $str(this).addClass('opened-side-menu'); 155 } 156 $str(this).siblings('.sub-menu').slideDown(200); 157 }, function(e) { 158 e.preventDefault(); 159 if ( $str(this).hasClass('opened-side-menu') ) { 160 $str(this).removeClass('opened-side-menu'); 161 } 162 $str(this).siblings('.sub-menu').slideUp(200); 163 }); 164 } 165 166 167 // Mobile menu animations 168 $str('.mobile-menu-trigger-container').click(function() { 169 var device = bentoCheckDevice(); 170 if ( device == false ) { 171 $str('body').addClass('mobile-menu-open'); 172 } 173 $str('.mobile-menu-shadow').fadeIn(500); 174 $str('#nav-mobile').css("left", '0'); 175 }); 176 $str('.mobile-menu-close,.mobile-menu-shadow').click(function() { 177 if ( $str('body').hasClass('mobile-menu-open') ) { 178 $str('body').removeClass('mobile-menu-open'); 179 } 180 $str('.mobile-menu-shadow').fadeOut(500); 181 $str('#nav-mobile').css("left", '-100%'); 182 }); 183 184 185 // Side menu position on load 186 if ( bentoThemeVars.menu_config == 3 ) { 187 var bento_headertop = 0; 188 if ( $str('#wpadminbar').outerHeight(true) > 0 ) { 189 bento_headertop = $str('#wpadminbar').outerHeight(true); 190 } 191 if ( $str('.bnt-topbar').length ) { 192 bento_headertop += $str('.bnt-topbar').outerHeight(true); 193 } 194 $str('.header-side .site-header').css('top',bento_headertop+'px'); 195 } 196 197 198 // Comment form labels 199 $str('.comment-form-field input').focus(function() { 200 $str(this).siblings('label').fadeIn(500); 201 }).blur(function() { 202 if ( ! $str(this).val() ) { 203 $str(this).siblings('label').fadeOut(500); 204 } 205 }); 206 if ( $str('.comment-form-field input').val() ) { 207 $str(this).siblings('label').css('display','block'); 208 } 209 210 211 // Responsive videos 212 $str('.entry-content iframe[src*="youtube.com"],.entry-content iframe[src*="vimeo.com"]').each(function() { 213 $str(this).parent().fitVids(); 214 }); 215 216 217 // Ajax pagination 218 var bento_page = 1; 219 if ( bentoThemeVars.paged && bentoThemeVars.paged > 1 ) { 220 bento_page = bentoThemeVars.paged; 221 } 222 if ( bento_page < bentoThemeVars.max_pages ) { 223 $str('.ajax-load-more').fadeIn(100).css('display','block'); 224 } 225 $str('.ajax-load-more').click(function () { 226 $str('.spinner-ajax').fadeIn(400); 227 $str.ajax({
228 url: bentoThemeVars.ajaxurl, 229 type: 'post', 230 data: { 231 action: 'ajax_pagination', 232 query_vars: bentoThemeVars.query_vars, 233 page: bento_page 234 }, 235 success: function (html) { 236 var $posts = $str(html).fadeIn(400); 237 if ( bentoThemeVars.grid_mode != 'nogrid' ) { 238 $str('.grid-container').append($posts); 239 } else { 240 $str('.site-main').append($posts); 241 } 242 } 243 }); 244 bento_page++; 245 $str('.spinner-ajax').fadeOut(400); 246 if ( bento_page >= bentoThemeVars.max_pages ) { 247 $str('.ajax-load-more').remove(); 248 } 249 }); 250 251 252 // Scroll to bottom of header with CTA buttons 253 $str('.post-header-cta div').click(function() { 254 bento_headerHeight = 0; 255 if ( bentoThemeVars.fixed_menu == 1 ) { 256 bento_headerHeight = $str('.site-header').outerHeight(true); 257 } 258 var hb = $str('.post-header').position().top + $str('.post-header').outerHeight(true) - bento_headerHeight; 259 $str('html, body').animate( { scrollTop: hb }, 1000 ); 260 }); 261 262 263 // Display "add to cart" buttons on products 264 $str('.products .product').hover(function() { 265 $str(this).find('.add_to_cart_button').fadeIn(200); 266 }, function() { 267 $str(this).find('.add_to_cart_button').fadeOut(200); 268 }); 269 270 271 // Set side menu width for boxed layout 272 bentoSideMenuWidth(); 273 274 275 // Side menu scrollable if too high 276 if ( bentoThemeVars.menu_config == 3 ) { 277 var $bento_header = $str('.header-side .site-header'); 278 var bento_headerHeight = $bento_header.outerHeight(true); 279 var bento_bodyHeight = $str(document).height(); 280 if ( bento_headerHeight > bento_bodyHeight ) { 281 $bento_header.addClass('header-side-high'); 282 } 283 } 284 285 286}); 287 288 289$str(window).load(function () { 290 291 292 // Scroll to the correct position for hash URLs 293 if ( window.location.hash ) { 294 var bento_cleanhash = window.location.hash.substr(1); 295 if ( $str('#' + bento_cleanhash).length ) { 296 var bento_headerHeight = 0; 297 if ( bentoThemeVars.fixed_menu == 1 ) { 298 bento_headerHeight = $str('.site-header').outerHeight(true); 299 } 300 scrollPosition = $str('#' + bento_cleanhash).offset().top - bento_headerHeight - 10; 301 $str('html, body').animate( { scrollTop: scrollPosition }, 1 ); 302 } 303 } 304 305 306 // Same-page menu links 307 var bento_op_menu = bentoOnePage(); 308 if ( ! $str.isEmptyObject(bento_op_menu) ) { 309 $str('.primary-menu li, .primary-mobile-menu li').removeClass('current-menu-item'); 310 } 311 $str('.primary-menu li a[href*="#"]').on( 'click', function(e) { 312 if ( this.pathname === window.location.pathname ) { 313 e.stopPropagation(); 314 e.preventDefault(); 315 if ( $str('body').hasClass('mobile-menu-open') ) { 316 $str('body').removeClass('mobile-menu-open'); 317 } 318 var headerHeight = 0; 319 if ( bentoThemeVars.fixed_menu == 1 ) { 320 headerHeight = $str('.site-header').outerHeight(true); 321 } 322 var hash = $str(this).attr('href').substring($str(this).attr('href').indexOf('#')+1); 323 var itemPos = $str('#' + hash).offset().top - headerHeight - 10; 324 $str('html, body').animate( { scrollTop: itemPos }, 500, function() { 325 $str('.mobile-menu-shadow').fadeOut(500); 326 $str('#nav-mobile').css("left", '-100%'); 327 }); 328 } 329 }); 330 331 332}); 333 334 335$str(window).resize(function () { 336 337 338 // Set overlay menu margin 339 if ( bentoThemeVars.menu_config == 2 ) { 340 var $bento_menu = $str('#nav-primary'); 341 var bento_menuHeight = 0; 342 if ( $bento_menu.outerHeight(false) > 0 ) { 343 bento_menuHeight = $bento_menu.outerHeight(false); 344 } 345 var bento_menuMargin = ( $str(window).height() - bento_menuHeight ) / 2; 346 $bento_menu.css('margin-top',bento_menuMargin+'px'); 347 } 348 349 350 // Set side menu width for boxed layout 351 bentoSideMenuWidth(); 352 353 354}); 355 356 357$str(window).scroll(function () { 358 359 360 // Side menu on scroll 361 if ( bentoThemeVars.menu_config == 3 ) { 362 var $bento_header = $str('.header-side .site-header'); 363 var bento_windowPos = $str(window).scrollTop(); 364 var bento_headertop = parseInt($bento_header.css('top'),10); 365 var bento_windowHeight = $str(window).height(); 366 var bento_headerHeight = $bento_header.outerHeight(true); 367 var bento_bodyHeight = $str(document).height(); 368 var bento_coef = 1; 369 if ( bento_headerHeight > bento_windowHeight ) { 370 var bento_headerDiff = bento_headerHeight - bento_windowHeight; 371 if ( bento_headerDiff * 2 < bento_bodyHeight - bento_windowHeight ) { 372 bento_coef = 2; 373 } 374 if ( bento_windowPos > bento_lastwindowPos ) { 375 if ( bento_headertop >= -bento_headerDiff ) { 376 bento_headertop = bento_headertop - ( ( bento_windowPos - bento_lastwindowPos ) / bento_coef ); 377 } 378 if ( bento_windowHeight + bento_windowPos >= bento_bodyHeight ) { 379 bento_headertop = -bento_headerDiff; 380 } 381 } else { 382 if ( bento_windowPos == 0 || bento_headertop >= bento_adminbarHeight ) { 383 bento_headertop = bento_adminbarHeight; 384 } else { 385 bento_headertop = bento_headertop + ( ( bento_lastwindowPos - bento_windowPos ) / bento_coef ); 386 } 387 } 388 } 389 $bento_header.css('top',bento_headertop+'px'); 390 bento_lastwindowPos = bento_windowPos; 391 } 392 393 394 // Fixed header on scroll 395 if ( bentoThemeVars.fixed_menu == 1 && bentoThemeVars.menu_config != 3 && $str(window).width() > bentoEmValue(64) ) { 396 var topbar = 0; 397 if ( $str('.bnt-topbar').length ) { 398 topbar = $str('.bnt-topbar').outerHeight(true); 399 } 400 if ( $str(window).scrollTop() > topbar ) { 401 if ( ! $str('.fixed-header').length ) { 402 var $bento_headerClone = $str('.site-header > .bnt-container').clone(true); 403 $str('.site-wrapper').append('<header class="site-header fixed-header"></header>'); 404 $str('.fixed-header').html($bento_headerClone).fadeIn(600); 405 } 406 } else { 407 if ( $str('.fixed-header').length ) { 408 $str('.fixed-header').remove(); 409 } 410 } 411 } 412 413 414 // Same-page menu links on scroll 415 var bento_op_menu = bentoOnePage(); 416 var activeParent = ''; 417 var activeParentPrev = ''; 418 if ( ! $str.isEmptyObject(bento_op_menu) ) { 419 var currentPosition = $str(window).scrollTop(); 420 $str.each( bento_op_menu, function( ind, val ) { 421 val = val - 10; 422 if ( currentPosition >= val ) { 423 activeParent = ind; 424 } 425 }); 426 if ( activeParent != '' && activeParent != activeParentPrev ) { 427 $str('.'+activeParent).addClass('current-menu-item'); 428 $str('.primary-menu li:not(".'+activeParent+'"),.primary-mobile-menu li:not(".'+activeParent+'")').removeClass('current-menu-item'); 429 var activeParentPrev = activeParent; 430 } 431 } 432 433 434});
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.