PageSourceSearch

http://popstache.com/wp-content/plugins/slidedeck-pro-for-wordpres…/image_caption_bottom/skin.js?ver=1.4.8

js popstache.com collected 2026-10-02 07:19:18 UTC 7,215 bytes, 208 lines download raw bytes

1(function($){
2	SlideDeckSkin['image_caption_bottom'] = function(slidedeck){
3		var slidedeck = $(slidedeck);
4		var slidedeckFrame = slidedeck.closest('.slidedeck_frame')
5		var deck = slidedeck.slidedeck();
6		var prev = slidedeckFrame.find('.sd-node-previous');
7		var next = slidedeckFrame.find('.sd-node-next');
8        var prevNext = slidedeckFrame.find('.sd-node-next, .sd-node-previous');
9		var primaryNavs = slidedeckFrame.find('.sd-node-nav-primary a.sd-node-nav-link');
10        var showHideSpeed = 250;
11        
12        var sizeDeckFrame = function(){
13            if( slidedeck.width() && slidedeck.height() ){
14                slidedeckFrame.css({
15                    width: slidedeck.css('width'),
16                    height: slidedeck.css('height')
17                });
18            }
19        };
20		
21		var updateActive = function(activeSlide){
22			if(deck.options.cycle == false){
23				if(activeSlide == 1){
24					prev.addClass('disabled');
25					next.removeClass('disabled');
26				}
27				if(activeSlide == deck.slides.length){
28					next.addClass('disabled');
29					prev.removeClass('disabled');
30				}
31			}
32			primaryNavs.removeClass('active');
33			$(primaryNavs[activeSlide - 1]).addClass('active');
34		};
35		
36		var oldNext = deck.next;
37		deck.next = function(params){
38			var nextSlide = Math.min(deck.slides.length,(deck.current + 1));
39			if(deck.options.cycle === true){
40				if(deck.current + 1 > deck.slides.length){
41					nextSlide = 1;
42				}
43			}
44			
45			oldNext(params);
46			updateActive(nextSlide);
47		};
48		var oldPrev = deck.prev;
49		deck.prev = function(params){
50			var prevSlide = Math.max(1,(deck.current - 1));
51			if(deck.options.cycle === true){
52				if(deck.current - 1 < 1){
53					prevSlide = deck.slides.length;
54				}
55			}
56			
57			oldPrev(params);
58			updateActive(prevSlide);
59		};
60		var oldGoTo = deck.goTo;
61		deck.goTo = function(ind, params){
62		    ind = parseInt(ind);
63			oldGoTo(ind, params);
64			updateActive(Math.min(deck.slides.length,Math.max(1,ind)));
65		};
66		
67		slidedeckFrame.find('.sd-node-nav-link').bind('click', function(event){
68			event.preventDefault();
69
70			var action = this.href.split('#')[1];
71			
72			deck.pauseAutoPlay = true;
73
74			switch(action){
75				case "previous":
76					deck.prev();
77				break;
78				case "next":
79					deck.next();
80				break;
81				default:
82					deck.goTo(action);
83				break;
84			}
85		});
86		
87		$(primaryNavs[0]).addClass('active');
88        
89        // add animation events to prev/next buttons
90        prevNext.show().animate({ opacity: 0 }, 0);
91        slidedeckFrame.bind('mouseenter',function(){
92            prevNext.stop(true).animate({
93                opacity: 1
94            }, showHideSpeed);
95        });
96        slidedeckFrame.bind('mouseleave',function(){
97            prevNext.animate({
98                opacity: 0
99            }, showHideSpeed);
100        });
101        
102        // size the deck frame
103        sizeDeckFrame();
104		
105        function imgLoaded(el, thisSlide){
106            if($.data(el, 'image_caption_bottom-sized') == true){
107                return false;
108            }
109            
110            var $el = $(el);
111            
112            var slideWidth = thisSlide.innerWidth();
113            var slideHeight = thisSlide.innerHeight();
114
115            // Remove attributes in case img-element has set width and height
116            var pic_real_width = $el.width();
117            var pic_real_height = $el.height();
118            
119            $el.removeAttr("width").removeAttr("height").css({ width: "", height: "" }); // Remove css dimensions as well
120            pic_real_width = el.width;
121            pic_real_height = el.height;
122            
123            var image_ratio = (pic_real_width / pic_real_height);
124            var deck_ratio = (slideWidth / slideHeight);
125            
126            if(image_ratio < deck_ratio){
127                // image too tall
128                var newHeight = Math.round(slideWidth / (image_ratio));
129                var newWidth = slideWidth;
130            }else if(image_ratio >= deck_ratio){
131                // image too wide
132                var newWidth = Math.round(slideHeight * (image_ratio));
133                var newHeight = slideHeight;
134            }
135            $el.css({
136                position: 'absolute',
137                top: '50%',
138                left: '50%',
139                width: newWidth + 'px',
140                maxWidth: newWidth + 'px',
141                height: newHeight + 'px',
142                maxHeight: newHeight + 'px',
143                marginLeft: '-' + Math.round(newWidth / 2) + 'px',
144                marginTop: '-' + Math.round(newHeight / 2) + 'px'
145            });
146            
147            if(pic_real_width > 0 && pic_real_height > 0){
148                $.data(el, 'image_caption_bottom-sized', true);
149            }
150        }
151        
152        deck.loaded(function(){
153            for(var z=0, slides=slidedeckFrame.find('dd.slide .sd-node-container'); z<slides.length; z++){
154                var thisSlide = $(slides[z]);
155                
156                if(thisSlide.find('.sd-node-image img').length){
157                    
158                    // strip any false image sizes
159                    var img = thisSlide.find('.sd-node-image img')[0];
160                    
161                    $(img).load(function() {
162                        imgLoaded(this, thisSlide);
163                    });
164                    
165                    var src = img.src;
166                    img.src = "";
167                    img.src = src;
168                    // fade the first image in
169                    if( z == 0 ){
170                        $(img).fadeIn(100);
171                    }else{
172                        $(img).show();
173                    }
174                }
175            }
176        });
177        
178        
179        /**
180         * Try to accommodate for the race condition created between the image loading,
181         * the DOM being ready, the browser determining when images actual have dimensions
182         * associated with them and the page being ready for view. The imgLoaded() function
183         * is run on the loaded event of each image as well as DOMReady and Window Loaded.
184         * The imgLoaded() function will return boolean(false) if it has already processed
185         * and been able to scale the image properly.
186         */
187        $(document).ready(function(){
188            deck.slides.find('.sd-node-image img').each(function(){
189                imgLoaded(this, $(this).closest('dd.slide .sd-node-container'));
190            });
191        });
192        $(window).load(function(){
193            deck.slides.find('.sd-node-image img').each(function(){
194                imgLoaded(this, $(this).closest('dd.slide .sd-node-container'));
195            });
196        });
197		
198		return true;
199	};
200    
201    $(document).ready(function(){
202        $('.skin-image_caption_bottom .slidedeck').each(function(){
203            if(typeof($.data(this, 'skin-image_caption_bottom')) == 'undefined'){
204                $.data(this, 'skin-image_caption_bottom', new SlideDeckSkin['image_caption_bottom'](this));
205            }
206        });
207    });
208})(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.