Documentation

This commit is contained in:
Simon Vieille 2018-05-14 13:57:27 +02:00
parent 9934c59ef6
commit 71ca412ba1
No known key found for this signature in database
GPG key ID: 919533E2B946EA10

View file

@ -40,6 +40,12 @@ if (!Array.prototype.forEach) {
});
})([Element.prototype, Document.prototype, DocumentFragment.prototype]);
/**
* Instance of SoziUi.
*
* @param Node element
* @param Object|null options
*/
var SoziUi = function(element, options) {
this.element = element;
@ -63,6 +69,9 @@ var SoziUi = function(element, options) {
this.document.document.querySelector('#sozi-framenumber').style.display = 'none';
}
/**
* Add the controls.
*/
SoziUi.prototype.addControls = function() {
var ui = `
<div class="sozi-ui-element sozi-ui-player-previous">${this.options.lang.previous}</div>
@ -128,6 +137,9 @@ SoziUi.prototype.addControls = function() {
this.uiFrameCurrentTitle.textContent = this.currentFrameTitle();
}
/**
* Attach events listeners.
*/
SoziUi.prototype.addEvents = function() {
var that = this;
@ -179,31 +191,54 @@ SoziUi.prototype.addEvents = function() {
}
}
/**
* Return the number of frames.
*/
SoziUi.prototype.frameNumber = function() {
return this.sozi.document.frames.length;
}
/**
* Return the current frame index (begin from 1)
*/
SoziUi.prototype.currentFrame = function() {
return this.sozi.location.getFrameIndex() + 1;
}
/**
* Return the current frame title.
*/
SoziUi.prototype.currentFrameTitle = function() {
return this.sozi.document.frames[this.currentFrame() - 1].title;
}
/**
* Move to previous frame.
*/
SoziUi.prototype.previousFrame = function() {
return this.player.moveToPrevious();
}
/**
* Move to next frame.
*/
SoziUi.prototype.nextFrame = function() {
return this.player.moveToNext();
}
/**
* Triggered when the frame change.
*/
SoziUi.prototype.onFrameChange = function() {
this.uiFrameCurrent.textContent = this.currentFrame();
this.uiFrameCurrentTitle.textContent = this.currentFrameTitle();
}
/**
* Enter/exit fullscreen.
*
* @param bool active
*/
SoziUi.prototype.fullscreen = function(active) {
if (active) {
if (this.container.requestFullscreen) {