var PlayControl = function (parent, id) { this.Self = $(id); this.Parent = parent; this.PlayTimer = null; this.CurrentTimeList = null; this.PrevButton = this.Self.find('.prev-btn:first'); this.NextButton = this.Self.find('.next-btn:first'); this.PlayButton = this.Self.find('.play-btn:first'); this.PauseButton = this.Self.find('.pause-btn:first'); this.Startup = function () { this.PrevButton.on('click', this.OnPreButtonClick.bind(this)); this.NextButton.on('click', this.OnNextButtonClick.bind(this)); this.PlayButton.on('click', this.OnPlayButtonClick.bind(this)); this.PauseButton.on('click', this.OnPauseButtonClick.bind(this)); }; this.OnPreButtonClick = function () { var active = this.CurrentTimeList.find('.active:first'); var prev = active.prev(); if (prev.length === 0) prev = this.CurrentTimeList.find('li:last'); prev.trigger('click'); }; this.OnNextButtonClick = function () { var active = this.CurrentTimeList.find('.active:first'); var next = active.next(); if (next.length === 0) next = this.CurrentTimeList.find('li:first'); next.trigger('click'); }; this.OnPlayButtonClick = function () { this.PlayTimer = setInterval(this.OnNextButtonClick.bind(this), 1500); this.PauseButton.parent('.pause').show(); this.PlayButton.parent('.play').hide(); }; this.OnPauseButtonClick = function () { clearInterval(this.PlayTimer); this.PauseButton.parent('.pause').hide(); this.PlayButton.parent('.play').show(); }; };