1var $ = jQuery.noConflict(); //Wordpress by default uses jQuery instead of $ 2 3jQuery(document).ready(function(){ 4 5 //Hover styles 6 otw_hover_styles(); 7 8 //Socail shares 9 otw_social_shares(); 10 11 // Responsive Videos 12 otw_responsive_videos(); 13 14 // Blog image slides 15 jQuery('.otw_blog_manager-format-gallery').each( function( i, v ) { 16 $this = jQuery(this); 17 18 if( $this.find('.slides').length > 0 ) { 19 $this.flexslider({ 20 namespace: "otw-flex-", 21 animation: "slide", // slide or fade 22 animationLoop: true, 23 }); 24 } 25 }); 26 27 // Load More Other Items 28 jQuery(document).on('click', '.js-otw_blog_manager-load-more a', function(e) { 29 e.preventDefault(); 30 $this = jQuery(this); 31 32 if( !$this.parent().hasClass('otw_blog_manager-load-more-newspapper') ) { 33 34 $this.html('<div class="preloader">Loading posts...</div>'); 35 36 var url = $this.parent('.otw_blog_manager-load-more').parent().find('.otw_blog_manager-pagination.hide a').attr('href'); 37 38 if(url === 'undefined' || url === '#' || url === ''){ 39 $this.text($this.attr('data-empty')); 40 return false; 41 } 42 43 $this.prop('disabled', true); 44 45 $container = $this.parent().parent().parent().parent().parent().parent().parent().parent().find('.otw_blog_manager-blog-item-holder').parent(); 46 $mainContainer = $this.parent().parent().parent().parent().parent(); 47 48 jQuery.get(url, function(data) { 49 if( data.length > 1 ) { 50 $pagination = jQuery(data).find('.js-pagination_container').parent().parent(); 51 52 jQuery('.js-pagination_container').parent().parent().remove(); 53 54 $newElements = jQuery(data).find('.otw_blog_manager-blog-item-holder'); 55 56 $container.append( $newElements ); 57 58 $mainContainer.append( $pagination ); 59 60 otw_hover_styles(); 61 otw_responsive_videos(); 62 otw_social_shares(); 63 otw_enable_sliders(); 64 horizontal_layout('.otw_blog_manager-horizontal-layout-items'); 65 } else { 66 $this.html('No More Posts Found').animate({ opacity: 1 }, 2000, function () { 67 $this.fadeOut('fast'); 68 }); 69 } 70 }); 71 72 } 73 74 }); 75 76 // Load More Widgets 77 jQuery(document).on('click', '.js-widget-otw_blog_manager-load-more a', function(e) { 78 79 e.preventDefault(); 80 $this = jQuery(this); 81 82 var url = $this.parent('.js-widget-otw_blog_manager-load-more').parent().find('.otw_blog_manager-pagination.hide a').attr('href'); 83 84 if(url === 'undefined' || url === '#' || url === ''){ 85 $this.text($this.attr('data-empty')); 86 return false; 87 } 88 $this.html('<div class="preloader">Loading posts...</div>'); 89 $this.prop('disabled', true); 90 91 $container = $this.parent().parent().parent().parent().parent().parent().find('.js-widget-list'); 92 93 jQuery.get(url, function(data) { 94 if( data.length > 1 ) { 95 $pagination = jQuery(data).find('.js-otw_blog_manager-widget-pagination-holder').parent().parent(); 96 97 // Remove Load More 98 $this.parent().parent().remove(); 99 100 // Add new Load More BTN 101 jQuery('.js-otw_blog_manager-widget-pagination-holder').html( jQuery(data).find('.js-widget-pagination_container') ); 102 103 104 $container.append( jQuery(data).find('.js-widget-list').children() ); 105 otw_hover_styles(); 106 otw_responsive_videos(); 107 otw_social_shares(); 108 otw_enable_sliders(); 109 } else { 110 $this.html('No More Posts Found').animate({ opacity: 1 }, 2000, function () { 111 $this.fadeOut('fast'); 112 }); 113 } 114 }); 115 116 }); 117 118 //Load More NewsPapper 119 jQuery(document).on("click", '.otw_blog_manager-load-more-newspapper a',function(e){ 120 121 e.preventDefault(); 122 123 $this = jQuery(this); 124 125 var url = $this.attr('href'); 126 127 if(url === 'undefined' || url === '#' || url === ''){ 128 $this.text($this.attr('data-empty')); 129 return false; 130 } 131 $this.html('<div class="preloader">Loading posts...</div>'); 132 $container = jQuery(this).parent().parent().parent().parent().parent().find('.otw_blog_manager-blog-newspaper') 133 134 jQuery.get(url, function(data) { 135 if( data.length > 1 ) { 136 var $newElements = jQuery( jQuery(data).find('.otw_blog_manager-blog-item-holder').html() ); 137 138 //slider fixing 139 $newElements.find('.otw_blog_manager-blog-media-wrapper.otw_blog_manager-format-gallery').each(function(){ 140 var image = new Image(); 141 image.src = jQuery(this).find('.slides li img').attr("src");
142 jQuery(this).css({'max-width': image.naturalWidth + 'px' }); 143 jQuery(this).find('.slides li').css({'max-width': image.naturalWidth + 'px' }); 144 }); 145 146 if($newElements.find('.otw_blog_manager-format-gallery .slides').length > 0 ) { 147 $newElements.find('.otw_blog_manager-format-gallery').flexslider({ 148 namespace: "otw-flex-", 149 animation: "slide" 150 }); 151 } 152 153 $paginationElement = jQuery(data).find('.js-pagination_container').parent().parent(); 154 155 if($this.data('isotope') !== false){ 156 157 $container.append( $newElements ).isotope( 'appended', $newElements, function(){ 158 jQuery(this).isotope('reLayout'); 159 }); 160 } else { 161 $newElements.appendTo( $this.parent('.otw_blog_manager-load-more').parent().find('.otw_blog_manager-blog-item-holder') ).each(function(){ 162 if($this.data('layout') === 'horizontal'){ 163 horizontal_layout('.otw_blog_manager-horizontal-layout-items'); 164 } 165 }); 166 } 167 168 otw_social_shares(); 169 otw_enable_sliders(); 170 171 //next page 172 jQuery('.js-pagination_container').parent().parent().remove(); 173 $container.parent().append( $paginationElement ); 174 otw_calculate_columns('.otw_blog_manager-mosaic-layout'); 175 } else { 176 $this.html('No More Posts Found').animate({ opacity: 1 }, 2000, function () { 177 $this.fadeOut('fast'); 178 }); 179 } 180 }); 181 182 183 }); 184 185 //Infinite Scroll for Grid Layout 186 try { 187 188 jQuery('.otw_blog_manager-infinite-pagination-holder').infinitescroll({ 189 navSelector : '.otw_blog_manager-pagination', // selector for the paged navigation 190 nextSelector : '.otw_blog_manager-pagination a', // selector for the NEXT link (to page 2) 191 itemSelector : '.otw_blog_manager-blog-item-holder', // selector for all items you'll retrieve 192 // debug: true, 193 loading: { 194 finishedMsg: 'No More Posts Found', 195 msgText: 'Loading posts...', 196 img: 'https://i.imgur.com/o4Qsgvx.gif' 197 } 198 }, 199 //call horizontal layout as a callback 200 function( newElements ) { 201 otw_hover_styles(); 202 otw_responsive_videos(); 203 otw_social_shares(); 204 otw_enable_sliders(); 205 } 206 ); 207 } catch(err) { } 208 209 //Infinite Scroll for Newspaper Layout 210 try { 211 jQuery('.otw_blog_manager-infinite-scroll').infinitescroll({ 212 navSelector : '.otw_blog_manager-pagination', // selector for the paged navigation 213 nextSelector : '.otw_blog_manager-pagination a', // selector for the NEXT link (to page 2) 214 itemSelector : '.otw_blog_manager-blog-newspaper-item', // selector for all items you'll retrieve 215 loading: { 216 finishedMsg: 'No More Posts Found', 217 msgText: 'Loading posts...', 218 img: 'https://i.imgur.com/o4Qsgvx.gif' 219 } 220 }, 221 //call Isotope as a callback 222 function( newElements ) { 223 var $newElements = jQuery(newElements); 224 //slider fixing 225 $newElements.find('.otw_blog_manager-blog-media-wrapper.otw_blog_manager-format-gallery').each(function(){ 226 var image = new Image(); 227 image.src = jQuery(this).find('.slides li img').attr("src"); 228 // jQuery(this).css({'max-width': image.naturalWidth + 'px' }); 229 // jQuery(this).find('.slides li').css({'max-width': image.naturalWidth + 'px' }); 230 }); 231 232 if($newElements.find('.otw_blog_manager-format-gallery .slides').length > 0 ) { 233 $newElements.find('.otw_blog_manager-format-gallery').flexslider({ 234 namespace: "otw-flex-", 235 animation: "slide" 236 }); 237 } 238 239 jQuery('.otw_blog_manager-infinite-scroll').isotope( 'appended', $newElements, function(){ 240 otw_hover_styles(); 241 otw_responsive_videos(); 242 otw_social_shares(); 243 otw_enable_sliders(); 244 otw_calculate_columns('.otw_blog_manager-mosaic-layout'); 245 jQuery(this).isotope('reLayout'); 246 247 }); 248 } 249 ); 250 } catch(err) { 251 252 } 253 254 //Infinite Scroll for Horizontal Layout 255 try { 256 jQuery('.otw_blog_manager-horizontal-layout-items-infinite-scroll').infinitescroll({ 257 navSelector : '.otw_blog_manager-pagination', // selector for the paged navigation 258 nextSelector : '.otw_blog_manager-pagination a', // selector for the NEXT link (to page 2) 259 itemSelector : '.otw_blog_manager-horizontal-item', // selector for all items
259you'll retrieve 260 loading: { 261 finishedMsg: 'No More Posts Found', 262 msgText: 'Loading posts...', 263 img: 'https://i.imgur.com/o4Qsgvx.gif' 264 } 265 }, 266 267 //call horizontal layout as a callback 268 function( newElements ) { 269 $newElements = jQuery(newElements).find('.otw_blog_manager-horizontal-item'); 270 otw_social_shares(); 271 otw_enable_sliders(); 272 horizontal_layout('.otw_blog_manager-horizontal-layout-items'); 273 } 274 ); 275 } catch(err) { 276 277 } 278 279 // Timeline 280 try { 281 jQuery('.otw_blog_manager-blog-timeline').infinitescroll({ 282 navSelector : '.otw_blog_manager-pagination', // selector for the paged navigation 283 nextSelector : '.otw_blog_manager-pagination a', // selector for the NEXT link (to page 2) 284 itemSelector : '.otw_blog_manager-blog-timeline-item', // selector for all items you'll retrieve 285 loading: { 286 finishedMsg: 'No More Posts Found', 287 msgText: 'Loading posts...', 288 img: 'https://i.imgur.com/o4Qsgvx.gif' 289 } 290 }, 291 //callback 292 function( newElements ) { 293 var $newElements = jQuery(newElements); 294 295 //slider fixing 296 $newElements.find('.otw_blog_manager-blog-media-wrapper.otw_blog_manager-format-gallery').each(function(){ 297 var image = new Image(); 298 image.src = jQuery(this).find('.slides li img').attr("src"); 299 // jQuery(this).css({'max-width': image.naturalWidth + 'px' }); 300 // jQuery(this).find('.slides li').css({'max-width': image.naturalWidth + 'px' }); 301 }); 302 303 if($newElements.find('.otw_blog_manager-format-gallery .slides').length > 0 ) { 304 $newElements.find('.otw_blog_manager-format-gallery').flexslider({ 305 namespace: "otw-flex-", 306 animation: "slide" 307 }); 308 } 309 310 //hover styles 311 $newElements.each(function(){ 312 otw_hover_styles(); 313 otw_responsive_videos(); 314 otw_social_shares(); 315 otw_enable_sliders(); 316 }); 317 318 jQuery('.otw_blog_manager-blog-timeline').append($newElements); 319 320 jQuery('#infscr-loading').remove().insertAfter( jQuery('.otw_blog_manager-blog-timeline .otw_blog_manager-blog-timeline-item:last') ); 321 322 timeline_layout_fixer(); 323 } 324 ); 325 } catch(err) { 326 327 } 328 329 //Comment Form 330 jQuery('.otw_blog_manager-btn-reply').on('click', function() { 331 if (!jQuery(this).hasClass('otw_blog_manager-cancel-reply')) { 332 333 var comForm = jQuery('.otw_blog_manager-comment-form').clone(); 334 jQuery('.otw_blog_manager-comment-form').remove(); 335 336 jQuery('.otw_blog_manager-btn-reply').removeClass('otw_blog_manager-cancel-reply').html('<b>reply</b>'); 337 jQuery(this).addClass('otw_blog_manager-cancel-reply').html('<b>cancel</b>'); 338 jQuery(this).parent().parent().append(comForm); 339 340 jQuery(this).parent().parent().children('.otw_blog_manager-comment-form') 341 .focus(function() { 342 jQuery(this).siblings('i').addClass('otw_blog_manager-focused'); 343 }) 344 .focusout(function() { 345 jQuery(this).siblings('i').removeClass('otw_blog_manager-focused'); 346 }); 347 } 348 }); 349 350 jQuery(document) 351 .on('click', '.otw_blog_manager-cancel-reply', function() { 352 var comForm = jQuery(this).parent().siblings('.otw_blog_manager-comment-form').clone(); 353 jQuery(this).parent().siblings('.otw_blog_manager-comment-form').remove(); 354 355 jQuery(this).removeClass('otw_blog_manager-cancel-reply').html('<b>reply</b>'); 356 jQuery('.otw_blog_manager-single-post').append(comForm); 357 }) 358 .on('click', '.otw_blog_manager-cancel-reply2', function(event) { 359 event.preventDefault(); 360 361 var comForm = jQuery(this).parent().parent().clone(); 362 jQuery(this).parent().parent().remove(); 363 364 jQuery('.otw_blog_manager-cancel-reply').removeClass('otw_blog_manager-cancel-reply').html('<b>reply</b>'); 365 jQuery('.otw_blog_manager-single-post').append(comForm); 366 }) 367 .on('focus', 'input, textarea', function() { 368 jQuery(this).siblings('i').addClass('otw_blog_manager-focused'); 369 }) 370 .on('focusout', 'input, textarea', function() { 371 jQuery(this).siblings('i').removeClass('otw_blog_manager-focused'); 372 }); 373 374 //Slider 375 jQuery('.otw_blog_manager-slider').each(function(){ 376 var $this = jQuery(this); 377 378 var flexNav = true; // Show Navigation 379 var flexAuto = true; // Auto play 380 381 if( $this.data('nav') === 0 ) { 382 flexNav = false;
383 } 384 385 if( $this.data('auto-slide') === 0 ) { 386 flexAuto = false; 387 } 388 389 var slider_animation = jQuery(this).data('animation'); 390 391 if($this.find('.slides').length > 0 ) { 392 393 if( $this.hasClass('otw_blog_manager-carousel') ){ 394 var item_margin = $this.data('item-margin'); 395 var item_per_page = $this.data('item-per-page'); 396 var item_width = ( ($this.width() - ( item_margin * (item_per_page - 1) )) / item_per_page ); 397 398 var prev_text = ""; 399 var next_text = ""; 400 401 if($this.data('type') == "widget"){ 402 prev_text = '<i class="icon-angle-left"></i>'; 403 next_text = '<i class="icon-angle-right"></i>'; 404 } 405 406 $this.flexslider({ 407 namespace: "otw-flex-", 408 animation: slider_animation, 409 animationLoop: false, 410 prevText: prev_text, 411 nextText: next_text, 412 itemWidth: item_width, 413 itemMargin: item_margin, 414 controlNav: flexNav, 415 slideshow: flexAuto 416 }); 417 } else { 418 419 $this.flexslider({ 420 namespace: "otw-flex-", 421 controlNav: flexNav, 422 animation: slider_animation, 423 slideshow: flexAuto 424 }); 425 } 426 } 427 // Hide bullets if paginations is not enabled 428 if( $this.data('nav') === 0 ) { 429 $this.find( jQuery('.otw-flex-control-nav') ).hide(); 430 } 431 }); 432 433 //Timeline Layout 434 jQuery('.otw_blog_manager-blog-timeline.with-heading').before('<div class="otw_blog_manager-blog-timeline-heading"></div>'); 435 timeline_layout_fixer(); 436 437 /* Input & Textarea Placeholder */ 438/* jQuery('input[type="text"], textarea').each(function(){ 439 jQuery(this).attr({'data-value': jQuery(this).attr('placeholder')}); 440 jQuery(this).removeAttr('placeholder'); 441 jQuery(this).attr({'value': jQuery(this).attr('data-value')}); 442 }); 443 444 jQuery('input[type="text"], textarea').focus(function(){ 445 jQuery(this).removeClass('error'); 446 if(jQuery(this).val().toLowerCase() === jQuery(this).attr('data-value').toLowerCase()){ 447 jQuery(this).val(''); 448 } 449 }).blur( function(){ 450 if(jQuery(this).val() === ''){ 451 jQuery(this).val(jQuery(this).attr('data-value')); 452 } 453 }); 454*/ 455 //IE8 hover fixer 456 jQuery('.hover-style-14-desaturate a, .hover-style-16-orton a').on('mouseenter', function(){ 457 jQuery(this).find('.otw_blog_manager-hover-img').css({'opacity': '0'}); 458 }).on('mouseleave', function(){ 459 jQuery(this).find('.otw_blog_manager-hover-img').css({'opacity': '1'}); 460 }); 461 462 jQuery('.hover-style-15-blur a, .hover-style-17-glow a').on('mouseenter', function(){ 463 jQuery(this).find('.otw_blog_manager-hover-img').css({'opacity': '1'}); 464 }).on('mouseleave', function(){ 465 jQuery(this).find('.otw_blog_manager-hover-img').css({'opacity': '0'}); 466 }); 467}); 468 469var $container = jQuery('.otw_blog_manager-blog-newspaper'); 470 471//Blog Newspaper Filter 472 473jQuery(window).on('load', function() { 474 // Isotope 475 try { 476 $container = jQuery('.otw_blog_manager-blog-newspaper'); 477 478 otw_calculate_columns('.otw_blog_manager-mosaic-layout'); 479 480 $container.isotope({ 481 itemSelector: '.otw_blog_manager-blog-newspaper-item', 482 layoutMode: 'masonry', 483 getSortData: { 484 date: function( $elem ) { 485 return parseInt(String($elem.find('.otw_blog_manager-blog-date a').attr('data-date')).replace(/-/g, "")); 486 }, 487 alphabetical: function( $elem ) { 488 return $elem.find('.otw_blog_manager-blog-title a').text(); 489 } 490 }, 491 onLayout: function( $elem, instance ) { 492 493 if( $container.find('.otw_blog_manager-mosaic-layout').length !== 0 ) { 494 otw_calculate_columns('.otw_blog_manager-mosaic-layout'); 495 } 496 } 497 }); 498 499 var $optionSets_filter = jQuery('.option-set.otw_blog_manager-blog-filter'), 500 $optionLinks_filter = $optionSets_filter.find('a'); 501 502 $optionLinks_filter.click(function(e) { 503 e.preventDefault(); 504 505 var $this = jQuery(this); 506 507 508 if ($this.hasClass('selected')) { 509 return false; 510 } 511 512 var $optionSet = $this.parents('.option-set'); 513 $optionSet.find('.selected').removeClass('selected'); 514 $this.addClass('selected'); 515 516 var selector = jQuery(this).data('filter'); 517 518 jQuery(this).parents('.otw_blog_manager-blog-newspaper-filter').parent().parent().parent().find($container).isotope({filter: selector}); 519 }); 520 } catch(err) { 521 522 } 523 524 //Blog Sorting 525 var $optionSets_sort = jQuery('.option-set.otw_blog_manager-blog-sort'), 526 $optionLinks_sort = $optionSets_sort.find('a'); 527 528 $optionLinks_sort.click(function(e){ 529 e.preventDefault(); 530 531 var $this = jQuery(this); 532 533 if ($this.hasClass('selected')) { 534 return false;
535 } 536 537 var $optionSet = $this.parents('.option-set'); 538 $optionSet.find('.selected').removeClass('selected'); 539 $this.addClass('selected'); 540 541 var value = $this.attr('data-option-value'); 542 jQuery(this).parents('.otw_blog_manager-blog-newspaper-sort').parent().parent().parent().find($container).isotope({ sortBy : value }); 543 }); 544 545 //Slider width fixing 546 jQuery('.otw_blog_manager-blog-media-wrapper.otw_blog_manager-format-gallery.slider').each(function(){ 547 var image = new Image(); 548 image.src = jQuery(this).find('.slides li img').attr("src"); 549 jQuery(this).css({'max-width': image.naturalWidth + 'px' }); 550 jQuery(this).find('.slides li').css({'max-width': image.naturalWidth + 'px' }); 551 }); 552 553 //horizontal layout 554 horizontal_layout('.otw_blog_manager-horizontal-layout-items'); 555}); 556 557//Hover styles 558function otw_hover_styles(){ 559 560 jQuery('.hover-style-1-full > a, .hover-style-2-shadowin > a, .hover-style-3-border > a, .hover-style-7-shadowout > a').each(function(){ 561 if( jQuery(this).find('span.theHoverBorder').length == 0 ){ 562 jQuery(this).append('<span class="theHoverBorder"></span>'); 563 } 564 }); 565 566 jQuery('.hover-style-4-slidetop > a, .hover-style-5-slideright >
566 a, .hover-style-8-slidedown > a, .hover-style-9-slideleft > a').each(function(){ 567 if( jQuery(this).find('span.theHoverBorder').length == 0 ){ 568 var icon = jQuery(this).parents('.otw_blog_manager-blog-media-wrapper').attr('data-icon'); 569 jQuery(this).append('<span class="theHoverBorder"><i class="'+ icon +'"></i></span>'); 570 } 571 }); 572 573 //Special effects 574 jQuery('img', '.hover-style-14-desaturate').each(function(){ 575 576 jQuery(this).clone().addClass("otw_blog_manager-hover-img").insertAfter( jQuery(this) ).load(function(){ 577 Pixastic.process(this, "desaturate"); 578 }); 579 580 }); 581 582 jQuery('img', '.hover-style-15-blur').each(function(){ 583 // if( jQuery(this).parent().hasClass('otw-media-container') ) 584 jQuery(this).clone().addClass("otw_blog_manager-hover-img").insertAfter(jQuery(this)).load(function(){ 585 Pixastic.process(this, "blurfast", {amount: 0.3}); 586 }); 587 }); 588 589 jQuery('img', '.hover-style-16-orton').each(function(){ 590 jQuery(this).clone().addClass("otw_blog_manager-hover-img").insertAfter(jQuery(this)).load(function(){ 591 Pixastic.process(this, "blurfast", {amount: 0.05}); 592 }); 593 }); 594 595 jQuery('img', '.hover-style-17-glow').each(function(){ 596 jQuery(this).clone().addClass("otw_blog_manager-hover-img").insertAfter(jQuery(this)).load(function(){ 597 Pixastic.process(this, "glow", {amount: 0.3, radius: 0.2}); 598 }); 599 }); 600 601 //IE8 hover fixer 602 jQuery('.hover-style-15-blur a .otw_blog_manager-hover-img, .hover-style-17-glow a .otw_blog_manager-hover-img').css({'opacity': '0'}); 603 jQuery('.hover-style-14-desaturate a .otw_blog_manager-hover-img, .hover-style-16-orton a .otw_blog_manager-hover-img').css({'opacity': '1'}); 604 605 //IE8 frameborder fixer 606 jQuery('.otw_blog_manager-format-video iframe, .otw_blog_manager-format-audio iframe').each(function(){ 607 jQuery(this).attr({'frameBorder': 'no'}); 608 }); 609} 610 611function timeline_layout_fixer(){ 612 jQuery('.otw_blog_manager-blog-timeline .otw_blog_manager-blog-timeline-item').removeClass('odd').removeClass('even'); 613 jQuery('.otw_blog_manager-blog-timeline .otw_blog_manager-blog-timeline-item:nth-child(2n-1)').addClass('odd'); 614 jQuery('.otw_blog_manager-blog-timeline .otw_blog_manager-blog-timeline-item:nth-child(2n)').addClass('even'); 615} 616 617(function($,sr){ 618 // debouncing function from John Hann 619 // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ 620 var debounce = function (func, threshold, execAsap) { 621 var timeout; 622 623 return function debounced () { 624 var obj = this, args = arguments; 625 function delayed () { 626 if (!execAsap) 627 func.apply(obj, args); 628 timeout = null; 629 }; 630 631 if (timeout) 632 clearTimeout(timeout); 633 else if (execAsap) 634 func.apply(obj, args); 635 636 timeout = setTimeout(delayed, threshold || 100); 637 }; 638 } 639 // smartresize 640 jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); }; 641})(jQuery,'smartresize'); 642 643//Window resize event 644jQuery(window).smartresize(function(){ 645 try { 646 otw_calculate_columns('.otw_blog_manager-mosaic-layout'); 647 } catch(err) { } 648 649 try { 650 $container.isotope("reLayout"); 651 } catch(err) { } 652 653 try { 654 horizontal_layout('.otw_blog_manager-horizontal-layout-items'); 655 } catch(err) { } 656}); 657 658function otw_enable_sliders () { 659 jQuery('.otw_blog_manager-format-gallery').each( function( i, v ) { 660 $this = jQuery(this); 661 662 if( $this.find('.slides').length > 0 ) { 663 $this.flexslider({ 664 namespace: "otw-flex-", 665 animation: "slide", // slide or fade 666 animationLoop: true 667 }); 668 } 669 }); 670} 671 672//Masonry layout 673function otw_calculate_columns(container) { 674 675 jQuery(container).each(function(){ 676 677 var $this = jQuery(this), 678 containerWidth = $this.width(), 679 minCol = Math.floor(containerWidth / 12); 680 681 if (minCol*3 >= 200) { 682 jQuery('> .otw_blog_manager-iso-item', $this).each(function() { 683 684 var $this = jQuery(this); 685 if ($this.hasClass('otw_blog_manager-1-4')) { 686 $this.css('width', minCol*3); 687 } else if ($this.hasClass('otw_blog_manager-2-4') || $this.hasClass('otw_blog_manager-1-2')) { 688 $this.css('width', minCol*6); 689 } else if ($this.hasClass('otw_blog_manager-1-3')) { 690 $this.css('width', minCol*4); 691 } else if ($this.hasClass('otw_blog_manager-2-3')) { 692 $this.css('width', minCol*8); 693 } 694 }); 695 696 } else if ( minCol*3 < 200 && minCol*3 > 150) { 697 jQuery('> .otw_blog_manager-iso-item', $this).each(function() { 698 699 var $this = jQuery(this); 700 if ($this.hasClass('otw_blog_manager-1-4')) { 701 $this.css('width', minCol*6); 702 } else if ($this.hasClass('otw_blog_manager-2-4') || $this.hasClass('otw_blog_manager-1-2')) { 703 $this.css('width', minCol*12); 704 } else if ($this.hasClass('otw_blog_manager-1-3')) { 705 $this.css('width', minCol*6); 706 } else if ($this.hasClass('otw_blog_manager-2-3')) { 707 $this.css('width', minCol*12); 708 } 709 }); 710 711 } else if ( minCol*3 <= 150) { 712 jQuery('> .otw_blog_manager-iso-item', $this).each(function() { 713 jQuery(this).css('width', minCol*12); 714 }); 715 } 716 717 jQuery('> .otw_blog_manager-iso-item', $this).each(function() { 718 719 if( (jQuery(this).hasClass('otw_blog_manager-1-2') || jQuery(this).hasClass('otw_blog_manager-2-3')) && jQuery(this).hasClass('height1')){ 720 jQuery(this).css('height', jQuery(this).outerWidth()/2); 721 // jQuery(this).css('width', '-=1'); // Hack for spacing sincer margin-right: -1px is ignored 722 } else if(jQuery(this).hasClass('height2')){ 723 jQuery(this).css('height', jQuery(this).outerWidth()*2); 724 } else { 725 jQuery(this).css('height', jQuery(this).outerWidth()); 726 } 727 728 // console.log ( jQuery(this) ); 729 730 $imgWidth = jQuery(this).find('.otw_blog_manager-blog-media-wrapper').find('img').width(); 731 $imgHeight = jQuery(this).find('.otw_blog_manager-blog-media-wrapper').find('img').height(); 732 console.log ( jQuery(this).width(), jQuery(this).height() ); 733 console.log ( $imgWidth, $imgHeight ); 734 jQuery(this).find('.otw_blog_manager-blog-media-wrapper').css({'width': jQuery(this).width(), 'height': jQuery(this).height() }); 735 736 // if( $imgHeight > jQuery(this).height() ) { 737 // $heightDif = $imgHeight - jQuery(this).height(); 738 // $negativeMove = $heightDif / 2; 739 // console.log( $negativeMove ); 740 // jQuery(this).find('.otw_blog_manager-blog-media-wrapper').find('img').css({'margin-top': -$negativeMove}); 741 // } 742 743 }); 744 }); 745 746} 747 748function horizontal_layout(container){ 749 750 jQuery(container).each(function(){ 751 752 jQuery(this).css({'opacity': '0'}); 753 754 var $this = jQuery(this), 755 container_width = jQuery(document).find('.otw_blog_manager-horizontal-layout-wrapper').width(), 756 row = 1, 757 item_margin = $this.find('.otw_blog_manager-blog-item-holder').data('item-margin'), 758 cache_width = 0, 759 height_items = []; 760 761 $this.find('.otw_blog_manager-blog-item-holder').children('.otw_blog_manager-horizontal-item').each(function(){ 762 763 if( jQuery(this).attr('data-original-width') === undefined ){ 764 var $img = jQuery(this).find('.otw_blog_manager-blog-media-wrapper img'); 765 766 jQuery(this).attr({'data-original-width': $img.attr('width')}); 767 jQuery(this).attr({'data-original-height': $img.attr('height')}); 768 769 //remove image size 770 $img.attr({'width': ''}); 771 $img.attr({'height': ''}); 772 773 } 774 775 jQuery(this).css({'margin-right': ''}); 776 777 cache_width += ( jQuery(this).data('original-width') + item_margin ); 778 779 780 jQuery(this).attr({'data-row': row}); 781 782 if( cache_width >= container_width ){ 783 //new height = original height / original width x new width 784 height_items.push( Math.floor(jQuery(this).data('original-height') / (cache_width - item_margin ) * container_width) ); 785 786 jQuery(this).css({'margin-right': '-5px'}); 787 788 cache_width = 0; 789 row += 1; 790 } 791 }); 792 793 794 for (var i = 0; i < height_items.length; i++) { 795 cache_width = 0; 796 $this.find('.otw_blog_manager-blog-item-holder').children('.otw_blog_manager-horizontal-item[data-row="'+ (i + 1) +'"]').each(function($itemIndex){ 797 //new width = original wdith / original height x new height 798 var new_width = Math.ceil( jQuery(this).data('original-width') / jQuery(this).data('original-height') * height_items[i] ); 799 800 cache_width += (new_width+4); 801 802 if( cache_width >= container_width ) { 803 new_width -= ( cache_width - container_width ); 804 } 805 806 jQuery(this).find('.otw_blog_manager-blog-media-wrapper').css( {'width': new_width + 'px', 'height': parseInt(height_items[i]) }); 807 808 }); 809 } 810 811 if( $this.find('.otw_blog_manager-blog-item-holder').children('.otw_blog_manager-horizontal-item[data-row="'+ row +'"]').length > 0 ){ 812 $this.find('.otw_blog_manager-blog-item-holder').children('.otw_blog_manager-horizontal-item[data-row="'+ row +'"]').each(function(){ 813 jQuery(this).find('.otw_blog_manager-blog-media-wrapper').css({'width': jQuery(this).data('original-width') + 'px', 'height': jQuery(this).data('original-height') }); 814 }); 815 816 $this.find('.otw_blog_manager-blog-item-holder').children('.otw_blog_manager-horizontal-item[data-row="'+ row +'"]:last-child').css({'margin-right': '0px'}); 817 } 818 819 $this.css({'opacity': '1'}); 820 }); 821} 822 823//Social shares 824function otw_social_shares(){ 825 826 jQuery('.otw_blog_manager-social-share-buttons-wrapper').each(function(){ 827 828 var $this = jQuery(this); 829 title = jQuery(this).data('title'), 830 description = jQuery(this).data('description'), 831 image = jQuery(this).data('image'), 832 postUrl = jQuery(this).data('url'); 833 834 jQuery.ajax({ 835 type: 'POST', 836 url: socialShareURL, 837 dataType: 'json', 838 cache: false, 839 data: { url: postUrl }, 840 success: function(data) { 841 if(data.info !== 'error'){ 842 $this.find('.otw_blog-manager-social-share').each(function(){ 843 if(jQuery(this).hasClass('otw-facebook')){ 844 jQuery(this).append('<span class="data-shares">'+ data.facebook +'</span>'); 845 // jQuery(this).attr({'href': 'http://www.facebook.com/sharer.php?u='+ postUrl}); 846 } else if(jQuery(this).hasClass('otw-twitter')){ 847 jQuery(this).append('<span class="data-shares">'+ data.twitter +'</span>'); 848 // jQuery(this).attr({'href': 'https://twitter.com/intent/tweet?source=tweetbutton&text='+ escape(title) +'&url='+ encodeURIComponent(postUrl)}); 849 } else if(jQuery(this).hasClass('otw-google_plus')){ 850 jQuery(this).append('<span class="data-shares">'+ data.google_plus +'</span>'); 851 // jQuery(this).attr({'href': 'https://plus.google.com/share?url='+ postUrl}); 852 } else if(jQuery(this).hasClass('otw-linkedin')){ 853 jQuery(this).append('<span class="data-shares">'+ data.linkedin +'</span>'); 854 // jQuery(this).attr({'href': 'http://www.linkedin.com/shareArticle?mini=true&url='+ encodeURIComponent(postUrl) +'&title='+ escape(title) +'&summary='+ escape(description)}); 855 } else if(jQuery(this).hasClass('otw-pinterest')){ 856 jQuery(this).append('<span class="data-shares">'+ data.pinterest +'</span>'); 857 // jQuery(this).attr({'href': 'http://pinterest.com/pin/create/button/?url='+ encodeURIComponent(postUrl) +'&media='+ encodeURIComponent(image) +'&description='+ escape(description)}); 858 } 859 }); 860 } 861 } 862 }); 863 864 }); 865 866 jQuery('.otw_blog_manager-social-wrapper').each(function(){ 867 var $this = jQuery(this); 868 title = jQuery(this).data('title'), 869 description = jQuery(this).data('description'), 870 image = jQuery(this).data('image'), 871 url = jQuery(this).data('url'); 872 873 874 875 jQuery(this).children('.otw_blog_manager-social-item').each(function(){ 876 if(jQuery(this).hasClass('otw-facebook')){ 877 jQuery(this).attr({'href': 'http://www.facebook.com/sharer.php?u='+ url}); 878 } else if(jQuery(this).hasClass('otw-twitter')){ 879 jQuery(this).attr({'href': 'https://twitter.com/intent/tweet?source=tweetbutton&url='+ encodeURIComponent(url) +'&text='+ escape(title)}); 880 } else if(jQuery(this).hasClass('otw-google_plus')){ 881 jQuery(this).attr({'href': 'https://plus.google.com/share?url='+ url}); 882 } else if(jQuery(this).hasClass('otw-linkedin')){ 883 jQuery(this).attr({'href': 'http://www.linkedin.com/shareArticle?mini=true&url='+ encodeURIComponent(url) +'&title='+ escape(title) +'&summary='+ escape(description)}); 884 } else if(jQuery(this).hasClass('otw-pinterest')){ 885 jQuery(this).attr({'href': 'http://pinterest.com/pin/create/button/?url='+ encodeURIComponent(url) +'&media='+ encodeURIComponent(image) +'&description='+ escape(description)}); 886 } 887 }); 888 }); 889 890 update_social_stuff(); 891 892} 893 894 895function update_social_stuff() { 896 //Twitter 897 898 jQuery.getScript("https://platform.twitter.com/widgets.js"); 899 900 // G+ 901 (function() { 902 var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; 903 po.src = 'https://apis.google.com/js/platform.js'; 904 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); 905 })(); 906} 907 908function otw_responsive_videos() { 909 jQuery('.otw_blog_manager-blog-media-wrapper').fitVids({ customSelector: "iframe[src*='soundcloud.com']"}); 910}
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.