PageSourceSearch

https://www.motoroso.com/public/js/singleViewPopup.js

js motoroso.com collected 2026-10-05 02:41:38 UTC 16,231 bytes, 470 lines download raw bytes

1/*
2$(document).ready(function() {
3    //afterSinglePageLoad();
4    $(window).resize(function() {
5        $('.center-image').each(function() {
6            imageresize(this);
7        });
8    });
9});
10*/
11
12function resizeContainer(element) {
13    //$(element).closest(".singlebanner").css('max-height', $(element).naturalHeight());
14    $(element).siblings(".spacer").css('height', $(element).css('height'));
15    console.log("resizing container: image height: " + $(element).css('height'));
16    console.log("singlebanner height:" + $('.singlebanner').css('height'));
17    $(element).siblings(".image-container").css('height', $(element).css('height'));
18    $(element).siblings(".image-container").css('width', $(element).css('width'));
19    $(element).siblings(".image-container").css('left', $(element).css('left'));
20    $(element).siblings(".image-container").css('top', $(element).css('top'));
21    //$("#slider").css('height', $('#image').css('height'));
22}
23/*
24function imageresize(ele) {
25    console.log('resizing image');
26    var originalImageWidth = $(ele).attr('data-orig-width');
27    var originalImageHeight = $(ele).attr('data-orig-height');
28    console.log("original image: " + originalImageWidth + "x" + originalImageHeight);
29    var imageProportions = originalImageWidth / originalImageHeight;
30    var widthScale = 1;
31    if (originalImageWidth > 1020) {
32        //We need to scale down the max height, 1020 is the max width
33        widthScale = 1020/originalImageWidth; 
34    }
35    var windowHeight = $(window).height();
36    var conHeight = windowHeight * .70;
37    var maxHeight = Math.min(conHeight, originalImageHeight, originalImageHeight*widthScale);
38    console.log("imageProportions: " + imageProportions);
39    var maxImgWidth = originalImageWidth;
40    if (maxHeight < originalImageHeight) {
41        maxImgWidth = originalImageWidth * (maxHeight / originalImageHeight);
42    }
43    $('.singlebanner').css({'height': maxHeight + 'px'});
44    $(".image-container").css({'height': maxHeight + 'px'});
45    console.log("maxImgWidth:" + maxImgWidth + " maxHeight: " + maxHeight);
46    $(".image-container").css({'width': maxImgWidth});
47    $('.image').css({'height': maxHeight + 'px'});
48    $('#single-ajax-load').show();
49}
50*/
51
52
53function afterSinglePageLoad()
54{
55    console.log('afterSinglePageLoad');
56    $(".mfp-content .item-slider").imagesLoaded().done(function() {
57        console.log("images loaded");
58        bindMarkers($(".mfp-content .item-slider"));
59		/* Broken code, going unused anywyas
60        var ele = $('.mfp-content .center-image');
61        console.log(ele);
62        var originalImageWidth = ele.naturalWidth();
63        var originalImageHeight = ele.naturalHeight();
64        console.log("original image: " + originalImageWidth + "x" + originalImageHeight);
65        ele.attr('data-orig-width', originalImageWidth);
66        ele.attr('data-orig-height', originalImageHeight);
67        //imageresize(ele);
68		*/
69    });
70    initMagnificPopup();
71	if(isAuthenticated) {
72    	bindParkIt();
73	}
74	configureShareLink();
75}
76
77function bindMarkers(container) {
78    console.log("bindMarkers");
79    console.log(container);
80     //Product Markers
81    //instantiate QTip on product markers and howto's
82    $(container).find('div[data-typeid="2"] .isQtip, div[data-typeid="3"] .isQtip').qtip({
83        content: {
84            text: function(event, api) {
85                console.log("getting qtip content");
86                ajaxUrl = $(this).attr('data-ajaxurl');
87                $.ajax({url: ajaxUrl})
88                        .done(function(html) {
89                            api.set('content.text', html);
90                        })
91                        .fail(function(xhr, status, error) {
92                            api.set('content.text', status + ': ' + error);
93                        });
94                return 'Loading...';
95            }
96        },
97        show: {
98            //ready: true,
99            event: 'click'
100            //    solo: true,
101        },
102        hide: {
103            event: 'click unfocus'
104        },
105        position: {
106            my: 'left bottom',
107            at: 'bottom right',
108            viewport: $('#single-ajax-load, main'),
109            container: $('#image-container')
110        },
111        style: {
112            classes: 'qtip-light qtip-shadow'
113        },
114        events: {
115            /*
116             * Since your qTip will likely have prerender set to false, we'll bind within the render event
117             * so we're certain the tooltip is actually rendered before binding our handlers.
118             */
119            render: function(event, api) {
120                console.log("opening product marker");
121                // mixpanel.track("Product Marker Clicked");
122                // Grab the tooltip element from the API elements object
123                var tooltip = api.elements.tooltip;
124
125                // Notice the 'tooltip' prefix of the event name!
126                tooltip.bind('tooltipshow', function(event, api) {
127                    // Update our other plugin and pass our event object
128                    if (typeof bxslider != "undefined") {
129                        bxslider.trigger('stopScroll');
130
131                    }
132                });
133                // Notice the 'tooltip' prefix of the event name!
134                tooltip.bind('tooltiphide', function(event, api) {
135                    // Update our other plugin and pass our event object
136                    if (typeof bxslider != "undefined") {
137                        bxslider.trigger('startScroll');
138
139                    }
140                });
141
142            }
143        }
144    });
145
146    //Information markers
147     $(container).find('div[data-typeid="4"] .isQtip').each(function() {
148        console.log("binding information marker");
149        $(this).qtip({
150            content: {
151                text: $(this).next('.tooltiptext')
152            },
153            show: {
154                //ready: true,
155                event: 'click'
156                //    solo: true,
157            },
158            hide: {
159                event: 'click unfocus'
160            },
161            position: {
162                my: 'left bottom',
163                at: 'bottom right',
164                viewport: $('#slider'),
165                container: $('#image-container')
166            },
167            style: {
168                width: '300px',
169                classes: 'qtip-light qtip-shadow'
170            },
171            events: {
172                /*
173                 * Since your qTip will likely have prerender set to false, we'll bind within the render event
174                 * so we're certain the tooltip is actually rendered before binding our handlers.
175                 */
176                render: function(event, api) {
177                    console.log("opening information marker");
178                    // mixpanel.track("Information Marker Clicked");
179                    // Grab the tooltip element from the API elements object
180                    var tooltip = api.elements.tooltip;
181
182                    // Notice the 'tooltip' prefix of the event name!
183                    tooltip.bind('tooltipshow', function(event, api) {
184                        // Update our other plugin and pass our event object
185                        if (typeof bxslider != "undefined") {
186                            bxslider.trigger('stopScroll');
187                            console.log('stopping slider');
188                        }
189                    });
190                    // Notice the 'tooltip' prefix of the event name!
191                    tooltip.bind('tooltiphide', function(event, api) {
192                        // Update our other plugin and pass our event object
193                        if (typeof bxslider != "undefined") {
194                            bxslider.trigger('startScroll');
195                            console.log('starting slider');
196                        }
197                    });
198
199                }
200            }
201        });
202    });
203
204
205    //Video Markers
206    $(container).find('.marker[data-typeid="1"]').each(function(e) {
207        var str = $(this).attr('href');
208        var replace = str.replace(/(?:http:|https:)\/\/.*?(?:youtube.com\/|youtu.be\/)(?:embed\/|watch\?v=)?(.*)/g,
209                '//www.youtube.com/embed/$1?rel=0&feature=oembed&autoplay=1');
210        $(this).attr('href', replace);
211    });
212
213    $('.marker[data-typeid="1"]').click(function(e) {
214        console.log("playing video");
215        var url = $(this).attr('href');
216        e.preventDefault();
217        $.fancybox.showLoading();
218
219        $.fancybox.open({
220            href: url,
221            type: 'iframe',
222            scrolling: 'no',
223            width: 640,
224            height: 384,
225            autoSize: false
226        });
227
228        return false;
229    });
230
231
232    $(container).find('.marker[data-typeid="1"]').fancybox({
233        width: 640,
234        height: 384,
235        'type': "iframe",
236        media: true,
237        beforeShow: function() {
238            if (typeof bxslider != "undefined") {
239                bxslider.trigger('stopScroll');
240                console.log('stopping slider');
241            }
242        },
243        afterClose: function() {
244            if (typeof bxslider != "undefined") {
245                bxslider.trigger('startScroll');
246                console.log('starting slider');
247            }
248        }
249        //title: "test",
250    });
251
252
253    //Product Markers
254
255    //position fancybox
256    $(window).bind('resize', function() {
257        var top = ($('#slider1').height() / 2) - ($(".fancybox-wrap").outerHeight() / 2);
258        var left = ($('#slider1').width() / 2) - ($(".fancybox-wrap").outerWidth() / 2);
259        $(".fancybox-wrap").css({top: top, left: left});
260    }).trigger('resize');
261
262    $(container).find('.star-rating').find("a").click(function() {
263        var width = $(this).text();
264        $.ajax({
265            type: "GET",
266            url: "../collectionItem/rateItem",
267            data: {rating: $(this).text(), collectionItemId: $('.star-rating').data("collectionitemid")},
268            success: function(msg) {
269                width = width * 11;
270                $('.current-rating').css('width', width + "px");
271                //alert( "Data Saved: " + msg );
272            },
273            statusCode: {
274                403: function() {
275                    openSignupIFrame();
276                }
277            }
278        });
279    });
280	
281	function showMarkers() {
282        $('.markerdiv').show();
283        $('.show-markers').hide();
284        $('.hide-markers').show();
285		document.querySelector('#slider-image').dispatchEvent(new CustomEvent('wheelzoom.destroy'));
286		$('.zoom-info').hide();
287		$('.zoom-active').hide();
288		$('.zoom-inactive').show();
289		$('.image-container').addClass('view-tags');
290	}
291	function hideMarkers() {
292        $('.markerdiv').hide();
293        $('.hide-markers').hide();
294        $('.show-markers').show();
295		$('.image-container').removeClass('view-tags');
296	}
297	function enableZoom() {
298		$('.zoom-inactive').hide();
299		$('.zoom-active').show();
300		$('.zoom-info').show();
301		wheelzoom(document.querySelector('#slider-image'));
302	}
303	function disableZoom() {
304		$('.zoom-active').hide();
305		$('.zoom-info').hide();
306		$('.zoom-inactive').show();
307		document.querySelector('#slider-image').dispatchEvent(new CustomEvent('wheelzoom.destroy'));
308	}
309
310	// Controls the Show/Hide Markers
311    $(container).find('.hide-markers').click(function(e) {
312		hideMarkers();
313		return false;
314    });
315    $(container).find('.show-markers').click(function(e) {
316		showMarkers();
317		return false;
318    });
319	
320	// Controls image zoom
321	$(container).find('.zoom-inactive').click(function(e) {
322		hideMarkers();
323		enableZoom();
324		return false;
325	});
326	$(container).find('.zoom-active').click(function(e) {
327		disableZoom();
328		showMarkers();
329		return false;
330	});
331	
332	// Controls full screen
333	$(container).find(".fs").click(function(e) {
334						
335		if ((document.fullScreenElement && document.fullScreenElement !== null) ||    
336					(!document.mozFullScreen && !document.webkitIsFullScreen)) {
337			if (document.documentElement.requestFullScreen) {  
338			  document.documentElement.requestFullScreen();  
339			} else if (document.documentElement.mozRequestFullScreen) {  
340			  document.documentElement.mozRequestFullScreen();  
341			} else if (document.documentElement.webkitRequestFullScreen) {  
342			  document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);  
343			}  
344			$(".mfp-container").addClass("fullscreen");
345			$(this).addClass("active");
346			check = false;
347		}
348		else {
349			if (document.cancelFullScreen) {  
350			  document.cancelFullScreen();  
351			} else if (document.mozCancelFullScreen) {  
352			  document.mozCancelFullScreen();  
353			} else if (document.webkitCancelFullScreen) {  
354			  document.webkitCancelFullScreen();  
355			}  
356			$(".mfp-container").removeClass("fullscreen");
357			$(this).removeClass("active");
358			check = true;
359		}
360		disableZoom();
361		return false;
362	});
363}
364
365// jQuery.naturalWidth / jQuery.naturalHeight plugin for (already-loaded) images
366// Triple-licensed: Public Domain, MIT and WTFPL license - share and enjoy!
367/*
368(function($) {
369    function img(url) {
370        var i = new Image;
371        i.src = url;
372        return i;
373    }
374
375    if ('naturalWidth' in (new Image)) {
376        $.fn.naturalWidth = function() {
377            return this[0].naturalWidth;
378        };
379        $.fn.naturalHeight = function() {
380            return this[0].naturalHeight;
381        };
382        return;
383    }
384    $.fn.naturalWidth = function() {
385        return img(this.src).width;
386    };
387    $.fn.naturalHeight = function() {
388        return img(this.src).height;
389    };
390})(jQuery);
391*/
392
393/*
394 * Special event for image load events
395 * Needed because some browsers does not trigger the event on cached images.
396 
397 * MIT License
398 * Paul Irish     | @paul_irish | www.paulirish.com
399 * Andree Hansson | @peolanha   | www.andreehansson.se
400 * 2010.
401 *
402 * Usage:
403 * $(images).bind('load', function (e) {
404 *   // Do stuff on load
405 * });
406 * 
407 * Note that you can bind the 'error' event on data uri images, this will trigger when
408 * data uri images isn't supported.
409 * 
410 * Tested in:
411 * FF 3+
412 * IE 6-8
413 * Chromium 5-6
414 * Opera 9-10
415 */
416(function($) {
417    $.event.special.cacheload = {
418        add: function(hollaback) {
419            console.log("cacheload");
420            if (this.nodeType === 1 && this.tagName.toLowerCase() === 'img' && this.src !== '') {
421                // Image is already complete, fire the hollaback (fixes browser issues were cached
422                // images isn't triggering the load event)
423                if (this.complete || this.readyState === 4) {
424                    console.log("image complete");
425                    hollaback.handler.apply(this);
426                }
427
428                // Check if data URI images is supported, fire 'error' event if not
429                else if (this.readyState === 'uninitialized' && this.src.indexOf('data:') === 0) {
430                    $(this).trigger('error');
431                }
432
433                else {
434                    console.log("binding load");
435                    $(this).unbind('load');
436                    $(this).bind('load', hollaback.handler);
437                }
438            }
439        }
440    };
441}(jQuery));
442
443// Enable toggling full-screen mode, multi-browser compatible
444$(function() {
445	$(".fs").click(function() {
446		console.log("Toggled");
447		if ((document.fullScreenElement && document.fullScreenElement !== null) ||
448				(!document.mozFullScreen && !document.webkitIsFullScreen)) {
449			if (document.documentElement.requestFullScreen) {  
450			  document.documentElement.requestFullScreen();  
451			} else if (document.documentElement.mozRequestFullScreen) {  
452			  document.documentElement.mozRequestFullScreen();  
453			} else if (document.documentElement.webkitRequestFullScreen) {  
454			  document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);  
455			}
456			$(".mfp-container").addClass("fullscreen");
457			$(this).addClass("active");
458		} else {  
459			if (document.cancelFullScreen) {  
460			  document.cancelFullScreen();  
461			} else if (document.mozCancelFullScreen) {  
462			  document.mozCancelFullScreen();  
463			} else if (document.webkitCancelFullScreen) {  
464			  document.webkitCancelFullScreen();  
465			}  
466			$(".mfp-container").removeClass("fullscreen");
467			$(this).removeClass("active");
468		}
469	});
470});

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.