From 71ca412ba14c0f3fb902f2002b2918084ed04ab3 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 14 May 2018 13:57:27 +0200 Subject: [PATCH] Documentation --- src/sozi-ui.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/sozi-ui.js b/src/sozi-ui.js index 77cc4fd..b28b744 100644 --- a/src/sozi-ui.js +++ b/src/sozi-ui.js @@ -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 = `
${this.options.lang.previous}
@@ -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) {