File: /home/lesanew/www/wp-content/plugins/neobeat-core/inc/website-song/assets/js/parts/website-song.js
(function ($) {
"use strict";
$(document).ready(function () {
qodefWebsiteSong.init();
});
var qodefWebsiteSong = {
init: function () {
var playButton = $('.qodef-website-song');
var audioTrack = playButton.find('audio').get(0);
if (playButton.length){
playButton.each(function(){
playButton.on('click',function(){
if(playButton.hasClass('qodef-track-in-progress')){
audioTrack.pause();
playButton.addClass('qodef-track-paused').removeClass('qodef-track-in-progress');
$(".qodef-equalizer-bar").addClass("noAnim");
}else if(playButton.hasClass('qodef-track-paused')) {
audioTrack.play();
playButton.addClass('qodef-track-playing qodef-track-in-progress').removeClass('qodef-track-paused');
$(".qodef-equalizer-bar").removeClass("noAnim");
}else{
audioTrack.play();
playButton.addClass('qodef-track-playing qodef-track-in-progress');
$(".qodef-equalizer-bar").removeClass("noAnim");
}
});
playButton.find('audio').on("bind","ended", function(){
audioTrack.play();
});
});
qodefWebsiteSong.changeSkin();
}
},
changeSkin: function (){
var btt = $('.qodef-m-website-song'),
skinElements = $('.qodef-row-btt-light, #qodef-page-footer:not(.qodef-footer--light)'),
skinSet = false,
skinTrigger = new Array();
//Control button skin
var bttSkin = function() {
if (skinElements.length) {
skinElements.each(function(i){
var skinElement = $(this);
if (qodef.scroll + btt.position().top >= skinElement.offset().top && qodef.scroll + btt.position().top <= skinElement.offset().top + skinElement.outerHeight()) {
skinTrigger[i] = true;
} else {
skinTrigger[i] = false;
}
});
if (jQuery.inArray(true, skinTrigger) != -1) {
if (!skinSet) {
btt.addClass('qodef-light');
skinSet = true;
}
} else {
if (skinSet) {
btt.removeClass('qodef-light');
skinSet = false;
}
}
}
}
if (btt.length && skinElements.length) {
$(document).ready(function (){
bttSkin();
});
$(window).scroll(function() {
bttSkin();
});
}
}
};
})(jQuery);