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