Files
vivespos-landing/modules/system/assets/js/snowboard/extras/StripeLoader.js
avives 1f72193a64
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
feat: VivesPOS landing on Winter CMS 1.2 — theme + plugin + Dockerfile
- Base: wintercms/winter branch 1.2 (full framework)
- Theme vivespos: Canvas 7 + Bootstrap 5 CDN, custom CSS
- Layout: deferred GTM/GA4 tracking, JSON-LD SoftwareApplication
- Partials: hero (offline-first), features, modes (offline/nube toggle),
  screenshots, pricing (3 planes), comparison, FAQ, CTA
- Plugin VivesPOS.Site with ContactForm
- Dockerfile: PHP 8.2 Apache, port 80, healthcheck
- Added winter/wn-pages, blog, sitemap, seo plugins
- Active theme set to vivespos
2026-08-21 19:29:00 -06:00

95 lines
2.1 KiB
JavaScript

import Singleton from '../abstracts/Singleton';
/**
* Displays a stripe at the top of the page that indicates loading.
*
* @copyright 2021 Winter.
* @author Ben Thomson <git@alfreido.com>
*/
export default class StripeLoader extends Singleton {
/**
* Defines dependenices.
*
* @returns {string[]}
*/
dependencies() {
return ['request'];
}
/**
* Defines listeners.
*
* @returns {Object}
*/
listens() {
return {
ready: 'ready',
ajaxStart: 'ajaxStart',
};
}
ready() {
this.counter = 0;
this.createStripe();
}
ajaxStart(promise, request) {
if (request.loading === false || request.options.stripe === false) {
return;
}
this.show();
promise.then(() => {
this.hide();
}).catch(() => {
this.hide();
});
}
createStripe() {
this.indicator = document.createElement('DIV');
this.stripe = document.createElement('DIV');
this.stripeLoaded = document.createElement('DIV');
this.indicator.classList.add('stripe-loading-indicator', 'loaded');
this.stripe.classList.add('stripe');
this.stripeLoaded.classList.add('stripe-loaded');
this.indicator.appendChild(this.stripe);
this.indicator.appendChild(this.stripeLoaded);
document.body.appendChild(this.indicator);
}
show() {
this.counter += 1;
const newStripe = this.stripe.cloneNode(true);
this.indicator.appendChild(newStripe);
this.stripe.remove();
this.stripe = newStripe;
if (this.counter > 1) {
return;
}
this.indicator.classList.remove('loaded');
document.body.classList.add('wn-loading');
}
hide(force) {
this.counter -= 1;
if (force === true) {
this.counter = 0;
}
if (this.counter <= 0) {
this.indicator.classList.add('loaded');
document.body.classList.remove('wn-loading');
}
}
}