$this.find('.fm_radio__playlist-body span').on('click',function () {
init_track($(this).index('.fm_radio__playlist-body span'));
});
$this.find('.fm_radio__prev').on('click',function () {
$this.find('.fm_radio__playlist-body span').eq(cpl).removeClass('fm_radio__playlist-current');
if ($this.find('.fm_radio__random-on')[0]) {
for (var prevTrack = cpl; ( prevTrack === cpl ) && ( options.playlist.length > 1 ); cpl = Math.floor(Math.random() * options.playlist.length));
init_track(cpl);
} else {
if (cpl == 0) {
cpl = options.playlist.length;
}
init_track(cpl - 1);
}
return false;
});
$this.find('.fm_radio__pause').on('click',function () {
if ($audio.paused) {
$audio.play();
$(this).addClass('isplay');
$this.find('.fm_radio__playlist-body span').eq(cpl).addClass('fm_radio__playlist-current');
} else {
$audio.pause();
$(this).removeClass('isplay');
$this.find('.fm_radio__playlist-body span').eq(cpl).removeClass('fm_radio__playlist-current');
}
return false;
});
$this.find('.fm_radio__next').on('click',function () {
$this.find('.fm_radio__playlist-body span').eq(cpl).removeClass('fm_radio__playlist-current');
if ($this.find('.fm_radio__random-on')[0]) {
for (var prevTrack = cpl; ( prevTrack === cpl ) && ( options.playlist.length > 1 ); cpl = Math.floor(Math.random() * options.playlist.length));
init_track(cpl);
} else {
if (cpl == options.playlist.length - 1) {
cpl = -1;
}
init_track(cpl + 1);
}
return false;
});
};
return this.each(make);
};
$(document).ready(function () {
var $playlist = $('.fm_radio__playlist');
var $random = $('.fm_radio__random');
var $repeat = $('.fm_radio__repeat');
$playlist.css('display', 'none');
$('.fm_radio__playlist-btn-front').on('click',function () {
$playlist.fadeToggle();
});
$('.fm_radio__front-btn-playlist').on('click',function () {
$playlist.fadeToggle();
changeSize(); //perfectScrollbar
});
$random.on('click',function () {
$random.toggleClass("fm_radio__random-on");
});
$repeat.on('click',function () {
$repeat.toggleClass("fm_radio__repeat-on");
});
// perfectScrollbar
var $perfectScrollbar = $(".js-perfect-scrollbar");
function changeSize() {
var width = parseInt($perfectScrollbar.val(),10);
var height = parseInt($perfectScrollbar.val(),10);
$perfectScrollbar.width(width).height(height);
// update scrollbars
$perfectScrollbar.perfectScrollbar('update');
}
$perfectScrollbar.perfectScrollbar();
// END perfectScrollbar
});
// })(jQuery);