/**
   * Sets the maximum age an entity of this race can reach.
   *
   * @property lifeExpectancy
   * @type {number}
   */
  lifeExpectancy: null,

  /**
   * Triggers when the life expectancy of the race is modified.
   *
   * @event lifeExpectancyChanged
   */
  lifeExpectancyChanged: Ember.observer('lifeExpectancy', function() {
    Ember.assert(!isNaN(this.get('lifeExpectancy')),
      'race.lifeExpectancy must be a number');
  }),

  /**
   * Sets which is the primary stat in the Attack skill
   * calculation for this race. Must be a valid
   * stat id.
   *
   * @property primaryAttackStat
   * @type {string}
   */
  primaryAttackStat: null,

  /**
   * Triggers when primaryAttackStat is changed.
   *
  formattedSeries: Ember.observer('property.stream.@each', function () {
    // Go fetch the whole observation stream
    const observations = this.get('property.stream');
    if (observations.length === 0) {
      this.set('series', null);
      return;
    }

    const tzOffsetInMs = 60 * 1000 * (new Date().getTimezoneOffset());
    // Translate to Highcharts format
    const series = observations.map(({ datetime, value }) => {
      if (typeof value === 'number') {
        // Round to 3 decimal places.
        // And pray to the IEEE gods for no weird floating point shit.
        value = Math.round(value * 1000) / 1000; // eslint-disable-line no-param-reassign
      }

      return [moment(datetime).valueOf() - tzOffsetInMs, value];
    });

    // Throw it into Highcharts.
    // Be sure to transform to JS Array from Ember Array
    // so that Highcharts doesn't get confused.
    const vType = this.get('viewType');
    const tooltipName = vType === 'live' ? 'Value' : 'Average Over Hour';

    this.set('series', [{
      showInLegend: false,
      data: series.sort(),
      name: tooltipName,
    }]);
  }),
    @readOnly
  */
  records: [],

  /**
    Configurate rows 'flexberry-objectlistview' component by address.

    @property configurateRowByAddress
    @type String
   */
  configurateRowByAddress: undefined,

  _configurateRowByAddress: Ember.observer('configurateRowByAddress', function() {
    let rowConfig = { customClass: '' };

    this.get('records').forEach((record, index, records) => {
      this.send('configurateRow', rowConfig, record);
    });
  }),

  /**
    Template text for 'flexberry-objectlistview' component.

    @property componentTemplateText
    @type String
   */
  componentTemplateText: new Ember.Handlebars.SafeString(
    '{{flexberry-objectlistview<br>' +
    '  configurateRow=(action \"configurateRow\")<br>' +
    '}}'),
Beispiel #4
0
    yieldInLabel=true|false
    //If true validation icons will be rendered, by default inherited from the form
    v_icons: true
    //Label of the form group, default is a human friendly form of the property name
    label="Some label"
}}
 */
