Example #1
0
 addDays(days:int):CustomDate {
   var newDay = this.day + days;
   var newMonth = this.month + Math.floor(newDay / 30);
   newDay = newDay % 30;
   var newYear = this.year + Math.floor(newMonth / 12);
   return new CustomDate(newYear, newMonth, newDay);
 }
Example #2
0
 Animation.prototype.start = function () {
     this.addClasses(this.data.classesToAdd);
     this.addClasses(this.data.animationClasses);
     this.removeClasses(this.data.classesToRemove);
     if (this.data.toStyles != null)
         this.applyStyles(this.data.toStyles);
     var computedStyles = dom_adapter_1.DOM.getComputedStyle(this.element);
     this.computedDelay =
         math_1.Math.max(this.parseDurationString(computedStyles.getPropertyValue(this._stringPrefix + 'transition-delay')), this.parseDurationString(this.element.style.getPropertyValue(this._stringPrefix + 'transition-delay')));
     this.computedDuration = math_1.Math.max(this.parseDurationString(computedStyles.getPropertyValue(this._stringPrefix + 'transition-duration')), this.parseDurationString(this.element.style.getPropertyValue(this._stringPrefix + 'transition-duration')));
     this.addEvents();
 };
Example #3
0
 MdProgressCircular.prototype.getDiameterRatio = function () {
     if (!this.diameter)
         return Defaults.DEFAULT_SCALING;
     var match = /([0-9]*)%/.exec(this.diameter);
     var value = math_1.Math.max(0, (match && match[1] / 100) || parseFloat(this.diameter));
     return (value > 1) ? value / Defaults.DEFAULT_PROGRESS_SIZE : value;
 };
Example #4
0
 static calculateStandardDeviation(samples, mean) {
     var deviation = 0;
     // TODO: use reduce
     samples.forEach(x => deviation += Math.pow(x - mean, 2));
     deviation = deviation / (samples.length);
     deviation = Math.sqrt(deviation);
     return deviation;
 }
Example #5
0
 Animation.prototype.handleAnimationEvent = function (event) {
     var elapsedTime = math_1.Math.round(event.elapsedTime * 1000);
     if (!this.browserDetails.elapsedTimeIncludesDelay)
         elapsedTime += this.computedDelay;
     event.stopPropagation();
     if (elapsedTime >= this.totalTime)
         this.handleAnimationCompleted();
 };
Example #6
0
 handleAnimationEvent(event) {
     let elapsedTime = Math.round(event.elapsedTime * 1000);
     if (!this.browserDetails.elapsedTimeIncludesDelay)
         elapsedTime += this.computedDelay;
     event.stopPropagation();
     if (elapsedTime >= this.totalTime)
         this.handleAnimationCompleted();
 }
Example #7
0
 ListWrapper.map(this._metricNames, (metricName) => {
   var sample = ListWrapper.map(validSample, (measureValues) => measureValues.values[metricName]);
   var mean = Statistic.calculateMean(sample);
   var cv = Statistic.calculateCoefficientOfVariation(sample, mean);
   var formattedMean = ConsoleReporter._formatNum(mean)
   // Note: Don't use the unicode character for +- as it might cause
   // hickups for consoles...
   return NumberWrapper.isNaN(cv) ? formattedMean : `${formattedMean}+-${Math.floor(cv)}%`;
 })
Example #8
0
 static calculateStandardDeviation(sample, mean) {
   var deviation = 0;
   ListWrapper.forEach(sample, (x) => {
     deviation += Math.pow(x - mean, 2);
   });
   deviation = deviation / (sample.length);
   deviation = Math.sqrt(deviation);
   return deviation;
 }
Example #9
0
 static calculateRegressionSlope(xValues, xMean, yValues, yMean) {
     // See http://en.wikipedia.org/wiki/Simple_linear_regression
     var dividendSum = 0;
     var divisorSum = 0;
     for (var i = 0; i < xValues.length; i++) {
         dividendSum += (xValues[i] - xMean) * (yValues[i] - yMean);
         divisorSum += Math.pow(xValues[i] - xMean, 2);
     }
     return dividendSum / divisorSum;
 }
Example #10
0
 onScroll(evt) {
   var scrollTop = 0;
   if (evt != null) {
     var scrollDiv = evt.target;
     if (this.paddingDiv == null) {
       this.paddingDiv = scrollDiv.querySelector('#padding');
     }
     if (this.innerDiv == null) {
       this.innerDiv = scrollDiv.querySelector('#inner');
       this.innerDiv.style.setProperty('width', `${ROW_WIDTH}px`);
     }
     scrollTop = scrollDiv.scrollTop;
   }
   var iStart = Math.floor(scrollTop / ITEM_HEIGHT);
   var iEnd = Math.min(iStart + VISIBLE_ITEMS + 1, this._fullList.length);
   var padding = iStart * ITEM_HEIGHT;
   if (this.innerDiv != null) {
     this.innerDiv.style.setProperty('height', `${HEIGHT - padding}px`);
   }
   if (this.paddingDiv != null) {
     this.paddingDiv.style.setProperty('height', `${padding}px`);
   }
   this.visibleItems = ListWrapper.slice(this._fullList, iStart, iEnd);
 }
