mirror of
				https://github.com/ZetaKebab/kesper.git
				synced 2025-11-04 08:09:49 +00:00 
			
		
		
		
	Merge pull request #172 from mankittens/master
Improvement to .post-content .full-img
This commit is contained in:
		@@ -3,60 +3,16 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* globals jQuery, document */
 | 
			
		||||
(function ($, sr, undefined) {
 | 
			
		||||
(function ($, undefined) {
 | 
			
		||||
    "use strict";
 | 
			
		||||
 | 
			
		||||
    var $document = $(document),
 | 
			
		||||
 | 
			
		||||
        // debouncing function from John Hann
 | 
			
		||||
        // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
 | 
			
		||||
        debounce = function (func, threshold, execAsap) {
 | 
			
		||||
            var timeout;
 | 
			
		||||
 | 
			
		||||
            return function debounced () {
 | 
			
		||||
                var obj = this, args = arguments;
 | 
			
		||||
                function delayed () {
 | 
			
		||||
                    if (!execAsap) {
 | 
			
		||||
                        func.apply(obj, args);
 | 
			
		||||
                    }
 | 
			
		||||
                    timeout = null;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (timeout) {
 | 
			
		||||
                    clearTimeout(timeout);
 | 
			
		||||
                } else if (execAsap) {
 | 
			
		||||
                    func.apply(obj, args);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                timeout = setTimeout(delayed, threshold || 100);
 | 
			
		||||
            };
 | 
			
		||||
        };
 | 
			
		||||
    var $document = $(document);
 | 
			
		||||
 | 
			
		||||
    $document.ready(function () {
 | 
			
		||||
 | 
			
		||||
        var $postContent = $(".post-content");
 | 
			
		||||
        $postContent.fitVids();
 | 
			
		||||
 | 
			
		||||
        function updateImageWidth() {
 | 
			
		||||
            var $this = $(this),
 | 
			
		||||
                contentWidth = $postContent.outerWidth(), // Width of the content
 | 
			
		||||
                imageWidth = this.naturalWidth; // Original image resolution
 | 
			
		||||
 | 
			
		||||
            if (imageWidth >= contentWidth) {
 | 
			
		||||
                $this.addClass('full-img');
 | 
			
		||||
            } else {
 | 
			
		||||
                $this.removeClass('full-img');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var $img = $("img").on('load', updateImageWidth);
 | 
			
		||||
        function casperFullImg() {
 | 
			
		||||
            $img.each(updateImageWidth);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        casperFullImg();
 | 
			
		||||
        $(window).smartresize(casperFullImg);
 | 
			
		||||
 | 
			
		||||
        $(".scroll-down").arctic_scroll();
 | 
			
		||||
 | 
			
		||||
        $(".menu-button, .nav-cover, .nav-close").on("click", function(e){
 | 
			
		||||
@@ -66,9 +22,6 @@
 | 
			
		||||
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // smartresize
 | 
			
		||||
    jQuery.fn[sr] = function(fn) { return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };
 | 
			
		||||
 | 
			
		||||
    // Arctic Scroll by Paul Adam Davis
 | 
			
		||||
    // https://github.com/PaulAdamDavis/Arctic-Scroll
 | 
			
		||||
    $.fn.arctic_scroll = function (options) {
 | 
			
		||||
@@ -100,4 +53,4 @@
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
    };
 | 
			
		||||
})(jQuery, 'smartresize');
 | 
			
		||||
})(jQuery);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user