PageSourceSearch

https://www.christiandve.com/wp-content/themes/christian_10ab2/script.responsive.js?ver=6.6.2

js christiandve.com collected 2026-10-02 05:36:20 UTC 19,593 bytes, 507 lines download raw bytes

1/*jshint forin:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true, strict:true, undef:true, curly:false, browser:true, jquery:false */
2/*global jQuery */
3
4var responsiveDesign = {
5    isResponsive: false,
6    isDesktop: false,
7    isTablet: false,
8    isPhone: false,
9    lockedResponsiveMode: '', // free mode from start
10
11    responsiveType: 'desktop',
12    responsiveTypeIdx: 1,
13    lockedResponsiveType: '',
14
15    isCurrentDefaultResponsive: false,
16
17    defaultResponsive: [ false, true, true, true, true ], // turn on/off old or new responsive modes
18
19    windowWidth: 0,
20
21    responsive: (function ($) {
22        "use strict";
23        return function () {
24            var html = $("html");
25            this.windowWidth = $(window).width();
26            var triggerEvent = false;
27
28            var isRespVisible = $("#ch-resp").is(":visible");
29            if (this.lockedResponsiveMode === 'desktop') isRespVisible = false;
30
31            if (isRespVisible && !this.isResponsive) {
32                html.addClass("responsive").removeClass("desktop");
33                this.isResponsive = true;
34                this.isDesktop = false;
35                triggerEvent = true;
36            } else if (!isRespVisible && !this.isDesktop) {
37                html.addClass("desktop").removeClass("responsive default-responsive responsive-tablet responsive-phone");
38                this.isResponsive = this.isTablet = this.isPhone = false;
39                this.isDesktop = true;
40                triggerEvent = true;
41            }
42
43            if (this.isResponsive) {
44                // additional check to lock responsive mode
45                var isTablet = this.lockedResponsiveMode === 'tablet' || ($("#ch-resp-t").is(":visible") && this.lockedResponsiveMode === '');
46                var isPhone = this.lockedResponsiveMode === 'phone' || ($("#ch-resp-m").is(":visible") && this.lockedResponsiveMode === '');
47                if (isTablet && !this.isTablet) {
48                    html.addClass("responsive-tablet").removeClass("responsive-phone");
49                    this.isTablet = true;
50                    this.isPhone = false;
51                    triggerEvent = true;
52                } else if (isPhone && !this.isPhone) {
53                    html.addClass("responsive-phone").removeClass("responsive-tablet");
54                    this.isTablet = false;
55                    this.isPhone = true;
56                    triggerEvent = true;
57                }
58            }
59
60            var prevResponsiveIndx = this.responsiveTypeIdx;
61            if (this.lockedResponsiveType === 'tabletlandscape' || ($("#ch-resp-tablet-landscape").is(":visible") && this.lockedResponsiveType === '')) {
62                this.responsiveType = 'tabletlandscape';
63                this.responsiveTypeIdx = 1;
64            } else if (this.lockedResponsiveType === 'tabletportrait' || ($("#ch-resp-tablet-portrait").is(":visible") && this.lockedResponsiveType === '')) {
65                this.responsiveType = 'tabletportrait';
66                this.responsiveTypeIdx = 2;
67            } else if (this.lockedResponsiveType === 'phonelandscape' || ($("#ch-resp-phone-landscape").is(":visible") && this.lockedResponsiveType === '')) {
68                this.responsiveType = 'phonelandscape';
69                this.responsiveTypeIdx = 3;
70            } else if (this.lockedResponsiveType === 'phoneportrait' || ($("#ch-resp-phone-portrait").is(":visible") && this.lockedResponsiveType === '')) {
71                this.responsiveType = 'phoneportrait';
72                this.responsiveTypeIdx = 4;
73            } else { //if (this.lockedResponsiveType === 'desktop' || ($("#ch-resp-desktop").is(":visible") && this.lockedResponsiveType === '')) {
74                this.responsiveType = 'desktop';
75                this.responsiveTypeIdx = 0;
76            }
77
78            if (triggerEvent || prevResponsiveIndx !== this.responsiveTypeIdx) {
79                triggerEvent = true;
80                
81                if (this.isResponsive && this.defaultResponsive[ this.responsiveTypeIdx ]) {
82                    this.isCurrentDefaultResponsive = true;
83                    html.removeClass('custom-responsive').addClass('default-responsive');
84                } else {
85                    this.isCurrentDefaultResponsive = false;
86                    html.removeClass('default-responsive').addClass('custom-responsive');
87                }
88            }
89
90            if (triggerEvent) {
91                $(window).trigger("responsive", this);
92            }
93
94            $(window).trigger("responsiveResize", this);
95        };
96    })(jQuery),
97    initialize: (function ($) {
98        "use strict";
99        return function () {
100            // get correct defaultResponsive
101            if (typeof defaultResponsiveData !== 'undefined') responsiveDesign.defaultResponsive = defaultResponsiveData;
102
103            $("<div id=\"ch-resp\"><div id=\"ch-resp-m\"></div><div id=\"ch-resp-t\"></div></div>").appendTo("body");
104            $('<div id="ch-resp-tablet-landscape" /><div id="ch-resp-tablet-portrait" /><div id="ch-resp-phone-landscape" /><div id="ch-resp-phone-portrait" />').appendTo('body');
105
106
107            /* (1) Use this code for debug instead of (2):
108             * var resizeTimeout;
109             * $(window).resize(function () {
110             * clearTimeout(resizeTimeout);
111             * resizeTimeout = setTimeout(function () { responsiveDesign.responsive(); }, 50);
112             * });
113             */
114
115            /* (2) Use this code for production and comment (1): */
116            $(window).resize(function () {
117                responsiveDesign.responsive();
118            });
119
120            $(window).trigger("resize");
121        };
122    })(jQuery),
123    // lock responsive in some mode: desktop, tablet or phone for editor
124    lockResponsiveType: function (mode) {
125        responsiveDesign.lockedResponsiveType = mode;
126
127        if (mode.indexOf('tablet') === 0) mode = 'tablet';
128        if (mode.indexOf('phone') === 0) mode = 'phone';
129
130        responsiveDesign.lockedResponsiveMode = mode;
131    },
132    // using in editor to turn off default responsive
133    toogleDefaultResponsive: function (type, val) {
134        var old = responsiveDesign.defaultResponsive[ type ];
135        responsiveDesign.defaultResponsive[ type ] = val;
136        if (old !== val) responsiveDesign.responsiveTypeIdx = -1;
137    }
138};
139
140function responsiveAbsBg(responsiveDesign, el, bg) {
141    "use strict";
142    if (bg.length === 0)
143        return;
144
145    var desktopBgTop = bg.attr("data-bg-top");
146    var desktopBgHeight = bg.attr("data-bg-height");
147
148    if (responsiveDesign.isResponsive) {
149        if (typeof desktopBgTop === "undefined" || desktopBgTop === false) {
150            bg.attr("data-bg-top", bg.css("top"));
151            bg.attr("data-bg-height", bg.css("height"));
152        }
153
154        var elTop = el.offset().top;
155        var elHeight = el.outerHeight();
156        bg.css("top", elTop + "px");
157        bg.css("height", elHeight + "px");
158    } else if (typeof desktopBgTop !== "undefined" && desktopBgTop !== false) {
159        bg.css("top", desktopBgTop);
160        bg.css("height", desktopBgHeight);
161        bg.removeAttr("data-bg-top");
162        bg.removeAttr("data-bg-height");
163    }
164}
165
166var responsiveImages = (function ($) {
167    "use strict";
168    return function (responsiveDesign) {
169        $("img[width]").each(function () {
170            var img = $(this), newWidth = "", newMaxWidth = "", newHeight = "";
171            if (responsiveDesign.isResponsive) {
172                newWidth = "auto";
173                newHeight = "auto";
174                newMaxWidth = "100%";
175
176                var widthAttr = img.attr("width");
177                if (widthAttr !== null && typeof (widthAttr) === "string" && widthAttr.indexOf("%") === -1) {
178                    newWidth = "100%";
179                    newMaxWidth = parseInt($.trim(widthAttr), 10) + "px";
180                }
181            }
182            img.css("width", newWidth).css("max-width", newMaxWidth).css("height", newHeight);
183        });
184    };
185})(jQuery); 
186
187var responsiveVideos = (function ($) {
188    "use strict";
189    return function (responsiveDesign) {
190        $("iframe[width],object[width],embed[width]").each(function () {
191            var obj = $(this);
192            if ((obj.is('[width]') && obj.attr("width").indexOf("%") !== -1) ||
193                (obj.is('[class]') && obj.attr("class").indexOf("twitter") !== -1) ||
194                (obj.id && obj.id.indexOf("google") !== -1))
195                return;
196            var container = obj.parent(".ch-responsive-embed");
197            if (responsiveDesign.isResponsive) {
198                if (container.length !== 0)
199                    return;
200                container = $("<div class=\"ch-responsive-embed\">").insertBefore(obj);
201                obj.appendTo(container);
202            } else if (container.length > 0) {
203                obj.insertBefore(container);
204                container.remove();
205            }
206        });
207    };
208})(jQuery);
209
210// this must be called for collages only!
211var responsiveTextblocks = (function ($) {
212    "use strict";
213    return function (slider, responsiveDesign) {
214        slider.find(".ch-textblock").each(function () {
215            if (parseInt(slider.attr("data-width"), 10) === 0) {
216                return true;
217            }
218            var tb = $(this);
219            var c = slider.width() / slider.attr("data-width");
220            tb.css({
221                "height": "",
222                "width": "",
223                "top": "",
224                "margin-left": ""
225            });
226            if (responsiveDesign.isResponsive) {
227                var tbHeight = parseInt(tb.css("height"), 10);
228                var tbWidth = parseInt(tb.css("width"), 10);
229                var tbTop = parseInt(tb.css("top"), 10);
230                var tbMargin = parseInt(tb.css("margin-left"), 10);
231                tb.add(tb.find('div')).css({
232                    "height": tbHeight * c,
233                    "width": tbWidth * c
234                });
235                tb.css("top", tbTop * c);
236                tb.attr("style", function (i, s) { return s + "margin-left: " + (tbMargin * c) + "px !important"; });
237            }
238        });
239    };
240})(jQuery);
241
242var responsiveSlider = (function ($) {
243    "use strict";
244    return function (responsiveDesign) {
245        $(".ch-slider").each(function () {
246            var s = $(this);
247
248            var isHeaderSlider = s.parent('.ch-header').length > 0 || s.parent('.ch-pageslider').length > 0;
249            if (!isHeaderSlider && responsiveDesign.isResponsive) {
250                responsiveTextblocks(s, responsiveDesign);
251                return;
252            }
253
254            var initialWidth = s.attr("data-width");
255            var initialHeight = s.attr("data-height");
256
257            // set size
258
259            var obj = s.data("slider");
260            if (!obj) {
261                return false;
262            }
263
264            var inner = s.find(".ch-slider-inner");
265
266            if (!responsiveDesign.isResponsive && obj.settings.helper) {
267                obj.settings.helper.updateSize(inner, { width: initialWidth, height: initialHeight });
268                return;
269            }
270
271            // set slider
272            if (obj && obj.settings.helper) {
273                $(window).on("responsiveResize", function updateSize() {
274                    if (obj.settings.animation === "fade") return;
275                    if (responsiveDesign.isCurrentDefaultResponsive) {
276                        obj.settings.helper.updateSize(inner, { width: initialWidth, height: initialHeight });
277                        $.each(inner.children(), function () {
278                            $(this).css(
279                                "background-position",
280                                -Math.floor(initialWidth / 2 - parseInt(inner.outerWidth(), 10) / 2) + "px" +
281                                -Math.floor(initialHeight / 2 - parseInt(inner.outerHeight(), 10) / 2) + "px "
282                            );
283                        });
284                    } else {
285                        $(window).off("responsiveResize", updateSize);
286                    }
287                });
288            }
289        });
290    };
291})(jQuery);
292
293var responsiveCollages = (function ($) {
294    "use strict";
295    return function (responsiveDesign) {
296        $(".ch-collage").each(function() {
297            var collage = $(this);
298            var slider = collage.find(".ch-slider");
299
300            var initialWidth = slider.attr("data-width");
301            var initialHeight = slider.attr("data-height");
302
303            var parent = collage.closest(':not(.image-caption-wrapper, .ch-collage)');
304            var parentIcw = collage.closest('.image-caption-wrapper');
305            var parentWidth = parent.width();
306            var collageWidth = collage.width();
307
308            // for responsive try to make collage smaller
309            // a) no icw - check collage width and parent
310            // b) with icw - collage is bigger than icw
311            var doms = collage
312                .add(slider)
313                .add(collage.closest(".image-caption-wrapper"));
314
315            // so try to make collage smaller
316            if (responsiveDesign.isResponsive && collageWidth > parentWidth || (parentIcw.length > 0 && collageWidth > parentIcw.width())) {
317                doms.css("width", "100%");
318            }
319
320            // but if icw make collage too bit reset it width to noraml
321            collageWidth = collage.width();
322            if (collageWidth > initialWidth) {
323                doms.css("width", "");
324            }
325
326            var c = slider.width() / initialWidth;
327            var h = c * initialHeight;
328            slider.css("height", h + "px");
329        });
330    };
331})(jQuery);
332
333
334jQuery(window).bind("responsive", (function ($) {
335    "use strict";
336    return function (event, responsiveDesign) {
337        // so this event is main and it generate sub events to make important changes before we will modify slider
338        // for example we move out of slider menu button, and it change slider size
339        $(window).trigger('responsivePage', responsiveDesign);
340        responsiveImages(responsiveDesign);
341        responsiveVideos(responsiveDesign);
342
343        responsiveSlider(responsiveDesign);
344        responsiveNavigator(responsiveDesign);
345    };
346})(jQuery));
347
348jQuery(window).bind("responsiveResize", (function ($) {
349    "use strict";
350    return function (event, responsiveDesign) {
351        responsiveCollages(responsiveDesign);
352        responsiveNavigator(responsiveDesign);
353    };
354})(jQuery));
355
356jQuery(function ($) {
357    if (!browser.ie || browser.version > 8) return;
358    var timeout;
359    $(window).on("resize", function () {
360        clearTimeout(timeout);
361        timeout = setTimeout(function() {
362            responsiveCollages(responsiveDesign);
363            responsiveNavigator(responsiveDesign);
364        }, 25);
365    });
366    responsiveCollages(responsiveDesign);
367    responsiveNavigator(responsiveDesign);
368});
369
370var responsiveHeader = (function ($) {
371    "use strict";
372    return function(responsiveDesign) {
373        var header = $("header.ch-header");
374        var headerSlider = header.find(".ch-slider");
375
376        if (headerSlider.length) {
377            var firstSlide = headerSlider.find(".ch-slide-item").first();
378            var slidebg = firstSlide.css("background-image").split(",");
379            var previousSibling = headerSlider.prev();
380            var sliderNav = headerSlider.siblings(".ch-slidenavigator");
381            if (slidebg.length && responsiveDesign.isResponsive) {
382                // if prev is menu in header
383                if (previousSibling.is("nav.ch-nav")) {
384                    sliderNav.attr("data-offset", previousSibling.height());
385                }
386            } else {
387                sliderNav.removeAttr("data-offset");
388                header.removeAttr("style");
389            }
390        }
391    };
392})(jQuery);
393
394jQuery(window).bind("responsiveResize", (function ($) {
395    "use strict";
396    return function (event, responsiveDesign) {
397        responsiveAbsBg(responsiveDesign, $(".ch-header"), $("#ch-header-bg"));
398    };
399})(jQuery));
400
401jQuery(window).bind("responsive", (function ($) {
402    "use strict";
403    return function (event, responsiveDesign) {
404        if (browser.ie && browser.version <= 8) return;
405
406        if (responsiveDesign.isResponsive) {
407            $(window).on("responsiveResize.header", function () {
408                responsiveHeader(responsiveDesign);
409            });
410        } else {
411            $(window).trigger("responsiveResize.header");
412            $(window).off("responsiveResize.header");
413        }
414    };
415})(jQuery));
416
417jQuery(window).bind("responsiveResize", (function ($) {
418    "use strict";
419    return function (event, responsiveDesign) {
420        responsiveAbsBg(responsiveDesign, $("nav.ch-nav"), $("#ch-hmenu
420-bg"));
421        $(window).trigger("responsiveNav", { responsiveDesign: responsiveDesign });
422    };
423})(jQuery));
424
425
426
427jQuery(function($) {
428    "use strict";
429    $(".ch-hmenu a").each(function() {
430        var link = $(this);
431        if (link.get(0).href === location.href) {
432            link.addClass("active").parents("li").addClass("active");
433            return false;
434        }
435    });
436});
437
438
439
440jQuery(function($) {
441    $('<a href=\"#\" class=\"ch-menu-btn\"><span></span><span></span><span></span></a>').insertBefore(".ch-hmenu").click(function(e) {
442        var menu = $(this).next();
443        if (menu.is(":visible")) {
444            menu.slideUp("fast", function() {
445                $(this).removeClass("visible").css("display", "");
446            });
447        } else {
448            menu.slideDown("fast", function() {
449                $(this).addClass("visible").css("display", "");
450            });
451        }
452        e.preventDefault();
453    });
454});
455
456var responsiveLayoutCell = (function ($) {
457    "use strict";
458    return function (responsiveDesign) {
459        $(".ch-content .ch-content-layout-row,.ch-footer .ch-content-layout-row").each(function () {
460            var row = $(this);
461            var rowChildren = row.children(".ch-layout-cell");
462            if (rowChildren.length > 0) {
463                var c;
464                row.removeClass("responsive-layout-row-2").removeClass("responsive-layout-row-3").removeClass("responsive-layout-row-1");
465                if (rowChildren.length === 1) {
466                    c = 1;
467                    row.addClass("responsive-layout-row-1");
468                } else if (rowChildren.length % 2 === 0) {
469                    var c = 2;
470                    row.addClass("responsive-layout-row-2");
471                } else {
472                    var c = 3;
473                    row.addClass("responsive-layout-row-3");
474                }
475                if (c > 0 && responsiveDesign.isTablet) {
476                    rowChildren.addClass("responsive-tablet-layout-cell").each(function (i) {
477                        if ((i + 1) % c === 0) {
478                            $(this).after("<div class=\"cleared responsive-cleared\">");
479                        }
480                    });
481                } else {
482                    rowChildren.removeClass("responsive-tablet-layout-cell");
483                    row.children(".responsive-cleared").remove();
484                }
485            }
486        });
487    };
488})(jQuery);
489
490jQuery(window).bind("responsive", function (event, responsiveDesign) {
491    "use strict";
492
493    responsiveLayoutCell(responsiveDesign);
494});
495
496/*global jQuery, responsiveDesign*/
497
498
499
500
501//setTimeout(function () { $("html").addClass("desktop") }, 0);
502
503if (!browser.ie || browser.version > 8) {
504    jQuery(responsiveDesign.initialize);
505} else {
506    jQuery("html").addClass("desktop");
507}

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.