1/** 2 * 3 * Theme custom java scripts 4 * 5 * @author Codevz 6 * @copyright http://codevz.com 7 * 8 */ 9 10var j = jQuery, AjaxURL = j('body').data('ajax'), Theme = j('body').data('theme'); 11 12function codevzCount(i, k) { 13 j.ajax({ url: AjaxURL, data: {action: 'codevz_counter', id: i, key: k} }); 14} 15 16function codevzGallery() { 17 var a = '.lightbox,a[href$=".jpg"]:not(.esgbox,.jg-entry,[data-lightbox]),a[href$=".jpeg"]:not(.esgbox,.jg-entry,[data-lightbox]),a[href$=".png"]:not(.esgbox,.jg-entry,[data-lightbox]),a[href$=".gif"]:not(.esgbox,.jg-entry,[data-lightbox])', 18 b = j( 'body' ), 19 d = b.data( 'lightGallery' ); 20 if ( d ) { 21 d.destroy( true ); 22 } 23 if ( j.fn.lightGallery ) { 24 b.attr( 'data-lightGallery', 1 ).lightGallery({selector: a}); 25 } 26} 27 28function codevzClosest(num, arr) { 29 var mid; 30 var lo = 0; 31 var hi = arr.length - 1; 32 while (hi - lo > 1) { 33 mid = Math.floor((lo + hi) / 2); 34 if (arr[mid] < num) { 35 lo = mid; 36 } else { 37 hi = mid; 38 } 39 } 40 if (num - arr[lo] <= arr[hi] - num) { 41 return arr[lo]; 42 } 43 return arr[hi]; 44} 45 46function codevzSortNumber(a,b) { 47 return a - b; 48} 49 50function codevzConvertDataImg() { 51 j('img[srcset]').each(function() { 52 var srcset = j( this ).attr('srcset').split(', '), 53 images = [], 54 sizes = []; 55 56 j.each( srcset, function(i) { 57 var item = this.split(' '), 58 url = item[0], 59 width = item[1].match(/\d+/); 60 61 images[ width ] = url; 62 sizes.push( width[0] ); 63 }); 64 65 sizes.sort( codevzSortNumber ); 66 var parent_width = j( this ).parent().width(); 67 var new_size = codevzClosest( parent_width, sizes ); 68 69 j( this ).attr( 'src', images[ new_size ] ); 70 }); 71} 72 73function codevzTooltip() { 74 var t = '.tooltip'; 75 j(t).not(':first').detach(); 76 j('body').on({ 77 mouseenter: function () { 78 var d = j( this ), 79 a = d.attr( 'title' ); 80 if ( a ) { 81 d.data( 'tipText', a ).removeAttr( 'title' ); 82 if ( ! j( t ).length ) { 83 j( '<p class="tooltip"></p>' ).text( a ).appendTo( 'body' ).fadeIn( 100 ); 84 } 85 } 86 }, 87 mouseleave: function () { 88 j( this ).attr( 'title', j( this ).data( 'tipText' ) ); 89 j( t ).remove(); 90 }, 91 mousemove: function (e) { 92 var w = j( t ).width() / 2, 93 x = e.pageX - w, 94 y = e.pageY + 30; 95 j( t ).css( { top: y, left: x } ); 96 } 97 }, '.tip'); 98} 99 100function codevzScrollIntoView( e, offset ) { 101 102 var offset = offset || 0, 103 docViewTop = j( window ).scrollTop(), 104 docViewBottom = docViewTop + j( window ).height(), 105 elemTop = e.offset().top, 106 elemBottom = elemTop + e.height(); 107 108 return ( ( elemTop <= docViewBottom + offset ) && ( elemBottom >= docViewTop - offset ) ); 109 110} 111 112function codevzCountdown() { 113 if ( j('[data-countdown]').length ) { 114 j( '[data-countdown]' ).each(function() { 115 var dis = j( this ), 116 o = dis.data( 'countdown' ), 117 d = new Date( new Date().valueOf() + o.date * 1000 ); 118 dis.countdown( d ).on( 'update.countdown', function( e ) { 119 dis.html(e.strftime('' 120 + '<li><span>%D</span><p>' + o.d + '%!d:' + o.p + ';</p></li>' 121 + '<li><span>%H</span><p>' + o.h + '%!H:' + o.p + ';</p></li>' 122 + '<li><span>%M</span><p>' + o.m + '%!m:' + o.p + ';</p></li>' 123 + '<li><span>%S</span><p>' + o.s + '</p></li>' 124 )); 125 }).on('finish.countdown', function( e ) { 126 dis.html(e.strftime('<li><span>0</span><p>-</p></li><li><span>0</span><p>-</p></li><li><span>0</span><p>-</p></li><li><span>0</span>
126<p>-</p></li>')); 127 dis.addClass( 'ended' ).append( '<li class="expired">' + o.ex + '</li>' ); 128 }); 129 }); 130 } 131} 132 133function codevzCarousel() { 134 if ( j('.carousel').length ) { 135 j( '.carousel' ).each(function() { 136 var dis = j(this), 137 d = dis.data('carousel'), 138 w = dis.parent().width(), 139 i = ( w < 400 ) ? 1 : ( w < 500 ) ? 2 : ( w < 800 ) ? 3 : 4, 140 o = { 141 slidesToShow: ( d && d.slidestoshow ) ? j.parseJSON( d.slidestoshow ) : i, 142 slidesToScroll: ( d && d.slidestoscroll ) ? j.parseJSON( d.slidestoscroll ) : i, 143 infinite: ( d && d.infinite ) ? j.parseJSON( d.infinite ) : false, 144 speed: ( d && d.speed ) ? j.parseJSON( d.speed ) : 500, 145 centerMode: ( d && d.centermode ) ? j.parseJSON( d.centermode ) : false, 146 centerPadding: ( d && d.centerpadding ) ? d.centerpadding : '0px', 147 variableWidth: ( d && d.variablewidth ) ? j.parseJSON( d.variablewidth ) : false, 148 autoplay: ( d && d.autoplay ) ? j.parseJSON( d.autoplay ) : false, 149 autoplaySpeed: ( d && d.autoplayspeed ) ? j.parseJSON( d.autoplayspeed ) : 500, 150 prevArrow: '<button type="button" class="slick-prev"><i class="fa fa-chevron-left"></i></button>', 151 nextArrow: '<button type="button" class="slick-next"><i class="fa fa-chevron-right"></i></button>', 152 responsive: [{ 153 breakpoint: 1024, 154 settings: {slidesToShow: 4} 155 }, { 156 breakpoint: 800, 157 settings: {slidesToShow: 3} 158 }, { 159 breakpoint: 600, 160 settings: {slidesToShow: 2} 161 }, { 162 breakpoint: 480, 163 settings: {slidesToShow: 1} 164 }] 165 }; 166 167 dis.slick(o); 168 }); 169 } 170} 171 172function codevzAjaxSearch() { 173 var time = false; 174 175 j( '.search_opt' ).on( 'click', function() { 176 j( '.post_types' ).slideToggle(); 177 j( '.ajax_search_results' ).slideUp(); 178 }); 179 180 j( '#search [name="s"]' ).on( 'keyup', function() { 181 clearTimeout( time ); 182 var form = j( this ).parent(), 183 results = form.next( '.ajax_search_results' ); 184 185 if ( j( this ).val().length < 3 ) { 186 j( '.ajax_search_results' ).slideUp(); 187 j( '.fa-search', form ).removeClass( 'fa-spinner fa-pulse' ); 188 return; 189 } 190 191 j( '.post_types' ).slideUp(); 192 j( '.fa-search', form ).addClass( 'fa-spinner fa-pulse' ); 193 194 time = setTimeout( 195 function() { 196 j.ajax({ 197 type: "GET", 198 url: AjaxURL, 199 data: "action=codevz_ajax_search&" + form.serialize(), 200 success: function( data ) { 201 results.html( data ).slideDown(); 202 czLazyload(); 203 j( '.fa-search', form ).removeClass( 'fa-spinner fa-pulse' ); 204 205 /* Ajaxify new links */ 206 if ( j.fn.ajaxify ) { 207 j( '.ajax_search_results' ).ajaxify(); 208 } 209 }, 210 error: function( xhr, status, error ) { 211 results.html( '<h5>' + error + '</h5>' ).slideDown(); 212 j( '.fa-search', form ).removeClass( 'fa-spinner fa-pulse' ); 213 console.log( xhr, status, error ); 214 } 215 }); 216 }, 217 500 218 ); 219 }); 220 221 j( '.search, .ajax_search_results' ).on( 'click', function(e) { 222 e.stopPropagation(); 223 }); 224 225 j( 'body' ).on( 'click', function(e) {
226 j( '.post_types, .ajax_search_results' ).slideUp(); 227 }); 228 229 j( '.search' ).on( 'click', '[name="s"]', function(e) { 230 if ( j( this ).val() ) { 231 j( '.ajax_search_results' ).slideDown(); 232 } 233 }); 234} 235 236function codevzMasonry() { 237 j( '.modern .posts' ).each(function(){ 238 var dis = j( this ); 239 240 /* Gap */ 241 var gap = dis.closest('.def-block').data( 'gap' ), 242 pW = dis.closest('.def-block').width(); 243 if ( gap ) { 244 j( 'head' ).append('<style type="text/css">' + 245 '.modern .posts { margin: 0 0 0 -' + gap + 'px }' + 246 '.modern .ajax-item { margin: 0 0 ' + gap + 'px }' + 247 '.modern .ajax-item > div { margin: 0 0 0 ' + gap + 'px }' + 248 '</style>'); 249 } 250 251 /* Custom size */ 252 var bigger = '0,' + dis.find('.ajax-item').data('bigger'); 253 var biggers = bigger.split(','); 254 for ( var i = 0; i < biggers.length; i++ ) { 255 var item = dis.find('.ajax-item')[biggers[i] - 1]; 256 j( item ).addClass( 'bigger' ); 257 } 258 259 /* Check title */ 260 dis.find('.ajax-items').each(function( i ) { 261 if ( j('.after_cover_mas').length ) { 262 j( 'h3', this ).appendTo( j( this ) ); 263 } 264 }); 265 266 /* Run */ 267 dis.masonry({ 268 itemSelector: '.ajax-item', 269 columnWidth: '.ajax-item:not(.bigger)', 270 percentPosition: true, 271 originLeft: j( '#cd-rtl-css' ).length ? false : true, 272 isAnimated: true, 273 animationOptions: { 274 duration: 800, 275 easing: 'swing', 276 queue: true 277 } 278 }); 279 280 var isMobile = false; 281 // device detection 282 if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) 283 || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.
283substr(0,4))) { 284 isMobile = true; 285 } 286 287 dis.imagesLoaded().progress( function() { 288 dis.masonry( 'layout' ); 289 setTimeout( function() { 290 dis.masonry('layout'); 291 }, 100 ); 292 }); 293 }); 294} 295 296function codevzPopup() { 297 if ( window.location.search.indexOf( 'login' ) > -1 ) { 298 setTimeout(function() { 299 j( 'a[href="#login"]' ).trigger( 'click' ); 300 }, 100 ); 301 } 302 303 j( 'body' ).on( 'click', '.popup_link', function() { 304 var d = j( this ), 305 p = j( this ).next('.popup'), 306 w = j( window ).width(), 307 h = j( window ).height(), 308 css = { 309 'top': h / 2 - p.height() / 2, 310 'left': w / 2 - p.width() / 2 311 }; 312 313 j( '.popup_bg' ).remove(); 314 p.after( '<div class="popup_bg" />' ); 315 if ( ! p.find( '.popup_close' ).length ) { 316 p.append( '<div class="popup_close"><i class="fa fa-close" /></div>' ); 317 } 318 p.css( css ).fadeIn().next('.popup_bg').css( { height: w, opacity: 0.7 } ).fadeIn(); 319 320 j( '.popup_close' ).on( 'click', function() { 321 p.fadeOut().next('.popup_bg').fadeOut( 'fast', function() { j( this ).remove(); }); 322 }); 323 324 j( window ).on( 'resize', function(){ 325 var w = j( window ).width(), 326 h = j( window ).height(); 327 p.css({ 328 'top': h / 2 - p.height() / 2, 329 'left': w / 2 - p.width() / 2 330 }); 331 }); 332 333 return false; 334 }); 335 336 j( 'body' ).on( 'click', '.popup', function(e) { 337 e.stopPropagation(); 338 }); 339 340 j( 'body' ).on( 'click', function(e) { 341 j( '.popup' ).fadeOut().next('.popup_bg').fadeOut( 'fast', function() { j( this ).remove(); }); 342 }); 343} 344 345function codevzPreloader() { 346 var p = j( '.pageloader' ); 347 if ( p.length ) { 348 j(window).resize(function(){ 349 var w = j( window ).width(), 350 h = j( window ).height(), 351 ih = j( 'img', p ).height(), 352 iw = j( 'img', p ).width(); 353 j( 'img', p ).css({ 354 "top": h / 2 - ih / 2 - 50, 355 "left": w / 2 - iw / 2 - 50 356 }); 357 }).resize(); 358 j(window).load(function() { 359 p.fadeOut( 'slow', 'swing' ); 360 }); 361 setTimeout( function(){ 362 p.fadeOut( 'slow', 'swing' ); 363 }, p.data( 'time' ) ); 364 } 365} 366 367function codevzPlayer( o ) { 368 var i = j( '#' + o.attr( 'id' ) ), 369 cover = j( '.has_cover', i ), 370 data = o.data( 'player' ), 371 history_interval, history_timer, 372 tracks = data ? Object.keys( data.tracks ).map(function( n ){ 373 return data.tracks[ n ]; 374 }) : Object, 375 nitro = function() { 376 377 /* Cover */ 378 var p = j( '.jp-jplayer img', i ).removeAttr( 'style' ).clone(); 379 cover.find('span:first-child').html( p ); 380 381 if ( ! cover.find( 'img' ).attr( 'src' ) && tracks[0] && tracks[0].poster ) { 382 setTimeout( function() { 383 cover.find( 'img' ).attr( 'src', tracks[0].poster ); 384 }, 500 ); 385 } 386 387 if ( ! j( '.player_popup' ).length ) { 388 j.each( myPlaylist.playlist, function ( n, obj ) { 389 if ( n == myPlaylist.current && obj.poster_big ) { 390 j( p ).wrap(function() { 391 obj.title = obj.title ? obj.title.replace(/\"/g, "'") : ''; 392 return '<a data-sub-html="<h3>' + obj.title + '</h3>" class="cdEffect" href="' + obj.poster_big + '" />' 393 }); 394 j( p ).parent().append( '<i class="fa fa-expand"></i>' ); 395 } 396 }); 397 } 398 codevzGallery(); 399 400 /* Responsive */ 401 j(window).resize(function(){ 402 if ( cover.length ) { 403 j( '.has_cover_content', i ).css( { "width": cover.parent().width() - cover.width() - 20 } ); 404 } 405 j( '.jp-progress', i ).css( 'width', j( '.jp-audio', i ).width() - 204 ); 406 j( '.jp-playlist li', i ).each(function() { 407 var newWidth = j( this ).width() - j( '.buytrack', this ).width(); 408 j( '.jp-playlist-item', this ).css( 'width', newWidth - 20 ); 409 }); 410 j( '.inline_tracks' ).each(function() { 411 j( 'li', this ).each(function() { 412 var newWidth = j( this ).width() - j( '.buytrack', this ).width(); 413 j( 'a', this ).css( 'width', newWidth - 10 ); 414 }); 415 }); 416 }).resize(); 417 }, 418 history = function( type, history ) { 419 j( '#history', i ).slideDown().html( '<div style="display: block;position: relative;
419left: 40%" class="preloader mt mb clr"><span class="is_loading"><img style="display: block;" src="' + Theme + '/img/loading.gif" /></span></div>' ); 420 j.ajax({ 421 url: AjaxURL, 422 data: {action: 'codevz_new_nonce'}, 423 success: function( nonce ) { 424 j.ajax({ 425 url: AjaxURL, 426 data: { 427 action: "codevz_radio_history", 428 type: type, 429 history: history, 430 nonce: nonce 431 }, 432 success: function( msg ) { 433 if ( msg !== "-1" ) { 434 j( '#history', i ).html( msg ); 435 436 j( '#history', i ).prepend( '<div class="update_history">125s</div>' ); 437 clearInterval( history_timer ); 438 history_timer = setInterval(function() { 439 j( '.update_history' ).html( ( parseInt( j( '.update_history' ).html() ) - 1 ) + 's' ); 440 }, 1000 ); 441 442 j( '#history table', i ).animate( {opacity: 1}, "slow" ); 443 j( '#history', i ).slideDown(); 444 j( ".update_history i", i ).removeClass("fa-spin"); 445 j( '#history td' ).each(function(i) { 446 var now_playing = j( this ).html(); 447 if ( i === 3 ) { 448 j( '.played .played span' ).html( ' - ' + now_playing ); 449 j( '.ajax_current_title' ).html( '<i class="fa fa-play mi"></i> ' + now_playing ); 450 return false; 451 } 452 }); 453 } else { 454 j( '#history', i ).html( 'Error, Please reload track or page.' ).slideDown(); 455 } 456 } 457 }); 458 } 459 }); 460 }, 461 CookiePlay = function( n ) { 462 if ( ! GetCookiePlay( n ) ) { 463 var d = new Date(); 464 d.setTime( d.getTime() + 10000 ); 465 var expires = "expires=" + d.toUTCString(); 466 document.cookie = n + "=" + '1' + "; " + expires; 467 } 468 }, 469 GetCookiePlay = function( n ) { 470 var name = n + "="; 471 var ca = document.cookie.split(';'); 472 for ( var ii=0; ii<ca.length; ii++ ) { 473 var c = ca[ii]; 474 while ( c.charAt(0) == ' ' ) { 475 c = c.substring(1); 476 } 477 if ( c.indexOf(name) == 0 ) { 478 return name; 479 } 480 } 481 return ''; 482 }, 483 options = { 484 playlistOptions: { 485 autoPlay: data.autoplay 486 }, 487 swfPath: Theme + '/js', 488 supplied: "mp3, oga", 489 wmode: "window", 490 loop: data.repeat, 491 smoothPlayBar: true, 492 volume: data.volume || 1, 493 ready: function() { 494 j( '.preloader', i ).fadeOut(); 495 j( '.has_cover, .has_cover_content, .full_player', i ).css( 'opacity', 1 ); 496 nitro(); 497 codevzNiceScroll(); 498 499 /* Volume */ 500 j('.volume', i).on({ 501 mouseenter: function() { 502 j('.vol', this).fadeIn(); 503 }, 504 mouseleave: function() { 505 j('.vol', this).fadeOut(); 506 } 507 }); 508 509 /* Downloads */ 510 j( '.download_track' ).on('click', function() { 511 var link = document.createElement('a'); 512 var id = j( this ).data( 'id' ) || j( this ).closest('.player').data( 'id' ); 513 link.href = j( this ).attr( 'href' ); 514 link.download = link.href; 515 link.click; 516 codevzCount( id, 'downloads' ); 517 }); 518 519 /* Timer */ 520 j('[role="timer"]').on('click', function() { 521 j('[role="timer"]').fadeToggle(); 522 }); 523 524 j( '.toggle_playlist' ).on('click', function() { 525 j( '.ajax_player .jp-playlist' ).slideToggle(); 526 return false; 527 }); 528 529 j( '.toggle_player' ).on('click', function() { 530 i.slideToggle(); 531 532 if ( i.is(':visible') ) { 533 j( '.footer-last' ).toggleClass('mbs'); 534 } 535 536 return false; 537 }); 538 539 /* Back to music */ 540 j( '.original_player' ).on('click', function() { 541 window.open( j( this ).attr( 'href' ) ).focus(); 542 window.close(); 543 return false; 544 }); 545 546 /* Popup play */ 547 if ( j( '.player_popup' ).length ) { 548 j( '.jp-jplayer' ).jPlayer( 'play' ); 549 } 550 551 if ( data.autoplay != true ) { 552 553 setTimeout( function() { 554 555 j( '.jp-jplayer' ).jPlayer( 'stop' ); 556 557 }, 500 ); 558 559 } 560 561 }, 562 play: function () { 563 nitro(); 564 var cur = myPlaylist.current, 565 list = myPlaylist.playlist; 566 567 /* Scroll to played */ 568 var ajax_p = j( '.ajax_player' ); 569 if ( j( 'li.jp-playlist-current', ajax_p ).length ) { 570 j( '.scroll', ajax_p ).animate({ 571 scrollTop: j(".jp-playlist-current").position().top - j( ".scroll > ul", ajax_p ).position().top - (j( ".scroll", ajax_p ).height()/2) + (j(".jp-playlist-current").height()/2) + 10, 572 }, 200 ); 573 } 574 575 /* Track info */ 576 j.each( list, function ( n, obj ) { 577 if ( n === cur ) { 578 if ( ! j( '.ajax_current_title' ).length ) { 579 j( '.ajax_player .jp-type-playlist' ).append('<span class="ajax_current_title"></span>'); 580 } 581 j( '.ajax_player .ajax_current_title' ).html( obj.title + '<span>' + ( obj.artists ? obj.artists.replace(/(<([^>]+)>)/ig,"") : '' ) + '</span>' ); 582 j( '.artist b', i ).html( obj.artists ); 583 j( '.plays b', i ).html( obj.plays ); 584 if ( obj.type && obj.history ) { 585 history( obj.type, obj.history ); 586 clearInterval( history_interval ); 587 history_interval = setInterval(function() { 588 history( obj.type, obj.history ); 589 }, 120000 ); 590 } else { 591 j( "#history", i ).slideUp(); 592 clearInterval( history_interval ); 593 } 594 595 return false; 596 } 597 }); 598 599 /* Played-Paused */ 600 j( '.jp-playlist li', i ).removeClass( 'played' ).addClass( 'paused' ); 601 j( '.jp-playlist-current', i ).removeClass( 'paused' ).addClass( 'played' ); 602 603 /* Count Plays */ 604 if ( ! GetCookiePlay( 'cd_' + cur ) ) { 605 var n_id = ( typeof list[cur].track_id !== 'undefined' ) ? list[cur].track_id : o.data( 'id' ); 606 codevzCount( n_id, 'plays' ); 607 608 if ( j('.single-playlists').length ) { 609 codevzCount( o.data( 'id' ), 'plays' ); 610 } 611 612 CookiePlay( 'cd_' + cur ); 613 } 614 615 /* Popup links */ 616 if ( j( '.player_popup' ).length ) { 617 j( 'a' ).attr('target', 'blank'); 618 } 619 }, 620 pause: function () { 621 j( '.jp-playlist li', i ).removeClass( 'played' ).addClass( 'paused' ); 622 j( '#history', i ).slideUp(); 623 clearInterval( history_interval ); 624 clearInterval( history_timer ); 625 } 626 }; 627 628 var myPlaylist = new jPlayerPlaylist({ 629 jPlayer: ( '#' + o.attr( 'id' ) ) + ' .jp-jplayer', 630 cssSelectorAncestor: ( '#' + o.attr( 'id' ) ) + ' .jp-audio' 631 }, tracks, options ); 632 633 return myPlaylist; 634} 635 636function codevzRunPlayer() { 637 j( '.player' ).each(function() { 638 if ( j( '.ajax_player' ).length ) { 639 j( '.footer-last' ).addClass('mbs'); 640 return false; 641 } 642 codevzPlayer( j( this ) ); 643 });
644 645 /* Popup */ 646 j( '.popup_player' ).on('click', function() { 647 var pop_parent = j( this ).closest( '.inline_tracks, .player' ); 648 j( '.jp-jplayer', pop_parent ).jPlayer( 'stop' ); 649 window.open( j( this ).attr( 'href' ), "null", "height=" + ( pop_parent.height() + 50 ) + ", width=800, top=200, left=200" ).focus(); 650 return false; 651 }); 652 653 /* Share player */ 654 j( '.share_player, .close-share' ).on('click', function() { 655 var parent = j( this ).closest( '.inline_tracks, .player' ); 656 j( '.share_dialog', parent ).fadeToggle(); 657 return false; 658 }); 659 j( '.jp-socials a' ).on('click', function() { 660 window.open( j( this ).attr( 'href' ), "null", "height=300, width=600, top=200, left=200" ); 661 return false; 662 }); 663 664 /* Inline tracks */ 665 j( '.inline_tracks li' ).each(function() { 666 var data = j( 'a', this ).data( 'title' ); 667 j( this ).append( j( data ).filter( '.buytrack' ) ); 668 }); 669 j( '.inline_tracks' ).each(function() { 670 var c = j( '.has_cover', this ), 671 cn = j( '.has_cover_content', this ); 672 673 j(window).resize(function(){ 674 if ( c.length ) { 675 cn.css( { "width": c.parent().width() - c.width() - 5 } ); 676 } 677 j( '.jp-playlist li', this ).each(function() { 678 var nw = j( this ).width() - j( '.buytrack', this ).width(); 679 j( '.current_title', this ).css( 'width', nw ); 680 }); 681 }).resize(); 682 }); 683} 684 685/* Ajax posts */ 686function codevzAjaxPosts( o ) { 687 var s = '#listing_' + o.ajax_id, 688 dis = j( s ), 689 items = dis.find( '.ajax-item' ).length, 690 requestRunning = true, 691 action = { action: 'codevz_ajax_query' }, 692 param = j.extend({}, action, o), 693 offset = param['offset'] ? param['offset'] : 0; 694 695 param['offset'] = offset + items; 696 dis.find( '.load_more a' ).addClass( 'is_loading' ); 697 698 j.ajax({ 699 type: "GET", 700 url: AjaxURL, 701 dataType: 'html', 702 data: ( param ), 703 success: function( data ) { 704 if ( data == '-11' || data.replace(/(\r\n|\n|\r)/gm,"") == '-11' ) { 705 dis.find('.load_more a span').html('No more'); 706 dis.find('.load_more').addClass( 'no_more' ).html( o.no_more ); 707 } else { 708 709 if ( o.layout == 'modern' ) { 710 var moreBlocks = j( data ), 711 msnry = j( s + ' .modern .posts' ); 712 msnry.append( moreBlocks ); 713 msnry.masonry( 'appended', moreBlocks ); 714 codevzConvertDataImg(); 715 msnry.imagesLoaded().progress( function() { 716 msnry.masonry('layout'); 717 setTimeout( function() { 718 msnry.masonry('layout'); 719 }, 1500 ); 720 }); 721 } else { 722 j( data ).hide().appendTo( s + ' .posts' ).slideDown(); 723 } 724 725 czLazyload(); 726 dis.find('.load_more a').removeClass('is_loading'); 727 } 728 729 /* Ajaxify new links */ 730 if ( j.fn.ajaxify ) { 731 j( s ).ajaxify(); 732 } 733 } 734 }); 735} 736 737/* Nicescroll */ 738function codevzNiceScroll() { 739 if ( j('.scroll').length ) { 740 j( '.scroll' ).each(function() { 741 j( this ).niceScroll({ 742 railalign: j( '#cd-rtl-css' ).length ? 'left' : 'right', 743 cursorborder: 'inherit', 744 cursorcolor: '#999', 745 cursorwidth: '8px', 746 cursoropacitymin: 0.2, 747 zindex: 9999, 748 scrollspeed: 120, 749 mousescrollstep: 80 750 }); 751 }); 752 } 753} 754 755function codevzAjaxLoaded() { 756 return j( 'body' ).hasClass( 'ajax_loaded' ); 757} 758 759function czLazyload() { 760 761 var timeout, 762 isotope, 763 lazy = function() { 764 765 clearTimeout( timeout ); 766 767 timeout = setTimeout( function() { 768 769 j( 'img[data-src]' ).each( function( i, x ) { 770 771 x = j( x ); 772 773 if ( ! x.hasClass( 'lazyDone' ) && codevzScrollIntoView( x, 750 ) && ( x.closest( '.sf-menu, .offcanvas_area' ).length ? x.is( ':visible' ) : 1 ) ) { 774 775 x.attr( 'src', x.data( 'src' ) ).attr( 'data-src', '' ); 776 777 if ( x.closest( '.cz_grid' ).data( 'isotope' ) ) { 778 779 isotope = x.closest( '.cz_grid' ); 780 781 x.parent().imagesLoaded( function( ) { 782 783 isotope.isotope( 'layout' ); 784 x.addClass( 'lazyDone' ).attr( 'srcset', x.data( 'srcset' ) ).attr( 'sizes', x.data( 'sizes' ) ).removeAttr( 'data-srcset data-sizes data-czlz' ); 785 786 }); 787 788 } else { 789 x.addClass( 'lazyDone' ).attr( 'srcset', x.data( 'srcset' ) ).attr( 'sizes', x.data( 'sizes' ) ).removeAttr( 'data-srcset data-sizes data-czlz' ); 790 } 791 792 if ( x.innerWidth() - x.width() ) { 793 setTimeout( function() { 794 x.addClass( 'xtra-remove-bg-color' ); 795 }, 1000 ); 796 } 797 798 } 799 800 }); 801 802 // Lazyload parallax sections. 803 j( 'div[data-vc-parallax-image-lazyload]:not(.lazyDone)' ).each( function( i, x ) { 804 805 x = j( x ); 806 807 if ( codevzScrollIntoView( x, 750 ) ) { 808 x.find( '.vc_parallax-inner' ).css( 'background-image', 'url(' + x.data( 'vc-parallax-image-lazyload' ) + ')' ); 809 x.addClass( 'lazyDone' ); 810 } 811 812 }); 813 814 }, 250 ); 815 816 if ( ! j( '[data-czlz]' ).length ) { 817 818 j( window ).off( 'scroll.lazyload' ); 819 820 } 821 822 }; 823 824 j( window ).on( 'scroll.lazyload', lazy ).trigger( 'scroll.lazyload' ); 825 826} 827 828function czOpacityOneByOne( e, s ) { 829 e.css({opacity: 0,marginLeft: -20}).each(function( i ) { 830 j( this ).delay( s * i ).animate({opacity: 1,marginLeft: 0}); 831 });
832} 833 834j(document).ready(function() { 835 'use strict'; 836 837 // WP 5.0 full content 838 j(document).on( 'resize', function() { 839 var wind_width = j(window).width(); 840 841 j( '.alignfull' ).each(function() { 842 var inla_width = j( this ).parent().width(), 843 from_left = ( ( wind_width - inla_width ) / 2 ); 844 845 j( this ).css({ 846 width: wind_width, 847 left: -from_left 848 }); 849 }); 850 }); 851 852 // Lazyload 853 if ( j( '[data-src]' ).length ) { 854 j(window).scroll(function() { 855 czLazyload(); 856 }); 857 } 858 czLazyload(); 859 860 j( '#recentcomments a' ).attr('target', 'blank').addClass('no-ajax'); 861 862 // Init 863 codevzTooltip(); 864 codevzGallery(); 865 codevzPreloader(); 866 codevzCarousel(); 867 codevzMasonry(); 868 codevzConvertDataImg(); 869 codevzRunPlayer(); 870 codevzPopup(); 871 codevzCountdown(); 872 codevzNiceScroll(); 873 874 if ( ! codevzAjaxLoaded() ) { 875 codevzAjaxSearch(); 876 } 877 878 /* Videos view counter */ 879 if ( j('.single-videos').length ) { 880 codevzCount( j('article.videos').attr('id'), 'views' ); 881 } 882 if ( j('.lightbox').length ) { 883 j('.lightbox').on('click', function() { 884 var id = j( this ).parent().attr('id'); 885 id = id ? id.replace('post-', '') : 0; 886 if ( id ) { 887 codevzCount( id, 'views' ); 888 } 889 }); 890 } 891 892 /* Menu */ 893 var nav = j( '.sf-menu' ); 894 if ( nav.length ) { 895 nav.superfish({ 896 delay: 100, 897 onBeforeShow: function() { 898 if ( ! j( this ).is(':visible') ) { 899 czOpacityOneByOne( j( '> li', this ), 100 ); 900 } 901 }, 902 onInit: function() { 903 904 var currents = j( '> .current-menu-item, > .current-menu-parent', nav ); 905 906 if ( currents.length ) { 907 currents.addClass('selectedLava'); 908 } else if ( j( '.current_page_parent', nav ).length ) { 909 j( '.current_page_parent', nav ).closest('.menu-item-has-children').addClass('selectedLava'); 910 } else { 911 j( '> li:first-child', nav ).addClass('selectedLava'); 912 } 913 nav.lavaLamp({ 914 target:'> li:not(.child_menu_item)', 915 setOnClick: false, 916 click: function() { 917 return true; 918 } 919 }); 920 j( '.sf-with-ul' ).each(function(){ 921 if ( ! j( 'i', this ).length ) { 922 if ( j( '.sub', this ).length ) { 923 j( '.sub', this ).before( '<i class="fa fa-angle-down"></i>' ) 924 } else { 925 j( this ).append( '<i class="fa fa-angle-down"></i>' ); 926 } 927 } 928 }); 929 j( 'ul ul .fa-angle-down' ).addClass('fa-angle-right').removeClass('fa-angle-down'); 930 setTimeout( function() { 931 if ( j('.sf-menu > li > a > span').length ) { 932 var h = j('.sf-menu > li > a > span').parent().height(); 933 if ( h ) { 934 j( 'li a', nav ).css( 'height', h ); 935 j( 'li li a', nav ).css( 'height', 'inherit' ); 936 } 937 } else { 938 j( nav ).addClass( 'cd_no_sub' ); 939 j( 'li a', nav ).css( 'padding', '0 40px 20px 0' ); 940 j( 'li li a', nav ).css( 'padding', '8px 15px' ); 941 } 942 }, 1000 ); 943 setTimeout( function() { 944 if ( j( '> li.selectedLava', nav ).length ) { 945 var l = Math.round( j( '> li.selectedLava', nav ).offset().left - nav.offset().left ); 946 j( '.left', nav ).css( 'width', j( '> li.selectedLava', nav ).width() ); 947 j( '.back', nav ).css( 'width', j( '> li.selectedLava', nav ).width() ); 948 j( '.back', nav ).css( 'left', l ); 949 } 950 }, 1000 ); 951 } 952 }); 953 } 954 955 /* MobileMenu */ 956 if ( ! j( "#header .mobile" ).length ) { 957 j( '#header' ).prepend( '<div class="row"><a class="mobile" href="#"><i class="fa fa-remove fa-bars"></i></a><div class="mobile_nav"></div></div>' ); 958 j( '.mobile_nav' ).html( j( '#mobile' ).clone().html() ); 959 j( '.mobile_nav li, .mobile_nav ul, .mobile_nav a' ).removeClass(); 960 j( '.mobile_nav li' ).removeAttr( 'id' ); 961 j( '.mobile_nav .fa-angle-right' ).addClass( 'fa-angle-down' ).removeClass( 'fa-angle-right' ); 962 j( '.mobile_nav .fa-angle-down' ).wrap(function() { 963 return '<a href="#" class="openUl" />'; 964 }); 965 j( '.mobile_nav .openUl' ).parent().after( j( '.openUl' ) ); 966 j( '.mobile_nav .openUl' ).next('.openUl').remove(); 967 968 j( '.mobile' ).on('click', function() { 969 j( '.mobile_nav' ).slideToggle().toggleClass( 'isOpen' ); 970 j( 'i', this ).toggleClass( 'fa-bars' ); 971 return false; 972 }); 973 j( '.mobile_nav .openUl' ).on('click', function() { 974 j( this ).next().slideToggle(); 975 return false; 976 }); 977 978 j( '.mobile_nav' ).on( 'click', function(e) { 979 e.stopPropagation(); 980 }); 981 982 j( 'body, .mobile_nav a' ).on( 'click', function(e) { 983 if ( e.target.className == 'fa fa-angle-down' ) { 984 return; 985 }
986 j( '.mobile_nav' ).slideUp(); 987 j( '.mobile i' ).addClass( 'fa-bars' ); 988 }); 989 if ( j.fn.ajaxify ) { 990 j( '.mobile_nav' ).ajaxify(); 991 } 992 } 993 994 /* Fullscreen menu */ 995 var menu_fullscreen = j( '.fullscreen_menu' ); 996 var head_full = menu_fullscreen.closest('#header'); 997 if ( head_full.length ) { 998 j( '.full_menu, .fullscreen_menu_on, .full_menu', head_full ).detach(); 999 j( '.headdown .row', head_full ).append( '<i class="fa fa-remove fa-bars full_menu"></i><div class="fullscreen_menu_on"><div class="fullmenu_inner clr"></div></div>' ); 1000 1001 if ( j( '.social', head_full ).length ) { 1002 var social4 = j( '.social', head_full )[0].outerHTML, 1003 sf4 = j( '#mobile', head_full )[0].outerHTML; 1004 1005 j( '.fullmenu_inner' ).html( sf4 + social4 ); 1006 j( '.fullmenu_inner .sf-with-ul > i' ).remove(); 1007 j( '.fullmenu_inner .sf-with-ul' ).removeClass(); 1008 } 1009 1010 j( '.full_menu, .fullscreen_menu_on', head_full ).on('click', function(e) { 1011 j( '.full_menu', head_full ).toggleClass( 'fa-bars' ); 1012 j( '.fullscreen_menu_on' ).fadeToggle(); 1013 1014 j( '.fullmenu_inner .sf-menu > li' ).css({opacity: 0,marginLeft: -40}).each(function(i) { 1015 j( this ).delay( 200 * i ).animate({opacity: 1,marginLeft: 30}).animate({marginLeft: 0}); 1016 }); 1017 }); 1018 1019 j( '.fullmenu_inner', head_full ).on('click', function(e) { 1020 e.stopPropagation(); 1021 }); 1022 1023 j( '.fullscreen_menu_on .sub-menu' ).prev('a').on('click', function(e) { 1024 if ( e.target === this ) { 1025 j( this ).next( '.sub-menu' ).slideToggle(); 1026 } 1027 e.preventDefault(); 1028 }); 1029 1030 // Ajax re-call 1031 if ( j.fn.ajaxify ) { 1032 var History = window.History; 1033 if ( !History.enabled ) { 1034 return false; 1035 } else { 1036 j( '.fullscreen_menu_on li:not(.menu-item-has-children) a' ).on('click', function( e ) { 1037 var $t = j(this), 1038 url = $t.attr('href'), 1039 title = $t.attr('title') || null; 1040 1041 /* Continue as normal for cmd clicks etc */ 1042 if ( e.which == 2 || e.metaKey ) { return true; } 1043 1044 History.pushState( null, title, url ); 1045 e.preventDefault(); 1046 1047 /* Fix Nicescroll */ 1048 j( '.nicescroll-rails' ).detach(); 1049 1050 j( '.fullscreen_menu_on' ).fadeOut(); 1051 j( '.full_menu', head_full ).toggleClass( 'fa-bars' ); 1052 return false; 1053 }); 1054 } 1055 j( '.fullscreen_menu_on .fa-angle-down' ).detach(); 1056 } 1057 } 1058 1059 /* Likes */ 1060 if ( j('.likes_dislikes').length ) { 1061 j( '.likes_dislikes a' ).on( 'click', function() { 1062 var t = j( this ).data('type'), 1063 p = j( this ).parent(), 1064 i = p.data('id'), 1065 c = p.data('cm'), 1066 n = p.data('nonce'); 1067 1068 p.append( '<div class="cd_doing"><span></span></div>' ); 1069 j( 'b', this ).html( '...' ); 1070 1071 j.ajax({ 1072 type: 'POST', 1073 url: AjaxURL, 1074 data: 'action=codevz_likes_dislikes&type='+ t +'&cm='+ c +'&nonce='+ n +'&id='+i, 1075 success: function( m ) { 1076 var o = j.parseJSON( m ); 1077 if ( o.message !== 'Rated' ) { 1078 j('[ data-id=' + i + ']').append('<div class="error"></div>'); 1079 j('[ data-id=' + i + '] .error').html( o.message ).fadeIn().delay(2000).queue(function(){ 1080 j( this ).fadeOut().dequeue(); 1081 }); 1082 return; 1083 } 1084 1085 j( '.like', p ).removeClass( 'liked' ) 1086 .addClass( o.like_class ) 1087 .attr( 'title', o.like ) 1088 .attr( 'original-title', o.like ) 1089 .find( 'b' ).html( o.likes ); 1090 1091 j( '.dislike', p ).removeClass( 'disliked' ) 1092 .addClass( o.dislike_class ) 1093 .attr( 'title', o.dislike ) 1094 .attr( 'original-title', o.dislike ) 1095 .find( 'b' ).html( o.dislikes ); 1096 1097 j( '.cd_doing', p ).remove(); 1098 } 1099 }); 1100 1101 return false; 1102 }); 1103 } 1104 1105 /* Ajax load more */ 1106 var requestRunning = false; 1107 if ( j('.load_more').length ) { 1108 j('.load_more a').on('click', function(e){
1109 if ( requestRunning ) { 1110 e.preventDefault(); 1111 return; 1112 } 1113 codevzAjaxPosts( j( this ).parent().parent().data( 'param' ) ); 1114 return false; 1115 }); 1116 } 1117 1118 /* Ajax posts by scroll */ 1119 if ( j('.type_scroll').length ) { 1120 j(window).scroll(function(){ 1121 if ( !requestRunning && !j('.no_more').length && !j('.load_more .is_loading').length && codevzScrollIntoView( j('.type_scroll').parent().find('.load_more a') ) ) { 1122 codevzAjaxPosts( j( '.type_scroll' ).parent().data( 'param' ) ); 1123 } 1124 }); 1125 } 1126 1127 /* Slider position */ 1128 var header_height = j('#header').height(); 1129 j('.overlay_header').css('top', - header_height + 'px').css('margin-bottom', - header_height + 'px'); 1130 j('#header .logo img').on('load', function(){ 1131 var header_height = j( '#header' ).height(); 1132 j('.overlay_header').css('top', - header_height + 'px').css('margin-bottom', - header_height + 'px'); 1133 }); 1134 1135 /* iframes size */ 1136 var $iframes = j( '.cd_iframe, object, embed, .textwidget iframe' ).not('.wp-embedded-content'); 1137 if ( $iframes.length ) { 1138 $iframes.each(function() { 1139 j( this ).attr( 'data-aspectRatio', this.height / this.width ).removeAttr( 'height width' ); 1140 }); 1141 j(window).resize(function() { 1142 $iframes.each(function() { 1143 var newWidth = j( this ).parent().width(); 1144 var $el = j( this ); 1145 $el.width( newWidth ).height( newWidth * $el.attr( 'data-aspectRatio' ) ); 1146 }); 1147 }).resize(); 1148 } 1149 1150 /* Extra */ 1151 j( '.tagcloud' ).addClass( 'clr' ).find( 'a' ).prepend( '<i class="fa fa-tag mi"></i>' ); 1152 1153 j( '#toTop' ).on( 'click', function() { 1154 j( 'html, body' ).animate( { scrollTop: 0 }, 800, 'swing', function() { 1155 j( 'html, body' ).stop(); 1156 }); 1157 }); 1158 1159 // Sticky sidebar 1160 j( '.sticky_sidebar' ).theiaStickySidebar( 1161 { 1162 additionalMarginTop: j( '.headdown.is_sticky' ).length ? j( '.headdown.is_sticky' ).height() + 50 : 30, 1163 updateSidebarHeight: true 1164 } 1165 ); 1166 1167 /* Tabs */ 1168 if ( j('.tabs').length ) { 1169 j( '.tabs' ).each(function() { 1170 j( '.tabs-nav a:first', this ).addClass( 'active' ); 1171 j( '.tab:first', this ).addClass( 'active' ).siblings().hide().removeClass( 'active' ); 1172 j( '.tabs-nav a', this ).click(function (e) { 1173 var tabs = j( this ).parent().prop('className'), 1174 hash = j( this ).attr( 'href' ); 1175 if ( hash.charAt( 0 ) === '#' ) { 1176 e.preventDefault(); 1177 j( this ).closest( '.tabs' ).find( '.tabs-nav a' ).removeClass( 'active' ); 1178 j( this ).addClass('active'); 1179 j( this ).closest( '.tabs' ).find( hash ).show().addClass('active scaleIn').siblings().hide().removeClass('active'); 1180 } 1181 }); 1182 }); 1183 } 1184 1185 /* Gallery */ 1186 if ( j('.tp-grid').length ) { 1187 j( '.tp-grid' ).each(function() { 1188 var fix = function() { 1189 j( 'li', this ).each(function(){ 1190 if( j( this ).css( 'opacity' ) == 1 ) { 1191 j( this ).addClass( 'inview_item' ).fadeIn(); 1192 var h = j( 'a', this ).data( 'href' ); 1193 j( 'a', this ).attr( 'href', h ); 1194 } else { 1195 j( this ).removeClass( 'inview_item' ).fadeOut(); 1196 } 1197 }); 1198 }, 1199 parent = j( this ).parent().parent(), 1200 name = j( '.tt', parent ), 1201 oldname = j( '.tt', parent ).html(), 1202 close = j( '#close', parent ), 1203 loader = j( '<div class="loader"><i></i><i></i><i></i><i></i><i></i><i></i><span>Loading...</span></div>' ).insertBefore( j( this ) ), 1204 stapel = j( this ).stapel({ 1205 randomAngle : true, 1206 delay : 100, 1207 gutter : 0, 1208 pileAngles : 3, 1209 onLoad : function() { 1210 loader.remove(); 1211 }, 1212 onBeforeOpen: function() { 1213 codevzGallery(); 1214 }, 1215 onAfterOpen : function( pileName ) { 1216 name.html( pileName ); 1217 close.show();
1218 j( '.page-numbers', parent ).slideUp(); 1219 fix(); 1220 codevzGallery(); 1221 } 1222 }); 1223 close.on( 'click', function() { 1224 close.hide(); 1225 j( '.page-numbers', parent ).slideDown(); 1226 name.html( oldname ); 1227 stapel.closePile(); 1228 fix(); 1229 j( '.tp-grid', parent ).find( 'a' ).attr( 'href', '#' ); 1230 codevzGallery(); 1231 }); 1232 }); 1233 } 1234 1235 /* Login form */ 1236 if ( j('#login form').length ) { 1237 j( '#login form' ).each(function() { 1238 var form = j( this ), 1239 check = false, 1240 inputs = form.find( 'input' ); 1241 1242 form.submit(function() { 1243 /* Check inputs */ 1244 inputs.each(function() { 1245 if ( ! j( this ).val() ) { 1246 j( this ).select(); 1247 check = false; 1248 return check; 1249 } else { 1250 check = true; 1251 } 1252 }); 1253 1254 if ( j( '.cd_doing', form ).length ) { 1255 return false; 1256 } 1257 1258 if ( check ) { 1259 var btn = form.find( '.submit' ), 1260 btnHTML = btn.html(); 1261 btn.attr( 'disabled', 'disabled' ).html( ' ... <div class="cd_doing"><span></span></div>'); 1262 form.find( '.error' ).slideUp( 100 ); 1263 1264 j.post( AjaxURL, form.serialize(), function( msg ) { 1265 if ( msg ) { 1266 form.find( '.error' ).html( msg ).slideDown( 100 ); 1267 btn.html( btnHTML ); 1268 } else { 1269 window.location.reload( true ); 1270 } 1271 form.find( '.submit' ).removeAttr( 'disabled' ); 1272 }); 1273 } 1274 1275 return false; 1276 }); 1277 }).find( '.submit' ).click(function() { 1278 j( this ).parent('form').submit(); 1279 return false; 1280 }); 1281 } 1282 1283 /* Sticky */ 1284 if ( j('.is_sticky').length ) { 1285 j( '.is_sticky' ).each(function() { 1286 var dis = j( this ), 1287 divHeight = dis.height(), 1288 stickyNavTop = dis.offset().top, 1289 lastScrollTop = 0, 1290 stickyNav = function () { 1291 var scrollTop = j(window).scrollTop(); 1292 if ( scrollTop > stickyNavTop ) { 1293 dis.addClass('ONsticky'); 1294 j('.Corpse_Sticky').css('height', divHeight + 'px'); 1295 1296 /* Fix logo and sticky size */ 1297 j('.headdown').height( j('.Corpse_Sticky').height() ); 1298 var headdownH = j('.headdown').height(), 1299 logoH = j('.logo').height(), 1300 logoM = j('.logo').css('marginTop').replace('px', ''); 1301 } else { 1302 dis.css('height', 'auto'); 1303 j('.Corpse_Sticky').css('height', 'auto'); 1304 dis.removeClass('ONsticky'); 1305 j( '.logo' ).removeAttr( 'style' ); 1306 } 1307 }; 1308 1309 /* Add corpse */ 1310 if ( ! j( '.Corpse_Sticky' ).length ) { 1311 dis.before( '<div class="Corpse_Sticky"></div>' ); 1312 } 1313 1314 /* Scrolled */ 1315 j(window).scroll(function(e){ 1316 var divHeight = dis.height(); 1317 stickyNav(); 1318 dis.toggleClass( 'hasScrolled', j(document).scrollTop() >= 250 ); 1319 var st = j(this).scrollTop(); 1320 var wind_scr = j(window).scrollTop(); 1321 var window_width = j(window).width(); 1322 if( wind_scr > 300 ){ 1323 if (st > lastScrollTop){
1324 j('.ONsticky').addClass('T_off').css({'top' : '-' + divHeight + 'px'}); 1325 } else { 1326 j('.ONsticky').removeClass('T_off').css({'top' : '0'}); 1327 } 1328 lastScrollTop = st; 1329 } 1330 }); 1331 1332 /* On resize */ 1333 j(window).resize(function(){ 1334 var divHeight = dis.height(); 1335 var window_width = j(window).width(); 1336 if ( window_width <= 959 ) { 1337 if(dis.hasClass('ONsticky')){ 1338 dis.removeClass('ONsticky'); 1339 dis.stop(true).animate({opacity : 0}, 200, function(){ 1340 dis.removeClass('ONsticky'); 1341 dis.stop(true).animate({opacity : 1}, 200); 1342 j('.Corpse_Sticky').css('height', 'auto'); 1343 }); 1344 } 1345 } 1346 }).resize(); 1347 }); 1348 } 1349 1350 /* OnePage */ 1351 if ( j( '.page-template-page-onepage' ).length ) { 1352 var m = j( '.sf-menu, .mobile_nav' ); 1353 j( 'a', m ).click(function() { 1354 if ( location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname ) { 1355 var t = j( this.hash ); 1356 t = t.length ? t : j('[id="' + this.hash + '"]'); 1357 if ( t.length ) { 1358 j( 'html, body' ).animate( { scrollTop: t.offset().top - 20 }, 1500, 'swing' ); 1359 return false; 1360 } 1361 } 1362 }); 1363 1364 // Fix 1365 j( '.sf-menu li' ).removeClass('selectedLava'); 1366 1367 j(window).scroll(function(){ 1368 var h = m.outerHeight() + 15, 1369 i = j( "a[href*='#']", m ), 1370 s = i.map(function(){ 1371 var a = j( j( this ).attr( 'href' ) ); 1372 if ( a.length ) { return a; } 1373 }), 1374 t = j( this ).scrollTop() + h, 1375 c = s.map(function(){ 1376 if ( j(this).offset().top < t ) { 1377 return this; 1378 } 1379 }); 1380 1381 c = c[c.length-1]; 1382 var id = c && c.length ? c[0].id : ''; 1383 j( 'li', m ).removeClass( "current" ); 1384 j("[href='#" + id + "']").parent().addClass( "current" ); 1385 }); 1386 } 1387});
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.