diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2024-11-24 23:45:38 +0200 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2024-11-24 23:45:38 +0200 |
| commit | aa66a977a2dd63bb3b6255a018bbfe720b4ce2b4 (patch) | |
| tree | 30d9863e37c58a7337f4042f6ec1634175d60b14 /scripts/presentation-factory.js | |
| parent | 3d39ede6aa1d4e306ce44b816e3c082e4570abc7 (diff) | |
| download | slidetray-aa66a977a2dd63bb3b6255a018bbfe720b4ce2b4.tar.gz slidetray-aa66a977a2dd63bb3b6255a018bbfe720b4ce2b4.tar.bz2 slidetray-aa66a977a2dd63bb3b6255a018bbfe720b4ce2b4.zip | |
implement badic presentation builder function
Diffstat (limited to 'scripts/presentation-factory.js')
| -rw-r--r-- | scripts/presentation-factory.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/scripts/presentation-factory.js b/scripts/presentation-factory.js new file mode 100644 index 0000000..0a36ad1 --- /dev/null +++ b/scripts/presentation-factory.js @@ -0,0 +1,67 @@ + +const presentationFactory = (setup) => { + + return { + setup : {}, + presentation: { + html: '', + css: '', + swiper: {} + }, + + init: function (s) { + this.setup = s; + }, + + prepare: function() { + let html = []; + let css = []; + + this.setup.forEach( (slide, i) => { + slideHtml = ` + <div class="swiper-slide" data-id="${i}"> + <img src="${slide.image}" /> + `; + if (slide.poi && Array.isArray(slide.poi)) { + let slideClass = `f-${i}-${j}`; + slide.poi.forEach( (poi, j) => { + + if (poi.link) { + slideHtml += `<div class="${slideClass}"> + <a href="${poi.link}">${poi.text}</a> + </div>`; + + } else { + slideHtml += `<div class="f-${i}-${j}"> + ${poi.text} + </div>`; + } + + if (poi.style) { + poi.style.forEach( rs => { // ruleset + css.push(`.${slideClass} ${rs}`); + }); + } + }) + } + slideHtml += '</div>'; + html.push(slideHtml); + }); + this.presentation.html = html.join('\n'); + this.css = css.join('\n'); + + return this; + }, + + apply: function() { + document.querySelector(setup.selector).innerHTML = this.presentation.html; + let swiper = new Swiper(this.presentation.swiper); + + console.info('presentation is ready!'); + return this; + } + + + + } +}
\ No newline at end of file |
