You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

41 lines
1.4 KiB

var PlayControl = function (parent) {
this.Parent = parent;
this.Timer = null;
this.Startup = function () {
$('#prev').on('click', this.ActivePrevImage.bind(this));
$('#next').on('click', this.ActiveNextImage.bind(this));
$('#play').on('click', this.OnPlayButtonClick.bind(this));
$('#pause').on('click', this.OnPauseButtonClick.bind(this));
};
this.ActivePrevImage = function () {
var index = parseInt($(".calc-list").attr("index"));
var count = parseInt($(".calc-list").attr("count"));
var prevIndex = index > 0 ? index - 1 : count - 1;
this.Parent.SetActiveImage(prevIndex);
};
this.ActiveNextImage = function () {
var index = parseInt($(".calc-list").attr("index"));
var count = parseInt($(".calc-list").attr("count"));
var nextIndex = index < count - 1 ? index + 1 : 0;
this.Parent.SetActiveImage(nextIndex);
};
this.AutoPlay = function () {
this.Timer = setInterval(this.ActiveNextImage.bind(this), 1500);
};
this.OnPlayButtonClick = function () {
this.AutoPlay();
$('.btn-group div.pause').show();
$('.btn-group div.play').hide();
};
this.OnPauseButtonClick = function () {
clearInterval(this.Timer);
$('.btn-group div.pause').hide();
$('.btn-group div.play').show();
};
};