vendor: 23,077 bytes, lines 1-651
1;(function($, window, document, undefined) { 2 3 var pluginName = 'stellar', 4 defaults = { 5 scrollProperty: 'scroll', 6 positionProperty: 'position', 7 horizontalScrolling: true, 8 verticalScrolling: true, 9 horizontalOffset: 0, 10 verticalOffset: 0, 11 responsive: false, 12 parallaxBackgrounds: true, 13 parallaxElements: true, 14 hideDistantElements: true, 15 hideElement: function($elem) { $elem.hide(); }, 16 showElement: function($elem) { $elem.show(); } 17 }, 18 19 scrollProperty = { 20 scroll: { 21 getLeft: function($elem) { return $elem.scrollLeft(); }, 22 setLeft: function($elem, val) { $elem.scrollLeft(val); }, 23 24 getTop: function($elem) { return $elem.scrollTop(); }, 25 setTop: function($elem, val) { $elem.scrollTop(val); } 26 }, 27 position: { 28 getLeft: function($elem) { return parseInt($elem.css('left'), 10) * -1; }, 29 getTop: function($elem) { return parseInt($elem.css('top'), 10) * -1; } 30 }, 31 margin: { 32 getLeft: function($elem) { return parseInt($elem.css('margin-left'), 10) * -1; }, 33 getTop: function($elem) { return parseInt($elem.css('margin-top'), 10) * -1; } 34 }, 35 transform: { 36 getLeft: function($elem) { 37 var computedTransform = getComputedStyle($elem[0])[prefixedTransform]; 38 return (computedTransform !== 'none' ? parseInt(computedTransform.match(/(-?[0-9]+)/g)[4], 10) * -1 : 0); 39 }, 40 getTop: function($elem) { 41 var computedTransform = getComputedStyle($elem[0])[prefixedTransform]; 42 return (computedTransform !== 'none' ? parseInt(computedTransform.match(/(-?[0-9]+)/g)[5], 10) * -1 : 0); 43 } 44 } 45 }, 46 47 positionProperty = { 48 position: { 49 setLeft: function($elem, left) { $elem.css('left', left); }, 50 setTop: function($elem, top) { $elem.css('top', top); } 51 }, 52 transform: { 53 setPosition: function($elem, left, startingLeft, top, startingTop) { 54 $elem[0].style[prefixedTransform] = 'translate3d(' + (left - startingLeft) + 'px, ' + (top - startingTop) + 'px, 0)'; 55 } 56 } 57 }, 58 59 // Returns a function which adds a vendor prefix to any CSS property name 60 vendorPrefix = (function() { 61 var prefixes = /^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/, 62 style = $('script')[0].style, 63 prefix = '', 64 prop; 65 66 for (prop in style) { 67 if (prefixes.test(prop)) { 68 prefix = prop.match(prefixes)[0]; 69 break; 70 } 71 } 72 73 if ('WebkitOpacity' in style) { prefix = 'Webkit'; } 74 if ('KhtmlOpacity' in style) { prefix = 'Khtml'; } 75 76 return function(property) { 77 return prefix + (prefix.length > 0 ? property.charAt(0).toUpperCase() + property.slice(1) : property); 78 }; 79 }()), 80 81 prefixedTransform = vendorPrefix('transform'), 82 83 supportsBackgroundPositionXY = $('<div />', { style: 'background:#fff' }).css('background-position-x') !== undefined, 84 85 setBackgroundPosition = (supportsBackgroundPositionXY ? 86 function($elem, x, y) { 87 $elem.css({ 88 'background-position-x': x, 89 'background-position-y': y 90 }); 91 } : 92 function($elem, x, y) { 93 $elem.css('background-position', x + ' ' + y); 94 } 95 ), 96 97 getBackgroundPosition = (supportsBackgroundPositionXY ? 98 function($elem) { 99 return [ 100 $elem.css('background-position-x'), 101 $elem.css('background-position-y') 102 ]; 103 } : 104 function($elem) { 105 return $elem.css('background-position').split(' '); 106 } 107 ), 108 109 requestAnimFrame = ( 110 window.requestAnimationFrame || 111 window.webkitRequestAnimationFrame || 112 window.mozRequestAnimationFrame || 113 window.oRequestAnimationFrame || 114 window.msRequestAnimationFrame || 115 function(callback) { 116 setTimeout(callback, 1000 / 60); 117 } 118 ); 119 120 function Plugin(element, options) { 121 this.element = element; 122 this.options = $.extend({}, defaults, options); 123 124 this._defaults = defaults; 125 this._name = pluginName; 126 127 this.init(); 128 } 129 130 Plugin.prototype = { 131 init: function() { 132 this.options.name = pluginName + '_' + Math.floor(Math.random() * 1e9); 133 134 this._defineElements(); 135 this._defineGetters(); 136 this._defineSetters(); 137 this._handleWindowLoadAndResize(); 138 this._detectViewport(); 139 140 this.refresh({ firstLoad: true }); 141 142 if (this.options.scrollProperty === 'scroll') { 143 this._handleScrollEvent(); 144 } else { 145 this._startAnimationLoop(); 146 } 147 }, 148 _defineElements: function() { 149 if (this.element === document.body) this.element = window; 150 this.$scrollElement = $(this.element); 151 this.$element = (this.element === window ? $('body') : this.$scrollElement); 152 this.$viewportElement = (this.options.viewportElement !== undefined ? $(this.options.viewportElement) : (this.$scrollElement[0] === window || this.options.scrollProperty === 'scroll' ? this.$scrollElement : this.$scrollElement.parent()) ); 153 }, 154 _defineGetters: function() { 155 var self = this, 156 scrollPropertyAdapter = scrollProperty[self.options.scrollProperty]; 157 158 this._getScrollLeft = function() { 159 return scrollPropertyAdapter.getLeft(self.$scrollElement); 160 }; 161 162 this._getScrollTop = function() { 163 return scrollPropertyAdapter.getTop(self.$scrollElement); 164 }; 165 }, 166 _defineSetters: function() { 167 var self = this, 168 scrollPropertyAdapter = scrollProperty[self.options.scrollProperty], 169 positionPropertyAdapter = positionProperty[self.options.positionProperty], 170 setScrollLeft = scrollPropertyAdapter.setLeft, 171 setScrollTop = scrollPropertyAdapter.setTop; 172 173 this._setScrollLeft = (typeof setScrollLeft === 'function' ? function(val) { 174 setScrollLeft(self.$scrollElement, val); 175 } : $.noop); 176 177 this._setScrollTop = (typeof setScrollTop === 'function' ? function(val) { 178 setScrollTop(self.$scrollElement, val); 179 } : $.noop); 180 181 this._setPosition = positionPropertyAdapter.setPosition || 182 function($elem, left, startingLeft, top, startingTop) { 183 if (self.options.horizontalScrolling) { 184 positionPropertyAdapter.setLeft($elem, left, startingLeft); 185 } 186 187 if (self.options.verticalScrolling) { 188 positionPropertyAdapter.setTop($elem, top, startingTop); 189 } 190 }; 191 }, 192 _handleWindowLoadAndResize: function() { 193 var self = this, 194 $window = $(window); 195 196 if (self.options.responsive) { 197 $window.bind('load.' + this.name, function() { 198 self.refresh(); 199 }); 200 } 201 202 $window.bind('resize.' + this.name, function() { 203 self._detectViewport(); 204 205 if (self.options.responsive) { 206 self.refresh(); 207 } 208 }); 209 }, 210 refresh: function(options) { 211 var self = this, 212 oldLeft = self._getScrollLeft(), 213 oldTop = self._getScrollTop(); 214 215 if (!options || !options.firstLoad) { 216 this._reset(); 217 } 218 219 this._setScrollLeft(0); 220 this._setScrollTop(0); 221 222 this._setOffsets(); 223 this._findParticles(); 224 this._findBackgrounds(); 225 226 // Fix for WebKit background rendering bug 227 if (options && options.firstLoad && /WebKit/.test(navigator.userAgent)) { 228 $(window).load(function() { 229 var oldLeft = self._getScrollLeft(), 230 oldTop = self._getScrollTop(); 231 232 self._setScrollLeft(oldLeft + 1); 233 self._setScrollTop(oldTop + 1); 234 235 self._setScrollLeft(oldLeft); 236 self._setScrollTop(oldTop); 237 }); 238 } 239 240 this._setScrollLeft(oldLeft); 241 this._setScrollTop(oldTop); 242 }, 243 _detectViewport: function() { 244 var viewportOffsets = this.$viewportElement.offset(), 245 hasOffsets = viewportOffsets !== null && viewportOffsets !== undefined; 246 247 this.viewportWidth = this.$viewportElement.width(); 248 this.viewportHeight = this.$viewportElement.height(); 249 250 this.viewportOffsetTop = (hasOffsets ? viewportOffsets.top : 0); 251 this.viewportOffsetLeft = (hasOffsets ? viewportOffsets.left : 0); 252 }, 253 _findParticles: function() { 254 var self = this, 255 scrollLeft = this._getScrollLeft(), 256 scrollTop = this._getScrollTop(); 257 258 if (this.particles !== undefined) { 259 for (var i = this.particles.length - 1; i >= 0; i--) { 260 this.particles[i].$element.data('stellar-elementIsActive', undefined); 261 } 262 } 263 264 this.particles = []; 265 266 if (!this.options.parallaxElements) return; 267 268 this.$element.find('[data-stellar-ratio]').each(function(i) { 269 var $this = $(this), 270 horizontalOffset, 271 verticalOffset, 272 positionLeft, 273 positionTop, 274 marginLeft, 275 marginTop, 276 $offsetParent, 277 offsetLeft, 278 offsetTop, 279 parentOffsetLeft = 0, 280 parentOffsetTop = 0, 281 tempParentOffsetLeft = 0, 282 tempParentOffsetTop = 0; 283 284 // Ensure this element isn't already part of another scrolling element 285 if (!$this.data('stellar-elementIsActive')) { 286 $this.data('stellar-elementIsActive', this); 287 } else if ($this.data('stellar-elementIsActive') !== this) { 288 return; 289 } 290 291 self.options.showElement($this); 292 293 // Save/restore the original top and left CSS values in case we refresh the particles or destroy the instance 294 if (!$this.data('stellar-startingLeft')) { 295 $this.data('stellar-startingLeft', $this.css('left')); 296 $this.data('stellar-startingTop', $this.css('top')); 297 } else { 298 $this.css('left', $this.data('stellar-startingLeft')); 299 $this.css('top', $this.data('stellar-startingTop')); 300 } 301 302 positionLeft = $this.position().left; 303 positionTop = $this.position().top; 304 305 // Catch-all for margin top/left properties (these evaluate to 'auto' in IE7 and IE8) 306 marginLeft = ($this.css('margin-left') === 'auto') ? 0 : parseInt($this.css('margin-left'), 10); 307 marginTop = ($this.css('margin-top') === 'auto') ? 0 : parseInt($this.css('margin-top'), 10); 308 309 offsetLeft = $this.offset().left - marginLeft; 310 offsetTop = $this.offset().top - marginTop; 311 312 // Calculate the offset parent 313 $this.parents().each(function() { 314 var $this = $(this); 315 316 if ($this.data('stellar-offset-parent') === true) { 317 parentOffsetLeft = tempParentOffsetLeft; 318 parentOffsetTop = tempParentOffsetTop; 319 $offsetParent = $this; 320 321 return false; 322 } else { 323 tempParentOffsetLeft += $this.position().left; 324 tempParentOffsetTop += $this.position().top; 325 } 326 }); 327 328 // Detect the offsets 329 horizontalOffset = ($this.data('stellar-horizontal-offset') !== undefined ? $this.data('stellar-horizontal-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-horizontal-offset') !== undefined ? $offsetParent.data('stellar-horizontal-offset') : self.horizontalOffset)); 330 verticalOffset = ($this.data('stellar-vertical-offset') !== undefined ? $this.data('stellar-vertical-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-vertical-offset') !== undefined ? $offsetParent.data('stellar-vertical-offset') : self.verticalOffset)); 331 332 // Add our object to the particles collection 333 self.particles.push({ 334 $element: $this, 335 $offsetParent: $offsetParent, 336 isFixed: $this.css('position') === 'fixed', 337 horizontalOffset: horizontalOffset, 338 verticalOffset: verticalOffset, 339 startingPositionLeft: positionLeft, 340 startingPositionTop: positionTop, 341 startingOffsetLeft: offsetLeft, 342 startingOffsetTop: offsetTop, 343 parentOffsetLeft: parentOffsetLeft, 344 parentOffsetTop: parentOffsetTop, 345 stellarRatio: ($this.data('stellar-ratio') !== undefined ? $this.data('stellar-ratio') : 1), 346 width: $this.outerWidth(true), 347 height: $this.outerHeight(true), 348 isHidden: false 349 }); 350 }); 351 }, 352 _findBackgrounds: function() { 353 var self = this, 354 scrollLeft = this._getScrollLeft(), 355 scrollTop = this._getScrollTop(), 356 $backgroundElements; 357 358 this.backgrounds = []; 359 360 if (!this.options.parallaxBackgrounds) return; 361 362 $backgroundElements = this.$element.find('[data-stellar-background-ratio]'); 363 364 if (this.$element.data('stellar-background-ratio')) { 365 $backgroundElements = $backgroundElements.add(this.$element); 366 } 367 368 $backgroundElements.each(function() { 369 var $this = $(this), 370 backgroundPosition = getBackgroundPosition($this), 371 horizontalOffset, 372 verticalOffset, 373 positionLeft, 374 positionTop, 375 marginLeft, 376 marginTop, 377 offsetLeft, 378 offsetTop, 379 $offsetParent, 380 parentOffsetLeft = 0, 381 parentOffsetTop = 0, 382 tempParentOffsetLeft = 0, 383 tempParentOffsetTop = 0; 384 385 // Ensure this element isn't already part of another scrolling element 386 if (!$this.data('stellar-backgroundIsActive')) { 387 $this.data('stellar-backgroundIsActive', this); 388 } else if ($this.data('stellar-backgroundIsActive') !== this) { 389 return; 390 } 391 392 // Save/restore the original top and left CSS values in case we destroy the instance 393 if (!$this.data('stellar-backgroundStartingLeft')) { 394 $this.data('stellar-backgroundStartingLeft', backgroundPosition[0]); 395 $this.data('stellar-backgroundStartingTop', backgroundPosition[1]); 396 } else { 397 setBackgroundPosition($this, $this.data('stellar-backgroundStartingLeft'), $this.data('stellar-backgroundStartingTop')); 398 } 399 400 // Catch-all for margin top/left properties (these evaluate to 'auto' in IE7 and IE8) 401 marginLeft = ($this.css('margin-left') === 'auto') ? 0 : parseInt($this.css('margin-left'), 10); 402 marginTop = ($this.css('margin-top') === 'auto') ? 0 : parseInt($this.css('margin-top'), 10); 403 404 offsetLeft = $this.offset().left - marginLeft - scrollLeft; 405 offsetTop = $this.offset().top - marginTop - scrollTop; 406 407 // Calculate the offset parent 408 $this.parents().each(function() { 409 var $this = $(this); 410 411 if ($this.data('stellar-offset-parent') === true) { 412 parentOffsetLeft = tempParentOffsetLeft; 413 parentOffsetTop = tempParentOffsetTop; 414 $offsetParent = $this; 415 416 return false; 417 } else { 418 tempParentOffsetLeft += $this.position().left; 419 tempParentOffsetTop += $this.position().top; 420 } 421 }); 422 423 // Detect the offsets 424 horizontalOffset = ($this.data('stellar-horizontal-offset') !== undefined ? $this.data('stellar-horizontal-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-horizontal-offset') !== undefined ? $offsetParent.data('stellar-horizontal-offset') : self.horizontalOffset)); 425 verticalOffset = ($this.data('stellar-vertical-offset') !== undefined ? $this.data('stellar-vertical-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-vertical-offset') !== undefined ? $offsetParent.data('stellar-vertical-offset') : self.verticalOffset)); 426 427 self.backgrounds.push({ 428 $element: $this, 429 $offsetParent: $offsetParent, 430 isFixed: $this.css('background-attachment') === 'fixed', 431 horizontalOffset: horizontalOffset, 432 verticalOffset: verticalOffset, 433 startingValueLeft: backgroundPosition[0], 434 startingValueTop: backgroundPosition[1], 435 startingBackgroundPositionLeft: (isNaN(parseInt(backgroundPosition[0], 10)) ? 0 : parseInt(backgroundPosition[0], 10)), 436 startingBackgroundPositionTop: (isNaN(parseInt(backgroundPosition[1], 10)) ? 0 : parseInt(backgroundPosition[1], 10)), 437 startingPositionLeft: $this.position().left, 438 startingPositionTop: $this.position().top, 439 startingOffsetLeft: offsetLeft, 440 startingOffsetTop: offsetTop, 441 parentOffsetLeft: parentOffsetLeft, 442 parentOffsetTop: parentOffsetTop, 443 stellarRatio: ($this.data('stellar-background-ratio') === undefined ? 1 : $this.data('stellar-background-ratio')) 444 }); 445 }); 446 }, 447 _reset: function() { 448 var particle, 449 startingPositionLeft, 450 startingPositionTop, 451 background, 452 i; 453 454 for (i = this.particles.length - 1; i >= 0; i--) { 455 particle = this.particles[i]; 456 startingPositionLeft = particle.$element.data('stellar-startingLeft'); 457 startingPositionTop = particle.$element.data('stellar-startingTop'); 458 459 this._setPosition(particle.$element, startingPositionLeft, startingPositionLeft, startingPositionTop, startingPositionTop); 460 461 this.options.showElement(particle.$element); 462 463 particle.$element.data('stellar-startingLeft', null).data('stellar-elementIsActive', null).data('stellar-backgroundIsActive', null); 464 } 465 466 for (i = this.backgrounds.length - 1; i >= 0; i--) { 467 background = this.backgrounds[i]; 468 469 background.$element.data('stellar-backgroundStartingLeft', null).data('stellar-backgroundStartingTop', null); 470 471 setBackgroundPosition(background.$element, background.startingValueLeft, background.startingValueTop); 472 } 473 }, 474 destroy: function() { 475 this._reset(); 476 477 this.$scrollElement.unbind('resize.' + this.name).unbind('scroll.' + this.name); 478 this._animationLoop = $.noop; 479 480 $(window).unbind('load.' + this.name).unbind('resize.' + this.name); 481 }, 482 _setOffsets: function() { 483 var self = this, 484 $window = $(window); 485 486 $window.unbind('resize.horizontal-' + this.name).unbind('resize.vertical-' + this.name); 487 488 if (typeof this.options.horizontalOffset === 'function') { 489 this.horizontalOffset = this.options.horizontalOffset(); 490 $window.bind('resize.horizontal-' + this.name, function() { 491 self.horizontalOffset = self.options.horizontalOffset(); 492 }); 493 } else { 494 this.horizontalOffset = this.options.horizontalOffset; 495 } 496 497 if (typeof this.options.verticalOffset === 'function') { 498 this.verticalOffset = this.options.verticalOffset(); 499 $window.bind('resize.vertical-' + this.name, function() { 500 self.verticalOffset = self.options.verticalOffset(); 501 }); 502 } else { 503 this.verticalOffset = this.options.verticalOffset; 504 } 505 }, 506 _repositionElements: function() { 507 var scrollLeft = this._getScrollLeft(), 508 scrollTop = this._getScrollTop(), 509 horizontalOffset, 510 verticalOffset, 511 particle, 512 fixedRatioOffset, 513 background, 514 bgLeft, 515 bgTop, 516 isVisibleVertical = true, 517 isVisibleHorizontal = true, 518 newPositionLeft, 519 newPositionTop, 520 newOffsetLeft, 521 newOffsetTop, 522 i; 523 524 // First check that the scroll position or container size has changed 525 if (this.currentScrollLeft === scrollLeft && this.currentScrollTop === scrollTop && this.currentWidth === this.viewportWidth && this.currentHeight === this.viewportHeight) { 526 return; 527 } else { 528 this.currentScrollLeft = scrollLeft; 529 this.currentScrollTop = scrollTop; 530 this.currentWidth = this.viewportWidth; 531 this.currentHeight = this.viewportHeight; 532 } 533 534 // Reposition elements 535 for (i = this.particles.length - 1; i >= 0; i--) { 536 particle = this.particles[i]; 537 538 fixedRatioOffset = (particle.isFixed ? 1 : 0); 539 540 // Calculate position, then calculate what the particle's new offset will be (for visibility check) 541 if (this.options.horizontalScrolling) { 542 newPositionLeft = (scrollLeft + particle.horizontalOffset + this.viewportOffsetLeft + particle.startingPositionLeft - particle.startingOffsetLeft + particle.parentOffsetLeft) * -(particle.stellarRatio + fixedRatioOffset - 1) + particle.startingPositionLeft; 543 newOffsetLeft = newPositionLeft - particle.startingPositionLeft + particle.startingOffsetLeft; 544 } else { 545 newPositionLeft = particle.startingPositionLeft; 546 newOffsetLeft = particle.startingOffsetLeft; 547 } 548 549 if (this.options.verticalScrolling) { 550 newPositionTop = (scrollTop + particle.verticalOffset + this.viewportOffsetTop + particle.startingPositionTop - particle.startingOffsetTop + particle.parentOffsetTop) * -(particle.stellarRatio + fixedRatioOffset - 1) + particle.startingPositionTop; 551 newOffsetTop = newPositionTop - particle.startingPositionTop + particle.startingOffsetTop; 552 } else { 553 newPositionTop = particle.startingPositionTop; 554 newOffsetTop = particle.startingOffsetTop; 555 } 556 557 // Check visibility 558 if (this.options.hideDistantElements) { 559 isVisibleHorizontal = !this.options.horizontalScrolling || newOffsetLeft + particle.width > (particle.isFixed ? 0 : scrollLeft) && newOffsetLeft < (particle.isFixed ? 0 : scrollLeft) + this.viewportWidth + this.viewportOffsetLeft; 560 isVisibleVertical = !this.options.verticalScrolling || newOffsetTop + particle.height > (particle.isFixed ? 0 : scrollTop) && newOffsetTop < (particle.isFixed ? 0 : scrollTop) + this.viewportHeight + this.viewportOffsetTop; 561 } 562 563 if (isVisibleHorizontal && isVisibleVertical) { 564 if (particle.isHidden) { 565 this.options.showElement(particle.$element); 566 particle.isHidden = false; 567 } 568 569 this._setPosition(particle.$element, newPositionLeft, particle.startingPositionLeft, newPositionTop, particle.startingPositionTop); 570 } else { 571 if (!particle.isHidden) { 572 this.options.hideElement(particle.$element); 573 particle.isHidden = true; 574 } 575 } 576 } 577 578 // Reposition backgrounds 579 for (i = this.backgrounds.length - 1; i >= 0; i--) { 580 background = this.backgrounds[i]; 581 582 fixedRatioOffset = (background.isFixed ? 0 : 1); 583 bgLeft = (this.options.horizontalScrolling ? (scrollLeft + background.horizontalOffset - this.viewportOffsetLeft - background.startingOffsetLeft + background.parentOffsetLeft - background.startingBackgroundPositionLeft) * (fixedRatioOffset - background.stellarRatio) + 'px' : background.startingValueLeft); 584 bgTop = (this.options.verticalScrolling ? (scrollTop + background.verticalOffset - this.viewportOffsetTop - background.startingOffsetTop + background.parentOffsetTop - background.startingBackgroundPositionTop) * (fixedRatioOffset - background.stellarRatio) + 'px' : background.startingValueTop); 585 586 setBackgroundPosition(background.$element, bgLeft, bgTop); 587 } 588 }, 589 _handleScrollEvent: function() { 590 var self = this, 591 ticking = false; 592 593 var update = function() { 594 self._repositionElements(); 595 ticking = false; 596 }; 597 598 var requestTick = function() { 599 if (!ticking) { 600 requestAnimFrame(update); 601 ticking = true; 602 } 603 }; 604 605 this.$scrollElement.bind('scroll.' + this.name, requestTick); 606 requestTick(); 607 }, 608 _startAnimationLoop: function() { 609 var self = this; 610 611 this._animationLoop = function() { 612 requestAnimFrame(self._animationLoop); 613 self._repositionElements(); 614 }; 615 this._animationLoop(); 616 } 617 }; 618 619 $.fn[pluginName] = function (options) { 620 var args = arguments; 621 if (options === undefined || typeof options === 'object') { 622 return this.each(function () { 623 if (!$.data(this, 'plugin_' + pluginName)) { 624 $.data(this, 'plugin_' + pluginName, new Plugin(this, options)); 625 } 626 }); 627 } else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') { 628 return this.each(function () { 629 var instance = $.data(this, 'plugin_' + pluginName); 630 if (instance instanceof Plugin && typeof instance[options] === 'function') { 631 instance[options].apply(instance, Array.prototype.slice.call(args, 1)); 632 } 633 if (options === 'destroy') { 634 $.data(this, 'plugin_' + pluginName, null); 635 } 636 }); 637 } 638 }; 639 640 $[pluginName] = function(options) { 641 var $window = $(window); 642 return $window.stellar.apply($window, Array.prototype.slice.call(arguments, 0)); 643 }; 644 645 // Expose the scroll and position property function hashes so they can be extended 646 $[pluginName].scrollProperty = scrollProperty; 647 $[pluginName].positionProperty = positionProperty; 648 649 // Expose the plugin class so it can be modified 650 window.Stellar = Plugin; 651}(jQuery, this, document));
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.