// source --> https://www.zanews.co.za/wp-content/themes/zanews-responsive-template/js/placeholder.js var placeholders = [ 'placeholder.210x110.png', 'placeholder.210x235.png', 'placeholder.435x235.png', 'placeholder.210x210.png', 'placeholder.660x360.png' ]; jQuery(document).ready(function(){ imagePlaceholders(); }); function imagePlaceholders() { jQuery("img").each(function(){ var imgObj = jQuery(this); var determinedPlaceholder = ''; if(typeof(imgObj.attr('height')) !== 'undefined' && typeof(imgObj.attr('width')) !== 'undefined') { if (imgObj.attr('width') === imgObj.attr('height')) { determinedPlaceholder = placeholders[3]; } else if(imgObj.attr('height') <= 110) { determinedPlaceholder = placeholders[0]; } else if(imgObj.attr('height') <= 235) { if(typeof(imgObj.attr('width')) !== 'undefined') { if (imgObj.attr('height') >= 210 && imgObj.attr('height') < 235) { determinedPlaceholder = placeholders[3]; } else if(imgObj.attr('width') <= 210) { determinedPlaceholder = placeholders[1]; } else if(imgObj.attr('width') <= 435) { determinedPlaceholder = placeholders[2]; } } } else if(imgObj.attr('height') <= 360) { determinedPlaceholder = placeholders[4]; } } //console.log('Placeholder for: ' + imgObj.attr('width') + 'x' + imgObj.attr('height') + '. ' + determinedPlaceholder + ' has been chosen'); if(determinedPlaceholder !== '') { var img = new Image(); img.onerror=function(){ imgObj.attr('src', themeDir + 'img/' + determinedPlaceholder); imgObj.attr('style', 'width:100%;height:auto;'); } img.src = imgObj.attr('src'); } }); }; // source --> https://www.zanews.co.za/wp-content/themes/zanews-responsive-template/js/jquery.scrollTo-min.js?1.4.11 /** * Copyright (c) 2007-2014 Ariel Flesler - afleslergmailcom | http://flesler.blogspot.com * Licensed under MIT * @author Ariel Flesler * @version 1.4.11 */ ;(function(a){if(typeof define==='function'&&define.amd){define(['jquery'],a)}else{a(jQuery)}}(function($){var j=$.scrollTo=function(a,b,c){return $(window).scrollTo(a,b,c)};j.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1,limit:true};j.window=function(a){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var a=this,isWin=!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return a;var b=(a.contentWindow||a).document||a.ownerDocument||a;return/webkit/i.test(navigator.userAgent)||b.compatMode=='BackCompat'?b.body:b.documentElement})};$.fn.scrollTo=function(f,g,h){if(typeof g=='object'){h=g;g=0}if(typeof h=='function')h={onAfter:h};if(f=='max')f=9e9;h=$.extend({},j.defaults,h);g=g||h.duration;h.queue=h.queue&&h.axis.length>1;if(h.queue)g/=2;h.offset=both(h.offset);h.over=both(h.over);return this._scrollable().each(function(){if(f==null)return;var d=this,$elem=$(d),targ=f,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=$(targ,this);if(!targ.length)return;case'object':if(targ.is||targ.style)toff=(targ=$(targ)).offset()}var e=$.isFunction(h.offset)&&h.offset(d,targ)||h.offset;$.each(h.axis.split(''),function(i,a){var b=a=='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,old=d[key],max=j.max(d,a);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(h.margin){attr[key]-=parseInt(targ.css('margin'+b))||0;attr[key]-=parseInt(targ.css('border'+b+'Width'))||0}attr[key]+=e[pos]||0;if(h.over[pos])attr[key]+=targ[a=='x'?'width':'height']()*h.over[pos]}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)=='%'?parseFloat(c)/100*max:c}if(h.limit&&/^\d+$/.test(attr[key]))attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&h.queue){if(old!=attr[key])animate(h.onAfterFirst);delete attr[key]}});animate(h.onAfter);function animate(a){$elem.animate(attr,g,h.easing,a&&function(){a.call(this,targ,h)})}}).end()};j.max=function(a,b){var c=b=='x'?'Width':'Height',scroll='scroll'+c;if(!$(a).is('html,body'))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,html=a.ownerDocument.documentElement,body=a.ownerDocument.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return $.isFunction(a)||typeof a=='object'?a:{top:a,left:a}};return j})); // source --> https://www.zanews.co.za/wp-content/themes/zanews-responsive-template/js/jquery.localscroll-min.js?1.3.4 /** * Copyright (c) 2007-2014 Ariel Flesler - afleslergmailcom | http://flesler.blogspot.com * Licensed under MIT * @author Ariel Flesler * @version 1.3.4 */ ;(function(a){if(typeof define==='function'&&define.amd){define(['jquery'],a)}else{a(jQuery)}}(function($){var g=location.href.replace(/#.*/,'');var h=$.localScroll=function(a){$('body').localScroll(a)};h.defaults={duration:1000,axis:'y',event:'click',stop:true,target:window};$.fn.localScroll=function(b){b=$.extend({},h.defaults,b);if(b.hash&&location.hash){if(b.target)window.scrollTo(0,0);scroll(0,location,b)}return b.lazy?this.bind(b.event,function(e){var a=$([e.target,e.target.parentNode]).filter(filter)[0];if(a)scroll(e,a,b)}):this.find('a,area').filter(filter).bind(b.event,function(e){scroll(e,this,b)}).end().end();function filter(){return!!this.href&&!!this.hash&&this.href.replace(this.hash,'')==g&&(!b.filter||$(this).is(b.filter))}};h.hash=function(){};function scroll(e,a,b){var c=a.hash.slice(1),elem=document.getElementById(c)||document.getElementsByName(c)[0];if(!elem)return;if(e)e.preventDefault();var d=$(b.target);if(b.lock&&d.is(':animated')||b.onBefore&&b.onBefore(e,elem,d)===false)return;if(b.stop)d._scrollable().stop(true);if(b.hash){var f=elem.id===c?'id':'name',$a=$(' ').attr(f,c).css({position:'absolute',top:$(window).scrollTop(),left:$(window).scrollLeft()});elem[f]='';$('body').prepend($a);location.hash=a.hash;$a.remove();elem[f]=c}d.scrollTo(elem,b).trigger('notify.serialScroll',[elem])};return h})); // source --> https://www.zanews.co.za/wp-content/themes/zanews-responsive-template/js/jquery.serialScroll-min.js?1.2.4 /** * Copyright (c) 2007-2013 Ariel Flesler - afleslergmailcom | http://flesler.blogspot.com * Licensed under MIT. * @author Ariel Flesler * @version 1.2.4 */ ;(function($){var f='.serialScroll';var g=$.serialScroll=function(a){return $(window).serialScroll(a)};g.defaults={duration:1000,axis:'x',event:'click',start:0,step:1,lock:true,cycle:true,constant:true};$.fn.serialScroll=function(d){return this.each(function(){var c=$.extend({},g.defaults,d),event=c.event,step=c.step,lazy=c.lazy,context=c.target?this:document,$pane=$(c.target||this,context),pane=$pane[0],items=c.items,active=c.start,auto=c.interval,nav=c.navigation,timer;if(!pane)return;if(!lazy)items=getItems();if(c.force||auto)jump({},active);$(c.prev||[],context).bind(event,-step,move);$(c.next||[],context).bind(event,step,move);if(!pane.ssbound)$pane.bind('prev'+f,-step,move).bind('next'+f,step,move).bind('goto'+f,jump);if(auto)$pane.bind('start'+f,function(e){if(!auto){clear();auto=true;next()}}).bind('stop'+f,function(){clear();auto=false});$pane.bind('notify'+f,function(e,a){var i=index(a);if(i>-1)active=i});pane.ssbound=true;if(c.jump)(lazy?$pane:getItems()).bind(event,function(e){jump(e,index(e.target))});if(nav)nav=$(nav,context).bind(event,function(e){e.data=Math.round(getItems().length/nav.length)*nav.index(this);jump(e,this)});function move(e){e.data+=active;jump(e,this)};function jump(e,a){if(isNaN(a))a=e.data;var n,real=e.type,$items=c.exclude?getItems().slice(0,-c.exclude):getItems(),limit=$items.length-1,elem=$items[a],duration=c.duration;if(real)e.preventDefault();if(auto){clear();timer=setTimeout(next,c.interval)}if(!elem){n=a<0?0:limit;if(active!==n)a=n;else if(!c.cycle)return;else a=limit-n;elem=$items[a]}if(!elem||c.lock&&$pane._scrollable().is(':animated')||real&&c.onBefore&&c.onBefore(e,elem,$pane,getItems(),a)===false)return;if(c.stop)$pane._scrollable().stop(true);if(c.constant)duration=Math.abs(duration/step*(active-a));$pane.scrollTo(elem,duration,c);trigger('notify',a)};function next(){trigger('next')};function clear(){clearTimeout(timer)};function getItems(){return $(items,pane)};function trigger(a){$pane.trigger(a+f,[].slice.call(arguments,1))}function index(a){if(!isNaN(a))return a;var b=getItems(),i;while((i=b.index(a))===-1&&a!==pane)a=a.parentNode;return i}})}})(jQuery); // source --> https://www.zanews.co.za/wp-content/themes/zanews-responsive-template/js/nivo/nivo-lightbox.js /* * Nivo Lightbox v1.1 * http://dev7studios.com/nivo-lightbox * * Copyright 2013, Dev7studios * Free to use and abuse under the MIT license. * http://www.opensource.org/licenses/mit-license.php */ ;(function($, window, document, undefined){ var pluginName = 'nivoLightbox', defaults = { effect: 'fade', theme: 'default', keyboardNav: true, clickOverlayToClose: true, onInit: function(){}, beforeShowLightbox: function(){}, afterShowLightbox: function(lightbox){}, beforeHideLightbox: function(){}, afterHideLightbox: function(){}, onPrev: function(element){}, onNext: function(element){}, errorMessage: 'The requested content cannot be loaded. Please try again later.' }; function NivoLightbox(element, options){ this.el = element; this.$el = $(this.el); this.options = $.extend({}, defaults, options); this._defaults = defaults; this._name = pluginName; this.init(); } NivoLightbox.prototype = { init: function(){ var $this = this; // Need this so we don't use CSS transitions in mobile if(!$('html').hasClass('nivo-lightbox-notouch')) $('html').addClass('nivo-lightbox-notouch'); if('ontouchstart' in document) $('html').removeClass('nivo-lightbox-notouch'); // Setup the click this.$el.on('click', function(e){ e.preventDefault(); $this.showLightbox(); }); // keyboardNav if(this.options.keyboardNav){ $('body').off('keyup').on('keyup', function(e){ var code = (e.keyCode ? e.keyCode : e.which); // Escape if(code == 27) $this.destructLightbox(); // Left if(code == 37) $('.nivo-lightbox-prev').trigger('click'); // Right if(code == 39) $('.nivo-lightbox-next').trigger('click'); }); } this.options.onInit.call(this); }, showLightbox: function(){ var $this = this; this.options.beforeShowLightbox.call(this); var lightbox = this.constructLightbox(); if(!lightbox) return; var content = lightbox.find('.nivo-lightbox-content'); if(!content) return; var currentLink = this.$el; $('body').addClass('nivo-lightbox-body-effect-'+ this.options.effect); // Add content this.processContent(content, currentLink); // Nav if(this.$el.attr('data-lightbox-gallery')){ var $this = this, galleryItems = $('[data-lightbox-gallery="'+ this.$el.attr('data-lightbox-gallery') +'"]'); $('.nivo-lightbox-nav').show(); // Prev $('.nivo-lightbox-prev').off('click').on('click', function(e){ e.preventDefault(); var index = galleryItems.index(currentLink); currentLink = galleryItems.eq(index - 1); if(!$(currentLink).length) currentLink = galleryItems.last(); $this.processContent(content, currentLink); $this.options.onPrev.call(this, [ currentLink ]); }); // Next $('.nivo-lightbox-next').off('click').on('click', function(e){ e.preventDefault(); var index = galleryItems.index(currentLink); currentLink = galleryItems.eq(index + 1); if(!$(currentLink).length) currentLink = galleryItems.first(); $this.processContent(content, currentLink); $this.options.onNext.call(this, [ currentLink ]); }); } setTimeout(function(){ lightbox.addClass('nivo-lightbox-open'); $this.options.afterShowLightbox.call(this, [ lightbox ]); }, 1); // For CSS transitions }, processContent: function(content, link){ var $this = this; var href = link.attr('href'); content.html('').addClass('nivo-lightbox-loading'); // Is HiDPI? if(this.isHidpi() && link.attr('data-lightbox-hidpi')){ href = link.attr('data-lightbox-hidpi'); } // Image if(href.match(/\.(jpeg|jpg|gif|png)$/i) != null){ var img = $('', { src: href }); img.one('load', function() { var wrap = $('
'); wrap.append(img); content.html(wrap).removeClass('nivo-lightbox-loading'); // Vertically center images wrap.css({ 'line-height': $('.nivo-lightbox-content').height() +'px', 'height': $('.nivo-lightbox-content').height() +'px' // For Firefox }); $(window).resize(function() { wrap.css({ 'line-height': $('.nivo-lightbox-content').height() +'px', 'height': $('.nivo-lightbox-content').height() +'px' // For Firefox }); }); }).each(function() { if(this.complete) $(this).load(); }); img.error(function() { var wrap = $('

'+ $this.options.errorMessage +'

'); content.html(wrap).removeClass('nivo-lightbox-loading'); }); } // Video (Youtube/Vimeo) else if(video = href.match(/(youtube|youtu|vimeo)\.(com|be)\/(watch\?v=([\w-]+)|([\w-]+))/)){ var src = '', classTerm = 'nivo-lightbox-video'; if(video[1] == 'youtube'){ src = 'http://www.youtube.com/v/'+ video[4]; classTerm = 'nivo-lightbox-youtube'; } if(video[1] == 'youtu'){ src = 'http://www.youtube.com/v/'+ video[3]; classTerm = 'nivo-lightbox-youtube'; } if(video[1] == 'vimeo'){ src = 'http://player.vimeo.com/video/'+ video[3]; classTerm = 'nivo-lightbox-vimeo'; } if(src){ var iframe = $('