scala-news-reader

rss/atom news reader in scala

git clone https://9o.is/git/scala-news-reader.git

jquery.waypoints.sticky.js

(1734B)


      1 // Generated by CoffeeScript 1.6.2
      2 /*
      3 Sticky Elements Shortcut for jQuery Waypoints - v2.0.2
      4 Copyright (c) 2011-2013 Caleb Troughton
      5 Dual licensed under the MIT license and GPL license.
      6 https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt
      7 */
      8 
      9 
     10 (function() {
     11   (function(root, factory) {
     12     if (typeof define === 'function' && define.amd) {
     13       return define(['jquery', 'waypoints'], factory);
     14     } else {
     15       return factory(root.jQuery);
     16     }
     17   })(this, function($) {
     18     var defaults, wrap;
     19 
     20     defaults = {
     21       wrapper: '<div class="sticky-wrapper" />',
     22       stuckClass: 'stuck'
     23     };
     24     wrap = function($elements, options) {
     25       $elements.wrap(options.wrapper);
     26       return $elements.parent();
     27     };
     28     $.waypoints('extendFn', 'sticky', function(opt) {
     29       var $wrap, options, originalHandler;
     30 
     31       options = $.extend({}, $.fn.waypoint.defaults, defaults, opt);
     32       $wrap = wrap(this, options);
     33       originalHandler = options.handler;
     34       options.handler = function(direction) {
     35         var $sticky, shouldBeStuck;
     36 
     37         $sticky = $(this).children(':first');
     38         shouldBeStuck = direction === 'down' || direction === 'right';
     39         $sticky.toggleClass(options.stuckClass, shouldBeStuck);
     40         $wrap.height(shouldBeStuck ? $sticky.outerHeight() : '');
     41         if (originalHandler != null) {
     42           return originalHandler.call(this, direction);
     43         }
     44       };
     45       $wrap.waypoint(options);
     46       return this.data('stuckClass', options.stuckClass);
     47     });
     48     return $.waypoints('extendFn', 'unsticky', function() {
     49       this.parent().waypoint('destroy');
     50       this.unwrap();
     51       return this.removeClass(this.data('stuckClass'));
     52     });
     53   });
     54 
     55 }).call(this);