all files / addon/components/ ui-popup.js

86.96% Statements 20/23
66.67% Branches 10/15
100% Functions 2/2
86.96% Lines 20/23
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51              18× 18×                                                
import Ember from 'ember';
import Base from '../mixins/base';
 
export default Ember.Component.extend(Base, {
  module: 'popup',
 
  didInitSemantic() {
    this._super(...arguments);
    let possibleAttrs = ['content', 'title', 'html'];
    for (let i = 0; i < possibleAttrs.length; i++) {
      let possibleAttr = possibleAttrs[i];
      if (this._hasOwnProperty(this.attrs, possibleAttr) || this.get(possibleAttr) != null) {
        this.get('_settableAttrs').addObject(possibleAttr);
      }
    }
    this.get('_settableAttrs').removeObject('position');
  },
 
  setSemanticAttr(attrName, attrValue) {
    Eif (attrName === 'content' || attrName === 'title' || attrName === 'html') {
      let value = this._unwrapHTMLSafe(attrValue);
      let response = this.execute('setting', attrName, value);
      if (this.execute('is visible')) {
        let html;
        Iif (attrName === 'html') {
          html = value;
        } else {
          let text;
          Eif (attrName === 'content')  {
            text = {
              title: this.get('title'),
              content: value
            };
          } else {
            text = {
              title: value,
              content: this.get('content')
            };
          }
          let moduleGlobal = this.getSemanticModuleGlobal();
          html = moduleGlobal.settings.templates.popup(text);
        }
        this.execute('change content', html);
      }
      return response;
    }
    return this._super(...arguments);
  }
});