PageSourceSearch

https://www.nuovostudio.it/wp/wp-content/themes/opof/library/js/scripts.js

js nuovostudio.it collected 2026-10-02 00:02:45 UTC 7,892 bytes, 224 lines download raw bytes

1/*
2 * Bones Scripts File
3 * Author: Matteo Tagliatti
4 *
5 * This file should contain any js scripts you want to add to the site.
6 * Instead of calling it in the header or throwing it inside wp_head()
7 * this file will be called automatically in the footer so as not to
8 * slow the page load.
9 *
10 * There are a lot of example functions and tools in here. If you don't
11 * need any of it, just remove it. They are meant to be helpers and are
12 * not required. It's your world baby, you can do whatever you want.
13 */
14
15
16/*
17 * Get Viewport Dimensions
18 * returns object with viewport dimensions to match css in width and height properties
19 * ( source: http://andylangton.co.uk/blog/development/get-viewport-size-width-and-height-javascript )
20 */
21function updateViewportDimensions() {
22    var w = window, d = document, e = d.documentElement, g = d.getElementsByTagName('body')[0], x = w.innerWidth || e.clientWidth || g.clientWidth, y = w.innerHeight || e.clientHeight || g.clientHeight;
23    return {width: x, height: y};
24}
25// setting the viewport width
26var viewport = updateViewportDimensions();
27
28
29/*
30 * Throttle Resize-triggered Events
31 * Wrap your actions in this function to throttle the frequency of firing them off, for better performance, esp. on mobile.
32 * ( source: http://stackoverflow.com/questions/2854407/javascript-jquery-window-resize-how-to-fire-after-the-resize-is-completed )
33 */
34var waitForFinalEvent = (function () {
35    var timers = {};
36    return function (callback, ms, uniqueId) {
37        if (!uniqueId) {
38            uniqueId = "Don't call this twice without a uniqueId";
39        }
40        if (timers[uniqueId]) {
41            clearTimeout(timers[uniqueId]);
42        }
43        timers[uniqueId] = setTimeout(callback, ms);
44    };
45})();
46
47// how long to wait before deciding the resize has stopped, in ms. Around 50-100 should work ok.
48var timeToWaitForLast = 100;
49
50
51/*
52 * Here's an example so you can see how we're using the above function
53 *
54 * This is commented out so it won't work, but you can copy it and
55 * remove the comments.
56 *
57 *
58 *
59 * If we want to only do it on a certain page, we can setup checks so we do it
60 * as efficient as possible.
61 *
62 * if( typeof is_home === "undefined" ) var is_home = $('body').hasClass('home');
63 *
64 * This once checks to see if you're on the home page based on the body class
65 * We can then use that check to perform actions on the home page only
66 *
67 * When the window is resized, we perform this function
68 * $(window).resize(function () {
69 *
70 *    // if we're on the home page, we wait the set amount (in function above) then fire the function
71 *    if( is_home ) { waitForFinalEvent( function() {
72 *
73 *	// update the viewport, in case the window size has changed
74 *	viewport = updateViewportDimensions();
75 *
76 *      // if we're above or equal to 768 fire this off
77 *      if( viewport.width >= 768 ) {
78 *        console.log('On home page and window sized to 768 width or more.');
79 *      } else {
80 *        // otherwise, let's do this instead
81 *        console.log('Not on home page, or window sized to less than 768.');
82 *      }
83 *
84 *    }, timeToWaitForLast, "your-function-identifier-string"); }
85 * });
86 *
87 * Pretty cool huh? You can create functions like this to conditionally load
88 * content and other stuff dependent on the viewport.
89 * Remember that mobile devices and javascript aren't the best of friends.
90 * Keep it light and always make sure the larger viewports are doing the heavy lifting.
91 *
92 */
93
94/*
95 * We're going to swap out the gravatars.
96 * In the functions.php file, you can see we're not loading the gravatar
97 * images on mobile to save bandwidth. Once we hit an acceptable viewport
98 * then we can swap out those images since they are located in a data attribute.
99 */
100function loadGravatars() {
101    // set the viewport using the function above
102    viewport = updateViewportDimensions();
103    // if the viewport is tablet or larger, we load in the gravatars
104    if (viewport.width >= 768) {
105        jQuery('.comment img[data-gravatar]').each(function () {
106            jQuery(this).attr('src', jQuery(this).attr('data-gravatar'));
107        });
108    }
109} // end function
110
111function call_archive(arg) {
112    jQuery.ajax("/wp-admin/admin-ajax.php", {
113        data: {
114            action: 'archive',
115            archive: arg
116        },
117        success: function (result, status, xhrRequest) {
118            // console.info(jQuery.parseHTML(result.result));
119            // var res = jQuery.parseHTML(result.result);
120            return jQuery(result.result);
121            //$('.loader').show().delay(1000).fadeOut();
122        },
123        error: function (xhrRequest, status, errorMessage) {
124            //alert("Errore dal server. Status: " + status);
125            console.log("Errore: " + errorMessage);
126            console.info("xhrRequest: " + xhrRequest);
127        }
128    });
129}
130
131/*
132 * Put all your regular jQuery in here.
133 */
134jQuery(document).ready(function ($) {
135
136    /*
137     * Let's fire off the gravatar function
138     * You can remove this if you don't need it
139     */
140    loadGravatars();
141
142    //window.curr_vid = null;
143    //console.info(vars.current_slide);
144    $('<span> / </span>').insertBefore($('.sidebar ul li.videolink a:not(:eq(0))'));
145    var sameline_links = $('.sidebar ul li.videolink');
146    var merged = [];
147    $(sameline_links).each(function (index, el) {
148        var html = $(el).html();
149        merged[index] = $(html);
150    });
151    $('.sidebar ul li.videolink:not(:eq(0))').remove();
152    $('.sidebar ul li.videolink').empty().append(merged);
153
154}); /* end of as page load scripts */
155function hexToRgb(hex) {
156    // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
157    var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
158    hex = hex.replace(shorthandRegex, function (m, r, g, b) {
159        return r + r + g + g + b + b;
160    });
161    var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
162    return result ? (parseInt(result[1], 16) + ',' + parseInt(result[2], 16) + ',' + parseInt(result[3], 16)) : null;
163//    return result ? {
164//        r: parseInt(result[1], 16),
165//        g: parseInt(result[2], 16),
166//        b: parseInt(result[3], 16)
167//    } : null;
168//alert( hexToRgb("#0033ff").g ); // "51";
169//alert( hexToRgb("#03f").g ); // "51";
170}
171(function ($) {
172    var addClass = $.fn.addClass;
173    $.fn.addClass = function (value) {
174        var orig = addClass.apply(this, arguments);
175        var elem,
176                i = 0,
177                len = this.length;
178        for (; i < len; i++) {
179            elem = this[ i ];
180            if (elem instanceof SVGElement) {
181                var classes = $(elem).attr('class');
182                if (classes) {
183                    var index = classes.search(value);
184                    if (index === -1) {
185                        classes = classes + " " + value;
186                        $(elem).attr('class', classes);
187                    }
188                } else {
189                    $(elem).attr('class', value);
190                }
191            }
192        }
193        return orig;
194    };
195    var removeClass = $.fn.removeClass;
196    $.fn.removeClass = function (value) {
197        var orig = removeClass.apply(this, arguments);
198        var elem,
199                i = 0,
200                len = this.length;
201        for (; i < len; i++) {
202            elem = this[ i ];
203            if (elem instanceof SVGElement) {
204                var classes = $(elem).attr('class');
205                if (classes) {
206                    var index = classes.search(value);
207                    if (index !== -1) {
208                        classes = classes.substring(0, index) + classes.substring((index + value.length), classes.length);
209                        $(elem).attr('class', classes);
210                    }
211                }
212            }
213        }
214        return orig;
215    };
216})(jQuery);
217(function ($) {
218
219})(jQuery);
220jQuery(document).ready(function ($) {
221
222
223
224});

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.