1/*****************************************************************/ 2/* 5grid 0.4.3 by n33.co | MIT+GPLv2 license licensed */ 3/* init.js: Init script */ 4/*****************************************************************/ 5 6/*********************/ 7/* Settings */ 8/*********************/ 9 10 var _5grid_settings = { 11 breakpoint_1000px: 1200, 12 breakpoint_mobile: 480, 13 prefix: 'style', 14 use: 'mobile,desktop', 15 viewport_is1000px: 1040, 16 viewport_is1200px: 1280, 17 //////////////////////////////////////////////////////// 18 mobileUI: 0, 19 mobileUI_hideAddressBar: 0, 20 mobileUI_openerText: '=', 21 mobileUI_openerWidth: 60, 22 mobileUI_slideSpeed: 200, 23 mobileUI_theme: 'modern', 24 mobileUI_themeNavColor: '#1f1f1f', 25 mobileUI_themeTitleBarColor: '#444444', 26 mobileUI_titleBarFixed: 1, 27 mobileUI_titleBarHeight: 44, 28 mobileUI_titleBarOverlaid: 0, 29 //////////////////////////////////////////////////////// 30 mobileUI_navInnerPad: 0, 31 mobileUI_force: 0, 32 mobileUI_tapDelay: 200, 33 mobileUI_orientationDelay: 0, 34 debug_noExtLoad: 0 35 }; 36 37/*********************/ 38/* Helper plugins */ 39/*********************/ 40 41 /* jQuery resize event - v1.1 - 3/14/2010 http://benalman.com/projects/jquery-resize-plugin/ | Copyright (c) 2010 "Cowboy" Ben Alman | Dual licensed under the MIT and GPL licenses. | http://benalman.com/about/license/ */ 42 (function(jQuery,h,c){var a=jQuery([]),e=jQuery.resize=jQuery.extend(jQuery.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;jQuery.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=jQuery(this);a=a.add(l);jQuery.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=jQuery(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=jQuery(this),r=jQuery.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if(jQuery.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=jQuery(this),m=n.width(),l=n.height(),o=jQuery.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this); 43 44/*********************/ 45/* Object Setup */ 46/*********************/ 47 48 var _5gridC = function() 49 { 50 this.events = new Array(); 51 this.readyWait = false; 52 53 this.isReady = false; 54 this.isMobile = false; 55 this.isDesktop = false; 56 this.isFluid = false; 57 this.is1000px = false; 58 this.is1200px = false; 59 } 60 61 _5gridC.prototype.bind = function(name, f) 62 { 63 if (!this.events[name]) 64 this.events[name] = new Array(); 65 66 this.events[name].push(f); 67 } 68 69 _5gridC.prototype.trigger = function(name) 70 { 71 if (!this.isReady || !this.events[name] || this.events[name].length < 1) 72 return; 73 74 for (i in this.events[name]) 75 (this.events[name][i])(); 76 } 77 78 _5gridC.prototype.ready = function(f, wait) { 79 if (wait) 80 this.readyWait = true; 81 82 this.bind('ready', f); 83 } 84 85 // Custom events 86 _5gridC.prototype.orientationChange = function(f) { this.bind('orientationChange', f); } 87 _5gridC.prototype.mobileUINavOpen = function(f) { this.bind('mobileUINavOpen', f); } 88 _5gridC.prototype.mobileUINavClose = function(f) { this.bind('mobileUINavClose', f); } 89 90 _5gridC.prototype.readyCheck = function() 91 { 92 var x = this; 93 94 window.setTimeout(function() { 95 if (x.isReady) 96 x.trigger('ready'); 97 else 98 x.readyCheck(); 99 }, 50); 100 } 101 102 var _5grid = new _5gridC; 103 104 105(function() { 106 107/*********************/ 108/* Initialize */ 109/*********************/ 110 111 // Vars 112 var _settings = _5grid_settings, 113 _window = jQuery(window), 114 _head = jQuery('head'), 115 _document = jQuery(document); 116 var baseURL, 117 doFluid, do1000px, do1200px, doMobile, doDesktop, doMobileOnly,
118 isLocked = false, 119 isTapLocked = false, tapId, 120 isTouch = !!('ontouchstart' in window), 121 headQueue = new Array(); 122 var v, w, wk, wv, x, y; 123 124 // Tap handling 125 jQuery.fn.tap_5grid = function(f, suffix, noMove) { 126 var target = jQuery(this); 127 128 if (isTouch) 129 { 130 target 131 .bind('touchstart' + (suffix ? '.' + suffix : ''), function() { 132 if (!isTapLocked) 133 { 134 isTapLocked = true; 135 if (_settings.mobileUI_tapDelay > -1) 136 tapId = window.setTimeout(function() { window.clearTimeout(tapId); isTapLocked = false; }, _settings.mobileUI_tapDelay); 137 } 138 }) 139 .bind('touchend' + (suffix ? '.' + suffix : ''), function(e) { 140 if (isTapLocked) 141 { 142 isTapLocked = false; 143 window.clearTimeout(tapId); 144 (f)(e); 145 } 146 }); 147 148 if (noMove) 149 target 150 .bind('touchmove' + (suffix ? '.' + suffix : ''), function(e) { 151 isTapLocked = false; 152 window.clearTimeout(tapId); 153 }); 154 155 } 156 else 157 target.bind('click' + (suffix ? '.' + suffix : ''), f); 158 159 return target; 160 }; 161 162 jQuery.fn.untap_5grid = function(suffix) { 163 var target = jQuery(this); 164 165 if (isTouch) 166 { 167 target 168 .unbind('touchstart' + (suffix ? '.' + suffix : '')) 169 .unbind('touchend' + (suffix ? '.' + suffix : '')) 170 .unbind('touchmove' + (suffix ? '.' + suffix : '')); 171 } 172 else 173 target.unbind('click' + (suffix ? '.' + suffix : '')); 174 175 return target; 176 }; 177 178 // Shortcut methods 179 headQueue.pushI_5grid = function(s) { headQueue.push({ type: 'i', value: s }); }; 180 headQueue.pushE_5grid = function(s) { headQueue.push({ type: 'e', value: s }); }; 181 headQueue.process_5grid = function() { 182 var doE; 183 if (document.createStyleSheet) 184 doE = function(s) { document.createStyleSheet(s); }; 185 else 186 doE = function(s) { _head.append('<link rel="stylesheet" href="' + s + '" />'); }; 187 188 for (x in headQueue) 189 { 190 if (headQueue[x].type == 'i') 191 _head.append('<style>' + headQueue[x].value + '</style>'); 192 else if (headQueue[x].type == 'e') 193 (doE)(headQueue[x].value); 194 } 195 }; 196 jQuery.fn.disableSelection_5grid = function() { return jQuery(this).css('user-select', 'none').css('-khtml-user-select', 'none').css('-moz-user-select', 'none').css('-o-user-select', 'none').css('-webkit-user-select', 'none'); } 197 jQuery.fn.enableSelection_5grid = function() { return jQuery(this).css('user-select', 'auto').css('-khtml-user-select', 'auto').css('-moz-user-select', 'auto').css('-o-user-select', 'auto').css('-webkit-user-select', 'auto'); } 198 jQuery.fn.accelerate_5grid = function() { return jQuery(this).css('-webkit-transform', 'translateZ(0)').css('-webkit-backface-visibility', 'hidden').css('-webkit-perspective', '500'); } 199 200 // Determine settings 201 // DOM fix 202 document.getElementsByTagName('script'); 203 204 // Get base URL, query string 205 x = jQuery('script').filter(function() { return this.src.match(/5grid\/init\.js/); }).first(); 206 y = x.attr('src').split('?'); 207 baseURL = y[0].replace(/5grid\/init\.js/, ''); 208 209 // Override settings 210 if (y.length > 1) 211 { 212 x = y[1].split('&'); 213 for (v in x) 214 { 215 w = x[v].split('='); 216 wk = w[0].replace(/\./, '_'); 217 wv = w[1]; 218 219 // Thanks, @cmsalvado! :) 220 if (!isNaN(parseFloat(wv)) && isFinite(wv)) 221 wv = parseInt(wv); 222 223 _settings[wk] = wv; 224 } 225 } 226 227 // Debug settings 228 if (_settings.debug_noExtLoad == 1) 229 headQueue.pushE_5grid = function(s) { }; 230 231 // Determine viewing modes 232 doDesktop = doMobile = doFluid = do1000px = do1200px = doMobileOnly = false; 233 v = _settings.use.split(','); 234 235 if (jQuery.inArray('fluid', v) > -1) 236 doFluid = true; 237 if (jQuery.inArray('desktop', v) > -1) 238 doDesktop = true; 239 if (jQuery.inArray('1000px', v) > -1) 240 do1000px = true; 241 if (jQuery.inArray('1200px', v) > -1) 242 do1200px = true; 243 if (jQuery.inArray('mobile', v) > -1) 244 doMobile = true; 245 246 if (doMobile && !doFluid && !do1000px && !do1200px && !doDesktop) 247 doMobileOnly = true; 248 249 // Apply workarounds for broken/old browsers 250 251 // Android, Webkit <= 534
252 if (navigator.userAgent.match(/Android.+AppleWebKit\/534/)) 253 { 254 _settings.mobileUI_titleBarFixed = 0; 255 _settings.mobileUI_orientationDelay = 750; 256 } 257 258 // iOS <= 5 259 if (navigator.userAgent.match(/([0-9]+)_([0-9\.\_]+) like Mac OS X/)) 260 { 261 var version = RegExp.$1; 262 263 if (version <= 5) 264 _settings.mobileUI_titleBarFixed = 0; 265 } 266 267 // IE <= 8 268 if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) 269 { 270 var version = RegExp.$1; 271 272 // HTML5 Shiv 273 if (version < 9) 274 _head.append('<script type="text/javascript" src="' + baseURL + '5grid/html5shiv.js" />'); 275 276 // Versions that don't support CSS3 pseudo classes 277 if (version < 8) 278 { 279 jQuery(function() { 280 jQuery('.5grid, .5grid-layout, .do-5grid').after('<div style="clear: both;"></div>'); 281 jQuery('.5grid-layout').css('position', 'relative'); 282 jQuery('.5grid, .do-5grid').css('position', 'relative'); 283 jQuery('.5grid > .row > :first-child, .5grid-layout > .row > :first-child, .do-5grid > .row > :first-child').css('margin-left', '0'); 284 jQuery('.5grid > .row:first-child, .5grid-layout > .row:first-child, .do-5grid > .row:first-child').css('margin-top', '0'); 285 jQuery('.5grid > .row:last-child, .5grid-layout > .row:last-child, .do-5grid > .row:last-child').css('margin-bottom', '0'); 286 }); 287 } 288 } 289 290 // Insert stylesheets 291 headQueue.pushE_5grid(baseURL + '5grid/core.css') 292 headQueue.pushE_5grid(baseURL + _settings.prefix + '.css'); 293 294/*********************/ 295/* Responsive */ 296/*********************/ 297 298 (function() { 299 var ww = _window.width(), 300 sw = screen.width, 301 orientation = window.orientation, 302 devicePixelRatio = (window.devicePixelRatio ? window.devicePixelRatio : 1); 303 304 // Adjustments 305 // Scale breakpoints using device pixel ratio 306 _settings.breakpoint_1000px = _settings.breakpoint_1000px * devicePixelRatio; 307 _settings.breakpoint_mobile = _settings.breakpoint_mobile * devicePixelRatio; 308 309 // Always use device's width regardless of orientation 310 if (screen.width > screen.height 311 && Math.abs(orientation) == 90) 312 sw = screen.height; 313 314 // Get real screen width on iOS devices 315 if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) 316 sw = sw * devicePixelRatio; 317 318 // Mobile (exclusive) 319 if ((doMobile && (ww <= _settings.breakpoint_mobile || sw <= _settings.breakpoint_mobile)) || doMobileOnly) 320 { 321 _5grid.isMobile = true; 322 _head.prepend('<meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />'); 323 headQueue.pushE_5grid(baseURL + '5grid/core-mobile.css'); 324 325 if (_settings.mobileUI == 1) 326 { 327 _settings.mobileUI_force = 1; 328 329 if (_settings.mobileUI_theme != 'none') 330 { 331 headQueue.pushE_5grid(baseURL + '5grid/mobileUI-' + _settings.mobileUI_theme + '.css'); 332 333 if (_settings.mobileUI_themeTitleBarColor) 334 headQueue.pushI_5grid('#mobileUI-site-titlebar { background-color: ' + _settings.mobileUI_themeTitleBarColor + '; }'); 335 336 if (_settings.mobileUI_themeNavColor) 337 headQueue.pushI_5grid('#mobileUI-site-nav { background-color: ' + _settings.mobileUI_themeNavColor + '; }'); 338 } 339 } 340 341 headQueue.pushE_5grid(baseURL + _settings.prefix + '-mobile.css'); 342 } 343 // Other 344 else 345 { 346 // Fluid (exclusive) 347 if (doFluid) 348 { 349 _5grid.isFluid = true; 350 _head.prepend('<meta name="viewport" content="width=' + _settings.viewport_is1200px + '" />'); 351 headQueue.pushE_5grid(baseURL + '5grid/core-desktop.css'); 352 headQueue.pushE_5grid(baseURL + '5grid/core-fluid.css'); 353 headQueue.pushE_5grid(baseURL + _settings.prefix + '-fluid.css'); 354 } 355 // Desktop 356 else if (doDesktop) 357 { 358 _5grid.isDesktop = true; 359 headQueue.pushE_5grid(baseURL + '5grid/core-desktop.css'); 360 headQueue.pushE_5grid(baseURL + _settings.prefix + '-desktop.css'); 361 362 // 1200px 363 if (ww >= _settings.breakpoint_1000px) 364 { 365 _5grid.is1200px = true; 366 _head.prepend('<meta name="viewport" content="width=' + _settings.viewport_is1200px + '" />');
367 headQueue.pushE_5grid(baseURL + '5grid/core-1200px.css'); 368 369 // Load 1200px stylesheet if 1200px was explicitly enabled 370 if (do1200px) 371 headQueue.pushE_5grid(baseURL + _settings.prefix + '-1200px.css'); 372 } 373 // 1000px 374 else 375 { 376 _5grid.is1000px = true; 377 _head.prepend('<meta name="viewport" content="width=' + _settings.viewport_is1000px + '" />'); 378 headQueue.pushE_5grid(baseURL + '5grid/core-1000px.css'); 379 380 // Load 1000px stylesheet if 1000px was explicitly enabled 381 if (do1000px) 382 headQueue.pushE_5grid(baseURL + _settings.prefix + '-1000px.css'); 383 } 384 } 385 // Other 386 else 387 { 388 // 1000px (exclusive) 389 if (do1000px && (ww < _settings.breakpoint_1000px || !do1200px)) 390 { 391 _5grid.isDesktop = true; 392 _5grid.is1000px = true; 393 _head.prepend('<meta name="viewport" content="width=' + _settings.viewport_is1000px + '" />'); 394 headQueue.pushE_5grid(baseURL + '5grid/core-desktop.css'); 395 headQueue.pushE_5grid(baseURL + '5grid/core-1000px.css'); 396 headQueue.pushE_5grid(baseURL + _settings.prefix + '-1000px.css'); 397 } 398 // 1200px (exclusive) 399 else if (do1200px && (ww >= _settings.breakpoint_1000px || !do1000px)) 400 { 401 _5grid.isDesktop = true; 402 _5grid.is1200px = true; 403 _head.prepend('<meta name="viewport" content="width=' + _settings.viewport_is1200px + '" />'); 404 headQueue.pushE_5grid(baseURL + '5grid/core-desktop.css'); 405 headQueue.pushE_5grid(baseURL + '5grid/core-1200px.css'); 406 headQueue.pushE_5grid(baseURL + _settings.prefix + '-1200px.css'); 407 } 408 } 409 } 410 411 jQuery(function() { 412 var _body = jQuery('body'); 413 414 if (_5grid.isFluid) 415 _body.addClass('is-fluid'); 416 if (_5grid.isDesktop) 417 _body.addClass('is-desktop'); 418 if (_5grid.is1000px) 419 _body.addClass('is-1000px'); 420 if (_5grid.is1200px) 421 _body.addClass('is-1200px'); 422 if (_5grid.isMobile) 423 _body.addClass('is-mobile'); 424 425 jQuery('.5grid-layout').addClass('5grid'); 426 }); 427 })(); 428 429/*********************/ 430/* MobileUI */ 431/*********************/ 432 433 if (_settings.mobileUI_force == 1) 434 jQuery(function() { 435 var _body = jQuery('body'), 436 _viewer, 437 _wrapper, 438 _nav, 439 _nav_inner, 440 _opener, 441 _titlebar, 442 _content; 443 var speed = _settings.mobileUI_slideSpeed, 444 easing = 'swing', 445 ww = _window.width(), 446 wh = _window.height(), 447 _nav_isActing = false, 448 _nav_isOpen = false; 449 450 _body.wrapInner('<div id="mobileUI-site-content" />'); 451 _body.wrapInner('<div id="mobileUI-site-wrapper" />'); 452 _body.wrapInner('<div id="mobileUI-site-viewer" />'); 453 454 // Move primary content 455 var _main_content = jQuery('.mobileUI-main-content'), 456 _main_content_target = jQuery('.mobileUI-main-content-target'); 457 458 if (_main_content.length > 0) 459 if (_main_content_target.length > 0) 460 _main_content.prependTo(_main_content_target); 461 else 462 _main_content.prependTo(_main_content.parent()); 463 464 // Get site name, nav options 465 var x = jQuery('.mobileUI-site-name'), site_name = (x.length > 0 ? x.html() : ''), 466 site_nav_options = new Array(); 467 468 jQuery('.mobileUI-site-nav a').each(function() { 469 var t = jQuery(this), indent; 470 indent = Math.max(0,t.parents('li').length - 1); 471 site_nav_options.push( 472 '<div class="mobileUI-site-nav-link mobileUI-site-nav-link-depth-' + indent + '" xhref="' + t.attr('href') + '"><span class="indent-' + indent + '"></span>' + t.text() + '</div>' 473 ); 474 }); 475 476 // Configure elements 477 if (site_nav_options.length > 0) 478 { 479 _nav_inner = jQuery('<div id="mobileUI-site-nav-inner"><nav>' + site_nav_options.join('') + '</nav></div>'); 480 _nav = jQuery('<div id="mobileUI-site-nav"></div>'); 481 _nav_inner.appendTo(_nav); 482 _opener = jQuery('<div id="mobileUI-site-nav-opener">' + _settings.mobileUI_openerText + '</div>'); 483 } 484 else 485 { 486 _nav_inner = jQuery(); 487 _nav = jQuery(); 488 _opener = jQuery(); 489 } 490 491 _content = jQuery('#mobileUI-site-content'); 492 _titlebar = jQuery('<div id="mobileUI-site-titlebar"><div id="mobileUI-site-title">' + site_name + '</div></div>'); 493 _wrapper = jQuery('#mobileUI-site-wrapper'); 494 _viewer = jQuery('#mobileUI-site-viewer'); 495 496 var _nav_width = ww - _settings.mobileUI_openerWidth, 497 _nav_inner_pos, 498 _content_width = ww, 499 _wrapper_width = _nav_width + _content_width; 500 501 // Wrapper 502 _wrapper 503 .accelerate_5grid() 504 .css('position', 'absolute') 505 .width(_wrapper_width); 506 507 // Nav 508 _nav 509 .accelerate_5grid() 510 .width(_nav_width) 511 .prependTo(_wrapper) 512 .css('position', 'absolute') 513 .css('left', (-1 * _nav_width)) 514 .prepend('<div style="position: absolute; top: 0px; right: -1px; width: 1px; height: 1px;"></div>'); 515 516 // Inner 517 _nav_inner 518 .css('overflow', (isTouch ? 'hidden' : 'auto')) 519 .bind('touchstart', function(e) { 520 _nav_inner_pos = _nav_inner.scrollTop() + e.originalEvent.touches[0].pageY; 521 }) 522 .bind('touchmove', function(e) { 523 e.preventDefault(); 524 e.stopPropagation(); 525 _nav_inner.scrollTop(_nav_inner_pos - e.originalEvent.touches[0].pageY); 526 }); 527 528 // Links 529 _nav.find('.mobileUI-site-nav-link') 530 .disableSelection_5grid() 531 .css('cursor', 'pointer') 532 .each(function() { 533 var t = jQuery(this); 534 t.tap_5grid(function(e) { 535 e.preventDefault(); 536 e.stopPropagation(); 537 538 if (_nav_isOpen) 539 { 540 var href = t.attr('xhref'); 541 if (href && href.length > 0) 542 _body.trigger('5grid_closeNav', [href]); 543 } 544 }); 545 }); 546 547 // Opener 548 _opener 549 .accelerate_5grid() 550 .css('position', 'absolute') 551 .css('z-index', 10001) 552 .css('cursor', 'pointer') 553 .disableSelection_5grid() 554 .appendTo(_titlebar) 555 .tap_5grid(function(e) { 556 e.stopPropagation(); 557 e.preventDefault(); 558 _body.trigger('5grid_toggleNav'); 559 }, '', true); 560 561 // Titlebar 562 _titlebar 563 .accelerate_5grid() 564 .width(_content_width) 565 .height(_settings.mobileUI_titleBarHeight) 566 .css('z-index', 10000) 567 .prependTo(_viewer); 568 569 if (_settings.mobileUI_titleBarFixed) 570 { 571 _titlebar 572 .bind('goActive_5grid', function() { 573 _titlebar 574 .css('position', 'fixed') 575 .css('top', 0) 576 .css('left', 0); 577 }) 578 .bind('goInactive_5grid', function() { 579 _titlebar 580 .css('position', 'absolute') 581 .css('top', _window.scrollTop()) 582 .css('left', _nav.width); 583 }) 584 .trigger('goActive_5grid'); 585 } 586 else 587 { 588 _titlebar 589 .css('position', 'absolute') 590 .css('top', _window.scrollTop()) 591 .css('left', _nav.width); 592 } 593 594 // Content 595 _content 596 .width(_content_width) 597 .css('position', 'relative'); 598 599 if (_settings.mobileUI_titleBarOverlaid) 600 _content 601 .bind('resize', function() { _viewer.height(_content.height()); }); 602 else 603 _content 604 .css('padding-top', _settings.mobileUI_titleBarHeight) 605 .bind('resize', function() { _viewer.height(_content.height() + _settings.mobileUI_titleBarHeight); }); 606 607 // Viewer 608 _viewer 609 .css('position', 'absolute') 610 .css('overflow', 'hidden') 611 .width(_content_width) 612 .height(_content.height() + _settings.mobileUI_titleBarHeight); 613 614 // Body 615 _body 616 .bind('5grid_toggleNav', function() { 617 if (_nav_isOpen) 618 _body.trigger('5grid_closeNav'); 619 else 620 _body.trigger('5grid_openNav'); 621 }) 622 .bind('5grid_openNav', function() { 623 624 // Check locking 625 if (isLocked) 626 return true; 627
628 isLocked = true; 629 630 // Mark nav as acting 631 _nav_isActing = true; 632 633 // Disable scrolling 634 _body 635 .bind('touchstart.5grid_nav_block', function(e) { 636 e.stopPropagation(); 637 e.preventDefault(); 638 }); 639 640 _window 641 .bind('scroll.5grid_nav_block', function(e) { 642 e.preventDefault(); 643 e.stopPropagation(); 644 645 if (_nav_isOpen) 646 _body.trigger('5grid_closeNav', [null, true]); 647 }); 648 649 // Reposition nav 650 _nav 651 .css('top', _window.scrollTop()); 652 653 _nav_inner 654 .height(window.innerHeight - _settings.mobileUI_navInnerPad) 655 .scrollTop(0); 656 657 // Deactivate titlebar 658 _titlebar 659 .trigger('goInactive_5grid'); 660 661 // Animate 662 _wrapper.add(_titlebar) 663 .animate({ left: _nav_width }, speed, easing, function() { 664 // Unlock 665 isLocked = false; 666 667 // Correct body position (in case it was still scrolling when the nav opened) 668 var x = parseInt(_nav.css('top')); 669 if (x > 0) 670 _window.scrollTop(parseInt(_nav.css('top'))); 671 672 // Mark nav as open, unmark as acting 673 window.setTimeout(function() { 674 _nav_isOpen = true; 675 _nav_isActing = false; 676 }, 300); 677 678 // Add close event to content 679 _content 680 .tap_5grid(function(e) { 681 e.preventDefault(); 682 e.stopPropagation(); 683 _body.trigger('5grid_closeNav'); 684 }, '5grid_nav_cclose'); 685 686 // Trigger event 687 _5grid.trigger('mobileUINavOpen'); 688 }); 689 }) 690 .bind('5grid_closeNav', function(e, url, fast) { 691 692 // Check locking 693 if (isLocked) 694 return true; 695 696 isLocked = true; 697 698 // Mark nav as acting 699 _nav_isActing = true; 700 701 // Remove close event from content 702 _content.untap_5grid('5grid_nav_cclose'); 703 704 // Animate 705 _wrapper.add(_titlebar) 706 .animate({ left: 0 }, (fast ? 0 : speed), easing, function() { 707 708 // Reactivate titlebar 709 _titlebar 710 .trigger('goActive_5grid'); 711 712 // Trigger event 713 _5grid.trigger('mobileUINavclose'); 714 715 // Unlock 716 isLocked = false; 717 718 // Re-enable scrolling 719 _body.unbind('touchstart.5grid_nav_block'); 720 _window.unbind('touchmove.5grid_nav_block'); 721 722 // Mark nav as closed, unmark as acting 723 _nav_isOpen = false; 724 _nav_isActing = false; 725 726 // If a URL was passed, go to it 727 if (url) 728 window.setTimeout(function() { 729 window.location.href = url; 730 }, 150); 731 }); 732 }); 733 734 // Window 735 _window 736 .bind('orientationchange', function(e) { 737 window.setTimeout(function() { 738 ww = _window.width(); 739 740 // Recalculate widths 741 _nav_width = ww - _settings.mobileUI_openerWidth; 742 _content_width = ww; 743 _wrapper_width = _nav_width + _content_width; 744 745 // Resize 746 _wrapper.width(_wrapper_width); 747 _content.width(_content_width); 748 _nav 749 .css('left', (-1 * _nav_width)) 750 .width(_nav_width); 751 752 _titlebar.width(ww); 753 _viewer.width(ww); 754 755 // Trigger event 756 _5grid.trigger('orientationChange'); 757 758 }, _settings.mobileUI_orientationDelay); 759 }); 760 761 // Remove mobileUI-hide elements 762 jQuery('.mobileUI-hide').remove(); 763 764 // Remove address bar 765 if (_settings.mobileUI_hideAddressBar == 1) 766 _window.load(function() { 767 if (_window.scrollTop() == 0) 768 window.scrollTo(0, 1); 769 }); 770 }); 771 772/*********************/ 773/* Head Queue */ 774/*********************/ 775 776 headQueue.process_5grid(); 777 _5grid.isReady = true; 778 779 jQuery(function() { 780 if (_5grid.readyWait) 781 jQuery(window).load(function() { _5grid.readyCheck(); }); 782 else 783 _5grid.readyCheck(); 784 }); 785 786})();
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.