PageSourceSearch

https://jackbenimble.de/jack2/wp-content/plugins/cherry-media-parallax/js/cherry-media-parallax.js?ver=1.0

js jackbenimble.de collected 2026-10-05 19:07:37 UTC 15,749 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_html"
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                        if(typeMedia == "video_html"){
61                           posterUrl = mediaHolderObj.attr('poster'); 
62                       }else{
63                            posterUrl = mediaHolderObj.attr('src');
64                       }
65                        
66                        innerHolderObj.css({"background-image": "url("+posterUrl+")" });   
67                        $this.addClass('mobileState');  
68                       mediaHolderObj.remove();
69                    }
70
71                    if (typeMedia == "video_html"){
72                        sourcesCheckInfo();
73                    }
74
75                    addEventsFunction();                    
76                }
77                
78                function addEventsFunction(){
79                    //------------------ window scroll event -------------//
80                    windowSelector.on('scroll',
81                        function(){
82                            if(statusDevice=="desktop"){
83                                mainScrollFunction();
84                            }
85                        }
86                    ).trigger('scroll');
87                    //------------------ window resize event -------------//
88                    windowSelector.on("resize",
89                        function(){
90                            $this.width(windowSelector.width());
91                            $this.css({'width' : windowSelector.width(), 'margin-left' : Math.floor(windowSelector.width()*-0.5), 'left' : '50%'});
92
93                            if(statusDevice=="desktop"){
94                                mainResizeFunction();
95                            }
96                        }
97                    ).trigger('resize');
98                }
99                //------------------ window scroll function -------------//
100                function mainScrollFunction(){
101                    parallaxEffect();
102                }
103                //------------------ window resize function -------------//
104                function mainResizeFunction(){                    
105                    parallaxEffect();
106                    if (typeMedia == "video_html"){
107                        videoResize(mediaHolderObj, innerHolderObj);
108                    }else{
109                        objectResize(mediaHolderObj, innerHolderObj, "fill");
110                    }
111                }
112                
113                function parallaxEffect(){
114                    var 
115                        documentScrollTop
116                    ,   startScrollTop
117                    ,   endScrollTop
118                    ,   visibleScrollValue
119                    ;
120
121                    thisHeight = $this.outerHeight();
122
123                    windowHeight = windowSelector.height();
124                    thisOffsetTop = $this.offset().top;
125                    documentScrollTop = documentSelector.scrollTop();
126                    innerHolderHeight = thisHeight*bufferRatio;
127                    heightBuffer = innerHolderHeight-thisHeight;
128                    startScrollTop = documentScrollTop + windowHeight;
129                    endScrollTop = documentScrollTop - thisHeight;
130                    visibleScrollValue = startScrollTop - endScrollTop;
131
132                    _height = thisHeight*bufferRatio;
133                    innerHolderObj.css({"height": _height});
134
135                    if( ( startScrollTop > thisOffsetTop ) && ( endScrollTop < thisOffsetTop ) ){
136                        pixelScrolled = documentScrollTop - (thisOffsetTop - windowHeight);
137                        percentScrolled = pixelScrolled / visibleScrollValue;
138                        thisHidenScrollVal = thisOffsetTop - documentScrollTop;
139                        deltaTopScrollVal = heightBuffer * percentScrolled;
140
141                        if(settings.invert){
142                            _x = - heightBuffer + (deltaTopScrollVal);
143                            innerHolderObj.css({"top": _x});
144                        }else{
145                            _x = - deltaTopScrollVal;
146                            innerHolderObj.css({"top": _x});
147                        }
148                    }
149                }
150                //-------------------------------- objectResize --------------------------------------//
151                //objectResize($('> img', primaryImageHolder), mainImageHolder, "fill");
152                function objectResize(obj, container, type){
153                    var 
154                        prevImgWidth = 0
155                    ,   prevImgHeight = 0
156                    ,   imageRatio
157                    ,   newImgWidth
158                    ,   newImgHeight
159                    ,   newImgTop
160                    ,   newImgLeft
161                    ,   alignIMG = 'center'
162                    ;
163       
164                    prevImgWidth = parseInt(obj.data('base-width'));
165                    prevImgHeight = parseInt(obj.data('base-height'));
166
167                    imageRatio = prevImgHeight/prevImgWidth;
168                    containerRatio = container.height()/container.width();
169
170                    switch(type){
171                        case 'fill':
172                            if(containerRatio > imageRatio){
173                                newImgHeight = container.height();
174                                newImgWidth = Math.round( (newImgHeight*prevImgWidth) / prevImgHeight );
175                            }else{
176                                newImgWidth = container.width();
177                                newImgHeight = Math.round( (newImgWidth*prevImgHeight) / prevImgWidth );
178                            }
179
180                            obj.css({width: newImgWidth, height: newImgHeight});
181
182                            screenWidth = container.width();
183                            screenHeight = container.height();
184                            imgWidth = obj.width();
185                            imgHeight = obj.height();
186
187                            switch(alignIMG){
188                                case "top":
189                                    newImgLeft=-(imgWidth-screenWidth)*.5;
190                                    newImgTop=0;
191                                break;
192                                case "bottom":
193                                    newImgLeft=-(imgWidth-screenWidth)*.5;
194                                    newImgTop=-(imgHeight-screenHeight);
195                                break;
196                                case "right":
197                                    newImgLeft=-(imgWidth-screenWidth);
198                                    newImgTop=-(imgHeight-screenHeight)*.5;
199                                break;
200                                case "left":
201                                    newImgLeft=0;
202                                    newImgTop=-(imgHeight-screenHeight)*.5;
203                                break;
204                                case "top_left":
205                                    newImgLeft=0;
206                                    newImgTop=0;
207                                break;
208                                case "top_right":
209                                    newImgLeft=-(imgWidth-screenWidth);
210                                    newImgTop=0;
211                                break;
212                                case "bottom_right":
213                                    newImgLeft=-(imgWidth-screenWidth);
214                                    newImgTop=-(imgHeight-screenHeight);
215                                break;
216                                case "bottom_left":
217                                    newImgLeft=0;
218                                    newImgTop=-(imgHeight-screenHeight);
219                                break;
220                                default:
221                                    newImgLeft=-(imgWidth-screenWidth)*.5;
222                                    newImgTop= -(imgHeight-screenHeight)*.5;
223                                }
224                        break
225                        case 'fit':
226                            if(containerRatio > imageRatio){
227                                newImgWidth = container.width();
228                                newImgHeight = (prevImgHeight*container.width())/prevImgWidth;
229                                newImgTop = container.height()/2 - newImgHeight/2;
230                                newImgLeft = 0; 
231                            }else{
232                                newImgWidth = (prevImgWidth*container.height())/prevImgHeight;
233                                newImgHeight = container.height();
234                                newImgTop = 0;
235                                newImgLeft = container.width()/2 - newImgWidth/2;  
236                            }
237                            obj.css({width: newImgWidth, height: newImgHeight});
238                        break
239                    }
240
241                    obj.css({top: newImgTop, left: newImgLeft});
242                }
243                function videoResize(obj, container){
244                    var 
245                        prevImgWidth = 0
246                    ,   prevImgHeight = 0
247                    ,   imageRatio
248                    ,   newImgWidth
249                    ,   newImgHeight
250                    ;
251       
252                    prevImgWidth = parseInt(obj.data('base-width'));
253                    prevImgHeight = parseInt(obj.data('base-height'));
254
255                    imageRatio = prevImgHeight/prevImgWidth;
256                    containerRatio = container.height()/container.width();
257                    
258
259                    if(containerRatio > imageRatio){
260                        newImgWidth = "auto";
261                        newImgHeight = container.height();
262                    }else{
263                        newImgWidth = container.width();
264                        newImgHeight = "auto";
265                    }
266
267                    
268                    obj.css({width: newImgWidth, height: newImgHeight});
269
270                }
271                /*----------------------- sourcesCheckInfo --------------------------------------------------------*/
272                function sourcesCheckInfo(){
273                    var 
274                        infostring = ""
275                    ,   formatCounter = 0
276                    ,   posterUrl
277                    ;
278
279                    $this.append("<div class='info_alert'><span></span></div>");
280                    infoObj = $('.info_alert', $this);
281
282
283                    if(!check_all_format){
284                        infostring += "Not loaded the necessary content!<br>Please, make sure format(s) ";
285                        if(!check_mp4){
286                            infostring +="<b>MP4</b>, "
287                            formatCounter++;
288                        }
289                        if(!check_webm){
290                            infostring +="<b>WEBM</b>, "
291                            formatCounter++;
292                        }
293                        if(!check_ogv){
294                            infostring +="<b>OGV</b>"
295                            formatCounter++;
296                        }
297                        if(formatCounter == 1){
298                            infostring += " is loaded or name is specified correctly!<br>";
299                        }else{
300                            infostring += " are loaded or name is specified correctly!<br>";
301                        }
302                        
303                    }
304                    if(!check_poster){
305                        infostring +="Please make sure <b>poster file</b> is loaded or name is specified correctly!"
306                    }
307                    if(infostring!=""){
308                        $("span", infoObj).html(infostring);
309                    }else{
310                        infoObj.remove();
311                    }
312                }
313
314                function checkBrowser(){
315                    var ua = navigator.userAgent;
316                    
317                    if (ua.search(/MSIE/) > 0) return 'Internet Explorer';
318                    if (ua.search(/Firefox/) > 0) return 'Firefox';
319                    if (ua.search(/Opera/) > 0) return 'Opera';
320                    if (ua.search(/Chrome/) > 0) return 'Google Chrome';
321                    if (ua.search(/Safari/) > 0) return 'Safari';
322                    if (ua.search(/Konqueror/) > 0) return 'Konqueror';
323                    if (ua.search(/Iceweasel/) > 0) return 'Debian Iceweasel';
324                    if (ua.search(/SeaMonkey/) > 0) return 'SeaMonkey';
325                    if (ua.search(/Gecko/) > 0) return 'Gecko';
326
327                    return 'Search Bot';
328                }
329            });
330        },
331        destroy    : function( ) { },
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.