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(function($) { 10 11 var makanewsLite = { 12 initAll: function() { 13 this.scrollTop(); 14 this.toggledMenu(); 15 this.searchShow(); 16 this.stickyMenu(); 17 this.socialSharer(); 18 this.loadSocialScript(document, 'script'); 19 if (typeof loadStyle != 'undefined') { 20 if (loadStyle === 'infinite') { 21 this.infiniteScroll(); 22 } else { 23 this.infiniteLoading(); 24 } 25 } 26 }, 27 stickyMenu: function() { 28 var self = this; 29 30 var catcher = $('#catcher'), 31 sticky = $('#sticky'), 32 bodyTop = $('body').offset().top; 33 34 if ( sticky.length ) { 35 $(window).scroll(function() { 36 self.stickThatMenu(sticky,catcher,bodyTop); 37 }); 38 $(window).resize(function() { 39 self.stickThatMenu(sticky,catcher,bodyTop); 40 }); 41 } 42 }, 43 isScrolledTo: function(elem,top) { 44 var docViewTop = $(window).scrollTop(); 45 var docViewBottom = docViewTop + $(window).height(); 46 47 var elemTop = $(elem).offset().top - top; 48 var elemBottom = elemTop + $(elem).height(); 49 50 return ((elemTop <= docViewTop)); 51 }, 52 stickThatMenu: function(sticky,catcher,top) { 53 var self = this; 54 55 if(self.isScrolledTo(sticky,top)) { 56 sticky.addClass('sticky-nav'); 57 catcher.height(sticky.height()); 58 } 59 var stopHeight = catcher.offset().top; 60 61 if ( stopHeight > sticky.offset().top) { 62 sticky.removeClass('sticky-nav'); 63 catcher.height(0); 64 } 65 }, 66 searchShow: function() { 67 $('#trigger-overlay').on('click', function(e) { 68 e.preventDefault(); 69 e.stopPropagation(); 70 $('.overlay-slideleft').addClass('show'); 71 $('.search-row').find('input').focus(); 72 }); 73 $('.overlay-close').on('click', function(e){ 74 e.preventDefault(); 75 e.stopPropagation(); 76 $('.overlay-slideleft').removeClass('show'); 77 }); 78 $(document).on('click', function(e){ 79 $('.overlay-slideleft').removeClass('show'); 80 }); 81 $('.overlay-slideleft').click(function(e){ 82 e.preventDefault(); 83 e.stopPropagation(); 84 }); 85 }, 86 toggledMenu: function() { 87 var $top_menu = $('#top-menu'); 88 var $secondary_menu = $('#menu-main-menu'); 89 var $first_menu = ''; 90 var $second_menu = ''; 91 92 $('.sub-menu').parent().append('<span class="arrow-menu"><i class="fa fa-plus"></i></span>'); 93 94 if ($top_menu.length == 0 && $secondary_menu.length == 0) { 95 return; 96 } else { 97 if ($top_menu.length) { 98 $first_menu = $top_menu; 99 if($secondary_menu.length) { 100 $second_menu = $secondary_menu; 101 } 102 } else { 103 $first_menu = $secondary_menu; 104 } 105 } 106 var menu_wrapper = $first_menu 107 .clone().attr('class', 'top-menu') 108 .wrap('<div id="mobile-menu-wrapper" class="mobile-only"></div>').parent() 109 .appendTo('body'); 110 111 // Add items from the other menu 112 if ($second_menu.length) { 113 $second_menu.clone().appendTo('#mobile-menu-wrapper'); 114 } 115 116 $('.menu-toggle').click(function(e) { 117 e.preventDefault(); 118 e.stopPropagation(); 119 $('#mobile-menu-wrapper').show(); // only required once 120 $('body').toggleClass('mobile-menu-active'); 121 }); 122 123 $('#page').click(function() { 124 if ($('body').hasClass('mobile-menu-active')) { 125 $('body').removeClass('mobile-menu-active'); 126 } 127 }); 128 129 if($('#wpadminbar').length) { 130 $('#mobile-menu-wrapper').addClass('wpadminbar-active'); 131 } 132 133 134 $('.arrow-menu').on('click', function(e) { 135 e.preventDefault(); 136 e.stopPropagation(); 137 var subMenuOpen = $(this).hasClass('sub-menu-open'); 138 139 if ( subMenuOpen ) { 140 $(this).removeClass('sub-menu-open'); 141 $(this).find('i').removeClass('fa-minus').addClass('fa-plus'); 142 $(this).prev('ul.sub-menu').slideUp(); 143 } else { 144 $(this).prev('ul.sub-menu').slideDown(); 145 $(this).addClass('sub-menu-open'); 146 $(this).find('i').removeClass('fa-plus').addClass('fa-minus'); 147 } 148 149 }); 150 151 }, 152 scrollTop : function() { 153 $(".back-to-top").click(function () { 154 $('html, body').animate({scrollTop : 0},800); 155 return false; 156 }); 157 158 $(document).scroll ( function() { 159 var topPositionScrollBar = $(document).scrollTop(); 160 if ( topPositionScrollBar < "150" ) { 161 $(".back-to-top").fadeOut(); 162 } else { 163 $(".back-to-top").fadeIn(); 164 } 165 }); 166 }, 167 socialSharer: function() { 168 if( $('.tc-social-sharing').length ) { 169 //Call jqSocialSharer 170 $('.tc-social-sharing a').jqSocialSharer(); 171 172 $('.btn-hide').on('click', function(e) { 173 e.preventDefault(); 174 var open = $(this).hasClass('active'); 175 if(!open) { 176 $(this).addClass('active'); 177 $('.sticky-left').addClass('hide-social'); 178 } else { 179 $(this).removeClass('active'); 180 $('.sticky-left').removeClass('hide-social'); 181 } 182 }); 183 } 184 }, 185 infiniteLoading: function() { 186 var pageNumber = 2; 187 188 jQuery("#load-more-post").on('click', function(e) { 189 190 if ( pageNumber <= totalPages ) { 191 var that = this; 192 e.preventDefault(); 193 194 var data = { 195 action: 'infinite_scroll', 196 nonce: blackwhiteLoadMore.nonce, 197 page: pageNumber, 198 query: blackwhiteLoadMore.query, 199 }; 200 201 jQuery.ajax({ 202 url: blackwhiteLoadMore.url, 203 type:'POST', 204 data: data, 205 beforeSend : function() { 206 jQuery(that).html(jQuery(that).data('loading')); 207 } 208 209 }).done(function(html) { 210 jQuery(".post-wrap").append(html); 211 jQuery(that).html(jQuery(that).data('more')); 212 }); 213 pageNumber++; 214 215 if ( pageNumber > totalPages ) { 216 jQuery(this).parent().hide(); 217 } 218 } 219 220 e.preventDefault(); 221 222 }); 223 224 }, 225 infiniteScroll: function() { 226 var pageNumber = 2; 227 var isLoading = false;
228 jQuery(window).scroll(function(){ 229 230 if($(window).scrollTop() + $(window).height() > $('#main').height()) { 231 232 if (pageNumber <= totalPages && isLoading === false) { 233 234 var data = { 235 action: 'infinite_scroll', 236 nonce: blackwhiteLoadMore.nonce, 237 page: pageNumber, 238 query: blackwhiteLoadMore.query, 239 }; 240 241 jQuery.ajax({ 242 url: blackwhiteLoadMore.url, 243 type: 'POST', 244 data: data, 245 beforeSend: function () { 246 isLoading = true; 247 $('.infinite-scroll').show(); 248 }, 249 success: function (data) { 250 jQuery(".post-wrap").append(data); 251 isLoading = false; 252 pageNumber++; 253 $('.infinite-scroll').removeAttr('style'); 254 } 255 256 }); 257 258 } 259 } 260 }); 261 }, 262 socialSaring: function() { 263 var offsetTop = $('#content').offset(); 264 265 $('.wmpro-social-sharing.social-sharing-left').css('top', offsetTop.top + 130 ); 266 267 jQuery('.social-popup').on('click', function(e){ 268 var width = 580; 269 var height = 470; 270 271 var leftPosition, topPosition; 272 273 leftPosition = (window.screen.width / 2) - ((width / 2) + 10); 274 275 topPosition = (window.screen.height / 2) - ((height / 2) + 50); 276 var windowFeatures = "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no"; 277 278 var url = $(this).attr('href'); 279 window.open(url, 'socialSharer', windowFeatures); 280 e.preventDefault(); 281 }); 282 283 //pinterest 284 $('.social-pinterst').on("click", function(t) { 285 t.preventDefault(); 286 287 try { 288 var e = document.createElement('script'); 289 e.setAttribute('type', 'text/javascript'); 290 e.setAttribute('charset', 'UTF-8'); 291 e.setAttribute('src', '//assets.pinterest.com/js/pinmarklet.js?r=' + Math.random() * 99999999); 292 document.body.appendChild(e); 293 } catch (e) { 294 295 } 296 297 //record share 298 Nova.Social.recordShare($(this).attr('data-socialsite'), $(this).attr('data-location'), Nova.System.articleId); 299 }); 300 }, 301 loadSocialScript: function(d,s) { 302 var js, fjs = d.getElementsByTagName(s)[0], 303 load = function(url, id) { 304 if (d.getElementById(id)) { 305 return; 306 } 307 js = d.createElement(s); 308 js.src = url; 309 js.id = id; 310 fjs.parentNode.insertBefore(js, fjs); 311 }; 312 $('span.facebookbtn, .fb-like-box').exists(function() { 313 load('//connect.facebook.net/en_US/all.js#xfbml=1', 'fbjssdk'); 314 }); 315 $('span.gplusbtn').exists(function() { 316 load('https://apis.google.com/js/plusone.js', 'gplus1js'); 317 }); 318 $('span.twitterbtn').exists(function() { 319 load('//platform.twitter.com/widgets.js', 'tweetjs'); 320 }); 321 $('span.linkedinbtn').exists(function() { 322 load('//platform.linkedin.com/in.js', 'linkedinjs'); 323 }); 324 $('span.pinbtn, .tc-pinterest-profile').exists(function() { 325 load('//assets.pinterest.com/js/pinit.js', 'pinterestjs'); 326 }); 327 $('span.stumblebtn').exists(function() { 328 load('//platform.stumbleupon.com/1/widgets.js', 'stumbleuponjs'); 329 }); 330 }, 331 skipLinkFocusFix: function() { 332 var is_webkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1, 333 is_opera = navigator.userAgent.toLowerCase().indexOf( 'opera' ) > -1, 334 is_ie = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1; 335 336 if ( ( is_webkit || is_opera || is_ie ) && document.getElementById && window.addEventListener ) { 337 window.addEventListener( 'hashchange', function() { 338 var element = document.getElementById( location.hash.substring( 1 ) ); 339 340 if ( element ) { 341 if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) 342 element.tabIndex = -1; 343 344 element.focus(); 345 } 346 }, false ); 347 } 348 } 349 }; 350 351 $(document).ready(function() { 352 makanewsLite.initAll(); 353 }); 354 355})(jQuery);
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.