1
0
mirror of https://github.com/webslides/WebSlides.git synced 2025-09-01 09:03:04 +02:00

Removing counter link when index is disabled #88

This commit is contained in:
Luis Sacristán
2017-08-04 20:04:57 +02:00
parent e78e25ddea
commit e39fad9a16
4 changed files with 32 additions and 18 deletions

View File

@@ -48,7 +48,7 @@ export default class Navigation {
* Counter Element.
* @type {Element}
*/
this.counter = Navigation.createCounter(ELEMENT_ID.COUNTER);
this.counter = Navigation.createCounter(ELEMENT_ID.COUNTER, wsInstance);
/**
* @type {WebSlides}
* @private
@@ -81,7 +81,11 @@ export default class Navigation {
* @param {string|number} max Max slide number.
*/
updateCounter(current, max) {
this.counter.childNodes[0].textContent = `${current} / ${max}`;
if (this.ws_.options.showIndex) {
this.counter.childNodes[0].textContent = `${current} / ${max}`;
} else {
this.counter.textContent = `${current} / ${max}`;
}
}
/**
@@ -101,14 +105,17 @@ export default class Navigation {
/**
* Creates the navigation counter.
* @param {!String} id Desired ID for the counter.
* @param {WebSlides} ws_ WebSlides object.
* @return {Element} The arrow element.
*/
static createCounter(id) {
static createCounter(id, ws_) {
const counter = DOM.createNode('span', id);
const link = document.createElement('a');
link.href = '#';
link.title = 'View all slides';
counter.appendChild(link);
if (ws_.options.showIndex) {
const link = document.createElement('a');
link.href = '#';
link.title = 'View all slides';
counter.appendChild(link);
}
return counter;
}