PageSourceSearch

https://blog.ecampus.com/wp-content/themes/reblog/assets/js/custom.js?ver=20151215

js ecampus.com collected 2026-09-24 09:01:23 UTC 13,411 bytes, 386 lines download raw bytes

1jQuery(document).ready(function($) {
2
3/*------------------------------------------------
4            DECLARATIONS
5------------------------------------------------*/
6
7    var scroll = $(window).scrollTop();  
8    var scrollup = $('.backtotop');
9    var menu_toggle = $('.menu-toggle');
10    var secondary_menu_toggle = $('.secondary-menu-toggle');
11    var dropdown_toggle = $('button.dropdown-toggle');
12    var nav_menu = $('.main-navigation');
13    var secondary_nav_menu = $('.secondary-navigation');
14    var masonry_gallery = $('.grid');
15
16/*------------------------------------------------
17            BACK TO TOP
18------------------------------------------------*/
19
20    $(window).scroll(function() {
21        if ($(this).scrollTop() > 1) {
22            scrollup.css({bottom:"80px"});
23        } 
24        else {
25            scrollup.css({bottom:"-100px"});
26        }
27    });
28
29    scrollup.click(function() {
30        $('html, body').animate({scrollTop: '0px'}, 800);
31        return false;
32    });
33
34/*------------------------------------------------
35            MAIN NAVIGATION
36------------------------------------------------*/
37
38    $(window).scroll(function() {
39        if ($(this).scrollTop() >= 200) {
40            $('.menu-sticky #masthead').addClass('nav-shrink');
41        } 
42        else {
43            $('.menu-sticky #masthead').removeClass('nav-shrink');
44        }
45    });
46
47    $(window).scroll(function() {
48        if ($(this).scrollTop() >= 400) {
49            $('.menu-sticky #masthead').addClass('nav-sticky');
50        } 
51        else {
52            $('.menu-sticky #masthead').removeClass('nav-sticky');
53        }
54    });
55
56    menu_toggle.click(function(){
57        nav_menu.slideToggle();
58        $(this).toggleClass('active');
59        $('#search.hidden-small').fadeOut();
60        $('.menu-overlay').toggleClass('active');
61        $('.main-navigation').toggleClass('menu-open');
62        $('body').toggleClass('main-navigation-active');
63
64        if( $('body').hasClass('secondary-navigation-active') ) {
65            $('body').removeClass('secondary-navigation-active');
66            secondary_nav_menu.slideUp();
67            $('.menu-overlay').addClass('active');
68            $('#navigation-menu .secondary-menu-toggle').removeClass('active');
69        }
70
71        if( $('body').hasClass('search-menu-active') ) {
72            $('body').removeClass('search-menu-active');
73            $('.menu-overlay').addClass('active');
74        }
75    });
76
77    secondary_menu_toggle.click(function(){
78        secondary_nav_menu.slideToggle();
79        $(this).toggleClass('active');
80        $('.menu-overlay').toggleClass('active');
81        $('#navigation-menu').toggleClass('menu-open');
82        $('body').toggleClass('secondary-navigation-active');
83    });
84
85    dropdown_toggle.click(function() {
86        $(this).toggleClass('active');
87       $(this).parent().find('.sub-menu').first().slideToggle();
88    });
89
90     $('#site-menu .search-menu a').click(function() {
91        $(this).parent().toggleClass('active');
92        $('#search.hidden-small').fadeToggle();
93        nav_menu.slideUp();
94        menu_toggle.removeClass('active');
95        $('.menu-overlay').toggleClass('active');
96     });
97
98    $('.search-menu a').click(function(event) {
99        event.preventDefault();
100        $('.main-navigation #search').fadeToggle();
101        $('.search-menu .search-field').focus();
102        $('body').addClass('search-menu-active');
103
104        if( $('body').hasClass('secondary-navigation-active') ) {
105            $('body').removeClass('secondary-navigation-active');
106            secondary_nav_menu.slideUp();
107            $('.menu-overlay').addClass('active');
108            $('#navigation-menu .secondary-menu-toggle').removeClass('active');
109        }
110
111        if( $('body').hasClass('main-navigation-active') ) {
112            $('body').removeClass('main-navigation-active');
113            nav_menu.slideUp();
114            $('.menu-overlay').addClass('active');
115            $('.main-navigation .menu-toggle').removeClass('active');
116        }
117    });
118
119    $('#search-menu a').click(function(event) {
120        event.preventDefault();
121        $(this).parent().toggleClass('active');
122        $('#social-navigation #search-menu form.search-form').fadeToggle();
123        $('#search-menu .search-field').focus();
124    });
125
126    $(document).keyup(function(e) {
127        if (e.keyCode === 27) {
128            $('.secondary-navigation').slideUp();
129            $('.menu-overlay').removeClass('active');
130            $('#navigation-menu .secondary-menu-toggle').removeClass('active');
131        }
132    });
133
134    if( $(window).width() > 1023 ) {
135        $(document).click(function (e) {
136            var container = $("#masthead, #navigation-menu");
137            if (!container.is(e.target) && container.has(e.target).length === 0) {
138
139                // Secondary Navigation
140                $('.secondary-navigation').slideUp();
141                $('.menu-overlay').removeClass('active');
142                $('#navigation-menu .secondary-menu-toggle').removeClass('active');
143
144            }
145        });
146    }
147
148    if( $(window).width() < 1023 ) {
149        $(document).click(function (e) {
150            var container = $("#masthead, #navigation-menu");
151            if (!container.is(e.target) && container.has(e.target).length === 0) {
152
153                if( $('body').hasClass('secondary-navigation-active') ) {
154                    $('body').removeClass('secondary-navigation-active');
155                    secondary_nav_menu.slideUp();
156                    $('.menu-overlay').removeClass('active');
157                    $('#navigation-menu .secondary-menu-toggle').removeClass('active');
158                }
159
160                if( $('body').hasClass('main-navigation-active') ) {
161                    $('body').removeClass('main-navigation-active');
162                    nav_menu.slideUp();
163                    $('.menu-overlay').removeClass('active');
164                    $('.main-navigation .menu-toggle').removeClass('active');
165                    $('.menu-toggle').removeClass('active');
166                }
167
168                if( $('body').hasClass('search-menu-active') ) {
169                    $('body').removeClass('search-menu-active');
170                    $('.menu-overlay').removeClass('active');
171                    $('.search-menu #search').fadeOut();
172                    $('.search-menu').removeClass('active');
173                }
174            }
175        });
176    }
177
178/*------------------------------------------------
179            MASONRY GALLERY
180------------------------------------------------*/
181    
182    masonry_gallery.imagesLoaded( function() {
183        masonry_gallery.packery({
184            itemSelector: '.grid-item'
185        });
186    });
187                    
188    $('#filter-posts ul li a').on('click', function(event) {
189        event.preventDefault();
190
191        var selector = $(this).attr('data-filter');
192        masonry_gallery.isotope({ filter: selector });
193        $('#filter-posts ul li').removeClass('active');
194        $(this).parent().addClass('active');
195        return false;
196    });
197
198    packery = function () {
199        masonry_gallery.isotope({
200            resizable: true,
201            itemSelector: '.grid-item',
202            layoutMode : 'packery',
203            gutter: 0,
204        });
205    };
206    packery();
207
208    if ( $( document.body ).has( '#infinite-handle' ) ) {
209        $('#infinite-handle').insertAfter('#infinite-post-wrap');
210    }
211
212    $( document.body ).on( 'post-load', function () {
213        masonry_gallery.imagesLoaded( function() {
214            masonry_gallery.packery( 'appended', '.grid-item' ).isotope('reloadItems');
215            packery( 'reLayout', true );
216            if ( $( document.body ).has( '#infinite-handle' ) ) {
217                $('#infinite-handle').insertAfter('#infinite-post-wrap');
218            }
219        } );
220        
221    } );
222
223
224
225    /*--------------------------------------------------------------
226 Keyboard Navigation
227----------------------------------------------------------------*/
228if( $(window).width() < 1024 ) {
229    $('#primary-menu').find("li").last().bind( 'keydown', function(e) {
230        if( e.which === 9 ) {
231            e.preventDefault();
232            $('#masthead').find('.menu-toggle').focus();
233        }
234    });
235
236    $('#secondary-menu').find("li").last().bind( 'keydown', function(e) {
237        if( e.which === 9 ) {
238            e.preventDefault();
239            $('#top-navigation').find('.menu-toggle').focus();
240        }
241    });
242
243    $('#primary-menu > li:last-child button:not(.active)').bind( 'keydown', function(e) {
244        if( e.which === 9 ) {
245            e.preventDefault();
246            $('#masthead').find('.menu-toggle').focus();
247        }
248    });
249
250    $('#secondary-menu > li:last-child button:not(.active)').bind( 'keydown', function(e) {
251        if( e.which === 9 ) {
252            e.preventDefault();
253            $('#top-navigation').find('.menu-toggle').focus();
254        }
255    });
256
257    $('#search').find("button").unbind('keydown');
258
259}
260else {
261    $('#primary-menu').find("li").unbind('keydown');
262    $('#secondary-menu').find("li").unbind('keydown');
263
264    $('#search').find("button").bind( 'keydown', function(e) {
265        var tabKey              = e.keyCode === 9;
266        var shiftKey            = e.shiftKey;
267
268        if( tabKey ) {
269            e.preventDefault();
270            $('#search').hide();
271            $('.search-menu > a').removeClass('search-active').focus();
272        }
273
274        if( shiftKey && tabKey ) {
275            e.preventDefault();
276            $('#search').show();
277            $('.main-navigation .search-field').focus();
278            $('.search-menu > a').addClass('search-active');
279        }
280    });
281
282    $('.search-menu > a').on('keydown', function (e) {
283        var tabKey              = e.keyCode === 9;
284        var shiftKey            = e.shiftKey;
285        
286        if( $('.search-menu > a').hasClass('search-active') ) {
287            if ( shiftKey && tabKey ) {
288                e.preventDefault();
289                $('#search').hide();
290                $('.search-menu > a').removeClass('search-active').focus();
291            }
292        }
293    });
294}
295
296$(window).resize(function() {
297    if( $(window).width() < 1024 ) {
298        $('#primary-menu').find("li").last().bind( 'keydown', function(e) {
299            if( e.which === 9 ) {
300                e.preventDefault();
301                $('#masthead').find('.menu-toggle').focus();
302            }
303        });
304
305        $('#secondary-menu').find("li").last().bind( 'keydown', function(e) {
306            if( e.which === 9 ) {
307                e.preventDefault();
308                $('#top-navigation').find('.menu-toggle').focus();
309            }
310        });
311
312        $('#primary-menu > li:last-child button:not(.active)').bind( 'keydown', function(e) {
313            if( e.which === 9 ) {
314                e.preventDefault();
315                $('#masthead').find('.menu-toggle').focus();
316            }
317        });
318
319        $('#secondary-menu > li:last-child button:not(.active)').bind( 'keydown', function(e) {
320            if( e.which === 9 ) {
321                e.preventDefault();
322                $('#top-navigation').find('.menu-toggle').focus();
323            }
324        });
325
326        $('#search').find("button").unbind('keydown');
327
328    }
329    else {
330        $('#primary-menu').find("li").unbind('keydown');
331        $('#secondary-menu').find("li").unbind('keydown');
332
333        $('#search').find("button").bind( 'keydown', function(e) {
334            var tabKey              = e.keyCode === 9;
335            var shiftKey            = e.shiftKey;
336
337            if( tabKey ) {
338                e.preventDefault();
339                $('#search').hide();
340                $('.search-menu > a').removeClass('search-active').focus();
341            }
342
343            if( shiftKey && tabKey ) {
344                e.preventDefault();
345                $('#search').show();
346                $('.main-navigation .search-field').focus();
347                $('.search-menu > a').addClass('search-active');
348            }
349        });
350
351        $('.search-menu > a').on('keydown', function (e) {
352            var tabKey              = e.keyCode === 9;
353            var shiftKey            = e.shiftKey;
354            
355            if( $('.search-menu > a').hasClass('search-active') ) {
356                if ( shiftKey && tabKey ) {
357                    e.preventDefault();
358                    $('#search').hide();
359                    $('.search-menu > a').removeClass('search-active').focus();
360                }
361            }
362        });
363    }
364});
365
366menu_toggle.on('keydown', function (e) {
367    var tabKey    = e.keyCode === 9;
368    var shiftKey  = e.shiftKey;
369
370    if( menu_toggle.hasClass('active') ) {
371        if ( shiftKey && tabKey ) {
372            e.preventDefault();
373            nav_menu.slideUp();
374            $('.main-navigation').removeClass('menu-open');
375            $('.menu-overlay').removeClass('active');
376            menu_toggle.removeClass('active');
377        };
378    }
379});
380
381
382/*------------------------------------------------
383                END JQUERY
384------------------------------------------------*/
385
386});

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.