Sha256: 2b37fd605a3f9b4d0ff4bf08184d217bba58baf425ea54f78ef30c4dfdc2fb46

Contents?: true

Size: 1.5 KB

Versions: 31

Compression:

Stored size: 1.5 KB

Contents

(function () {
  var alreadyLoaded = {};
  EasyGem.dynamic = {
    _alreadyLoaded: alreadyLoaded,
    /**
     * Append Javascript <script> tag to page
     * @example
     * EasyGem.dynamic.jsTag("/plugin_assets/my_plugin/javascripts/counter.js");
     * EasyGem.schedule.require(function(counter){
     *   setInterval(counter.count(), 1000);
     * }, function(){
     *   return window.utils.counter;
     * })
     * @param {String} src - absolute path to requested file
     */
    jsTag: function (src) {
      if (alreadyLoaded[src]) return;
      alreadyLoaded[src] = true;
      var jsScript = document.createElement("script");
      jsScript.setAttribute("src", src);
      jsScript.setAttribute("defer", "true");
      document.head.appendChild(jsScript);
    },
    /**
     * Append CSS <link> tag to page
     * @param {String} src - absolute path to requested file
     */
    cssTag: function (src) {
      if (alreadyLoaded[src]) return;
      alreadyLoaded[src] = true;
      var link = document.createElement('link');
      link.rel = "stylesheet";
      link.type = "text/css";
      link.href = src;
      link.media = "all";
      document.head.appendChild(link);
    },
    /**
     * Load multiple JS files into page
     * @param {Array.<String>} array
     */
    jsTags: function (array) {
      array.forEach(this.jsTag);
    },
    /**
     * Load multiple CSS files into page
     * @param {Array.<String>} array
     */
    cssTags: function (array) {
      array.forEach(this.cssTag);
    }
  };
})();

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
redmine_extensions-1.2.0 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-1.1.2 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-1.1.1 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-1.1.0 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-1.0.0 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-0.6.3 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-0.6.2 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-0.6.1 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-0.6.0 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-0.4.5 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-0.5.1 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-0.4.4 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-0.4.3 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-0.4.1 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-0.4.0 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-0.4.0.beta app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-0.3.11 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-0.3.10 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-0.3.9 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js
redmine_extensions-0.3.8 app/assets/javascripts/redmine_extensions/blocking_dynamic_loading.js