//@prepros-prepend underscore-min.js
//@prepros-prepend vendor/backbone-min.js
//@prepros-prepend vendor/icanhaz.min.js
//@prepros-prepend vendor/jquery.easing.1.3.js
//@prepros-prepend vendor/jquery.easing.compatibility.js
//@prepros-prepend vendor/jquery.mousewheel.js
//@prepros-prepend vendor/jquery.bgvideo.min.js
//@prepros-prepend vendor/jquery.counter.min.js
//@prepros-prepend vendor/jquery.easy-opener.min.js
//@prepros-prepend vendor/jquery.fitvids.min.js
//@prepros-prepend vendor/jquery.flexslider.min.js
//@prepros-prepend vendor/jquery.isotope.min.js
//@prepros-prepend vendor/jquery.owl.carousel.min.js
//@prepros-prepend vendor/jquery.perfect.scrollbar.js
//@prepros-prepend vendor/jquery.visible.min.js
/*
@ prepros-prepend vendor/jquery.fancybox.pack.js
@ prepros-prepend vendor/jquery.flip.min.js
@ prepros-prepend vendor/jquery.parallax.min.js
@ prepros-prepend vendor/parallax.min.js
@ prepros-prepend vendor/snap.svg-min.js
@ prepros-prepend vendor/typed.min.js
@ prepros-prepend vendor/jquery.textillate.js
@ prepros-prepend models/video.js
@ prepros-prepend models/socialitem.js
@ prepros-prepend models/playlist.js
@ prepros-prepend collections/videos.js
@ prepros-prepend collections/socialitems.js
@ prepros-prepend views/socialitem.js
@ prepros-prepend views/socialnews.js
@ prepros-prepend vendor/animsition.min.js
*/
//@prepros-prepend vendor/jquery.magnific-popup.min.js
//@prepros-prepend vendor/skrollr.min.js
//@prepros-prepend vendor/snap.svg-min.js
//@prepros-prepend tcc-header.js
//@prepros-prepend tcc-loader.js
//@prepros-prepend tcc-form.js
//@prepros-prepend app.init.js
//@prepros-prepend models/video.js
//@prepros-prepend views/tabs.js
//@prepros-prepend views/player.js
//@prepros-prepend views/header.js
//@prepros-prepend views/body.js
//@prepros-prepend vendor/jquery.lettering.js
//@prepros-prepend vendor/jquery.lazyload.min.js
/*-----------------------------------------------------------------------------------
Script - All Custom frontend jQuery scripts & functions
-----------------------------------------------------------------------------------*/
var app = app || {};
var loading = false;
var wheight = jQuery(window).height(); // Returns height of browser viewport
var wwidth = jQuery(window).width();
var dheight = jQuery(document).height(); // Returns height of HTML document
var dwidth = jQuery(document).width();
var mobile = false;
var tablet = false;
if( /iPad/i.test(navigator.userAgent) || wwidth<1023) {
tablet = true;
console.log('tablet');
}
if( /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || wwidth<768) {
mobile = true;
console.log('mobile');
}
jQuery(document).ready(function() {
/*----------------------------------------------
P A G E A N I M A T I O N
------------------------------------------------*/
/*jQuery(".animsition-overlay").animsition({
inClass: 'overlay-slide-in-right',
outClass: 'overlay-slide-out-right',
inDuration: 800,
outDuration: 1500,
linkElement: 'a:not([target="_blank"]):not([href^="#"])',
// e.g. linkElement: 'a:not([target="_blank"]):not([href^="#"])'
loading: true,
loadingParentElement: 'body', //animsition wrapper element
loadingClass: 'animsition-loading',
loadingInner: '', // e.g ''
timeout: false,
timeoutCountdown: 5000,
onLoadEvent: true,
browser: [ 'animation-duration', '-webkit-animation-duration'],
// "browser" option allows you to disable the "animsition" in case the css property in the array is not supported by your browser.
// The default setting is to disable the "animsition" in a browser that does not support "animation-duration".
overlay : true,
overlayClass : 'animsition-overlay-slide',
overlayParentElement : 'body',
transition: function(url){
window.location.href = url;
}
});
jQuery('.animsition-overlay').on('animsition.outEnd', function(){
});*/
/*var Glitcher = (function () {
function Glitcher(options) {
this.canvas = document.createElement('canvas');
this.context = this.canvas.getContext('2d');
this.origCanvas = document.createElement('canvas');
this.origContext = this.origCanvas.getContext('2d');
this.options = options;
}
Glitcher.prototype.glitch = function (url, callback) {
var _this = this;
this.loadImage(url, function (img) {
_this.renderImage(img);
_this.process();
callback();
});
};
Glitcher.prototype.process = function () {
var imageData = this.origContext.getImageData(0, 0, this.width, this.height), pixels = imageData.data, length = pixels.length, options = this.options, brightness, offset, i, x, y;
for (i = 0; i < length; i += 4) {
if (options.color) {
pixels[i] *= options.color.red;
pixels[i + 1] *= options.color.green;
pixels[i + 2] *= options.color.blue;
}
if (options.greyscale) {
brightness = pixels[i] * options.greyscale.red + pixels[i + 1] * options.greyscale.green + pixels[i + 2] * options.greyscale.blue;
pixels[i] = brightness;
pixels[i + 1] = brightness;
pixels[i + 2] = brightness;
}
if (options.stereoscopic) {
offset = options.stereoscopic.red;
pixels[i] = (pixels[i + 4 * offset] === undefined) ? 0 : pixels[i + 4 * offset];
offset = options.stereoscopic.green;
pixels[i + 1] = (pixels[i + 1 + 4 * offset] === undefined) ? 0 : pixels[i + 1 + 4 * offset];
offset = options.stereoscopic.blue;
pixels[i + 2] = (pixels[i + 2 + 4 * offset] === undefined) ? 0 : pixels[i + 2 + 4 * offset];
}
}
if (options.lineOffset) {
i = 0;
for (y = 0; y < this.height; y++) {
offset = (y % options.lineOffset.lineHeight === 0) ? Math.round(Math.random() * options.lineOffset.value) : offset;
for (x = 0; x < this.width; x++) {
i += 4;
pixels[i + 0] = (pixels[i + 4 * offset] === undefined) ? 0 : pixels[i + 4 * offset];
pixels[i + 1] = (pixels[i + 1 + 4 * offset] === undefined) ? 0 : pixels[i + 1 + 4 * offset];
pixels[i + 2] = (pixels[i + 2 + 4 * offset] === undefined) ? 0 : pixels[i + 2 + 4 * offset];
}
}
}
if (options.glitch) {
}
this.context.putImageData(imageData, 0, 0);
};
Glitcher.prototype.loadImage = function (url, callback) {
var img = document.createElement('img');
img.crossOrigin = 'anonymous';
img.onload = function () {
callback(img);
};
img.src = url;
};
Glitcher.prototype.renderImage = function (img) {
this.canvas.width = this.origCanvas.width = this.width = img.width;
this.canvas.height = this.origCanvas.height = this.height = img.height;
this.origContext.drawImage(img, 0, 0);
};
return Glitcher;
})();
var glitcher = new Glitcher({
color: {
red: 1,
green: 1,
blue: 1
},
stereoscopic: {
red: 1,
green: 10,
blue: 2
},
lineOffset: {
value: 4
}
});
glitcher.glitch('http://185.116.213.142/~nin/wp-content/themes/nin/files/images/preloader.png', function () {
jQuery('.animsition-loading').append(glitcher.canvas);
});
function randomRange(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
setInterval(function () {
glitcher.options = {
color: {
red: 1,
green: 0.8,
blue: 0.58
},
stereoscopic: {
red: 1 * randomRange(1, 1),
green: 2 * randomRange(1, 2),
blue: 1 * randomRange(1, 2)
},
lineOffset: {
value: 1 * randomRange(1, 2),
lineHeight: 3 * randomRange(1, 2)
}
};
glitcher.process();
}, 600);
*/
});
//
// Events bus
//
app.events = {};
_.extend(app.events, Backbone.Events);
//
//
//
(function($, window, document) {
$.fn.countdown = function(callback, duration, message) {
message = message || "%duration%";
var container = $(this[0]).html(message.replace('%duration%', duration));
var countdown = setInterval(function() {
if (--duration) {
container.html(message.replace('%duration%', duration));
} else {
clearInterval(countdown);
if (callback) {
callback.call(container);
}
}
}, 1000);
};
//
// Vars
//
var $audioPlayer = $('#audioPlayer');
//
//
$(function() {
// Initializing views
new App.Views.HeaderView();
new App.Views.BodyView();
// Adding lightbox
$('#page-content').magnificPopup({
delegate: '.js-photo',
type: 'image',
tLoading: 'Loading image #%curr%...',
removalDelay: 300,
midClick: true,
mainClass: 'mfp-zoom-in',
fixedContentPos: true,
gallery: {
enabled: true,
navigateByImgClick: false,
preload: [0, 1],
arrowMarkup: ''
},
image: {
markup: '
' + '' + '
' + '' + '' + '
' + '
',
tError: 'The image #%curr% could not be loaded.',
titleSrc: function(item) {
return item.el.attr('title');
}
},
closeBtnInside: false,
closeMarkup: ''
});
// popup videos player
var player = {
el: null,
onPlayerReady: function(event) {
if (!Modernizr.touch) {
event.target.playVideo();
}
},
onPlayerStateChange: function(event) {
switch (event.data) {
case YT.PlayerState.ENDED:
var mpi = $.magnificPopup.instance;
var _getLoopedId = function(index) {
var numSlides = mpi.items.length;
if (index > numSlides - 1) {
return index - numSlides;
} else if (index < 0) {
return numSlides + index;
}
return index;
};
var next = mpi.items[_getLoopedId(mpi.currItem.index + 1)];
mpi.content.find('#mfplayer,h1').removeClass('animated fadeInRight').addClass('animated fadeOutLeft');
$.ajax({
url: "https://www.googleapis.com/youtube/v3/videos?id=" + next.el.data('youtube') + "&key=AIzaSyAge_dhlmNzd_sApyywWlcnipExcSZu73Y&part=snippet",
dataType: "jsonp",
success: function(data) {
if (data.items.length === 1) {
var preview = ich.video_tpl({
video: data.items[0].snippet
});
mpi.content.prepend(preview);
mpi.content.find('.countdown').countdown(function() {
if ($.magnificPopup.instance.isOpen) {
// remove countdown
this.closest('.video-player').remove();
// trigger next
mpi.next();
}
}, 10, 'Next video playing in %duration%');
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, +' | ' + errorThrown);
}
});
}
},
onPlayerError: function(event) {
console.log(event);
}
};
$('.js-video').magnificPopup({
type: 'iframe',
iframe: {
markup: '
',
patterns: {
youtube: {
src: '//www.youtube.com/embed/%id%?version=3&rel=0&showinfo=0&enablejsapi=1'
}
}
},
gallery: {
enabled: true,
navigateByImgClick: false,
arrowMarkup: ''
},
mainClass: 'fadeIn animated',
removalDelay: 200,
fixedContentPos: true,
tLoading: 'Loading video...',
closeBtnInside: false,
closeMarkup: '',
callbacks: {
open: function() {
player.el = new YT.Player('mfplayer', {
videoId: this.currItem.el.data('youtube'),
events: {
onReady: player.onPlayerReady,
onStateChange: player.onPlayerStateChange,
onError: player.onPlayerError
}
});
},
change: function() {
if (player.el) {
player.el.destroy();
}
},
afterChange: function() {
this.content.find('#mfplayer,h1').removeClass('fadeOutLeft').addClass('animated fadeInRight');
player.el = new YT.Player('mfplayer', {
videoId: this.currItem.el.data('youtube'),
events: {
onReady: player.onPlayerReady,
onStateChange: player.onPlayerStateChange,
onError: player.onPlayerError
}
});
},
markupParse: function(template, values, item) {
values.title = item.el.attr('title');
}
}
});
$('.overlay-link').magnificPopup({
// you may add other options here, e.g.:
preloader: true,
callbacks: {
open: function() {
// Will fire when this exact popup is opened
// this - is Magnific Popup object
},
close: function() {
// Will fire when popup is closed
}
// e.t.c.
}
});
});
$(window).load(function() {
/*function ballanceGallery() {
$('#nin-grid').BalancedGallery({
autoResize: false, // re-partition and resize the images when the window size changes
background: '#000', // the css properties of the gallery's containing element
myIdealHeight: 320, // ideal row height, only used for horizontal galleries, defaults to half the containing element's height
dansIdealWidth: null, // ideal column width, only used for vertical galleries, defaults to 1/4 of the containing element's width
maintainOrder: true, // keeps images in their original order, setting to 'false' can create a slightly better balance between rows
orientation: 'horizontal', // 'horizontal' galleries are made of rows and scroll vertically; 'vertical' galleries are made of columns and scroll horizontally
padding: 5, // pixels between images
shuffleUnorderedPartitions: true, // unordered galleries tend to clump larger images at the begining, this solves that issue at a slight performance cost
viewportHeight: null, // the assumed height of the gallery, defaults to the containing element's height
viewportWidth: null // the assumed width of the gallery, defaults to the containing element's width
});
console.log('ballanced');
}
ballanceGallery();*/
lazyLoad = function(){
$("img.lazy").lazyload({
effect : "fadeIn",
threshold : 200,
skip_invisible : true,
failure_limit : 50
});
//console.log('LAZY!');
}
lazyLoad();
$('.home a.sr-button.sr-button4.medium-button.sr-buttonicon.scroll-to').click(function() {
$('html, body').animate({
scrollTop: wheight - 100
}, 1000, 'easeInOutQuart');
return false;
});
$(".social a").wrapInner("");
$("#main-nav li.newsletter a").addClass("scroll-to");
/*$(".fullheight").css({
'max-height':+wheight+'px'
});*/
/* $(".flex-viewport").css({
'max-height':+wheight+'px'
});*/
/*----------------------------------------------
SCROLL FUNCTIONS
------------------------------------------------*/
// left: 37, up: 38, right: 39, down: 40,
// spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
var keys = {37: 1, 38: 1, 39: 1, 40: 1};
function preventDefault(e) {
e = e || window.event;
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
}
function preventDefaultForScrollKeys(e) {
if (keys[e.keyCode]) {
preventDefault(e);
return false;
}
}
function disableScroll() {
if (window.addEventListener) // older FF
window.addEventListener('DOMMouseScroll', preventDefault, false);
window.onwheel = preventDefault; // modern standard
window.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE
window.ontouchmove = preventDefault; // mobile
document.onkeydown = preventDefaultForScrollKeys;
}
function enableScroll() {
if (window.removeEventListener)
window.removeEventListener('DOMMouseScroll', preventDefault, false);
window.onmousewheel = document.onmousewheel = null;
window.onwheel = null;
window.ontouchmove = null;
document.onkeydown = null;
}
/*----------------------------------------------
N E W S
------------------------------------------------*/
$(document).on('click', '.news-title a',function(e){
e.preventDefault();
//console.log('hello');
disableScroll();
$newsID = $(this).data("id");
$("#news-"+$newsID).toggleClass("active");
$(this).toggleClass("active");
setTimeout(function(){
var offset = $("#news-"+$newsID).offset();
var offset_adjust = 22;
if(mobile || tablet){
offset_adjust = $("#nav").height()+11;
}
$('html, body').animate({
scrollTop: offset.top -offset_adjust
}, 1000, 'easeInOutQuart', function() { enableScroll(); });
}, 500);
return false;
});
/*----------------------------------------------
C O N N E C T
------------------------------------------------*/
$('.connectcat-toggle').click(function() {
$catID = $(this).data("group");
$("#"+$catID).toggleClass("active");
$(this).toggleClass("active");
return false;
});
/*----------------------------------------------
D I S C O G R A P H Y
------------------------------------------------*/
$('.albumcat-toggle').click(function() {
$catID = $(this).data("group");
$("#"+$catID).toggleClass("active");
$(this).toggleClass("active");
//lazyLoad();
return false;
});
/*$('.album, #close-reveal').click(function() {
$('#section-discography').toggleClass("reveal-hide");
$('#section-discography-reveal').toggleClass("reveal-show");
return false;
});*/
$('.album-detail-toggle').click(function() {
$('.album-info').removeClass('active');
disableScroll();
$albumID = $(this).data("id");
//center album info
var packHeight = parseInt($("#album-detials-"+$albumID).find('img').height());
var blockHeight = parseInt(packHeight / 2);
var blurbHeight = parseInt($("#album-detials-"+$albumID).find('.centered').height() / 2);
var newMargin = (blockHeight - blurbHeight);
//- Album blurb is too big
if(newMargin <=0){
$("#album-detials-"+$albumID).find('.centered').css({
'marginTop': '' + 0 + 'px',
// 'maxHeight': '' + packHeight + 'px',
});
} else{
$("#album-detials-"+$albumID).find('.centered').css({
'marginTop': '' + newMargin + 'px',
//'maxHeight': '' + packHeight + 'px',
});
}
setTimeout(function(){
$("#album-detials-"+$albumID).toggleClass("active");
$("#section-discography").addClass("tint");
var offset = $("#album-detials-"+$albumID).offset();
var offset_adjust = 22;
if(mobile){
offset_adjust = $("#nav").height()+6;
} else if(tablet){
offset_adjust = $("#nav").height()+12;
}
$('html, body').animate({
scrollTop: offset.top -offset_adjust
}, 1000, 'easeInOutQuart', function() { enableScroll(); });
//$("#album-detials-"+$albumID+" .tlt").textillate('in');
}, 500);
return false;
});
$('.close-info').click(function() {
disableScroll();
$albumID = $(this).data("id");
$("#album-detials-"+$albumID).toggleClass("active");
$("#section-discography").removeClass("tint");
var offset = $("#album-"+$albumID).offset();
var offset_adjust = 8;
if(mobile || tablet){
offset_adjust = $("#nav").height();
}
$('html, body').animate({
scrollTop: offset.top-offset_adjust
}, 1000, 'easeInOutQuart', function() { enableScroll(); });
return false;
});
//- Toggle tracklist
$('.tracklist-title').click(function() {
$parent = $(this).parent();
//console.log($parent);
$($parent).find(".tracklist-tracks").slideToggle();
return false;
});
/*$('.tlt').textillate({
loop: false,
in: {
effect: 'fadeInLeft',
delayScale: 1.5,
delay: 50,
sync: false,
shuffle: true,
reverse: false,
callback: function () {
$(this).textillate('stop');
}
},
out: {
effect: 'fadeOutRight',
delayScale: 1.5,
delay: 50,
sync: false,
shuffle: true,
reverse: false,
callback: function () {}
},
callback: function () {},
type: 'char'
});
$('.newloader').textillate({
loop: true,
in: {
effect: 'fadeInLeft',
delayScale: 1.5,
delay: 50,
sync: false,
shuffle: true,
reverse: false,
callback: function () {
}
},
out: {
effect: 'fadeOutRight',
delayScale: 1.5,
delay: 50,
sync: false,
shuffle: true,
reverse: false,
callback: function () {}
},
callback: function () {},
type: 'char'
});*/
//$('.share-toggle').click(function() {
// $(document).on('click', '.share-toggle',function(e){
// $(this).parents('.share').toggleClass('active');
// return false;
// });
$(document).on('click', '.share-toggle',function(e){
//$(document).ready(function(){
//$('.share-toggle').on('click', function(e) {
$(this).parent('.share').toggleClass('active');
//});
});
/*----------------------------------------------
A U D I O P L A Y E R
------------------------------------------------*/
$audioPlayer.on('click', '#toggle', function() {
$audioPlayer.toggleClass("closed");
return false;
});
$('.stream-this').click(function() {
var encodedStr = $(this).data("embed");
$audioPlayer.find('.inner').html(encodedStr).text();
$audioPlayer.removeClass("closed");
return false;
});
$('.stream-this-new').click(function() {
var encodedStr = decodeURIComponent($(this).data("embed"));
var albumID = $(this).data("id");
if(mobile){
//- Packshot is hidden on mobile so display inline
$('#album-detials-'+albumID).find('.mobile-player .inner').html(encodedStr).text();
//- add white theme to spotify players
var src = $('#album-detials-'+albumID+ ' iframe').attr('src');
$('#album-detials-'+albumID+ ' iframe').attr("src", src+"&theme=white");
} else{
//- Add embed player on packshot
$('#stream-player-'+albumID).find('.inner').html(encodedStr).text();
$('#stream-player-'+albumID).addClass("active");
//- add white theme to spotify players
var src = $('#stream-player-'+albumID+ ' iframe').attr('src');
$('#stream-player-'+albumID+ ' iframe').attr("src", src+"&theme=white");
}
return false;
});
$('.close-overlay').click(function() {
$(this).parent().removeClass('active');
return false;
});
/*----------------------------------------------
N E W S L E T T E R
------------------------------------------------*/
/*(function theForm() {
var thedata = {};
try {
$.ajax({
url: 'https://content.warnerartists.com/geoip/country.php?callback=?',
dataType: 'json',
timeout: 3000,
success: function(data) {
thedata['country'] = data.country_code;
},
error: function(data) {
thedata['country'] = "";
}
});
} catch (err) {
thedata['country'] = "";
}
$(document).on('submit', '#signupform', function(e) {
e.preventDefault();
$('.submit').val('Loading');
var that = $(this);
var formData = $(this).serializeArray()
var firstname = formData[0].value;
var email = formData[1].value;
// console.log(formData);
thedata['newsletterId'] = '14075311';
thedata['autoreply'] = 'no';
thedata['_trigger'] = '3631';
thedata['source'] = 'DuaLipaMainList_MainSignupWebsite';
thedata['email'] = email;
thedata['firstname'] = firstname;
$.ajax({
url: "https://signup.wmg.com/register",
type: "POST",
data: thedata,
dataType: "jsonp",
jsonp: "jsonp",
jsonpCallback: "cdcresult",
success: function(result) {
if (result.status == 'success') {
that.hide().html("Thanks. We'll be in touch.").fadeIn();
} else {
alert("Well, that didn't work. Please try again.")
}
}
});
})
})();*/
/*----------------------------------------------
LIVEFYRE SHIZ (only homepage)
------------------------------------------------*/
/* if ($('body').hasClass('home')) {
// Set values for the collection. articleid needs to be encoded as base64.
var siteid = '368524';
var articleid = 'Y3VzdG9tLTE0NTgxMjMxMjE4NDU='; //Instagram //Y3VzdG9tLTE0NTcwMTg1Njk3OTE=
// Call init to fetch the feed details
$.getJSON('https://wmg.bootstrap.fyre.co/bs3/wmg.fyre.co/' + siteid + '/' + articleid + '/init.json?callback=?', function(initdata) {
// update the JSON init feed url for this demo
//$('#initfeed').attr('href', 'https://wmg.bootstrap.fyre.co/bs3/wmg.fyre.co/'+siteid+'/'+articleid+'/init.json?callback=?');
// Set the value of the last page - subtract 1 to get final page
var totalpages = initdata.archiveInfo.nPages - 1;
//$('#info').append('Total number of pages: '+totalpages+' ');
// Fetch the most recent batch of content;
fetchcontent(totalpages, siteid, articleid, 1);
});
var articleid2 = 'Y3VzdG9tLTE0NTgxMjMzMTUwODc='; //Twitter
$.getJSON('https://wmg.bootstrap.fyre.co/bs3/wmg.fyre.co/' + siteid + '/' + articleid2 + '/init.json?callback=?', function(initdata) {
var totalpages2 = initdata.archiveInfo.nPages - 1;
fetchcontent(totalpages2, siteid, articleid2, 1);
});
}*/
/*----------------------------------------------
H I D E P A G E L O A D E R
------------------------------------------------*/
$("#page-loader .page-loader-inner").delay(1000).fadeOut(500, function() {
$("#page-loader").fadeOut(500);
//- Animate nav in
$( "#primary > li" ).each(function( index ) {
var timer = index * 100;
var menuItem = $(this);
setTimeout(function() {
$(menuItem).addClass('animated');
}, timer);
});
});
//- Animate nav out
$( "#primary li" ).click(function() {
$( "#primary > li" ).each(function( index ) {
$(this).removeClass('animated');
});
});
/*----------------------------------------------
H O R I Z O N T A L S E C T I O N
------------------------------------------------*/
function horizontaladapt() {
if ($('.horizontalsection').length) {
var leftpos = $('.horizontalsection').position().left + 1;
var fullwidth = $(window).width() + 2;
$('.horizontalsection').find('.horizontalinner').css({
'left': '-' + leftpos + 'px',
'width': fullwidth + 'px'
});
}
}
horizontaladapt();
$(window).resize(function() {
horizontaladapt();
});
flexInit('body');
if ($().isotope) {
/*----------------------------------------------
C A L L I S O T O P E
------------------------------------------------*/
$('.masonry').each(function() {
var $container = $(this);
$container.imagesLoaded(function() {
$container.isotope({
itemSelector: '.masonry-item',
transformsEnabled: true // Important for videos
});
});
});
/*----------------------------------------------
I S O T O P E : Filter
------------------------------------------------*/
$('.filter li a').click(function() {
var parentul = $(this).parents('ul.filter').data('related-grid');
$(this).parents('ul.filter').find('li a').removeClass('active');
$(this).addClass('active');
var selector = $(this).attr('data-option-value');
$('#' + parentul).isotope({
filter: selector
}, function() {});
return (false);
});
/*----------------------------------------------
I S O T O P E : Load More
------------------------------------------------*/
// var load_more = $('#load-more a'),
// origtext = load_more.text(),
// maxnumpage = $('#load-more a').data('maxnumpage'),
// type = $('#load-more a').data('type'),
// tax = $('#load-more a').data('tax'),
// related = $('#load-more a').data('related'),
// page = 1;
// load_more.click(function() {
// page++;
// //$('#load-more a').find('.icon').fadeOut(300);
// $('#load-more').find('.loader-icon').fadeIn(300);
// jQuery.ajax({
// type: 'POST',
// url: srvars.ajaxurl,
// data: {
// action: 'sr_load_more',
// page: page,
// type: type,
// tax: tax
// },
// success: function(response) {
// $content = $(response);
// $content.hide();
// $($content).imagesLoaded(function() {
// $('.' + related).append($content);
// $('#load-more').find('.loader-icon').delay(800).fadeOut(300, function() {
// $content.show();
// $('.' + related).isotope('appended', $content, function() {
// if (page >= maxnumpage) $('#load-more').slideUp(500);
// });
// });
// });
// }
// });
// return false;
// });
/*----------------------------------------------
I S O T O P E : reorganize
------------------------------------------------*/
// function reorganizeIsotope() {
// $('.masonry').each(function() {
// $container = $(this);
// var maxitemwidth = $container.data('maxitemwidth');
// if (!maxitemwidth) {
// maxitemwidth = 370;
// }
// var containerwidth = $container.width();
// var containerwidth = (containerwidth / 110) * 100;
// var itemrightmargin = parseInt($container.children('div').css('marginRight'));
// var rows = Math.ceil(containerwidth / maxitemwidth);
// var marginperrow = (rows - 1) * itemrightmargin;
// var newitemmargin = marginperrow / rows;
// var itemwidth = Math.floor((containerwidth / rows) - newitemmargin + 1);
// $container.css({
// 'width': '110%'
// });
// $container.children('div').css({
// 'width': itemwidth + 'px'
// });
// if ($container.children('div').hasClass('isotope-item')) {
// $container.isotope('reLayout');
// }
// });
// }
// reorganizeIsotope();
// $(window).resize(function() {
// reorganizeIsotope();
// });
}
/*----------------------------------------------
D R O P D O W N N A V I
------------------------------------------------*/
var timer = [];
var timerout = [];
$("nav#main-nav li").each(function(index) {
if ($(this).find("ul").length > 0) {
var element = $(this);
//show subnav on hover
$(this).mouseenter(function() {
if (timer[index]) {
clearTimeout(timer[index]);
timer[index] = null;
}
timer[index] = setTimeout(function() {
$(element).children('ul').fadeIn(200);
}, 150)
});
//hide submenus on exit
$(this).mouseleave(function() {
if (timer[index]) {
clearTimeout(timer[index]);
timer[index] = null;
}
timer[index] = setTimeout(function() {
$(element).children('ul').fadeOut(200);
}, 150)
});
}
});
$('nav#main-nav').on("click", "li", function() {
if ($(window).width() < 1025) {
if ($(this).find("ul").length > 0) {
if ($(this).find("ul").css('display') !== 'block') {
$(this).children("ul").fadeIn(200);
return false;
}
}
}
});
$('nav#main-menu > ul').on("click", "li", function() {
if ($(this).find("ul").length > 0) {
if ($(this).find("ul").css('display') !== 'block') {
$(this).children("ul").fadeIn(200);
return false;
} else{
$(this).children("ul.sub-menu").fadeOut(200);
}
}
});
/*----------------------------------------------
R E S P O N S I V E N A V
------------------------------------------------*/
$('').appendTo(".header-inner .menu");
$("#page-content").prepend('
');
$("nav#responsive-nav > ul").html($("nav#main-menu > ul > li:not(.social)").clone());
$("nav#responsive-nav").append($('
').append($("nav#main-nav li.social").clone()));
$("nav#responsive-nav a" ).attr( "data-text", function( arr ) {
return $( this ).text();
});
jQuery('aside').on("click", ".open-responsive-nav", function() {
$('.open-responsive-nav').toggleClass('open');
var topPos = jQuery('aside').height();
var fullheight = jQuery(window).height()-topPos;
jQuery("#menu-responsive").css({'height':fullheight+'px','top':topPos+'px'});
if (jQuery('#menu-responsive').css('right') == 0 || jQuery('#menu-responsive').css('right') == '0px') {
hideResponsiveNav();
} else {
jQuery('#menu-responsive').animate({'right': '0'}, 800, 'easeInOutQuart');
jQuery('.page-body').animate({'right': '260px'}, 800, 'easeInOutQuart');
jQuery(".open-responsive-nav span").css({'background-position':'-305px 5px'});
//jQuery('html, body').animate({scrollTop: 0}, 1000, 'easeInOutQuart');
}
return false;
});
$('#page-content').on("click", "#menu-responsive", function() {
hideResponsiveNav();
});
/*function hideResponsiveNav() {
var top = $('#menu-responsive').height();//$('#menu-responsive').width() + 10;
$('#menu-responsive').animate({
'top': '-' + top + 'px'
}, 800, 'easeInOutQuart');
$(".open-responsive-nav span").css({
'background-position': '-380px 0px'
});
}*/
function hideResponsiveNav(){
var right = jQuery('#menu-responsive').width()+100;
jQuery('#menu-responsive').animate({'right': '-'+right+'px'}, 800, 'easeInOutQuart');
jQuery('.page-body').animate({'right': '0px'}, 400, 'easeInOutQuart');
jQuery(".open-responsive-nav span").css({'background-position':'-340px 0px'});
}
/*----------------------------------------------
T A B S
------------------------------------------------*/
// $(".tabs").each(function(i) {
// $(this).find('.tab-content').removeClass('active');
// var rel = $(this).find('.active').attr('href');
// $(this).find('.' + rel).addClass('active');
// });
// $("body").on("click", ".tab-nav a", function() {
// var parentdiv = $(this).parent('li').parent('ul').parent('div');
// var rel = $(this).attr('href');
// $(parentdiv).find(".tab-nav a").removeClass("active");
// $(this).addClass("active");
// $(parentdiv).find(".tab-container .tab-content").hide().removeClass('active');
// $(parentdiv).find(".tab-container ." + rel).fadeIn(500).addClass('active');
// return (false);
// });
/*----------------------------------------------
T O G G L E & A C C O R D I O N
------------------------------------------------*/
$(".toggle-item").each(function(i) {
$(this).find('.toggle-active').siblings('.toggle-inner').slideDown(300);
});
$("body").on("click", ".toggle-title", function() {
var parentdiv = $(this).parent('div').parent('div');
var active = $(this).parent('div').find('.toggle-inner').css('display');
if ($(parentdiv).attr('class') == 'accordion') {
if (active !== 'none') {
$(parentdiv).find('.toggle-item .toggle-inner').slideUp(300);
$(this).toggleClass('toggle-active');
} else {
$(parentdiv).find('.toggle-item .toggle-inner').slideUp(300);
$(parentdiv).find('.toggle-item .toggle-title').removeClass('toggle-active');
$(this).toggleClass('toggle-active');
$(this).siblings('.toggle-inner').slideDown(300);
}
} else {
$(this).toggleClass('toggle-active');
$(this).siblings('.toggle-inner').slideToggle(300);
}
return (false);
});
/*----------------------------------------------
B A C K T O P T O P
------------------------------------------------*/
$('#backtotop').click(function() {
$('html, body').animate({
scrollTop: 0
}, 1000, 'easeInOutQuart');
return false;
});
/*----------------------------------------------
O V E R L A Y I N F O C E N T E R
------------------------------------------------*/
$('body').on("mouseenter", ".imgoverlay", function() {
var infoHeight = parseInt($(this).find('.overlayinfo').height() / 2);
$(this).find('.overlayinfo').css({
'marginTop': '-' + infoHeight + 'px'
});
});
/*----------------------------------------------
C R E D I T S
------------------------------------------------*/
var mincontentheight = wheight - $('.main-content').height() - $('footer').height();
if(mincontentheight>0){
$('.main-inner').css({
'minHeight': mincontentheight + 'px'
});
}
/*----------------------------------------------
F I T V I D E O S
------------------------------------------------*/
if ($().fitVids) {
$("body").fitVids({ /*ignore: '.single iframe'*/});
}
/*----------------------------------------------
P A R A L L A X
------------------------------------------------*/
if ($().srParallax) {
$('.parallax-section').srParallax();
}
/*----------------------------------------------
R E S P O N S I V E J P L A Y E R
------------------------------------------------*/
if ($().jPlayer && $('.jp-interface').length) {
$('.jp-interface').each(function() {
var playerwidth = $(this).width();
var newwidth = playerwidth - 175;
$(this).find('.jp-progress-container').css({
width: newwidth + 'px'
});
});
}
/*----------------------------------------------
V I D E O B G
------------------------------------------------*/
if ($().bgVideo) {
setTimeout(function() {
$('.videobg-section').bgVideo();
}, 1000);
}
/*----------------------------------------------
O W L C A R O U S E L
------------------------------------------------*/
if ($().owlCarousel) {
$(".portfolio-carousel").owlCarousel({
navigation: false,
items: 4,
itemsCustom: false,
itemsDesktop: [1199, 4],
itemsDesktopSmall: [980, 3],
itemsTablet: [768, 2],
itemsTabletSmall: false,
itemsMobile: [479, 1],
});
$("#blog-carousel").owlCarousel({
navigation: false,
items: 3,
itemsCustom: false,
itemsDesktop: [1199, 3],
itemsDesktopSmall: [980, 2],
itemsTablet: [768, 2],
itemsTabletSmall: false,
itemsMobile: [479, 1],
});
}
/*----------------------------------------------
F A N C Y B O X
------------------------------------------------*/
if ($().fancybox) {
$('.openfancybox').fancybox({
openEffect: 'fade',
closeEffect: 'fade'
});
}
/*----------------------------------------------
S C R O L L B A R
------------------------------------------------*/
if ($().perfectScrollbar) {
$('.scrollbar').perfectScrollbar({
suppressScrollX: true
});
}
smoothShow();
/*$(".flip").flip({
axis: 'y',
trigger: 'hover',
autoSize: true
});*/
});
$(window).scroll(function() {
var $el = $('a#load-more');
var wintop = $(window).scrollTop(),
docheight = $(document).height(),
winheight = $(window).height();
var scrolltrigger = 0.5;
//
if (!loading && $el && (wintop / (docheight - winheight)) > scrolltrigger) {
var opts = $el.data('query');
var $container = $($el.data('container'));
if (opts) {
loading = true;
opts.paged++;
$.post(srvars.ajaxurl, {
action: 'load_more',
query: JSON.stringify(opts)
}).done(function(html) {
if (html) {
var $items = $(html);
$container.append($items);
if ($container.hasClass('masonry')) {
$container.isotope('appended', $items).imagesLoaded(function() {
$container.isotope('layout');
setTimeout(function() {
$items.removeClass('loading');
app.events.trigger('Skrollr', 'reset');
}, 50);
});
}
$el.data('query', opts);
} else {
$('a#load-more').remove();
}
loading = false;
}).error(function() {
loading = false;
});
}
}
smoothShow();
});
// SMOOTH SHOW FUNCION FOR ELEMENTS THAT TAKE ACTION WHEN VISIBLE (counter & animations & skills)
function smoothShow() {
$(".typed").each(function() {
$(this).typed({
strings: [$(this).html()],
loop: false,
typeSpeed: 25,
startDelay: 200,
});
});
/*----------------------------------------------
C O U N T E R
------------------------------------------------*/
$('.counter-value').each(function() {
if ($(window).width() > 700) {
var visible = $(this).visible(false);
if ($(this).hasClass("anim")) {} else if (visible) {
$(this).addClass("anim");
var from = parseInt($(this).attr('data-from'));
var to = parseInt($(this).attr('data-to'));
var speed = parseInt($(this).attr('data-speed'));
$(this).count(from, to, speed);
}
} else {
var to = parseInt($(this).attr('data-to'));
$(this).html(to);
}
});
/*----------------------------------------------
G E N E R A L A N I M A T I O N S
------------------------------------------------*/
$('.sr-animation').each(function() {
if ($(window).width() > 700) {
var visible = $(this).visible(true);
var delay = $(this).attr("data-delay");
if (!delay) {
delay = 0;
}
if ($(this).hasClass("animated")) {} else if (visible) {
$(this).delay(delay).queue(function() {
$(this).addClass('animated')
});
}
} else {
$(this).addClass('animated');
}
});
/*----------------------------------------------
S K I L L A N I M A T I O N
------------------------------------------------*/
$('.skill').each(function() {
var visible = $(this).visible(true);
var percent = $(this).find('.skill-bar .skill-active ').attr('data-perc');
if ($(this).hasClass("anim")) {} else if (visible) {
var randomval = Math.floor(Math.random() * (300 - 50 + 1)) + 50;
$(this).addClass("anim");
$(this).find('.skill-bar .skill-active ').animate({
'width': percent + '%',
}, 2000, 'easeInOutQuart', function() {
$(this).find('.tooltip').delay(randomval).animate({
'top': '-28px',
'opacity': 1
}, 500);
}).css('overflow', 'visible');
}
});
}
// FLEXSLIDER INIT FUNCTION BECAUSE IT ALSO HAS TO BE REINITIALISED AFTER A PORTFOLIO ITEM IS LOADED
function flexInit(el) {
/*----------------------------------------------
F L E X S L I D E R
------------------------------------------------*/
if ($().flexslider) {
$(el + " .flexslider").flexslider({
animation: "slide",
slideshowSpeed: 7000,
animationDuration: 1000,
slideshow: true,
directionNav: false,
controlNav: true,
smoothHeight: true,
touch: true,
video: true,
randomize: false
});
}
}
/*----------------------------------------------
LIVFYRE
------------------------------------------------*/
// Define the funciton to fetch content by calling a page of results.
function fetchcontent(pgnum, siteid, articleid, output) {
$.getJSON('https://wmg.bootstrap.fyre.co/bs3/wmg.fyre.co/' + siteid + '/' + articleid + '/' + pgnum + '.json?callback=?', function(data) {
var insta_count = 0;
var tweet_count = 0;
// Update JSON content feed url for this demo
//$('#contentfeed').attr('href', 'https://wmg.bootstrap.fyre.co/bs3/wmg.fyre.co/'+siteid+'/'+articleid+'/'+pgnum+'.json?callback=?');
// Loop through all the content from the content node. .reverse() is included to ensure most recent content appears at the top.
if (data.content === undefined || data.content.length === 0) {
return;
}
$.each(data.content.reverse(), function(i, value) {
// Look for items with vis=1 to only display visible content
if (value.vis == 1) {
// Set some values based on the content feed.
var postid = value.content.id;
var contenthtml = value.content.bodyHtml;
var authorid = value.content.authorId;
var unixtime = new Date(value.content.createdAt * 1000);
var createdtime = unixtime.getHours() + ':' + unixtime.getMinutes() + ' ' + unixtime.getDate() + '.' + unixtime.getMonth() + '.' + unixtime.getFullYear(); //unixtime.toString();
//var createdtime = unixtime.getFullYear()+'-'+unixtime.getMonth()+'-'+unixtime.getDate()+' '+unixtime.getHours()+':'+unixtime.getMinutes()+':'+unixtime.getSeconds();
//createdtime = moment(createdtime).format('hh:mm D MMM');
// Set blank variables for photo content
var photoembed = '';
var thumbimg = '';
var mainimg = '';
if (value.hasOwnProperty('childContent') && value.childContent.length > 0) {
// Look for an oembed node and see if it is set to photo
if (value.childContent[0].content.oembed != undefined && value.childContent[0].content.oembed.type == 'photo') {
var thumbimg = value.childContent[0].content.oembed.thumbnail_url;
var mainimg = value.childContent[0].content.oembed.url;
photoembed = '';
}
}
// The content source is represented by the following numbers
var sources = {
0: 'Livefyre',
1: 'Twitter_Stream',
2: 'Twitter_GNIP',
3: 'Facebook_Fanpage',
4: 'Import',
5: 'Fyrehose_Livefyre',
6: 'Fyrehose_Facebook',
7: 'Fyrehose_Twitter',
8: 'Fyrehose_Import',
10: 'Google Plus',
11: 'Flickr',
12: 'YouTube',
13: 'Feed',
14: 'Datasift_Facebook',
15: 'Datasift_Twitter',
16: 'Datasift_YouTube',
19: 'Instagram',
23: 'Facebook_Publicfeed'
};
var source = sources[value.source];
var sourceicon = '';
var sourcemore = '';
switch (value.source) {
case 1:
//- strip LF stuff from tweet ID
var tweet_id = postid.replace("@twitter.com", "");
tweet_id = tweet_id.replace("tweet-", "");
sourceicon = '';
sourcemore = '
';
break;
case 3:
sourceicon = '';
break;
case 19:
sourceicon = '';
break;
}
//sourceicon=value.source;
// Use authorid to fetch user details from the authors node.
var username = data.authors[authorid].displayName;
var userurl = data.authors[authorid].profileUrl;
var userpic = data.authors[authorid].avatar;
var last_col;
// Append all the content to the list.
//$('#results').append('
');
if (insta_count % 4 == 0) {
$('#instagram-feed').append('');
}
}
}
//- Add 1 tweet
if ($('#twitter-feed').length) {
if ((value.source == 1) && tweet_count < 1) {
tweet_count++;
$('#twitter-feed').append('' + contenthtml + '');
}
}
} //end if vis=1
// Update more button to include reference to previous page.
// $('#more').attr('prev', pgnum-1);
}); // end each
// If this is the first page of results, remove the more button
/*if (pgnum > 0){
$('#more').show();
$('#more').hide();
}else{
$('#more').hide();
}*/
//- Do fancy stuff with feed layouts
$('.masonry').each(function() {
var $container = jQuery(this);
$container.imagesLoaded(function() {
$container.isotope({
itemSelector: '.masonry-item',
transformsEnabled: true // Important for videos
});
});
});
$('#instagram-feed').imagesLoaded('always', function() {
app.events.trigger('Skrollr', 'reset');
});
//reorganizeIsotope();
// Add functionality to the more button.
/* $('#more').click(function( event ) {
event.preventDefault();
fetchcontent($('#more').attr('prev'));
});*/
//fudge loading more if not enough on page 1 of results
//fetchcontent(pgnum-1);
}); // end JSON funciton.
} // end fetchcontent function.
/*----------------------------------------------
H O M E L O A D M O R E
------------------------------------------------*/
var ppp = 3; // Posts per page
//var cat = 1;
var pageNumber = 2;
function load_posts(){
pageNumber++;
var str = '&pageNumber=' + pageNumber + '&ppp=' + ppp + '&action=more_post_ajax';
$.ajax({
type: "POST",
dataType: "html",
url: 'http://www.nin.com/wp-admin/admin-ajax.php',
//url: 'http://nin.dev/wp-admin/admin-ajax.php',
data: str,
success: function(data){
var $data = $(data);
if($data.length){
$("#ajax-posts").append($data);
$("#more_posts").attr("disabled",false);
} else{
$("#more_posts").hide();
}
},
error : function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR + " :: " + textStatus + " :: " + errorThrown);
}
});
return false;
}
$("#more_posts").on("click",function(){ // When btn is pressed.
$("#more_posts").attr("disabled",true); // Disable the button, temp.
load_posts();
});
var cat = $('#more_posts').data('category');
//ENABLE BELOW ONCE GETTING THE CORRECT POSTS *****************************************
$(window).on('scroll', function () {
if ($(window).scrollTop() + $(window).height() >= $(document).height() - 500) {
load_posts();
}
});
// $("#open_close").click(function(event){
// event.preventDefault();
// });
}(jQuery, window, document));