{"size": 2396, "ext": "js", "max_stars_repo_path": "dist/brick-dialog/dist/brick-dialog.js", "max_stars_repo_name": "rx007/brick", "max_stars_repo_stars_event_min_datetime": "2015-01-02T09:18:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-10T12:14:22.000Z", "max_issues_repo_path": "dist/brick-dialog/dist/brick-dialog.js", "max_issues_repo_name": "rx007/brick", "max_issues_repo_issues_event_min_datetime": "2015-01-01T17:32:09.000Z", "max_issues_repo_issues_event_max_datetime": "2017-10-22T06:37:45.000Z", "max_forks_repo_path": "dist/brick-dialog/dist/brick-dialog.js", "max_forks_repo_name": "rx007/brick", "max_forks_repo_forks_event_min_datetime": "2015-01-11T02:03:40.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-16T03:39:10.000Z"}
{"max_stars_count": 690, "max_issues_count": 8, "max_forks_count": 106, "avg_line_length": 29.2195121951, "max_line_length": 76, "alphanum_fraction": 0.6786310518}
/* globals Platform */

(function () {

  var currentScript = document._currentScript || document.currentScript;

  var requestAnimationFrame = window.requestAnimationFrame ||
                              window.webkitRequestAnimationFrame ||
                              function (fn) { setTimeout(fn, 16); };

  var skipFrame = function(fn){
    requestAnimationFrame(function(){ requestAnimationFrame(fn); });
  };

  var BrickDialogElementPrototype = Object.create(HTMLElement.prototype);

  BrickDialogElementPrototype.attachedCallback = function() {

    var importDoc = currentScript.ownerDocument;
    var template = importDoc.querySelector('#brick-dialog-template');

    // fix styling for polyfill
    if (Platform.ShadowCSS) {
      var styles = template.content.querySelectorAll('style');
      for (var i = 0; i < styles.length; i++) {
        var style = styles[i];
        var cssText = Platform.ShadowCSS.shimStyle(style, 'brick-dialog');
        Platform.ShadowCSS.addCssToDocument(cssText);
        style.remove();
      }
    }

    // create shadowRoot and append template to it.
    var shadowRoot = this.createShadowRoot();
    shadowRoot.appendChild(template.content.cloneNode(true));

    
    this.addEventListener('click', this.hide.bind(this));

    var dialog = shadowRoot.querySelector('.dialog');
    dialog.addEventListener('click', function(e) {
      e.stopPropagation();
    });

  };

  BrickDialogElementPrototype.detachedCallback = function() {
    this.removeEventListener('click', this.hide.bind(this));
  };



  BrickDialogElementPrototype.show = function() {
    var dialog = this;
    dialog.setAttribute('show','');

    skipFrame(function() {
      dialog.setAttribute('show', 'in');
    });
  };

  BrickDialogElementPrototype.hide = function() {
    var dialog = this;
    dialog.setAttribute('show', 'out');

    var animationendHandler = function() {
      dialog.removeAttribute('show');
      dialog.removeEventListener('animationend', animationendHandler);
      dialog.removeEventListener('webkitAnimationEnd', animationendHandler);
    };

    dialog.addEventListener('animationend', animationendHandler);
    dialog.addEventListener('webkitAnimationEnd', animationendHandler);
  };

  // Register the element
  window.BrickDialogElement = document.registerElement('brick-dialog', {
    prototype: BrickDialogElementPrototype
  });

})();
