PageSourceSearch

http://www.abigailvigoa.com/wp-content/plugins/cherry-media-parallax/js/cherry-media-parallax.js?ver=1.0

js abigailvigoa.com collected 2026-10-06 13:14:48 UTC 15,550 bytes, 348 lines download raw bytes

1(function($){
2    var methods = {
3        init : function( options ) {
4
5            var settings = {
6                bufferRatio: 1.5
7            ,   invert: true
8            }
9
10            return this.each(function(){
11                if ( options ){
12                    $.extend(settings, options);
13                } 
14                
15                var 
16                    $this = $(this)
17                ,   windowSelector = $(window)
18                ,   documentSelector = $(document)
19                ,   thisHeight = 0
20                ,   innerHolderObj
21                ,   mediaHolderObj
22                ,   infoObj
23                ,   imageObj
24                ,   innerHolderHeight
25                ,   thisOffsetTop
26                ,   heightBuffer = 0
27                ,   check_mp4
28                ,   check_webm
29                ,   check_ogv
30                ,   check_poster
31                ,   check_none_format
32                ,   check_all_format
33                ,   statusDevice = "desktop"
34                ,   typeMedia = "video"
35                ,   msie8 = Boolean(navigator.userAgent.match(/MSIE ([8]+)\./))
36                ,   checkBrowser
37                ,   bufferRatio = parseFloat(settings.bufferRatio)
38                ;
39                
40                _constructor();
41                function _constructor(){
42                    
43                    innerHolderObj = $('.parallax_inner', $this);
44                    mediaHolderObj = $('.parallax_media', $this);
45
46                    typeMedia = $this.data("type-media");
47
48                    checkBrowser = checkBrowser();
49                    
50                    check_mp4 = $this.data("mp4");
51                    check_webm = $this.data("webm");
52                    check_ogv = $this.data("ogv");
53                    check_poster = $this.data("poster");
54
55                    (!check_mp4 && !check_webm && !check_ogv)? check_none_format = false : check_none_format = true;
56                    (check_mp4 && check_webm && check_ogv)? check_all_format = true : check_all_format = false;
57
58                    if (device.mobile() || device.tablet() || msie8 || checkBrowser == 'Safari') {
59                        statusDevice = "mobile";
60                        posterUrl = mediaHolderObj.attr('poster');
61                        innerHolderObj.css({"background-image": "url("+posterUrl+")" });   
62                        $this.addClass('mobileState');  
63                        mediaHolderObj.remove();
64                    }
65
66                    if (typeMedia == "video"){
67                        sourcesCheckInfo();
68                    }
69
70                    addEventsFunction();                    
71                }
72                
73                function addEventsFunction(){
74                    //------------------ window scroll event -------------//
75                    windowSelector.on('scroll',
76                        function(){
77                            if(statusDevice=="desktop"){
78                                mainScrollFunction();
79                            }
80                        }
81                    ).trigger('scroll');
82                    //------------------ window resize event -------------//
83                    windowSelector.on("resize",
84                        function(){
85                            $this.width(windowSelector.width());
86                            $this.css({'width' : windowSelector.width(), 'margin-left' : Math.floor(windowSelector.width()*-0.5), 'left' : '50%'});
87
88                            if(statusDevice=="desktop"){
89                                mainResizeFunction();
90                            }
91                        }
92                    ).trigger('resize');
93                }
94                //------------------ window scroll function -------------//
95                function mainScrollFunction(){
96                    parallaxEffect();
97                }
98                //------------------ window resize function -------------//
99                function mainResizeFunction(){                    
100                    parallaxEffect();
101                    if (typeMedia == "image"){
102                        objectResize($('.parallax_media', innerHolderObj), innerHolderObj, "fill");
103                    }else{
104                        videoResize($('.parallax_media', innerHolderObj), innerHolderObj);
105                    }
106                }
107                
108                function parallaxEffect(){
109                    var 
110                        documentScrollTop
111                    ,   startScrollTop
112                    ,   endScrollTop
113                    ,   visibleScrollValue
114                    ;
115
116                    thisHeight = $this.outerHeight();
117
118                    windowHeight = windowSelector.height();
119                    thisOffsetTop = $this.offset().top;
120                    documentScrollTop = documentSelector.scrollTop();
121                    innerHolderHeight = thisHeight*bufferRatio;
122                    heightBuffer = innerHolderHeight-thisHeight;
123                    startScrollTop = documentScrollTop + windowHeight;
124                    endScrollTop = documentScrollTop - thisHeight;
125                    visibleScrollValue = startScrollTop - endScrollTop;
126
127                    if( ( startScrollTop > thisOffsetTop ) && ( endScrollTop < thisOffsetTop ) ){
128                        pixelScrolled = documentScrollTop - (thisOffsetTop - windowHeight);
129                        percentScrolled = pixelScrolled / visibleScrollValue;
130                        thisHidenScrollVal = thisOffsetTop - documentScrollTop;
131                        deltaTopScrollVal = heightBuffer * percentScrolled;
132
133                        if(settings.invert){
134                            _x = - heightBuffer + (deltaTopScrollVal);
135                            _height = thisHeight*bufferRatio;
136                            innerHolderObj.css({"top": _x, "height": _height});
137                        }else{
138                            _x = - deltaTopScrollVal;
139                            _height = thisHeight*bufferRatio;
140                            innerHolderObj.css({"top": _x, "height": _height});
141                        }
142                    }
143                }
144                //-------------------------------- objectResize --------------------------------------//
145                //objectResize($('> img', primaryImageHolder), mainImageHolder, "fill");
146                function objectResize(obj, container, type){
147                    var 
148                        prevImgWidth = 0
149                    ,   prevImgHeight = 0
150                    ,   imageRatio
151                    ,   newImgWidth
152                    ,   newImgHeight
153                    ,   newImgTop
154                    ,   newImgLeft
155                    ,   alignIMG = 'center'
156                    ;
157       
158                    prevImgWidth = parseInt(obj.data('base-width'));
159                    prevImgHeight = parseInt(obj.data('base-height'));
160
161                    imageRatio = prevImgHeight/prevImgWidth;
162                    containerRatio = container.height()/container.width();
163
164                    switch(type){
165                        case 'fill':
166                            if(containerRatio > imageRatio){
167                                newImgHeight = container.height();
168                                newImgWidth = Math.round( (newImgHeight*prevImgWidth) / prevImgHeight );
169                            }else{
170                                newImgWidth = container.width();
171                                newImgHeight = Math.round( (newImgWidth*prevImgHeight) / prevImgWidth );
172                            }
173
174                            obj.css({width: newImgWidth, height: newImgHeight});
175
176                            screenWidth = container.width();
177                            screenHeight = container.height();
178                            imgWidth = obj.width();
179                            imgHeight = obj.height();
180
181                            switch(alignIMG){
182                                case "top":
183                                    newImgLeft=-(imgWidth-screenWidth)*.5;
184                                    newImgTop=0;
185                                break;
186                                case "bottom":
187                                    newImgLeft=-(imgWidth-screenWidth)*.5;
188                                    newImgTop=-(imgHeight-screenHeight);
189                                break;
190                                case "right":
191                                    newImgLeft=-(imgWidth-screenWidth);
192                                    newImgTop=-(imgHeight-screenHeight)*.5;
193                                break;
194                                case "left":
195                                    newImgLeft=0;
196                                    newImgTop=-(imgHeight-screenHeight)*.5;
197                                break;
198                                case "top_left":
199                                    newImgLeft=0;
200                                    newImgTop=0;
201                                break;
202                                case "top_right":
203                                    newImgLeft=-(imgWidth-screenWidth);
204                                    newImgTop=0;
205                                break;
206                                case "bottom_right":
207                                    newImgLeft=-(imgWidth-screenWidth);
208                                    newImgTop=-(imgHeight-screenHeight);
209                                break;
210                                case "bottom_left":
211                                    newImgLeft=0;
212                                    newImgTop=-(imgHeight-screenHeight);
213                                break;
214                                default:
215                                    newImgLeft=-(imgWidth-screenWidth)*.5;
216                                    newImgTop= -(imgHeight-screenHeight)*.5;
217                                }
218                        break
219                        case 'fit':
220                            if(containerRatio > imageRatio){
221                                newImgWidth = container.width();
222                                newImgHeight = (prevImgHeight*container.width())/prevImgWidth;
223                                newImgTop = container.height()/2 - newImgHeight/2;
224                                newImgLeft = 0; 
225                            }else{
226                                newImgWidth = (prevImgWidth*container.height())/prevImgHeight;
227                                newImgHeight = container.height();
228                                newImgTop = 0;
229                                newImgLeft = container.width()/2 - newImgWidth/2;  
230                            }
231                            obj.css({width: newImgWidth, height: newImgHeight});
232                        break
233                    }
234
235                    obj.css({top: newImgTop, left: newImgLeft});
236                }
237                function videoResize(obj, container){
238                    var 
239                        prevImgWidth = 0
240                    ,   prevImgHeight = 0
241                    ,   imageRatio
242                    ,   newImgWidth
243                    ,   newImgHeight
244                    ;
245       
246                    prevImgWidth = parseInt(obj.data('base-width'));
247                    prevImgHeight = parseInt(obj.data('base-height'));
248
249                    imageRatio = prevImgHeight/prevImgWidth;
250                    containerRatio = container.height()/container.width();
251                    
252                    
253                    if(containerRatio > imageRatio){
254                        newImgHeight = container.height();
255                        newImgWidth = "auto";
256                    }else{
257                        newImgWidth = container.width();
258                        newImgHeight = "auto";
259                    }
260
261                    obj.css({width: newImgWidth, height: newImgHeight});
262
263                    imgHeight = obj.height();
264                    newImgTop = -(imgHeight-container.height())*.5;
265                    obj.css({top: newImgTop});
266                }
267                /*----------------------- sourcesCheckInfo --------------------------------------------------------*/
268                function sourcesCheckInfo(){
269                    var 
270                        infostring = ""
271                    ,   formatCounter = 0
272                    ,   posterUrl
273                    ;
274
275                    $this.append("<div class='info_alert'><span></span></div>");
276                    infoObj = $('.info_alert', $this);
277
278
279                    if(!check_all_format){
280                        infostring += "Not loaded the necessary content!<br>Please, make sure format(s) ";
281                        if(!check_mp4){
282                            infostring +="<b>MP4</b>, "
283                            formatCounter++;
284                        }
285                        if(!check_webm){
286                            infostring +="<b>WEBM</b>, "
287                            formatCounter++;
288                        }
289                        if(!check_ogv){
290                            infostring +="<b>OGV</b>"
291                            formatCounter++;
292                        }
293                        if(formatCounter == 1){
294                            infostring += " is loaded or name is specified correctly!<br>";
295                        }else{
296                            infostring += " are loaded or name is specified correctly!<br>";
297                        }
298                        
299                    }
300                    if(!check_poster){
301                        infostring +="Please make sure <b>poster file</b> is loaded or name is specified correctly!"
302                    }
303                    if(infostring!=""){
304                        $("span", infoObj).html(infostring);
305                    }else{
306                        infoObj.remove();
307                    }
308                }
309
310                function checkBrowser(){
311                    var ua = navigator.userAgent;
312                    
313                    if (ua.search(/MSIE/) > 0) return 'Internet Explorer';
314                    if (ua.search(/Firefox/) > 0) return 'Firefox';
315                    if (ua.search(/Opera/) > 0) return 'Opera';
316                    if (ua.search(/Chrome/) > 0) return 'Google Chrome';
317                    if (ua.search(/Safari/) > 0) return 'Safari';
318                    if (ua.search(/Konqueror/) > 0) return 'Konqueror';
319                    if (ua.search(/Iceweasel/) > 0) return 'Debian Iceweasel';
320                    if (ua.search(/SeaMonkey/) > 0) return 'SeaMonkey';
321                    if (ua.search(/Gecko/) > 0) return 'Gecko';
322
323                    return 'Search Bot';
324                }
325            });
326        },
327        destroy    : function( ) {
328            return this.each(function(){
329                $(window).off('.cherryVideoParallax');
330            })
331        },
332        reposition : function( ) { },
333        update     : function( content ) { }
334    };
335
336    $.fn.cherryMediaParallax = function( method ){ 
337        
338        if ( methods[method] ) {
339            return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
340        } else if ( typeof method === 'object' || ! method ) {
341            return methods.init.apply( this, arguments );
342        } else {
343            $.error( 'Method with name ' +  method + ' is not exist for jQuery.cherryMediaParallax' );
344        }
345         
346        
347    }//end plugin
348})(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.