Example #11
0
 Animation.prototype.parseDurationString = function (duration) {
     var maxValue = 0;
     // duration must have at least 2 characters to be valid. (number + type)
     if (duration == null || duration.length < 2) {
         return maxValue;
     }
     else if (duration.substring(duration.length - 2) == 'ms') {
         var value = lang_1.NumberWrapper.parseInt(this.stripLetters(duration), 10);
         if (value > maxValue)
             maxValue = value;
     }
     else if (duration.substring(duration.length - 1) == 's') {
         var ms = lang_1.NumberWrapper.parseFloat(this.stripLetters(duration)) * 1000;
         var value = math_1.Math.floor(ms);
         if (value > maxValue)
             maxValue = value;
     }
     return maxValue;
 };
Example #12
0
 /**
  * Converts the duration string to the number of milliseconds
  * @param duration
  * @returns {number}
  */
 parseDurationString(duration) {
     var maxValue = 0;
     // duration must have at least 2 characters to be valid. (number + type)
     if (duration == null || duration.length < 2) {
         return maxValue;
     }
     else if (duration.substring(duration.length - 2) == 'ms') {
         let value = NumberWrapper.parseInt(this.stripLetters(duration), 10);
         if (value > maxValue)
             maxValue = value;
     }
     else if (duration.substring(duration.length - 1) == 's') {
         let ms = NumberWrapper.parseFloat(this.stripLetters(duration)) * 1000;
         let value = Math.floor(ms);
         if (value > maxValue)
             maxValue = value;
     }
     return maxValue;
 }
Example #13
0
 DOM.on(div, 'transitionend', (event) => {
     var elapsed = Math.round(event.elapsedTime * 1000);
     this.elapsedTimeIncludesDelay = elapsed == 2;
     DOM.remove(div);
 });
Example #14
0
 samples.forEach(x => deviation += Math.pow(x - mean, 2));
};
var lang_1 = require('angular2/src/facade/lang');
var math_1 = require('angular2/src/facade/math');
var collection_1 = require('angular2/src/facade/collection');
var di_1 = require('angular2/di');
var visibility_1 = require('angular2/src/core/annotations/visibility');
var di_2 = require('angular2/src/core/annotations/di');
var viewModule = require('angular2/src/core/compiler/view');
var view_container_1 = require('angular2/src/core/compiler/view_container');
var element_1 = require('angular2/src/core/dom/element');
var annotations_1 = require('angular2/src/core/annotations/annotations');
var change_detection_1 = require('angular2/change_detection');
var pclModule = require('angular2/src/core/compiler/private_component_location');
var property_setter_factory_1 = require('angular2/src/render/dom/view/property_setter_factory');
var _MAX_DIRECTIVE_CONSTRUCTION_COUNTER = 10;
var MAX_DEPTH = math_1.Math.pow(2, 30) - 1;
var _undefined = new Object();
var _staticKeys;
var StaticKeys = (function () {
    function StaticKeys() {
        this.viewId = di_1.Key.get(viewModule.View).id;
        this.ngElementId = di_1.Key.get(element_1.NgElement).id;
        this.viewContainerId = di_1.Key.get(view_container_1.ViewContainer).id;
        this.bindingPropagationConfigId = di_1.Key.get(change_detection_1.BindingPropagationConfig).id;
        this.privateComponentLocationId = di_1.Key.get(pclModule.PrivateComponentLocation).id;
    }
    StaticKeys.instance = function () {
        if (lang_1.isBlank(_staticKeys))
            _staticKeys = new StaticKeys();
        return _staticKeys;
    };
Example #16
0
import {List, ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
import {Injector, Key, Dependency, bind, Binding, ResolvedBinding, NoBindingError,
  AbstractBindingError, CyclicDependencyError} from 'angular2/di';
import {Parent, Ancestor} from 'angular2/src/core/annotations/visibility';
import {PropertySetter, Attribute, Query} from 'angular2/src/core/annotations/di';
import * as viewModule from 'angular2/src/core/compiler/view';
import {ViewContainer} from 'angular2/src/core/compiler/view_container';
import {NgElement} from 'angular2/src/core/compiler/ng_element';
import {Directive, Component, onChange, onDestroy, onAllChangesDone} from 'angular2/src/core/annotations/annotations';
import {ChangeDetector, ChangeDetectorRef} from 'angular2/change_detection';
import {QueryList} from './query_list';
import {reflector} from 'angular2/src/reflection/reflection';

var _MAX_DIRECTIVE_CONSTRUCTION_COUNTER = 10;

var MAX_DEPTH = Math.pow(2, 30) - 1;

var _undefined = new Object();

var _staticKeys;

/**
 * @exportedAs angular2/view
 */
export class ElementRef {
  hostView:viewModule.AppView;
  boundElementIndex:number;
  injector:Injector;
  elementInjector:ElementInjector;

  constructor(elementInjector, hostView, boundElementIndex, injector){
Example #17
0
 ListWrapper.forEach(sample, (x) => {
   deviation += Math.pow(x - mean, 2);
 });
 dom_adapter_1.DOM.on(div, 'transitionend', function (event) {
     var elapsed = math_1.Math.round(event.elapsedTime * 1000);
     _this.elapsedTimeIncludesDelay = elapsed == 2;
     dom_adapter_1.DOM.remove(div);
 });