PageSourceSearch

https://www.scena.hr/wp-content/themes/magazine/js/customscript.js?ver=6.2.13

js scena.hr collected 2026-10-02 13:31:18 UTC 9,408 bytes, 263 lines download raw bytes

1jQuery.fn.exists = function(callback) {
2  var args = [].slice.call(arguments, 1);
3  if (this.length) {
4    callback.call(this, args);
5  }
6  return this;
7};
8
9/*! .isOnScreen() returns bool */
10jQuery.fn.isOnScreen = function(){
11
12    var win = jQuery(window);
13
14    var viewport = {
15        top : win.scrollTop(),
16        left : win.scrollLeft()
17    };
18    viewport.right = viewport.left + win.width();
19    viewport.bottom = viewport.top + win.height();
20
21    var bounds = this.offset();
22    bounds.right = bounds.left + this.outerWidth();
23    bounds.bottom = bounds.top + this.outerHeight();
24
25    return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
26
27};
28
29/*----------------------------------------------------
30/* Scroll to top
31/*--------------------------------------------------*/
32jQuery(document).ready(function() {
33    //move-to-top arrow
34    jQuery("body").prepend("<a href='#blog' id='move-to-top' class='to-top animate'><i class='fa fa-angle-double-up'></i></a>");
35    var scrollDes = 'html,body';
36    /*Opera does a strange thing if we use 'html' and 'body' together so my solution is to do the UA sniffing thing*/
37    if(navigator.userAgent.match(/opera/i)){
38        scrollDes = 'html';
39    }
40    //show ,hide
41    jQuery(window).scroll(function () {
42        if (jQuery(this).scrollTop() > 160 && !jQuery('#footer-to-top').isOnScreen()) {
43            jQuery('#move-to-top').addClass('filling').removeClass('hiding');
44        } else {
45            jQuery('#move-to-top').removeClass('filling').addClass('hiding');
46        }
47    });
48});
49
50/*----------------------------------------------------
51/* Make all anchor links smooth scrolling
52/*--------------------------------------------------*/
53jQuery(document).ready(function($) {
54 // scroll handler
55  var scrollToAnchor = function( id, event ) {
56    // grab the element to scroll to based on the name
57    var elem = $("a[name='"+ id +"']");
58    // if that didn't work, look for an element with our ID
59    if ( typeof( elem.offset() ) === "undefined" ) {
60      elem = $("#"+id);
61    }
62    // if the destination element exists
63    if ( typeof( elem.offset() ) !== "undefined" ) {
64      // cancel default event propagation
65      event.preventDefault();
66      var scroll_to = elem.offset().top;
67      // do the scroll
68      $('html, body').animate({
69              scrollTop: scroll_to
70      }, 600, 'swing', function() { if (scroll_to > 46) window.location.hash = id; } );
71    }
72  };
73  // bind to click event
74  $("a").click(function( event ) {
75    // only do this if it's an anchor link
76    var href = $(this).attr("href");
77    var exclude = ['#tab-description', '#tab-additional_information', '#tab-reviews'];
78    if (exclude.includes(href)) {
79      return;
80    }
81    if (href && href.match("#") && href !== '#' && !$(this).hasClass('comment-reply-link')) {
82      // scroll to the location
83      var parts = href.split('#'),
84        url = parts[0],
85        target = parts[1];
86      if ((!url || url == window.location.href.split('#')[0]) && target)
87        scrollToAnchor( target, event );
88    }
89  });
90});
91
92/*----------------------------------------------------
93/* Responsive Navigation
94/*--------------------------------------------------*/
95if (mts_customscript.responsive && mts_customscript.nav_menu != 'none') {
96    jQuery(document).ready(function($){
97        // merge if two menus exist
98        if (mts_customscript.nav_menu == 'both') {
99            $('#navigation').not('.mobile-menu-wrapper').find('.menu').clone().appendTo('.mobile-menu-wrapper').hide();
100        }
101    
102        $('.toggle-mobile-menu').click(function(e) {
103            e.preventDefault();
104            e.stopPropagation();
105            $('body').toggleClass('mobile-menu-active');
106        });
107        
108        // prevent propagation of scroll event to parent
109        $(document).on('DOMMouseScroll mousewheel', '.mobile-menu-wrapper', function(ev) {
110            var $this = $(this),
111                scrollTop = this.scrollTop,
112                scrollHeight = this.scrollHeight,
113                height = $this.height(),
114                delta = (ev.type == 'DOMMouseScroll' ?
115                    ev.originalEvent.detail * -40 :
116                    ev.originalEvent.wheelDelta),
117                up = delta > 0;
118        
119            var prevent = function() {
120                ev.stopPropagation();
121                ev.preventDefault();
122                ev.returnValue = false;
123                return false;
124            }
125
126            if ( $('a#pull').css('display') !== 'none' ) { // if toggle menu button is visible ( small screens )
127        
128              if (!up && -delta > scrollHeight - height - scrollTop) {
129                  // Scrolling down, but this will take us past the bottom.
130                  $this.scrollTop(scrollHeight);
131                  return prevent();
132              } else if (up && delta > scrollTop) {
133                  // Scrolling up, but this will take us past the top.
134                  $this.scrollTop(0);
135                  return prevent();
136              }
137            }
138        });
139    }).on('click', function(event) {
140
141        var $target = jQuery(event.target);
142        if ( ( $target.hasClass("fa") && $target.parent().hasClass("toggle-caret") ) ||  $target.hasClass("toggle-caret") ) {// allow clicking on menu toggles
143            return;
144        }
145
146        jQuery('body').removeClass('mobile-menu-active');
147    });
148
149
150}
151
152/*----------------------------------------------------
153/*  Dropdown menu
154/* ------------------------------------------------- */
155jQuery(document).ready(function($) {
156    
157    function mtsDropdownMenu() {
158        var wWidth = $(window).width();
159        if(wWidth > 865) {
160            $('#navigation ul.sub-menu, #navigation ul.children').hide();
161            var timer;
162            var delay = 100;
163            $('#navigation li').hover( 
164              function() {
165                var $this = $(this);
166                timer = setTimeout(function() {
167                    $this.children('ul.sub-menu, ul.children').slideDown('fast');
168                }, delay);
169                
170              },
171              function() {
172                $(this).children('ul.sub-menu, ul.children').hide();
173                clearTimeout(timer);
174              }
175            );
176        } else {
177            $('#navigation li').unbind('hover');
178            $('#navigation li.active > ul.sub-menu, #navigation li.active > ul.children').show();
179        }
180    }
181
182    mtsDropdownMenu();
183
184    $(window).resize(function() {
185        mtsDropdownMenu();
186    });
187});
188
189/*---------------------------------------------------
190/*  Vertical menus toggles
191/* -------------------------------------------------*/
192jQuery(document).ready(function($) {
193
194    $('.widget_nav_menu, #navigation .menu').addClass('toggle-menu');
195    $('.toggle-menu ul.sub-menu, .toggle-menu ul.children').addClass('toggle-submenu');
196    $('.toggle-menu ul.sub-menu').parent().addClass('toggle-menu-item-parent');
197
198    $('.toggle-menu .toggle-menu-item-parent').append('<span class="toggle-caret"><i class="fa fa-plus"></i></span>');
199
200    $('.toggle-caret').click(function(e) {
201        e.preventDefault();
202        $(this).parent().toggleClass('active').children('.toggle-submenu').slideToggle('fast');
203    });
204});
205
206/*----------------------------------------------------
207/* Social button scripts
208/*---------------------------------------------------*/
209jQuery(document).ready(function($){
210	(function(d, s) {
211	  var js, fjs = d.getElementsByTagName(s)[0], load = function(url, id) {
212		if (d.getElementById(id)) {return;}
213		js = d.createElement(s); js.src = url; js.id = id;
214		fjs.parentNode.insertBefore(js, fjs);
215	  };
216	jQuery('span.facebookbtn, .facebook_like').exists(function() {
217	  load('//connect.facebook.net/en_US/all.js#xfbml=1', 'fbjssdk');
218	});
219	jQuery('span.twitterbtn').exists(function() {
220	  load('//platform.twitter.com/widgets.js', 'tweetjs');
221	});
222	jQuery('span.linkedinbtn').exists(function() {
223	  load('//platform.linkedin.com/in.js', 'linkedinjs');
224	});
225	jQuery('span.pinbtn').exists(function() {
226	  load('//assets.pinterest.com/js/pinit.js', 'pinterestjs');
227	});
228	jQuery('span.stumblebtn').exists(function() {
229	  load('//platform.stumbleupon.com/1/widgets.js', 'stumbleuponjs');
230	});
231	}(document, 'script'));
232});
233
234/*----------------------------------------------------
235/* Lazy load avatars
236/*---------------------------------------------------*/
237jQuery(document).ready(function($){
238    var lazyloadAvatar = function(){
239        $('.comment-author .avatar').each(function(){
240            var distanceToTop = $(this).offset().top;
241            var scroll = $(window).scrollTop();
242            var windowHeight = $(window).height();
243            var isVisible = distanceToTop - scroll < windowHeight;
244            if( isVisible ){
245                var hashedUrl = $(this).attr('data-src');
246                if ( hashedUrl ) {
247                    $(this).attr('src',hashedUrl).removeClass('loading');
248                }
249            }
250        });
251    };
252    if ( $('.comment-author .avatar').length > 0 ) {
253        $('.comment-author .avatar').each(function(i,el){
254            $(el).attr('data-src', el.src).removeAttr('src').addClass('loading');
255        });
256        $(function(){
257            $(window).scroll(function(){
258                lazyloadAvatar();
259            });
260        });
261        lazyloadAvatar();
262    }
263});

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.