Projekt

Obecné

Profil

Stáhnout (810 Bajtů) Statistiky
| Větev: | Tag: | Revize:
1
import {Position} from './app/model/crates/Position';
2

    
3
export default class Utils {
4

    
5
  static removeFileSuffix(file: File): string {
6
    return file.name.substring(0, file.name.indexOf('.'));
7
  }
8

    
9
  static isIterable(obj): boolean {
10
    // checks for null and undefined
11
    if (obj == null) {
12
      return false;
13
    }
14
    return typeof obj[Symbol.iterator] === 'function';
15
  }
16

    
17
  static getAbsolutePositionOfElement(element: HTMLElement): Position {
18
    let top = 0, left = 0;
19

    
20
    do {
21
      top += element.offsetTop  || 0;
22
      left += element.offsetLeft || 0;
23
      element = <HTMLElement> element.offsetParent;
24
    } while (element);
25

    
26
    return new Position(top, left);
27
  }
28

    
29
  static getStringAfterLastChar(text: string, char: string): string {
30
    return text.substr(text.lastIndexOf(char) + 1);
31
  }
32
}
(1-1/8)