plus-8.x-4.x-dev/js/Drupal.AssetManager.js

js/Drupal.AssetManager.js
/**
* DO NOT EDIT THIS FILE.
* THIS FILE IS COMPILED AUTOMATICALLY FROM ITS ES6 SOURCE.
* @preserve
**/'use strict';

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

(function ($, Drupal) {
  'use strict';

  var AssetManager = function () {
    function AssetManager() {
      _classCallCheck(this, AssetManager);

      this.css = Drupal.settings.ajaxPageState ? Drupal.settings.ajaxPageState.css : {};
      this.js = Drupal.settings.ajaxPageState ? Drupal.settings.ajaxPageState.js : {};
      this.library = Drupal.settings.ajaxPageState ? Drupal.settings.ajaxPageState.library : {};
      this.modules = {};
    }

    _createClass(AssetManager, [{
      key: 'add',
      value: function add(type, data, options) {
        options = options || {};

        if (typeof type === 'string' && typeof data !== 'string') {
          var _AssetManager$getAsse = AssetManager.getAssetType(data);

          var _AssetManager$getAsse2 = _slicedToArray(_AssetManager$getAsse, 2);

          type = _AssetManager$getAsse2[0];
          data = _AssetManager$getAsse2[1];
        }

        return new Promise(function (resolve, reject) {});
      }
    }], [{
      key: 'getAssetType',
      value: function getAssetType(data) {
        var type = 'js';

        if (/^@[\w]+/.test(data)) {
          type = 'library';
          data = data.replace(/^@/, '');
        } else {
          var match = data.replace(/\?.*/, '').replace(/#.*$/, '').match(/^(css|js):\/\/|\.(css|js)$/);
          if (match) {
            type = match[1] || match[2] || 'js';
          }
          data = data.replace(/^(css|js):\/\//, '');
        }
        return [type, data];
      }
    }]);

    return AssetManager;
  }();

  document.addEventListener('DOMContentLoaded', function () {
    var _this = this;

    Drupal.assets = new AssetManager();

    Drupal.add = function (type, data, options) {
      return _this.proxy(Drupal.assets, 'add', [type, data, options]);
    };
  });
})(window.jQuery, window.Drupal);

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc