1/* 2 * jQuery Superfish Menu Plugin - v1.7.4 3 * Copyright (c) 2013 Joel Birch 4 * 5 * Dual licensed under the MIT and GPL licenses: 6 * http://www.opensource.org/licenses/mit-license.php 7 * http://www.gnu.org/licenses/gpl.html 8 */ 9 10 ;(function(e){"use strict";var s=function(){var s={bcClass:"sf-breadcrumb",menuClass:"sf-js-enabled",anchorClass:"sf-with-ul",menuArrowClass:"sf-arrows"},o=function(){var s=/iPhone|iPad|iPod/i.test(navigator.userAgent);return s&&e(window).on('load', function(){e("body").children().on("click",e.noop)}),s}(),n=function(){var e=document.documentElement.style;return"behavior"in e&&"fill"in e&&/iemobile/i.test(navigator.userAgent)}(),t=function(e,o){var n=s.menuClass;o.cssArrows&&(n+=" "+s.menuArrowClass),e.toggleClass(n)},i=function(o,n){return o.find("li."+n.pathClass).slice(0,n.pathLevels).addClass(n.hoverClass+" "+s.bcClass).filter(function(){return e(this).children(n.popUpSelector).hide().show().length}).removeClass(n.pathClass)},r=function(e){e.children("a").toggleClass(s.anchorClass)},a=function(e){var s=e.css("ms-touch-action");s="pan-y"===s?"auto":"pan-y",e.css("ms-touch-action",s)},l=function(s,t){var i="li:has("+t.popUpSelector+")";e.fn.hoverIntent&&!t.disableHI?s.hoverIntent(u,p,i):s.on("mouseenter.superfish",i,u).on("mouseleave.superfish",i,p);var r="MSPointerDown.superfish";o||(r+=" touchend.superfish"),n&&(r+=" mousedown.superfish"),s.on("focusin.superfish","li",u).on("focusout.superfish","li",p).on(r,"a",t,h)},h=function(s){var o=e(this),n=o.siblings(s.data.popUpSelector);n.length>0&&n.is(":hidden")&&(o.one("click.superfish",!1),"MSPointerDown"===s.type?o.trigger("focus"):e.proxy(u,o.parent("li"))())},u=function(){var s=e(this),o=d(s);clearTimeout(o.sfTimer),s.siblings().superfish("hide").end().superfish("show")},p=function(){var s=e(this),n=d(s);o?e.proxy(f,s,n)():(clearTimeout(n.sfTimer),n.sfTimer=setTimeout(e.proxy(f,s,n),n.delay))},f=function(s){s.retainPath=e.inArray(this[0],s.$path)>-1,this.superfish("hide"),this.parents("."+s.hoverClass).length||(s.onIdle.call(c(this)),s.$path.length&&e.proxy(u,s.$path)())},c=function(e){return e.closest("."+s.menuClass)},d=function(e){return c(e).data("sf-options")};return{hide:function(s){if(this.length){var o=this,n=d(o);if(!n)return this;var t=n.retainPath===!0?n.$path:"",i=o.find("li."+n.hoverClass).add(this).not(t).removeClass(n.hoverClass).children(n.popUpSelector),r=n.speedOut;s&&(i.show(),r=0),n.retainPath=!1,n.onBeforeHide.call(i),i.stop(!0,!0).animate(n.animationOut,r,function(){var s=e(this);n.onHide.call(s)})}return this},show:function(){var e=d(this);if(!e)return this;var s=this.addClass(e.hoverClass),o=s.children(e.popUpSelector);return e.onBeforeShow.call(o),o.stop(!0,!0).animate(e.animation,e.speed,function(){e.onShow.call(o)}),this},destroy:function(){return this.each(function(){var o,n=e(this),i=n.data("sf-options");return i?(o=n.find(i.popUpSelector).parent("li"),clearTimeout(i.sfTimer),t(n,i),r(o),a(n),n.off(".superfish").off(".hoverIntent"),o.children(i.popUpSelector).attr("style",function(e,s){return s.replace(/display[^;]+;?/g,"")}),i.$path.removeClass(i.hoverClass+" "+s.bcClass).addClass(i.pathClass),n.find("."+i.hoverClass).removeClass(i.hoverClass),i.onDestroy.call(n),n.removeData("sf-options"),void 0):!1})},init:function(o){return this.each(function(){var n=e(this);if(n.data("sf-options"))return!1;var h=e.extend({},e.fn.superfish.defaults,o),u=n.find(h.popUpSelector).parent("li");h.$path=i(n,h),n.data("sf-options",h),t(n,h),r(u),a(n),l(n,h),u.not("."+s.bcClass).superfish("hide",!0),h.onInit.call(this)})}}}();e.fn.superfish=function(o){return s[o]?s[o].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof o&&o?e.error("Method "+o+" does not exist on jQuery.fn.superfish"):s.init.apply(this,arguments)},e.fn.superfish.defaults={popUpSelector:"ul,.sf-mega",hoverClass:"sfHover",pathClass:"overrideThisToUse",pathLevels:1,delay:800,animation:{opacity:"show"},animationOut:{opacity:"hide"},speed:"normal",speedOut:"fast",cssArrows:!0,disableHI:!1,onInit:e.noop,onBeforeShow:e.noop,onShow:e.noop,onBeforeHide:e.noop,onHide:e.noop,onIdle:e.noop,onDestroy:e.noop}
10,e.fn.extend({hideSuperfishUl:s.hide,showSuperfishUl:s.show})})(jQuery); 11 12 /** 13 * jQuery Mobile Menu 14 * Turn unordered list menu into dropdown select menu 15 * version 1.0(31-OCT-2011) 16 * 17 * Built on top of the jQuery library 18 * http://jquery.com 19 * 20 * Documentation 21 * http://github.com/mambows/mobilemenu 22 */ 23 24 ;(function(e){e.fn.mobileMenu=function(t){var n={defaultText:"Navigate to...",className:"select-menu",subMenuClass:"sub-menu",subMenuDash:"–"},r=e.extend(n,t),i=e(this);this.each(function(){i.find("ul").addClass(r.subMenuClass);e("<select />",{"class":r.className,id:"menu-"+i.attr("id")}).insertAfter(i);e("<option />",{value:"#",text:r.defaultText}).appendTo("#menu-"+i.attr("id"));i.find("a, .separator").each(function(){var t=e(this),n=""+t.text(),s=t.parents("."+r.subMenuClass),o=s.length,u;if(t.parents("ul").hasClass(r.subMenuClass)){u=Array(o+1).join(r.subMenuDash);n=u+n}if(!t.hasClass("separator")){e("<option />",{value:this.href,html:n,selected:this.href==window.location.href}).appendTo("#menu-"+i.attr("id"))}else{e("<option />",{value:"#",html:n}).appendTo("#menu-"+i.attr("id"))}});e("."+r.className).change(function(){var t=e(this).val();if(t!=="#"){window.location.href=e(this).val()}})});return this}})(jQuery) 25 26 /** 27 * hoverIntent is similar to jQuery's built-in "hover" method except that 28 * instead of firing the handlerIn function immediately, hoverIntent checks 29 * to see if the user's mouse has slowed down (beneath the sensitivity 30 * threshold) before firing the event. The handlerOut function is only 31 * called after a matching handlerIn. 32 * 33 * hoverIntent r7 // 2013.03.11 // jQuery 1.9.1+ 34 * http://cherne.net/brian/resources/jquery.hoverIntent.html 35 * 36 * You may use hoverIntent under the terms of the MIT license. Basically that 37 * means you are free to use hoverIntent as long as this header is left intact. 38 * Copyright 2007, 2013 Brian Cherne 39 * 40 * // basic usage ... just like .hover() 41 * .hoverIntent( handlerIn, handlerOut ) 42 * .hoverIntent( handlerInOut ) 43 * 44 * // basic usage ... with event delegation! 45 * .hoverIntent( handlerIn, handlerOut, selector ) 46 * .hoverIntent( handlerInOut, selector ) 47 * 48 * // using a basic configuration object 49 * .hoverIntent( config ) 50 * 51 * @param handlerIn function OR configuration object 52 * @param handlerOut function OR selector for delegation OR undefined 53 * @param selector selector OR undefined 54 * @author Brian Cherne <brian(at)cherne(dot)net> 55 **/ 56 57 ;(function(e){e.fn.hoverIntent=function(t,n,r){var i={interval:100,sensitivity:7,timeout:0};if(typeof t==="object"){i=e.extend(i,t)}else if(e.isFunction(n)){i=e.extend(i,{over:t,out:n,selector:r})}else{i=e.extend(i,{over:t,out:t,selector:n})}var s,o,u,a;var f=function(e){s=e.pageX;o=e.pageY};var l=function(t,n){n.hoverIntent_t=clearTimeout(n.hoverIntent_t);if(Math.abs(u-s)+Math.abs(a-o)<i.sensitivity){e(n).off("mousemove.hoverIntent",f);n.hoverIntent_s=1;return i.over.apply(n,[t])}else{u=s;a=o;n.hoverIntent_t=setTimeout(function(){l(t,n)},i.interval)}};var c=function(e,t){t.hoverIntent_t=clearTimeout(t.hoverIntent_t);t.hoverIntent_s=0;return i.out.apply(t,[e])};var h=function(t){var n=jQuery.extend({},t);var r=this;if(r.hoverIntent_t){r.hoverIntent_t=clearTimeout(r.hoverIntent_t)}if(t.type=="mouseenter"){u=n.pageX;a=n.pageY;e(r).on("mousemove.hoverIntent",f);if(r.hoverIntent_s!=1){r.hoverIntent_t=setTimeout(function(){l(n,r)},i.interval)}}else{e(r).off("mousemove.hoverIntent",f);if(r.hoverIntent_s==1){r.hoverIntent_t=setTimeout(function(){c(n,r)},i.timeout)}}};return this.on({"mouseenter.hoverIntent":h,"mouseleave.hoverIntent":h},i.selector)}})(jQuery) 58 59 /* 60 * Supersubs v0.3b - jQuery plugin 61 * Copyright (c) 2013 Joel Birch 62 * 63 * Dual licensed under the MIT and GPL licenses: 64 * http://www.opensource.org/licenses/mit-license.php 65 * http://www.gnu.org/licenses/gpl.html 66 * 67 * 68 * This plugin automatically adjusts submenu widths of suckerfish-style menus to that of 69 * their longest list item children. If you use this, please expect bugs and report them 70 * to the jQuery Google Group with the word 'Superfish' in the subject line. 71 * 72 */ 73 74 ;(function(e){e.fn.supersubs=function(t){var n=e.extend({},e.fn.supersubs.defaults,t);return this.each(function(){var t=e(this);var r=e.meta?e.extend({},n,t.data()):n;$ULs=t.find("ul").show();var i=e('<li id="menu-fontsize">—</li>').css({padding:0,position:"absolute",top:"-999em",width:"auto"}).appendTo(t)[0].clientWidth;e("#menu-fontsize").remove();$ULs.each(function(t){var n=e(this);var s=n.children();var u=s.children("a");var a=s.css("white-space","nowrap").css("float");n.add(s).add(u).css({"float":"none",width:"auto"});var f=n[0].clientWidth/i;f+=r.extraWidth;
74if(f>r.maxWidth){f=r.maxWidth}else if(f<r.minWidth){f=r.minWidth}f+="em";n.css("width",f);s.css({"float":a,width:"100%","white-space":"normal"}).each(function(){var t=e(this).children("ul");var n=t.css("left")!==undefined?"left":"right";t.css(n,"100%")})}).hide()})};e.fn.supersubs.defaults={minWidth:9,maxWidth:25,extraWidth:0}})(jQuery) 75 76 /* 77 * sf-Touchscreen v1.0b - Provides touchscreen compatibility for the jQuery Superfish plugin. - LAST UPDATE: MARCH 23rd, 2011 78 * 79 * Developer's notes: 80 * Built as a part of the Superfish project for Drupal (http://drupal.org/project/superfish) 81 * Found any bug? have any cool ideas? contact me right away! http://drupal.org/user/619294/contact 82 * 83 * jQuery version: 1.3.x or higher. 84 * 85 * Dual licensed under the MIT and GPL licenses: 86 * http://www.opensource.org/licenses/mit-license.php 87 * http://www.gnu.org/licenses/gpl.html 88 */ 89 90 ;(function(e){e.fn.sftouchscreen=function(){return this.each(function(){e(this).find("li > ul").closest("li").children("a").each(function(){var t=e(this);t.click(function(e){if(t.hasClass("sf-clicked")){var n=t.attr("href");window.location=n}else{e.preventDefault();t.addClass("sf-clicked")}}).closest("li").mouseleave(function(){t.removeClass("sf-clicked")})})})}})(jQuery) 91 92 /* 93 * ScrollToFixed 94 * https://github.com/bigspotteddog/ScrollToFixed 95 * 96 * Copyright (c) 2011 Joseph Cava-Lynch 97 * MIT license 98 */ 99 ;(function($) { 100 $.isScrollToFixed = function(el) { 101 return !!$(el).data('ScrollToFixed'); 102 }; 103 104 $.ScrollToFixed = function(el, options) { 105 // To avoid scope issues, use 'base' instead of 'this' to reference this 106 // class from internal events and functions. 107 var base = this; 108 109 // Access to jQuery and DOM versions of element. 110 base.$el = $(el); 111 base.el = el; 112 113 // Add a reverse reference to the DOM object. 114 base.$el.data('ScrollToFixed', base); 115 116 // A flag so we know if the scroll has been reset. 117 var isReset = false; 118 119 // The element that was given to us to fix if scrolled above the top of 120 // the page. 121 var target = base.$el; 122 123 var position; 124 var originalPosition; 125 var originalFloat; 126 var originalOffsetTop; 127 var originalZIndex; 128 129 // The offset top of the element when resetScroll was called. This is 130 // used to determine if we have scrolled past the top of the element. 131 var offsetTop = 0; 132 133 // The offset left of the element when resetScroll was called. This is 134 // used to move the element left or right relative to the horizontal 135 // scroll. 136 var offsetLeft = 0; 137 var originalOffsetLeft = -1; 138 139 // This last offset used to move the element horizontally. This is used 140 // to determine if we need to move the element because we would not want 141 // to do that for no reason. 142 var lastOffsetLeft = -1; 143 144 // This is the element used to fill the void left by the target element 145 // when it goes fixed; otherwise, everything below it moves up the page. 146 var spacer = null; 147 148 var spacerClass; 149 150 var className; 151 152 // Capture the original offsets for the target element. This needs to be 153 // called whenever the page size changes or when the page is first 154 // scrolled. For some reason, calling this before the page is first 155 // scrolled causes the element to become fixed too late. 156 function resetScroll() { 157 // Set the element to it original positioning. 158 target.trigger('preUnfixed.ScrollToFixed'); 159 setUnfixed(); 160 target.trigger('unfixed.ScrollToFixed'); 161 162 // Reset the last offset used to determine if the page has moved 163 // horizontally. 164 lastOffsetLeft = -1; 165 166 // Capture the offset top of the target element. 167 offsetTop = target.offset().top; 168 169 // Capture the offset left of the target element. 170 offsetLeft = target.offset().left; 171 172 // If the offsets option is on, alter the left offset. 173 if (base.options.offsets) { 174 offsetLeft += (target.offset().left - target.position().left); 175 } 176 177 if (originalOffsetLeft == -1) { 178 originalOffsetLeft = offsetLeft; 179 } 180 181 position = target.css('position'); 182 183 // Set that this has been called at least once. 184 isReset = true; 185 186 if (base.options.bottom != -1) { 187 target.trigger('preFixed.ScrollToFixed'); 188 setFixed(); 189 target.trigger('fixed.ScrollToFixed'); 190 } 191 } 192 193 function getLimit() { 194 var limit = base.options.limit; 195 if (!limit) return 0; 196 197 if (typeof(limit) === 'function') { 198 return limit.apply(target); 199 } 200 return limit; 201 } 202 203 // Returns whether the target element is fixed or not. 204 function isFixed() { 205 return position === 'fixed'; 206 } 207 208 // Returns whether the target element is absolute or not. 209 function isAbsolute() { 210 return position === 'absolute'; 211 } 212 213 function isUnfixed() { 214 return !(isFixed() || isAbsolute()); 215 } 216 217 // Sets the target element to fixed. Also, sets the spacer to fill the 218 // void left by the target element. 219 function setFixed() { 220 // Only fix the target element and the spacer if we need to. 221 if (!isFixed()) { 222 //get REAL dimensions (decimal fix) 223 //Ref. http://stackoverflow.com/questions/3603065/how-to-make-jquery-to-not-round-value-returned-by-width 224 var dimensions = target[0].getBoundingClientRect(); 225 226 // Set the spacer to fill the height and width of the target
vendor: 17,165 bytes, lines 227-658
227 // element, then display it. 228 spacer.css({ 229 'display' : target.css('display'), 230 'width' : dimensions.width, 231 'height' : dimensions.height, 232 'float' : target.css('float') 233 }); 234 235 // Set the target element to fixed and set its width so it does 236 // not fill the rest of the page horizontally. Also, set its top 237 // to the margin top specified in the options. 238 239 cssOptions={ 240 'z-index' : base.options.zIndex, 241 'position' : 'fixed', 242 'top' : base.options.bottom == -1?getMarginTop():'', 243 'bottom' : base.options.bottom == -1?'':base.options.bottom, 244 'margin-left' : '0px' 245 } 246 if (!base.options.dontSetWidth){ cssOptions['width']=target.css('width'); }; 247 248 target.css(cssOptions); 249 250 target.addClass(base.options.baseClassName); 251 252 if (base.options.className) { 253 target.addClass(base.options.className); 254 } 255 256 position = 'fixed'; 257 } 258 } 259 260 function setAbsolute() { 261 262 var top = getLimit(); 263 var left = offsetLeft; 264 265 if (base.options.removeOffsets) { 266 left = ''; 267 top = top - offsetTop; 268 } 269 270 cssOptions={ 271 'position' : 'absolute', 272 'top' : top, 273 'left' : left, 274 'margin-left' : '0px', 275 'bottom' : '' 276 } 277 if (!base.options.dontSetWidth){ cssOptions['width']=target.css('width'); }; 278 279 target.css(cssOptions); 280 281 position = 'absolute'; 282 } 283 284 // Sets the target element back to unfixed. Also, hides the spacer. 285 function setUnfixed() { 286 // Only unfix the target element and the spacer if we need to. 287 if (!isUnfixed()) { 288 lastOffsetLeft = -1; 289 290 // Hide the spacer now that the target element will fill the 291 // space. 292 spacer.css('display', 'none'); 293 294 // Remove the style attributes that were added to the target. 295 // This will reverse the target back to the its original style. 296 target.css({ 297 'z-index' : originalZIndex, 298 'width' : '', 299 'position' : originalPosition, 300 'left' : '', 301 'top' : originalOffsetTop, 302 'margin-left' : '' 303 }); 304 305 target.removeClass('scroll-to-fixed-fixed'); 306 307 if (base.options.className) { 308 target.removeClass(base.options.className); 309 } 310 311 position = null; 312 } 313 } 314 315 // Moves the target element left or right relative to the horizontal 316 // scroll position. 317 function setLeft(x) { 318 // Only if the scroll is not what it was last time we did this. 319 if (x != lastOffsetLeft) { 320 // Move the target element horizontally relative to its original 321 // horizontal position. 322 target.css('left', offsetLeft - x); 323 324 // Hold the last horizontal position set. 325 lastOffsetLeft = x; 326 } 327 } 328 329 function getMarginTop() { 330 var marginTop = base.options.marginTop; 331 if (!marginTop) return 0; 332 333 if (typeof(marginTop) === 'function') { 334 return marginTop.apply(target); 335 } 336 return marginTop; 337 } 338 339 // Checks to see if we need to do something based on new scroll position 340 // of the page. 341 function checkScroll() { 342 if (!$.isScrollToFixed(target) || target.is(':hidden')) return; 343 var wasReset = isReset; 344 var wasUnfixed = isUnfixed(); 345 346 // If resetScroll has not yet been called, call it. This only 347 // happens once. 348 if (!isReset) { 349 resetScroll(); 350 } else if (isUnfixed()) { 351 // if the offset has changed since the last scroll, 352 // we need to get it again. 353 354 // Capture the offset top of the target element. 355 offsetTop = target.offset().top; 356 357 // Capture the offset left of the target element. 358 offsetLeft = target.offset().left; 359 } 360 361 // Grab the current horizontal scroll position. 362 var x = $(window).scrollLeft(); 363 364 // Grab the current vertical scroll position. 365 var y = $(window).scrollTop(); 366 367 // Get the limit, if there is one. 368 var limit = getLimit(); 369 370 // If the vertical scroll position, plus the optional margin, would 371 // put the target element at the specified limit, set the target 372 // element to absolute. 373 if (base.options.minWidth && $(window).width() < base.options.minWidth) { 374 if (!isUnfixed() || !wasReset) { 375 postPosition(); 376 target.trigger('preUnfixed.ScrollToFixed'); 377 setUnfixed(); 378 target.trigger('unfixed.ScrollToFixed'); 379 } 380 } else if (base.options.maxWidth && $(window).width() > base.options.maxWidth) { 381 if (!isUnfixed() || !wasReset) { 382 postPosition(); 383 target.trigger('preUnfixed.ScrollToFixed'); 384 setUnfixed(); 385 target.trigger('unfixed.ScrollToFixed'); 386 } 387 } else if (base.options.bottom == -1) { 388 // If the vertical scroll position, plus the optional margin, would 389 // put the target element at the specified limit, set the target 390 // element to absolute. 391 if (limit > 0 && y >= limit - getMarginTop()) { 392 if (!wasUnfixed && (!isAbsolute() || !wasReset)) { 393 postPosition(); 394 target.trigger('preAbsolute.ScrollToFixed'); 395 setAbsolute(); 396 target.trigger('unfixed.ScrollToFixed'); 397 } 398 // If the vertical scroll position, plus the optional margin, would 399 // put the target element above the top of the page, set the target 400 // element to fixed. 401 } else if (y > offsetTop - getMarginTop()) { 402 if (!isFixed() || !wasReset) { 403 postPosition(); 404 target.trigger('preFixed.ScrollToFixed'); 405 406 // Set the target element to fixed. 407 setFixed(); 408 409 // Reset the last offset left because we just went fixed. 410 lastOffsetLeft = -1; 411 412 target.trigger('fixed.ScrollToFixed'); 413 } 414 // If the page has been scrolled horizontally as well, move the 415 // target element accordingly. 416 setLeft(x); 417 } else { 418 // Set the target element to unfixed, placing it where it was 419 // before. 420 if (!isUnfixed() || !wasReset) { 421 postPosition(); 422 target.trigger('preUnfixed.ScrollToFixed'); 423 setUnfixed(); 424 target.trigger('unfixed.ScrollToFixed'); 425 } 426 } 427 } else { 428 if (limit > 0) { 429 if (y + $(window).height() - target.outerHeight(true) >= limit - (getMarginTop() || -getBottom())) { 430 if (isFixed()) { 431 postPosition(); 432 target.trigger('preUnfixed.ScrollToFixed'); 433 434 if (originalPosition === 'absolute') { 435 setAbsolute(); 436 } else { 437 setUnfixed(); 438 } 439 440 target.trigger('unfixed.ScrollToFixed'); 441 } 442 } else { 443 if (!isFixed()) { 444 postPosition(); 445 target.trigger('preFixed.ScrollToFixed'); 446 setFixed(); 447 } 448 setLeft(x); 449 target.trigger('fixed.ScrollToFixed'); 450 } 451 } else { 452 setLeft(x); 453 } 454 } 455 } 456 457 function getBottom() { 458 if (!base.options.bottom) return 0; 459 return base.options.bottom; 460 } 461 462 function postPosition() { 463 var position = target.css('position'); 464 465 if (position == 'absolute') { 466 target.trigger('postAbsolute.ScrollToFixed'); 467 } else if (position == 'fixed') { 468 target.trigger('postFixed.ScrollToFixed'); 469 } else { 470 target.trigger('postUnfixed.ScrollToFixed'); 471 } 472 } 473 474 var windowResize = function(event) { 475 // Check if the element is visible before updating it's position, which 476 // improves behavior with responsive designs where this element is hidden. 477 if(target.is(':visible')) { 478 isReset = false; 479 checkScroll(); 480 } else { 481 // Ensure the spacer is hidden 482 setUnfixed(); 483 } 484 } 485 486 var windowScroll = function(event) { 487 (!!window.requestAnimationFrame) ? requestAnimationFrame(checkScroll) : checkScroll(); 488 } 489 490 // From: http://kangax.github.com/cft/#IS_POSITION_FIXED_SUPPORTED 491 var isPositionFixedSupported = function() { 492 var container = document.body; 493 494 if (document.createElement && container && container.appendChild && container.removeChild) { 495 var el = document.createElement('div'); 496 497 if (!el.getBoundingClientRect) return null; 498 499 el.innerHTML = 'x'; 500 el.style.cssText = 'position:fixed;top:100px;'; 501 container.appendChild(el); 502 503 var originalHeight = container.style.height, 504 originalScrollTop = container.scrollTop; 505 506 container.style.height = '3000px'; 507 container.scrollTop = 500; 508 509 var elementTop = el.getBoundingClientRect().top; 510 container.style.height = originalHeight; 511 512 var isSupported = (elementTop === 100); 513 container.removeChild(el); 514 container.scrollTop = originalScrollTop; 515 516 return isSupported; 517 } 518 519 return null; 520 } 521 522 var preventDefault = function(e) { 523 e = e || window.event; 524 if (e.preventDefault) { 525 e.preventDefault(); 526 } 527 e.returnValue = false; 528 } 529 530 // Initializes this plugin. Captures the options passed in, turns this 531 // off for devices that do not support fixed position, adds the spacer, 532 // and binds to the window scroll and resize events. 533 base.init = function() { 534 // Capture the options for this plugin. 535 base.options = $.extend({}, $.ScrollToFixed.defaultOptions, options); 536 537 originalZIndex = target.css('z-index') 538 539 // Turn off this functionality for devices that do not support it. 540 // if (!(base.options && base.options.dontCheckForPositionFixedSupport)) { 541 // var fixedSupported = isPositionFixedSupported(); 542 // if (!fixedSupported) return; 543 // } 544 545 // Put the target element on top of everything that could be below 546 // it. This reduces flicker when the target element is transitioning 547 // to fixed. 548 base.$el.css('z-index', base.options.zIndex); 549 550 // Create a spacer element to fill the void left by the target 551 // element when it goes fixed. 552 spacer = $('<div />'); 553 554 position = target.css('position'); 555 originalPosition = target.css('position'); 556 originalFloat = target.css('float'); 557 originalOffsetTop = target.css('top'); 558 559 // Place the spacer right after the target element. 560 if (isUnfixed()) base.$el.after(spacer); 561 562 // Reset the target element offsets when the window is resized, then 563 // check to see if we need to fix or unfix the target element. 564 $(window).bind('resize.ScrollToFixed', windowResize); 565 566 // When the window scrolls, check to see if we need to fix or unfix 567 // the target element. 568 $(window).bind('scroll.ScrollToFixed', windowScroll); 569 570 // For touch devices, call checkScroll directlly rather than 571 // rAF wrapped windowScroll to animate the element 572 if ('ontouchmove' in window) { 573 $(window).bind('touchmove.ScrollToFixed', checkScroll); 574 } 575 576 if (base.options.preFixed) { 577 target.bind('preFixed.ScrollToFixed', base.options.preFixed); 578 } 579 if (base.options.postFixed) { 580 target.bind('postFixed.ScrollToFixed', base.options.postFixed); 581 } 582 if (base.options.preUnfixed) { 583 target.bind('preUnfixed.ScrollToFixed', base.options.preUnfixed); 584 } 585 if (base.options.postUnfixed) { 586 target.bind('postUnfixed.ScrollToFixed', base.options.postUnfixed); 587 } 588 if (base.options.preAbsolute) { 589 target.bind('preAbsolute.ScrollToFixed', base.options.preAbsolute); 590 } 591 if (base.options.postAbsolute) { 592 target.bind('postAbsolute.ScrollToFixed', base.options.postAbsolute); 593 } 594 if (base.options.fixed) { 595 target.bind('fixed.ScrollToFixed', base.options.fixed); 596 } 597 if (base.options.unfixed) { 598 target.bind('unfixed.ScrollToFixed', base.options.unfixed); 599 } 600 601 if (base.options.spacerClass) { 602 spacer.addClass(base.options.spacerClass); 603 } 604 605 target.bind('resize.ScrollToFixed', function() { 606 spacer.height(target.height()); 607 }); 608 609 target.bind('scroll.ScrollToFixed', function() { 610 target.trigger('preUnfixed.ScrollToFixed'); 611 setUnfixed(); 612 target.trigger('unfixed.ScrollToFixed'); 613 checkScroll(); 614 }); 615 616 target.bind('detach.ScrollToFixed', function(ev) { 617 preventDefault(ev); 618 619 target.trigger('preUnfixed.ScrollToFixed'); 620 setUnfixed(); 621 target.trigger('unfixed.ScrollToFixed'); 622 623 $(window).unbind('resize.ScrollToFixed', windowResize); 624 $(window).unbind('scroll.ScrollToFixed', windowScroll); 625 626 target.unbind('.ScrollToFixed'); 627 628 //remove spacer from dom 629 spacer.remove(); 630 631 base.$el.removeData('ScrollToFixed'); 632 }); 633 634 // Reset everything. 635 windowResize(); 636 }; 637 638 // Initialize the plugin. 639 base.init(); 640 }; 641 642 // Sets the option defaults. 643 $.ScrollToFixed.defaultOptions = { 644 marginTop : 0, 645 limit : 0, 646 bottom : -1, 647 zIndex : 1000, 648 baseClassName: 'scroll-to-fixed-fixed' 649 }; 650 651 // Returns enhanced elements that will fix to the top of the page when the 652 // page is scrolled. 653 $.fn.scrollToFixed = function(options) { 654 return this.each(function() { 655 (new $.ScrollToFixed(this, options)); 656 }); 657 }; 658 })(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.