PHP Classes

File: modules/system/assets/js/snowboard/extras/StylesheetLoader.js

Recommend this page to a friend!
  Packages of Luke Towers   Winter   modules/system/assets/js/snowboard/extras/StylesheetLoader.js   Download  
File: modules/system/assets/js/snowboard/extras/StylesheetLoader.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Winter
Content management system that uses MVC
Author: By
Last change:
Date: 7 months ago
Size: 1,104 bytes
 

Contents

Class file image Download
import Singleton from '../abstracts/Singleton'; /** * Embeds the "extras" stylesheet into the page, if it is not loaded through the theme. * * @copyright 2021 Winter. * @author Ben Thomson <git@alfreido.com> */ export default class StylesheetLoader extends Singleton { /** * Defines listeners. * * @returns {Object} */ listens() { return { ready: 'ready', }; } ready() { let stylesLoaded = false; // Determine if stylesheet is already loaded document.querySelectorAll('link[rel="stylesheet"]').forEach((css) => { if (css.href.endsWith('/modules/system/assets/css/snowboard.extras.css')) { stylesLoaded = true; } }); if (!stylesLoaded) { const stylesheet = document.createElement('link'); stylesheet.setAttribute('rel', 'stylesheet'); stylesheet.setAttribute('href', this.snowboard.url().asset('/modules/system/assets/css/snowboard.extras.css')); document.head.appendChild(stylesheet); } } }