export default Em.Component.extend(InFormMixin, HasPropertyMixin, HasPropertyValidationMixin, {
  tagName: 'div',
  "class": 'form-group',
  layoutName: 'components/em-form-group',
  classNameBindings: ['class', 'hasSuccess', 'hasWarning', 'hasError', 'v_icons:has-feedback'],
  attributeBindings: ['disabled'],
  canShowErrors: false,
  canShowErrorsObserver: Em.observer('form', 'form.model', function() {
    this.set('canShowErrors', false);
  }),
  hasSuccess: Em.computed('status', 'canShowErrors', function() {
    var success;
    success = this.get('validations') && this.get('status') === 'success' && this.get('canShowErrors');
    this.set('success', success);
    return success;
  }),
  hasWarning: Em.computed('status', 'canShowErrors', function() {
    var warning;
    warning = this.get('validations') && this.get('status') === 'warning' && this.get('canShowErrors');
    this.set('warning', warning);
    return warning;
  }),
  hasError: Em.computed('status', 'canShowErrors', function() {
    var error;
import Ember from 'ember';

export default Ember.Controller.extend({
  needs: ['application'],
  navigationTitle: Ember.computed.alias('controllers.application.navigationTitle'),
  isActiveObserver: Ember.observer('isActive', function() {
    this.set('navigationTitle','About');
  })
});
import Ember from 'ember';
import layout from '../templates/components/s-map-marker';

export default Ember.Component.extend({
  layout: layout,
  marker: null,

  layerObserver: Ember.observer('layer.layer', function () {
    let layer = this.get('layer.layer');
    let latitude = this.get('latitude');
    let longitude = this.get('longitude');
    let center = SMap.Coords.fromWGS84(longitude, latitude);
    let guid = Ember.guidFor(this);
    let markerId = `s-map-marker-${guid}`;
    let options = {};
    let marker = new SMap.Marker(center, markerId, options);
    layer.addMarker(marker);

    this.set('marker', marker);
  }),
});
Beispiel #7
0
    /**
     * Class names to apply to the modal
     *
     * @property {String} theme
    */
    theme:'',
	/**
     * @method showModal
     * @observes "show" property
     * @returns  {void}
    */
	showModal: Ember.observer('show', function(){
        if(this.get('show')){
            this.$().modal('setting', 'transition', this.transition);
            this.$().modal('setting', 'closable', this.closable);
            this.$().modal('show');            
        }else{
            this.$().modal('hide');
        }
	}),
	didInsertElement() {
		let that = this,
            closable = this.get('closable');

		this.$().modal({
            allowMultiple: true,
            closable: closable,
            observeChanges: true,
			onHide(){
                if(that.get('show')){
                    that.set('show', false);
  templateName: 'scroll-container',
  classNames: ['ember-table-scroll-container'],
  styleBindings: ['left', 'width', 'height'],
  scrollElementSelector: '.antiscroll-inner',
  width: Ember.computed.alias('tableComponent._scrollContainerWidth'),
  // 10 is the height of the horizontal scrollbar
  height: 10,
  left: Ember.computed.alias('tableComponent._fixedColumnsWidth'),
  scrollTop: Ember.computed.alias('tableComponent._tableScrollTop'),
  scrollLeft: Ember.computed.alias('tableComponent._tableScrollLeft'),

  // HACK: onScrollLeftDidChange will not fire unless scrollLeft has been get
  // at least once. Therefore, we want to call onScrollLeftDidChange in
  // didInsertElement
  didInsertElement: function() {
    this._super();
    this.onScrollLeftDidChange();
  },

  // `event` here is a jQuery event
  onScroll: function(event) {
    this.set('scrollLeft', event.target.scrollLeft);
    event.preventDefault();
  },

  onScrollLeftDidChange: Ember.observer(function() {
    var selector = this.get('scrollElementSelector');
    this.$(selector).scrollLeft(this.get('scrollLeft'));
  }, 'scrollLeft', 'scrollElementSelector')
});
Beispiel #9
0
function observerForParam(param) {
  return Ember.observer('controller.' + param, function() { this.update(); });
}
Beispiel #10
0
  }),

  nodeCount: Ember.computed('nodes.[]', function () {
    return this.get('nodes.length');
  }),

  isDraggingRole: Ember.computed('roles.[]', '*****@*****.**', function () {
    return this.get('roles').any(role => role.get('isDraggingObject') === true);
  }),

  droppableClass: Ember.computed('isDraggingRole', function () {
    return this.get('isDraggingRole') ? 'deployment-roles-active' : '';
  }),

  roleCountChanged: Ember.observer('*****@*****.**', function () {
    Ember.run.once(this, 'updateRoleCounts');
  }),

  hasValidNodeAssignments: Ember.computed.alias('openstackDeployment.hasValidNodeAssignments'),

  disableAssignNodesNext: Ember.computed(
    'hasValidNodeAssignments',
    'hasValidRoleCountsPerFlavor',
    function() {
      return !this.get('hasValidNodeAssignments') || !this.get('hasValidRoleCountsPerFlavor');
    }
  ),

  availableNodesPerFlavor: Ember.computed('nodes.[]', '*****@*****.**', function() {
    const profiles = this.get('profiles');
 import Ember from 'ember';

export default Ember.Component.extend({
  classNames:  ['form-group'],
  classNameBindings: ['inputErrors:has-danger', 'isValid:has-success'],
  inputErrors: "",
  isValid: false,
  
  errorObserver: Ember.observer('errors', function() {
    var name   = this.get('name').decamelize();
    var errors = this.set('inputErrors', this.get('errors').errorsFor(name));

    if (errors.length) {
      return errors;
    } else {
      this.set('isValid', true);
      this.set('inputErrors', "");
    }
  })
});
Beispiel #12
0
  queue: null,

  setupConnection: Ember.on('init', function() {
    this.set('subscriptions', Subscriptions.create({ consumer: this }));
    this.set('connection', Connection.create({ consumer: this }));
    this.set('queue', []);
  }),

  send(data) {
    this.get('queue').push(data);
  },

  queueObserver: Ember.on('init', Ember.observer('queue.[]', 'connection.connected', function() {
    const connection = this.get('connection');
    const queue = this.get('queue');

    if (!connection || !connection.get('connected')) {
      return;
    }

    if (Ember.isEmpty(queue)) {
      return;
    }

    queue.forEach((data, index) => {
      connection.send(data);
      queue.splice(index, 1);
    });
  }))
});
      this.get('stats').pushObject(StatHeight.create({
        size: this.get('size')
      }));
      this.get('stats').pushObject(StatWeight.create({
        size: this.get('size')
      }));
    },

    raceChanged: Ember.observer('race', function() {
      // Skills registration.
      this.set('skills', Ember.A());
      this.get('skills').pushObject(SkillAttack.create({
        strength: this.get('strength'),
        dexterity: this.get('dexterity'),
        agility: this.get('agility'),
        accuracy: this.get('accuracy'),
        primaryAttackStat: this.getStat(this.get('race.primaryAttackStat'))
      }));
      this.get('skills').pushObject(SkillDodge.create({
        dexterity: this.get('dexterity'),
        agility: this.get('agility'),
        weight: this.get('weight')
      }));
    }),

    /**
     * Sets a random number for the age, according to the race's
     * life expectancy.
     *
     * @method rollAge
     */
    rollAge: function() {
Beispiel #14
0
    @method init
  */
  init: function() {
    this._super();
    this._cachedHeights = [0];
    this.on('didInsertElement', this._syncListContainerWidth);
    this.columnCountDidChange();
    this._syncChildViews();
    this._addContentArrayObserver();
  },

  _addContentArrayObserver: Ember.observer(function () {
    var content    = get(this, 'content');
    var oldContent = get(this, 'oldContent');

    if (oldContent === content) { return; }

    addContentArrayObserver.call(this);
    set(this, 'oldContent', content);
  }, 'content'),

  /**
    Called on your view when it should push strings of HTML into a
    `Ember.RenderBuffer`.

    Adds a [div](https://developer.mozilla.org/en-US/docs/HTML/Element/div)
    with a required `ember-list-container` class.

    @method render
    @param {Ember.RenderBuffer} buffer The render buffer
  */
Beispiel #15
0
import Ember from 'ember';

const { computed: { alias, bool }, inject } = Ember;

export default Ember.Controller.extend({
  queryParams: ['delete-account'],
  session: inject.service(),
  name:    alias('session.data.authenticated.name'),
  optin:   bool('session.data.authenticated.optin'),
  locale:  alias('session.data.authenticated.locale'),

  locales: ['', 'PT', 'EN'],

  whenOptinWasChanged: Ember.observer('optin', function() {
    this.send('save');
  })
});
Beispiel #16
0
import Ember from 'ember';

export default Ember.Component.extend({
  tagName: 'span',

  classNames: ['label label-success label-fade'],
  classNameBindings: ['isShowing:label-show'],

  isShowing: false,

  isShowingChanged: Ember.observer('isShowing', function() {
    setTimeout(() => {
      this.set('isShowing', false);
    }, 5000);
  })
});
Beispiel #17
0
  changeChart: Ember.observer('data', function() {
    
    const margin = this.get('margin');
    const w = (this.$().css('width')).slice(0, (this.$().css('width')).indexOf('p'));
    const h = (this.$().css('height')).slice(0, (this.$().css('height')).indexOf('p'));
    const width = w - margin.left - margin.right;
    const height = h - margin.top - margin.bottom;
    const selection = this.get('currentSelection');
    const	data = this.get('data');

    let x = d3.scale.ordinal()
              .domain( data.map(function(d) {return d.key;}) )
              .rangeRoundBands([0, width], 0.1);

    let y = d3.scale.linear()
              .domain([0, d3.max(data, function(d) { return d.value; })])
              .range([height, 0]);

    let yd = y.domain();
    let yAxis = d3.svg.axis()
                  .scale(y)
                  .orient("left")
                  .ticks(5)
                  .outerTickSize(1);

    let svg = d3.select('#'+this.get('elementId'));

    svg.selectAll('.bar')
        .data(data)
        .transition()
        .ease('bounce')
        .duration(1100)
        .attr('y', function(d) { return y(d.value); })
        .attr('height', function(d) { return height - y(d.value); });

    svg.select('.y.axis')
       .transition()
       .duration(750)
       .call(yAxis);

  }),
    const fieldOptions = meta.columns.map((col) => {
      const name = col.field_name;
      return { computerName: name, humanName: humanizeName(name) };
    });
    this.set('fieldOptions', fieldOptions);
  },

  operators: ['=', '>', '>=', '<', '<=', '!=', 'LIKE', 'IN'],

  // Take in filters as JSON
  // And operate on them internally as JS objects.
  // When user adds or removes a filter,
  // mutate the passed in JSON accordingly.

  filtersChanged: Ember.observer('filters', function () {
    this.renderFilters();
  }),

  renderFilters() {
    const filterJSON = this.get('filters');
    this.set('filterHashes', JSON.parse(filterJSON));
  },

  mutateFilterJSON() {
    const hashes = this.get('filterHashes');
    this.set('filters', JSON.stringify(hashes));
  },

  actions: {
    madeSelection(fieldName, value) {
      this.set(fieldName, value);
Beispiel #19
0
  _currentViewDidChange: Ember.on('init', Ember.observer('currentView', function() {
    // Normally there is only one child (the view we're
    // replacing). But sometimes there may be two children (because a
    // transition is already in progress). In any case, we tell all of
    // them to start heading for the exits now.

    var oldView = this.get('childViews.lastObject'),
        newView = this.get('currentView'),
        firstTime;

    // For the convenience of the transition rules, we explicitly
    // track our first transition, which happens at initial render.
    firstTime = !this._hasTransitioned;
    this._hasTransitioned = true;

    // Idempotence
    if ((!oldView && !newView) ||
        (oldView && oldView.get('currentView') === newView) ||
        (this._runningTransition &&
         this._runningTransition.oldView === oldView &&
         this._runningTransition.newContent === newView
        )) {
      return;
    }

    // `transitions` comes from dependency injection, see the
    // liquid-fire app initializer.
    var transition = this.get('transitions').transitionFor(this, oldView, newView, this.get('use'), firstTime);

    if (this._runningTransition) {
      this._runningTransition.interrupt();
    }

    this._runningTransition = transition;
    transition.run().catch(function(err){
      // Force any errors through to the RSVP error handler, because
      // of https://github.com/tildeio/rsvp.js/pull/278.  The fix got
      // into Ember 1.7, so we can drop this once we decide 1.6 is
      // EOL.
      Ember.RSVP.Promise.resolve()._onerror(err);
    });
  })),
Beispiel #20
0
  /**
   * Watch properties that determine the disabled state of the input.
   */
  watchDisabled: Ember.observer(
    '_hasSelectedMissingItems',
    '_hasPendingContentPromise',
    '_hasFailedContentPromise',
    '_hasPendingValuePromise',
    '_hasFailedValuePromise',
    'enabled',
    function() {
      var select = this._select,
          disabled = this.get('_hasSelectedMissingItems') ||
            this.get('_hasPendingContentPromise') ||
            this.get('_hasFailedContentPromise') ||
            this.get('_hasPendingValuePromise') ||
            this.get('_hasFailedValuePromise') ||
            !this.get('enabled');

      if (select) {
        Ember.run(function() {
          select.select2("readonly", disabled);
        });
      }
    }
  )
});

export default Select2Component;
 _selectionDidChange: Ember.observer(function() {
   if (!this._selectize) {
     return;
   }
   var multiple = this.get('multiple');
   var selection = this.get('selection');
   if (multiple) {
     if (selection) {
       //Normalize selection to an array
       if (!isArray(selection)) {
         selection = Ember.A([selection]);
         this.set('selection', selection);
         return;
       }
       //bind array observers to listen for selection changes
       selection.addArrayObserver(this, {
         willChange: 'selectionArrayWillChange',
         didChange: 'selectionArrayDidChange'
       });
     } else {
       //selection was changed to nothing
       this.set('selection', Ember.A());
       return;
     }
     //Trigger a selection change that will update selectize with the new selection
     var len = selection ? get(selection, 'length') : 0;
     this.selectionArrayDidChange(selection, 0, null, len);
   } else {
     if (selection) {
       //select item in selectize
       this._selectize.addItem(get(selection, this.get('_valuePath')));
     } else {
       //selection was changed to a falsy value. Clear selectize.
       if (this._selectize) {
         this._selectize.clear();
         this._selectize.showInput();
       }
     }
   }
 }, 'selection'),
Beispiel #22
0
import Ember from 'ember';

export default Ember.Helper.extend({
  units: Ember.inject.service(),

  liftUnitObserver: Ember.observer('units.liftUnit', function() {
    this.recompute();
  }),

  compute([value], options) {
    return this.get('units').formatLift(value, options);
  },
});
         value: optionValuePath ? Ember.get(option, optionValuePath) : option,
         label: optionLabelPath ? Ember.get(option, optionLabelPath) : option
       });
     }));
   }),

  // TODO: clean up any listeners that $.select() puts in place
  // _teardownSelect() {
  //
  // }

  // TODO: this could be converted to a computed property, returning a string
  //  that is bound to the class attribute of the inputSelector
  errorsDidChange: Ember.observer('errors', function() {
    const inputSelector = this.$('input');
    // monitor the select's validity and copy the appropriate validation class to the materialize input element.
    if (!Ember.isNone(inputSelector)) {
      Ember.run.later(this, function() {
        const isValid = this.$('select').hasClass('valid');
        if (isValid) {
          inputSelector.removeClass('invalid');
          inputSelector.addClass('valid');
        } else {
          inputSelector.removeClass('valid');
          inputSelector.addClass('invalid');
        }
      }, 150);
    }
  })
});