/** * PlatypusTS v0.28.0 (https://platypi.io) * Copyright 2015 Platypi, LLC. All rights reserved. * * PlatypusTS is licensed under the MIT license found at * https://github.com/Platypi/platypusts/blob/master/LICENSE * */ /** * The entry point into the platypus library. */ declare namespace plat { /** * Holds all the classes and interfaces related to registering components for platypus. */ namespace register { /** * Registers the IApp with the framework. The framework will instantiate the IApp * when needed, and wire up the Application Lifecycle events. The dependencies array corresponds to injectables that will be * passed into the Constructor of the app. * @param {string} name The name of your app. * @param {new (...args: any[]) => plat.App} Type The constructor for the IApp. * @param {Array} dependencies? An array of strings representing the dependencies needed for the app injector. */ const app: IRegisterFunction; /** * Registers an Control with the framework. The framework will instantiate the * Control when needed. The dependencies array corresponds to injectables that * will be passed into the Constructor of the control. * @param {string} name The control type, corresponding to the HTML notation for creating a new Control (e.g. 'plat-foreach'). * @param {new (...args: any[]) => plat.Control} Type The constructor for the Control. * @param {Array} dependencies? An array of strings representing the dependencies needed for the Control * injector. */ const control: IExtendedRegisterFunction; /** * Registers an ViewControl with the framework. The framework will * instantiate the control when needed. The dependencies array corresponds to injectables that will be * passed into the Constructor of the control. * @param {string} name The control type, corresponding to the HTML notation for creating a new * ViewControl. Used for navigation to the specified ViewControl. * @param {new (...args: any[]) => plat.ui.ViewControl} Type The constructor for the ViewControl. * @param {Array} dependencies? An optional array of strings representing the dependencies needed for the * ViewControl injector. */ const viewControl: IRegisterFunction; /** * Registers an injectable with the framework. Injectables are objects that can be used for dependency injection into other objects. * The dependencies array corresponds to injectables that will be passed into the Constructor of the injectable. * @param {string} name The name of the injector, used when another component is specifying dependencies. * @param {(...args: any[]) => any} method A method that returns the injectable. * @param {Array} dependencies? An array of strings representing the dependencies needed for the injectable's injector. * @param {string} injectableType? Specifies the type of injectable, either SINGLETON, * STATIC, INSTANCE, * FACTORY, CLASS * (defaults to SINGLETON). */ const injectable: IInjectableType & IExtendedRegisterFunction; interface IInjectableType { STATIC?: string; SINGLETON?: string; INSTANCE?: string; FACTORY?: string; CLASS?: string; } /** * Adds a JS animation denoted by its name. If Intended to be used when JS animation implementations for legacy browsers * is desired. * @param {string} name The unique identifer of the animation. * @param {new (...args: any[]) => plat.ui.animations.BaseAnimation} Type The constructor for the custom animation. * @param {Array} dependencies? Any dependencies that need to be injected into the animation at * instantiation. * @param {string} animationType The type of animation. Both the intended type and default value are * JS. */ const animation: IAnimationType & IExtendedRegisterFunction; interface IAnimationType { CSS?: string; JS?: string; } interface IRegisterFunction { (name: string, Type: ((d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7, d8: D8, d9: D9, d10: D10) => T) | (new (d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7, d8: D8, d9: D9, d10: D10) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string, ((...args: any[]) => D4) | (new (...args: any[]) => D4) | string, ((...args: any[]) => D5) | (new (...args: any[]) => D5) | string, ((...args: any[]) => D6) | (new (...args: any[]) => D6) | string, ((...args: any[]) => D7) | (new (...args: any[]) => D7) | string, ((...args: any[]) => D8) | (new (...args: any[]) => D8) | string, ((...args: any[]) => D9) | (new (...args: any[]) => D9) | string, ((...args: any[]) => D10) | (new (...args: any[]) => D10) | string]): typeof register; (name: string, Type: ((d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7, d8: D8, d9: D9) => T) | (new (d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7, d8: D8, d9: D9) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string, ((...args: any[]) => D4) | (new (...args: any[]) => D4) | string, ((...args: any[]) => D5) | (new (...args: any[]) => D5) | string, ((...args: any[]) => D6) | (new (...args: any[]) => D6) | string, ((...args: any[]) => D7) | (new (...args: any[]) => D7) | string, ((...args: any[]) => D8) | (new (...args: any[]) => D8) | string, ((...args: any[]) => D9) | (new (...args: any[]) => D9) | string]): typeof register; (name: string, Type: ((d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7, d8: D8) => T) | (new (d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7, d8: D8) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string, ((...args: any[]) => D4) | (new (...args: any[]) => D4) | string, ((...args: any[]) => D5) | (new (...args: any[]) => D5) | string, ((...args: any[]) => D6) | (new (...args: any[]) => D6) | string, ((...args: any[]) => D7) | (new (...args: any[]) => D7) | string, ((...args: any[]) => D8) | (new (...args: any[]) => D8) | string]): typeof register; (name: string, Type: ((d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7) => T) | (new (d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string, ((...args: any[]) => D4) | (new (...args: any[]) => D4) | string, ((...args: any[]) => D5) | (new (...args: any[]) => D5) | string, ((...args: any[]) => D6) | (new (...args: any[]) => D6) | string, ((...args: any[]) => D7) | (new (...args: any[]) => D7) | string]): typeof register; (name: string, Type: ((d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6) => T) | (new (d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string, ((...args: any[]) => D4) | (new (...args: any[]) => D4) | string, ((...args: any[]) => D5) | (new (...args: any[]) => D5) | string, ((...args: any[]) => D6) | (new (...args: any[]) => D6) | string]): typeof register; (name: string, Type: ((d1: D1, d2: D2, d3: D3, d4: D4, d5: D5) => T) | (new (d1: D1, d2: D2, d3: D3, d4: D4, d5: D5) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string, ((...args: any[]) => D4) | (new (...args: any[]) => D4) | string, ((...args: any[]) => D5) | (new (...args: any[]) => D5) | string]): typeof register; (name: string, Type: ((d1: D1, d2: D2, d3: D3, d4: D4) => T) | (new (d1: D1, d2: D2, d3: D3, d4: D4) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string, ((...args: any[]) => D4) | (new (...args: any[]) => D4) | string]): typeof register; (name: string, Type: ((d1: D1, d2: D2, d3: D3) => T) | (new (d1: D1, d2: D2, d3: D3) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string]): typeof register; (name: string, Type: ((d1: D1, d2: D2) => T) | (new (d1: D1, d2: D2) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string]): typeof register; (name: string, Type: ((d1: D1) => T) | (new (d1: D1) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string]): typeof register; (name: string, Type: (() => T) | (new () => T)): typeof register; } interface IExtendedRegisterFunction { (name: string, Type: ((d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7, d8: D8, d9: D9, d10: D10) => T) | (new (d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7, d8: D8, d9: D9, d10: D10) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string, ((...args: any[]) => D4) | (new (...args: any[]) => D4) | string, ((...args: any[]) => D5) | (new (...args: any[]) => D5) | string, ((...args: any[]) => D6) | (new (...args: any[]) => D6) | string, ((...args: any[]) => D7) | (new (...args: any[]) => D7) | string, ((...args: any[]) => D8) | (new (...args: any[]) => D8) | string, ((...args: any[]) => D9) | (new (...args: any[]) => D9) | string, ((...args: any[]) => D10) | (new (...args: any[]) => D10) | string], type?: XT): typeof register; (name: string, Type: ((d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7, d8: D8, d9: D9) => T) | (new (d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7, d8: D8, d9: D9) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string, ((...args: any[]) => D4) | (new (...args: any[]) => D4) | string, ((...args: any[]) => D5) | (new (...args: any[]) => D5) | string, ((...args: any[]) => D6) | (new (...args: any[]) => D6) | string, ((...args: any[]) => D7) | (new (...args: any[]) => D7) | string, ((...args: any[]) => D8) | (new (...args: any[]) => D8) | string, ((...args: any[]) => D9) | (new (...args: any[]) => D9) | string], type?: XT): typeof register; (name: string, Type: ((d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7, d8: D8) => T) | (new (d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7, d8: D8) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string, ((...args: any[]) => D4) | (new (...args: any[]) => D4) | string, ((...args: any[]) => D5) | (new (...args: any[]) => D5) | string, ((...args: any[]) => D6) | (new (...args: any[]) => D6) | string, ((...args: any[]) => D7) | (new (...args: any[]) => D7) | string, ((...args: any[]) => D8) | (new (...args: any[]) => D8) | string], type?: XT): typeof register; (name: string, Type: ((d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7) => T) | (new (d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string, ((...args: any[]) => D4) | (new (...args: any[]) => D4) | string, ((...args: any[]) => D5) | (new (...args: any[]) => D5) | string, ((...args: any[]) => D6) | (new (...args: any[]) => D6) | string, ((...args: any[]) => D7) | (new (...args: any[]) => D7) | string], type?: XT): typeof register; (name: string, Type: ((d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6) => T) | (new (d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string, ((...args: any[]) => D4) | (new (...args: any[]) => D4) | string, ((...args: any[]) => D5) | (new (...args: any[]) => D5) | string, ((...args: any[]) => D6) | (new (...args: any[]) => D6) | string], type?: XT): typeof register; (name: string, Type: ((d1: D1, d2: D2, d3: D3, d4: D4, d5: D5) => T) | (new (d1: D1, d2: D2, d3: D3, d4: D4, d5: D5) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string, ((...args: any[]) => D4) | (new (...args: any[]) => D4) | string, ((...args: any[]) => D5) | (new (...args: any[]) => D5) | string], type?: XT): typeof register; (name: string, Type: ((d1: D1, d2: D2, d3: D3, d4: D4) => T) | (new (d1: D1, d2: D2, d3: D3, d4: D4) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string, ((...args: any[]) => D4) | (new (...args: any[]) => D4) | string], type?: XT): typeof register; (name: string, Type: ((d1: D1, d2: D2, d3: D3) => T) | (new (d1: D1, d2: D2, d3: D3) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string, ((...args: any[]) => D3) | (new (...args: any[]) => D3) | string], type?: XT): typeof register; (name: string, Type: ((d1: D1, d2: D2) => T) | (new (d1: D1, d2: D2) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string, ((...args: any[]) => D2) | (new (...args: any[]) => D2) | string], type?: XT): typeof register; (name: string, Type: ((d1: D1) => T) | (new (d1: D1) => T), dependencies: [((...args: any[]) => D1) | (new (...args: any[]) => D1) | string], type?: XT): typeof register; (name: string, Type: (() => T) | (new () => T)): typeof register; } } /** * Holds classes and interfaces related to dependency injection components in platypus. */ namespace dependency { /** * The Injector class is used for dependency injection. You can create an injector object, * specify dependencies and a constructor for your component. When the injector object is * 'injected' it will create a new instance of your component and pass in the dependencies * to the constructor. */ class Injector { /** * The dependencies for this injector */ dependencies: string[]; name: string; Constructor: new () => T; type: string; /** * Initializes all static injectors. */ static initialize(): void; /** * Gathers and returns the array of listed dependencies. * @param {Array} dependencies The array of dependencies specified * by either their Constructor or their registered name. */ static getDependencies(dependencies: any[]): Injector[]; /** * Finds and returns the dependency. * @param {any} dependency an object/string used to find the dependency. */ static getDependency(dependency: any): Injector; /** * Converts dependencies specified by their Constructors into * equivalent dependencies specified by their registered string * name. * @param {Array} dependencies The array of dependencies specified * by either their Constructor or their registered name. */ static convertDependencies(dependencies: any[]): string[]; /** * Converts a dependency specified by its Constructors into an * equivalent dependency specified by its registered string * name. * @param {any} dependency The dependency specified * by either a Constructor or a registered name. */ static convertDependency(dependency: any): string; /** * Checks if the object being passed in fulfills the requirements for being an Injector. * @param {plat.dependency.Injector} dependency The object to check. */ static isInjector(dependency: Injector): boolean; /** * Gets the string name related to an injector. * @param {any} dependency The object to search for. */ private static __getInjectorName; /** * Calls the injector's constructor with the associated dependencies. * @param {any} Constructor The Constructor to call. * @param {Array} args The arguments to pass to the constructor. */ private static __construct; /** * Walks up an object's prototype, injecting dependencies if they are * registered on static '_inject' objects. * @param {any} obj The object to walk. * @param {any} proto the prototype of the object. */ private static __walk; /** * Finds an injector object with the associated constructor. * @param {any} Constructor The Constructor to locate. */ private static __locateInjector; /** * Finds an injector object with the associated constructor in the given InjectorObject. * @param {Function} Constructor The Function */ private static __findInjector; /** * Once an injector is injected, it is wrapped to prevent further injection. * @param {any} value The injected value. */ private static __wrap; /** * Returns an empty injector object. */ private static __noop; /** * Determines if there is a circular dependency in a dependency tree. * @param {plat.dependency.Injector} injector The starting point for the dependency tree search. */ private static __findCircularReferences; /** * The constructor for an injector. Converts any non-string dependencies to strings to support mocking Injectors during runtime. * @param {string} name The name of the injected type. * @param {new () => T} Constructor The constructor method for the component requiring the dependency * injection. * @param {Array} dependencies An array of strings specifying the injectable dependencies for the * associated constructor. * @param {string} type The type of injector, used for injectables specifying a injectableType of * STATIC, SINGLETON, FACTORY, INSTANCE, or CLASS. The default is SINGLETON. */ constructor(name: string, Constructor: new () => T, dependencies?: any[], type?: string); /** * Gathers the dependencies for the Injector object and creates a new instance of the * Constructor, passing in the dependencies in the order they were specified. If the * Injector contains a Constructor for an injectable and the Constructor is registered * as a SINGLE type it will only inject that injectable once. */ inject(): T; /** * Wraps the injector with the instantiated value in the case of a * SINGLE or STATIC type so that it does not re-instantiate. * @param {any} value The value to wrap */ protected _wrapInjector(value: any): Injector; } /** * An object whose values are all Injectors. */ interface InjectorObject extends IObject> { } /** * Publicly exposes all the dependency injector objects. */ namespace injectors { /** * An InjectorObject of Controls. * Contains all the registered controls for an application. */ const control: InjectorObject; /** * An InjectorObject of IBaseViewControls. * Contains all the registered view controls for an application. */ const viewControl: InjectorObject; /** * An InjectorObject of objects. Contains all the registered * injectables for an application. */ const injectable: InjectorObject; /** * An InjectorObject of static objects. Contains all the registered * static injectables for an application. Once the injectables have been injected, they are removed from this object. */ const staticInjectable: InjectorObject; /** * An InjectorObject of animations. Can be either CSS or JS implementations. */ const animation: InjectorObject; /** * An InjectorObject of animations. Should only contain JS implementations. */ const jsAnimation: InjectorObject; } } /** * Gathers dependencies and returns them as an array in the order they were requested. * @param {Array} dependencies An array of strings or Functions specifying the injectable dependencies. */ function acquire(dependencies: [((...args: any[]) => T1) | (new (...args: any[]) => T1), ((...args: any[]) => T2) | (new (...args: any[]) => T2), ((...args: any[]) => T3) | (new (...args: any[]) => T3), ((...args: any[]) => T4) | (new (...args: any[]) => T4), ((...args: any[]) => T5) | (new (...args: any[]) => T5), ((...args: any[]) => T6) | (new (...args: any[]) => T6), ((...args: any[]) => T7) | (new (...args: any[]) => T7), ((...args: any[]) => T8) | (new (...args: any[]) => T8), ((...args: any[]) => T9) | (new (...args: any[]) => T9), ((...args: any[]) => T10) | (new (...args: any[]) => T10)]): [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]; function acquire(dependencies: [((...args: any[]) => T1) | (new (...args: any[]) => T1), ((...args: any[]) => T2) | (new (...args: any[]) => T2), ((...args: any[]) => T3) | (new (...args: any[]) => T3), ((...args: any[]) => T4) | (new (...args: any[]) => T4), ((...args: any[]) => T5) | (new (...args: any[]) => T5), ((...args: any[]) => T6) | (new (...args: any[]) => T6), ((...args: any[]) => T7) | (new (...args: any[]) => T7), ((...args: any[]) => T8) | (new (...args: any[]) => T8), ((...args: any[]) => T9) | (new (...args: any[]) => T9)]): [T1, T2, T3, T4, T5, T6, T7, T8, T9]; function acquire(dependencies: [((...args: any[]) => T1) | (new (...args: any[]) => T1), ((...args: any[]) => T2) | (new (...args: any[]) => T2), ((...args: any[]) => T3) | (new (...args: any[]) => T3), ((...args: any[]) => T4) | (new (...args: any[]) => T4), ((...args: any[]) => T5) | (new (...args: any[]) => T5), ((...args: any[]) => T6) | (new (...args: any[]) => T6), ((...args: any[]) => T7) | (new (...args: any[]) => T7), ((...args: any[]) => T8) | (new (...args: any[]) => T8)]): [T1, T2, T3, T4, T5, T6, T7, T8]; function acquire(dependencies: [((...args: any[]) => T1) | (new (...args: any[]) => T1), ((...args: any[]) => T2) | (new (...args: any[]) => T2), ((...args: any[]) => T3) | (new (...args: any[]) => T3), ((...args: any[]) => T4) | (new (...args: any[]) => T4), ((...args: any[]) => T5) | (new (...args: any[]) => T5), ((...args: any[]) => T6) | (new (...args: any[]) => T6), ((...args: any[]) => T7) | (new (...args: any[]) => T7)]): [T1, T2, T3, T4, T5, T6, T7]; function acquire(dependencies: [((...args: any[]) => T1) | (new (...args: any[]) => T1), ((...args: any[]) => T2) | (new (...args: any[]) => T2), ((...args: any[]) => T3) | (new (...args: any[]) => T3), ((...args: any[]) => T4) | (new (...args: any[]) => T4), ((...args: any[]) => T5) | (new (...args: any[]) => T5), ((...args: any[]) => T6) | (new (...args: any[]) => T6)]): [T1, T2, T3, T4, T5, T6]; function acquire(dependencies: [((...args: any[]) => T1) | (new (...args: any[]) => T1), ((...args: any[]) => T2) | (new (...args: any[]) => T2), ((...args: any[]) => T3) | (new (...args: any[]) => T3), ((...args: any[]) => T4) | (new (...args: any[]) => T4), ((...args: any[]) => T5) | (new (...args: any[]) => T5)]): [T1, T2, T3, T4, T5]; function acquire(dependencies: [((...args: any[]) => T1) | (new (...args: any[]) => T1), ((...args: any[]) => T2) | (new (...args: any[]) => T2), ((...args: any[]) => T3) | (new (...args: any[]) => T3), ((...args: any[]) => T4) | (new (...args: any[]) => T4)]): [T1, T2, T3, T4]; function acquire(dependencies: [((...args: any[]) => T1) | (new (...args: any[]) => T1), ((...args: any[]) => T2) | (new (...args: any[]) => T2), ((...args: any[]) => T3) | (new (...args: any[]) => T3)]): [T1, T2, T3]; function acquire(dependencies: [((...args: any[]) => T1) | (new (...args: any[]) => T1), ((...args: any[]) => T2) | (new (...args: any[]) => T2)]): [T1, T2]; function acquire(dependency: ((...args: any[]) => T) | (new (...args: any[]) => T)): T; function acquire(dependencies: ((...args: any[]) => any) | (new (...args: any[]) => any) | Function | Function[] | string | string[] | any[]): any; /** * Holds all classes and interfaces related to debugging components in platypus. */ namespace debug { /** * Handles all logging/debugging for the framework. All logs will be bubbled up to the * App.error event to allow for easy debugging. */ class Log { /** * The ERROR log level */ ERROR: number; /** * The WARN log level */ WARN: number; /** * The INFO log level */ INFO: number; /** * The DEBUG log level */ DEBUG: number; /** * The TRACE log level */ TRACE: number; /** * A configurable log level (defaults to INFO). Any logs sent below this * will be silent. */ protected _level: number; /** * The IErrorEventStatic injectable instance */ protected _ErrorEvent: events.IErrorEventStatic; /** * Logs fatal errors. This will throw the error after it is logged. * @param {Error} error The error to log. */ error(error: Error): void; /** * Logs at the warn level. * @param {Error} message The message to log. */ warn(message: string | Error): void; /** * Logs at the info level. * @param {string} message The message to log. */ info(message: string | Error): void; /** * Logs at the debug level. * @param {string} message The message to log. */ debug(message: string | Error): void; /** * Logs at the trace level. * @param {string} message The message to log. */ trace(message: string | Error): void; /** * Sets the log level level. * @param {string} level A string related to the log level to set (e.g. 'error'). It will be mapped to * the proper number. If the corresponding number level is not found, INFO * will be used. */ setLogLevel(level: number | string): void; /** * Dispatches an ErrorEvent to the app. * @param {number} level The log level denoting the severity of the message. */ protected _log(message: string | Error, level: number): void; /** * Determines whether or not a log level is at or above the current minimum log level. * @param {number} level The log level to check against the current minimum log level. */ protected _shouldLog(level: number): boolean; } } /** * A class containing boolean values signifying browser * and/or platform compatibilities. */ class Compat { protected static _inject: any; /** * The window injectable. */ protected _window: Window; /** * The window.history injectable. */ protected _history: History; /** * The document injectable. */ protected _document: Document; /** * Determines if the browser is modern enough to correctly * run PlatypusTS. */ isCompatible: boolean; /** * Signifies whether or not Cordova is defined. If it is, * we hook up ALM events to Cordova's functions. */ cordova: boolean; /** * Signifies whether window.history.pushState is defined. */ pushState: boolean; /** * Signifies whether the File API is supported. */ fileSupported: boolean; /** * Signifies whether Require is present. If it is, we assume * it is going to be used and leave the loading of the app up * to the developer. */ amd: boolean; /** * Signifies whether we are in the context of a Windows 8 app. */ msApp: boolean; /** * Signifies whether we are in the context of a WinJS app. */ winJs: boolean; /** * Signifies whether indexedDB exists on the window. */ indexedDb: boolean; /** * Signifies whether Object.prototype.__proto__ exists. */ proto: boolean; /** * Signifies whether Object.prototype.getPrototypeOf exists. */ getProto: boolean; /** * Signifies whether Object.prototype.setPrototypeOf exists. */ setProto: boolean; /** * Whether or not the current browser has touch events * like touchstart, touchmove, touchend, etc. */ hasTouchEvents: boolean; /** * Whether or not the current browser has pointer events * like pointerdown, MSPointerMove, pointerup, etc. */ hasPointerEvents: boolean; /** * Whether or not the current browser has touch events * like MSPointerDown, touchmove, MSPointerUp, etc. */ hasMsPointerEvents: boolean; /** * Whether or not the browser supports animations. */ animationSupported: boolean; /** * Whether the platypus.css file was included or not. */ platCss: boolean; /** * An object containing the correctly mapped touch events for the browser. */ mappedEvents: IMappedTouchEvents; /** * An object containing the properly prefixed animation events. * Undefined if animation isn't supported. */ animationEvents: IAnimationEvents; /** * An object containing information regarding any potential vendor prefix. */ vendorPrefix: IVendorPrefix; /** * The browser's requestAnimationFrame function if one exists. Otherwise undefined. */ requestAnimationFrame: (callback: FrameRequestCallback) => number; /** * The browser's cancelAnimationFrame function if one exists. Otherwise undefined. */ cancelAnimationFrame: (handle: number) => void; /** * The version of Internet Explorer being used. If not Internet Explorer, the value is undefined. */ IE: number; /** * The version of Android being used. If not Android, the value is undefined. */ ANDROID: number; /** * An object containing all event lookups. */ private __events; /** * Define everything. */ constructor(); /** * Check whether or not an event exists. * @param {string} event The event to check the existence of. */ hasEvent(event: string): boolean; /** * Define booleans. */ private __defineBooleans; /** * Define mapped events */ private __defineMappedEvents; /** * Define animation events and other vendor prefix * dependencies. */ private __defineVendorDependencies; /** * Determines whether or not platypus css styles exist. */ private __determineCss; } /** * Describes an object containing the correctly mapped touch events for the browser. */ interface ITouchMapping extends IObject { /** * An event type for touch start. */ $touchstart: T; /** * An event type for touch end. */ $touchend: T; /** * An event type for touch move. */ $touchmove: T; /** * An event type for touch cancel. */ $touchcancel: T; } /** * Describes an object containing the correctly mapped touch events for the browser. */ interface IMappedTouchEvents extends ITouchMapping { /** * An event type for touch start. */ $touchstart: string; /** * An event type for touch end. */ $touchend: string; /** * An event type for touch move. */ $touchmove: string; /** * An event type for touch cancel. */ $touchcancel: string; } /** * Describes an object containing the properly prefixed animation events. */ interface IAnimationEvents extends IObject { /** * The animation identifier. */ $animation: string; /** * The animation start event. */ $animationStart: string; /** * The animation end event. */ $animationEnd: string; /** * The animation iteration event. */ $animationIteration: string; /** * The transition identifier. */ $transition: string; /** * The transition start event. */ $transitionStart: string; /** * The transition end event. */ $transitionEnd: string; } /** * Describes an object that contains information regarding the browser's * vendor prefix. */ interface IVendorPrefix extends IObject { /** * The DOM based representation of the browser's vendor prefix generally denoted * by it beginning with a capital letter and camel-cased throughout. */ dom: string; /** * The lowercase representation of the browser's vendor prefix. */ lowerCase: string; /** * The css representation of the browser's vendor prefix * denoted by -{prefix}-. */ css: string; /** * The common uppercase representation of the browser's vendor prefix * generally denoted by it beginning with a capital letter. */ upperCase: string; } /** * An extensible class defining common utilities and helper functions. */ class Utils { /** * An empty method for quickly creating dummy objects. */ noop(): void; /** * Allows you to extend the properties of an object with any number * of other objects. If objects share properties, the last object in the * arguments will take precedence. This method is only a shallow copy of * all the source objects to the destination object. * @param {any} destination The destination object to extend. * @param {Array} ...sources Any number of objects with which to extend the * destination object. */ extend(destination: any, ...sources: any[]): any; /** * Allows you to extend the properties of an object with any number * of other objects. If objects share properties, the last object in the * arguments will take precedence. This method is a deep copy of * all the source objects to the destination object. * @param {any} destination The destination object to extend. * @param {Array} ...sources Any number of objects with which to extend the * destination object. */ deepExtend(destination: any, ...sources: any[]): any; /** * Creates a copy of the passed-in object. If deep is true it will * be a deep copy (duplicate), else nested objects/arrays will be copied by reference * and not duplicated. * @param {T} obj The object to clone. * @param {boolean} deep? Whether or not it is a deep clone. */ clone(obj: T, deep?: boolean): T; /** * Takes in anything and determines if it is a type of Object. * @param {any} obj Anything. */ isObject(obj: any): obj is Object; /** * Takes in anything and determines if it is a window object. * @param {any} obj Anything. */ isWindow(obj: any): obj is Window; /** * Takes in anything and determines if it is a document object. * @param {any} obj Anything. */ isDocument(obj: any): obj is Document; /** * Takes in anything and determines if it is a Node. * @param {any} obj Anything. */ isNode(obj: any): obj is Node; /** * Takes in anything and determines if it is a DocumentFragment. * @param {any} obj Anything. */ isDocumentFragment(obj: any): obj is DocumentFragment; /** * Takes in anything and determines if it is a string. * @param {any} obj Anything. */ isString(obj: any): obj is string; /** * Takes in anything and determines if it is a RegExp object. * @param {any} obj Anything. */ isRegExp(obj: any): obj is RegExp; /** * Takes in anything and determines if it is a Promise object. * @param {any} obj Anything. */ isPromise(obj: any): boolean; /** * Takes in anything and determines if it is empty. Useful for * checking for empty strings, arrays, or objects without keys. * @param {any} obj Anything. */ isEmpty(obj: any): boolean; /** * Takes in anything and determines if it is a boolean. * @param {any} obj Anything. */ isBoolean(obj: any): obj is boolean; /** * Takes in anything and determines if it is a number. * @param {any} obj Anything. */ isNumber(obj: any): obj is number; /** * Takes in anything and determines if it is a File. * @param {any} obj Anything. */ isFile(obj: any): obj is File; /** * Takes in anything and determines if it is a function. * @param {any} obj Anything. */ isFunction(obj: any): obj is Function; /** * Takes in anything and determines if it is null or undefined. * @param {any} obj Anything. */ isNull(obj: any): obj is null | undefined; /** * Takes in anything and determines if it is undefined. * @param {any} obj Anything. */ isUndefined(obj: any): obj is undefined; /** * Takes in anything and determines if it is an Array. * @param {any} obj Anything. */ isArray(obj: any): obj is any[]; /** * Takes in anything and determines if it has array-like qualities. * @param {any} obj Anything. */ isArrayLike(obj: any): obj is ArrayLike; /** * Takes in anything and determines if it is a Date object. * @param {any} obj Anything. */ isDate(obj: any): obj is Date; /** * Limits the rate at which a function can fire. * @param {Function} fn The function to debounce * @param {number} wait The amount of time to wait before calling fn (default=500ms) * @param {boolean} immediate Used to immediately call fn */ debounce(fn: Function, wait?: number, immediate?: boolean): Function; /** * Takes in an array and a function to evaluate the properties in the array. * Returns a filtered array of objects resulting from evaluating the function. * @param {plat.IListIterator} iterator The iterator function to call with array's properties. * Returns true if the property should be kept, false otherwise. * @param {Array} array The Array to filter. * @param {any} context? An optional context to bind to the iterator. */ filter(iterator: IListIterator, array: T[], context?: any): T[]; /** * Takes in an object/array and a function to evaluate the properties in the object/array. * Returns a filtered array of objects resulting from evaluating the function. * @param {plat.IObjectIterator} iterator The iterator function to call with array's properties. * Returns true if the property should be kept, false otherwise. * @param {plat.IObject} obj The object to filter. * @param {any} context? An optional context to bind to the iterator. */ filter(iterator: IObjectIterator, obj: IObject, context?: any): T[]; /** * Takes in a list and object containing key/value pairs to search for in the list. * @param {Object} properties An object containing key/value pairs to match with object's values. * @param {Array} array The list used for searching for properties. */ where(properties: Object, array: T[]): T[]; /** * Takes in an Array and a function to iterate over. Calls the iterator function with every property * in the Array, then returns the object. * @param {plat.IListIterator} iterator A method that takes in a value, index, and the object. * @param {Array} array An Array. * @param {any} context? An optional context to bind to the iterator. */ forEach(iterator: IListIterator, array: T[], context?: any): T[]; /** * Takes in an Array and a function to iterate over. Calls the iterator function with every property * in the Array, then returns the object. * @param {plat.IObjectIterator} iterator A method that takes in a value, index, and the object. * @param {plat.IObject} obj An object. * @param {any} context? An optional context to bind to the iterator. */ forEach(iterator: IObjectIterator, obj: IObject, context?: any): IObject; /** * Takes in an object and an iterator function. Calls the iterator with all the values in the object. The * iterator can transform the object and return it. The returned values will be pushed to an Array and * returned. * @param {plat.IListIterator} iterator The transformation function. * @param {Array} array An Array. * @param {any} context? An optional context to bind to the iterator. */ map(iterator: IListIterator, array: T[], context?: any): R[]; /** * Takes in an object and an iterator function. Calls the iterator with all the values in the object. The * iterator can transform the object and return it. The returned values will be pushed to an Array and * returned. * @param {(value: T, index: number, obj: any) => U} iterator The transformation function. * @param {plat.IObject} obj An Object. * @param {any} context? An optional context to bind to the iterator. */ map(iterator: IObjectIterator, obj: IObject, context?: any): R[]; /** * Takes in an array and an iterator function. Calls the iterator with all the values in the array. The * iterator can return a promise the will resolve with the mapped value. The returned values will be pushed * to an Array. A promise is returned that will resolve when all the iterators have resolved. * @param {plat.IListIterator>} iterator The transformation function. * @param {Array} array An array. * @param {any} context? An optional context to bind to the iterator. */ mapAsync(iterator: IListIterator>, array: T[], context?: any): async.Promise; /** * Takes in an object and an iterator function. Calls the iterator with all the values in the object. The * iterator can return a promise the will resolve with the mapped value. The returned values will be pushed * to an Array. A promise is returned that will resolve when all the iterators have resolved. * @param {plat.IObjectIterator>} iterator The transformation function. * @param {plat.IObject} obj An Object. * @param {any} context? An optional context to bind to the iterator. */ mapAsync(iterator: IObjectIterator>, obj: IObject, context?: any): async.Promise; /** * Takes in an array and an iterator function. Calls the iterator with all the values in the array. The * iterator can return a promise the will resolve with the mapped value. The next value in the array will not be passed to * the iterator until the previous promise fulfills. * @param {plat.IListIterator>} iterator The transformation function. * @param {Array} array An Array. * @param {any} context? An optional context to bind to the iterator. */ mapAsyncInOrder(iterator: IListIterator>, array: T[], context?: any): async.Promise; /** * Takes in an array and an iterator function. Calls the iterator with all the values in the array in descending order. The * iterator can return a promise the will resolve with the mapped value. The next value in the array will not be passed to * the iterator until the previous promise fulfills. * @param {plat.IListIterator>} iterator The transformation function. * @param {Array} array An Array. * @param {any} context? An optional context to bind to the iterator. */ mapAsyncInDescendingOrder(iterator: IListIterator>, array: T[], context?: any): async.Promise; /** * Takes in an object and a property to extract from all of the object's values. Returns an array of * the 'plucked' values. * @param {string} key The property to 'pluck' from each value in the array. * @param {Array} array The array to pluck the key from */ pluck(key: string, array: T[]): any[]; /** * Takes in an array and an iterator. Evaluates all the values in the array with the iterator. * Returns true if any of the iterators return true, otherwise returns false. * @param {plat.IListIterator} iterator A method with which to evaluate all the values in obj. * @param {Array} array An array. * @param {any} context? An optional context to bind to the iterator. */ some(iterator: IListIterator, array: T[], context?: any): boolean; /** * Takes in an array and an iterator. Evaluates all the values in the array with the iterator. * Returns true if any of the iterators return true, otherwise returns false. * @param {plat.IObjectIterator} iterator A method with which to evaluate all the values in obj. * @param {plat.IObject} obj An object. * @param {any} context? An optional context to bind to the iterator. */ some(iterator: IObjectIterator, obj: IObject, context?: any): boolean; /** * Takes in a method and array of arguments to pass to that method. Delays calling the method until * after the current call stack is clear. Equivalent to a setTimeout with a timeout of 0. * @param {(...args: Array) => void} method The method to call. * @param {Array} args? The arguments to apply to the method. * @param {any} context? An optional context to bind to the method. */ postpone(method: (...args: any[]) => void, args?: any[], context?: any): IRemoveListener; /** * Takes in a method and array of arguments to pass to that method. Delays calling the method until * after the current call stack is clear. Equivalent to a setTimeout with the specified timeout value. * @param {(...args: Array) => void} method The method to call. * @param {number} timeout The time (in milliseconds) to delay before calling the provided method. * @param {Array} args? The arguments to apply to the method. * @param {any} context? An optional context to bind to the method. */ defer(method: (...args: any[]) => void, timeout: number, args?: any[], context?: any): IRemoveListener; /** * Takes in a method and array of arguments to pass to that method. Adds the method to the call stack every * interval amount of time. Equivalent to a setInterval with the specified interval value. * @param {(...args: Array) => void} method The method to call. * @param {number} interval The time (in milliseconds) between each consecutive call of the provided method. * @param {Array} args? The arguments to apply to the method. * @param {any} context? An optional context to bind to the method. */ setInterval(method: (...args: any[]) => void, interval: number, args?: any[], context?: any): IRemoveListener; /** * Uses requestAnimationFrame if it is available, else it does a setTimeout. * @param {FrameRequestCallback} method The method to call when the request is fulfilled. * @param {any} context? An optional context to bind to the method. */ requestAnimationFrame(method: FrameRequestCallback, context?: any): IRemoveListener; /** * Takes in a prefix and returns a unique identifier string with the prefix prepended. If no prefix * is specified, none will be prepended. * @param {string} prefix? A string prefix to prepend to the unique ID. */ uniqueId(prefix?: string): string; /** * Takes in a spinal-case, dot.case, or snake_case string and returns * a camelCase string. Also can turn a string into camelCase with space * as a delimiter. * @param {string} str The spinal-case, dot.case, or snake_case string. */ camelCase(str: string): string; /** * Takes a camelCase string and delimits it using the specified delimiter. * @param {string} str The camelCased string. * @param {string} delimiter The delimiter to add. */ delimit(str: string, delimiter: string): string; } /** * The Type for a Utils list iterator callback method. */ type IListIterator = (value: T, index: number, list: T[]) => R; /** * The Type for a Utils object iterator callback method. */ type IObjectIterator = (value: T, key: string, obj: IObject) => R; /** */ function Window(): Window; /** */ function Document(_window?: Window): Document; /** * Holds classes and interfaces related to expression handling in platypus. */ namespace expressions { /** * A class for keeping track of commonly used regular expressions. */ class Regex { /** * A regular expression for finding markup in a string. */ markupRegex: RegExp; /** * Finds the arguments in a method expression. */ argumentRegex: RegExp; /** * Finds '/*.html' or '/*.htm' in a url. Useful for removing * the html file out of the url. */ initialUrlRegex: RegExp; /** * Finds a protocol delimiter in a string (e.g. ://). */ protocolRegex: RegExp; /** * Looks for any invalid variable syntax. */ invalidVariableRegex: RegExp; /** * Grabs the file name from a file path. */ fileNameRegex: RegExp; /** * Determines if a character is correlated with a shifted key code. */ shiftedKeyRegex: RegExp; /** * Determines if a url is relative or absolute. */ fullUrlRegex: RegExp; /** * Determines if an email address is valid. */ validateEmail: RegExp; /** * Determines if a telephone number is valid. */ validateTelephone: RegExp; /** * A regular expression for matching dynamic segments in a route. */ dynamicSegmentsRegex: RegExp; /** * A regular expression for matching splat segments in a route. */ splatSegmentRegex: RegExp; /** * A regular expression for matching or removing all newline characters. */ readonly newLineRegex: RegExp; /** * Finds optional parameters in a route string. */ readonly optionalRouteRegex: RegExp; /** * Finds named parameters in a route string. */ readonly namedParameterRouteRegex: RegExp; /** * Finds an alphanumeric wildcard match in a route string. * exec('/foo/*bar/baz'); */ readonly wildcardRouteRegex: RegExp; /** * Finds invalid characters in a route string. */ readonly escapeRouteRegex: RegExp; /** * Finds delimiters for spinal-case, snake_case, and dot.case. * useful for converting to camelCase. Also can turn a string * into camelCase with space as a delimiter. */ readonly camelCaseRegex: RegExp; /** * Finds all capital letters. */ readonly capitalCaseRegex: RegExp; /** * Finds all whitespace and newline characters * not in string literals. Needs to be combined * with string replace function using $1 argument. */ readonly whiteSpaceRegex: RegExp; /** * Finds all single and double quotes. */ readonly quotationRegex: RegExp; } /** * A class that is responsible for taking in a JavaScript expression string and * finding all of its tokens (i.e. delimiters, operators, etc). */ class Tokenizer { protected static _inject: any; /** * Reference to the Log injectable. */ protected _log: debug.Log; /** * The input string to tokenize. */ protected _input: string; /** * The previous character during tokenization. */ private __previousChar; /** * A regular expression for determining if a potential variable is valid syntax. */ private __variableRegex; /** * A queue used for determining the output of the tokenization. */ private __outputQueue; /** * A stack used for determining operator precedence and aiding with the evaluation * operands. */ private __operatorStack; /** * A collection used for determining argument count for certain operations. */ private __argCount; /** * A collection used for determining argument count for certain object literal operations. */ private __objArgCount; /** * The last character encountered while in an operation dealing with the colon operator. * Needs to be an array due to the possibility of nested colon operations. */ private __lastColonChar; /** * The last character encountered while in an operation dealing with commas. * Needs to be an array due to the possibility of nested comma operations. */ private __lastCommaChar; /** * Takes in an expression string and outputs a tokenized collection of * ITokens. * @param {string} input The JavaScript expression string to tokenize. */ createTokens(input: string): IToken[]; /** * Determines character type. * @param {string} char The character to check. * @param {boolean} isNumberLike Whether or not the character resembles a number. */ protected _checkType(char: string, isNumberLike: boolean): boolean; /** * Looks ahead in the expression to group similar character types. * @param {string} char The current character in the expression string. * @param {number} index The current index in the expression string. * @param {boolean} isNumberLike Whether or not the character resembles a number. */ protected _lookAhead(char: string, index: number, isNumberLike: boolean): string; /** * Looks ahead in the expression to try and complete the * current operator. * @param {string} char The operator to find. * @param {number} index The current index in the expression string. */ protected _lookAheadForOperatorFn(char: string, index: number): string; /** * Looks ahead in the expression until it comes to the ending * character to try and complete a particular sequence * (e.g. - a string literal). Also strips the first and last * characters of the result (i.e. removes the delimiters). * @param {string} endChar The ending character. * @param {number} index The current index in the expression string. */ protected _lookAheadForDelimiter(endChar: string, index: number): string; /** * Pops the operator stack onto the output queue until a particular * operator value is reached. * @param {plat.expressions.IToken} topOperator The top of the operator stack. * @param {string} char The operator value being searched for. * @param {string} error The error to throw in the case that the expression * is invalid. */ protected _popStackForVal(topOperator: IToken, char: string, error: string): void; /** * Check if the "val" property on an IToken * is present in a particular character string. * @param {plat.expressions.IToken} obj The IToken * with the "val" property to compare. * @param {string} char The char to compare with. */ protected _isValEqual(obj: IToken, char: string): boolean; /** * Check if the "val" property on an IToken * is not present in a particular character string. * @param {plat.expressions.IToken} obj The IToken * with the "val" property to compare. * @param {string} char The char to compare with. */ protected _isValUnequal(obj: IToken, char: string): boolean; /** * Resets all the tokenizer's properties. */ protected _resetTokenizer(): void; /** * Throws a fatal exception in the case of an error. * @param {string} error The error message to throw. */ protected _throwError(error: string): void; /** * Checks if a single character is numeric. * @param {string} char The character to check. */ protected _isNumeric(char: string): boolean; /** * Checks if a single character is a space. * @param {string} char The character to check. */ protected _isSpace(char: string): boolean; /** * Checks if a single character is alphanumeric. * @param {string} char The character to check. */ protected _isAlphaNumeric(char: string): boolean; /** * Checks if a string has proper JavaScript variable syntax. * @param {string} input The string to check. */ protected _isStringValidVariable(input: string): boolean; /** * Handles tokenizing an alphanumeric character. * @param {number} index The current index in the string being tokenized. * @param {string} char The current char. */ private __handleAlphaNumeric; /** * Handles tokenizing a "." character. * @param {number} index The current index in the string being tokenized. * @param {string} char The current char. */ private __handlePeriod; /** * Handles tokenizing a "{" character. * @param {string} char The current char. */ private __handleLeftBrace; /** * Handles tokenizing a "}" character. * @param {string} char The current char. */ private __handleRightBrace; /** * Handles tokenizing a "[" character. * @param {string} char The current char. */ private __handleLeftBracket; /** * Handles tokenizing a "]" character. * @param {string} char The current char. */ private __handleRightBracket; /** * Handles tokenizing a "(" character. * @param {string} char The current char. */ private __handleLeftParenthesis; /** * Handles tokenizing a ")" character. * @param {string} char The current char. */ private __handleRightParenthesis; /** * Handles tokenizing a "," character. * @param {string} char The current char. */ private __handleComma; /** * Handles tokenizing a string literal. * @param {number} index The current index in the string being tokenized. * @param {string} char The current char. */ private __handleStringLiteral; /** * Handles tokenizing a "?" character. * @param {string} char The current char. */ private __handleQuestion; /** * Handles tokenizing a ":" character. * @param {string} char The current char. * @param {number} ternary The current ternary counter. Increments when a ternary is found, * decrements when a ternary is completed. It can be very useful when there is nested ternaries. */ private __handleColon; /** * Handles tokenizing all other operators. * @param {number} index The current index in the string being tokenized. * @param {string} char The current char. */ private __handleOtherOperator; /** * Pops operators left on the operator stack onto the output queue * checking for mismatches. */ private __popRemainingOperators; /** * Grabs essential token details for a given operator. * @param {string} operator The operator whose details are being requested. */ private __determineOperator; /** * Determines the precedence of a given operator in relation to other operators * in the operator stack and places it in the operator stack. * @param {string} operator The operator whose precedence is being determined. */ private __determinePrecedence; /** * Removes a reference to a function that is present in the operator stack and places * it in the output queue. * @param {number} argCount The current local argument count used with functions, * arrays, and object literals. */ private __removeFnFromStack; } /** * Describes a single token in a string expression. */ interface IToken { /** * The string or number value of the token. */ val: any; /** * Denotes the type of token, as well as the number * of arguments for a function if it is the token. */ args: number; } /** * Provides all the necessary details on how to evaluate a token. */ interface ITokenDetails { /** * The precedence that this token takes with respect to the * evaluation order. */ precedence: number; /** * Whether or not the token associates with the expression on * their left or right. */ associativity: string; /** * A function used to evaluate an operator expression. */ fn: Function; } /** * A class for parsing JavaScript expression strings and creating * IParsedExpressions. */ class Parser { protected static _inject: any; /** * Reference to the Tokenizer injectable. */ protected _tokenizer: Tokenizer; /** * Reference to the Log injectable. */ protected _log: debug.Log; /** * A single expression's token representation created by a Tokenizer. */ protected _tokens: IToken[]; /** * An expression cache. Used so that a JavaScript expression is only ever parsed once. */ private __cache; /** * A dynamically built string array that represents the evaluation function. */ private __codeArray; /** * A list of all the identifiers discovered in the JavaScript expression string. */ private __identifiers; /** * A temporary list of identifiers found used to build and evaluate each actual identifier. */ private __tempIdentifiers; /** * An object whose keys represent a list of all unique aliases found in the JavaScript expression string. */ private __aliases; /** * The constant that needs to be prepended to every dynamic eval function. */ private __fnEvalConstant; /** * Parses a JavaScript expression string. * @param {string} expression The JavaScript expression string to parse. */ parse(expression: string): IParsedExpression; /** * If a key is passed in, it clears that single value in the expression cache. If no * key is present, the entire expression cache will be cleared. * @param {string} key? An optional key that will clear its stored value in the expression * cache if passed in. */ clearCache(key?: string): void; /** * Evaluate the current IToken array. * @param {string} expression The JavaScript expression to evaluate. */ protected _evaluate(expression: string): IParsedExpression; /** * Peek at the next IToken. * @param {number} index The index before the desired IToken * in the array. */ protected _peek(index: number): IToken; /** * Look back at the previous IToken. * @param {number} index The index after the desired IToken * in the array. */ protected _lookBack(index: number): IToken; /** * Evaluate and remove the leftover identifiers. */ protected _popRemainingIdentifiers(): void; /** * Remove duplicate identifiers. */ protected _makeIdentifiersUnique(): void; /** * Check if the "val" property on an IToken * is present in a particular character string. * @param {plat.expressions.IToken} obj The IToken * with the "val" property to compare. * @param {string} char The char to compare with. */ protected _isValEqual(obj: IToken, char: string): boolean; /** * Check if the "val" property on an IToken * is not present in a particular character string. * @param {plat.expressions.IToken} obj The IToken * with the "val" property to compare. * @param {string} char The char to compare with. */ protected _isValUnequal(obj: any, char: string): boolean; /** * Resets all the parser's properties. */ protected _resetParser(): void; /** * Throws a fatal exception in the case of an error. * @param {string} error The error message to throw. */ protected _throwError(error: string): void; /** * Handles a token that is a primitive value. * @param {number} index The current index in the IToken array. * @param {string} token The current IToken value. * @param {number} args The current IToken args. */ private __convertPrimitive; /** * Handles a potential function or object that needs to be indexed into. * @param {number} index The current index in the IToken array. * @param {string} token The current IToken value. * @param {boolean} useLocalContext Whether or not we need to use an already parsed object as the current context. */ private __convertFunction; /** * Handles an object literal. * @param {number} args The current IToken args. */ private __convertObject; /** * Handles an Array literal. * @param {number} args The current IToken args. */ private __convertArrayLiteral; /** * Handles an accessor type function token "()". * @param {number} index The current index in the IToken array. * @param {number} args The current IToken args. * @param {boolean} useLocalContext Whether or not we need to use an already parsed object as the current context. */ private __handleFunction; /** * Handles an accessor type token that is for indexing (i.e. "." or "[]"). * @param {number} index The current index in the IToken array. * @param {string} token The current IToken value. * @param {boolean} useLocalContext Whether or not we need to use an already parsed object as the current context. */ private __indexIntoObject; /** * Handles the "?" operator. */ private __handleQuestion; /** * Handles the ":" operator. */ private __handleColon; /** * Handles all other operators. * @param {string} token The current IToken value. * @param {number} args The current IToken args. */ private __handleOperator; /** * Safely finds an initial context. * @param {any} context The context object. * @param {any} aliases Any aliases that may exist. * @param {string} token The property used to find the initial context. */ private __findInitialContext; /** * Safely drills down into a specified context with a given token. * @param {any} context The context object. * @param {string} token The property used to drill into the context. */ private __indexIntoContext; } /** * Describes an object that is the result of parsing a JavaScript expression string. It contains detailed * information about the expression as well as a way to evaluate the expression with a context. */ interface IParsedExpression { /** * The original expression string. */ expression: string; /** * Contains all the identifiers found in an expression. Useful for determining * properties to watch on a context. */ identifiers: string[]; /** * Contains all the aliases (denoted without `@` as the first character) for this * IParsedExpression. */ aliases: string[]; /** * Specifies whether or not you want to do a one-time binding on identifiers * for this expression. Typically this is added to a clone of this * IParsedExpression. */ oneTime?: boolean; /** * A method for evaluating an expression with a context. * @param {any} context? The primary context for evaluation. * @param {IObject} aliases? An object containing resource alias values. * All property keys must never begin with `@`. */ evaluate(context?: any, aliases?: IObject): any; } } /** * Holds classes and interfaces related to web components in platypus. */ namespace web { /** */ function Location(_window?: Window): Location; /** * The class that handles all interaction with the browser. */ class Browser { protected static _inject: any; /** * The IBrowserConfig injectable object. */ static config: IBrowserConfig; /** * Reference to the IEventManagerStatic injectable. */ protected _EventManager: events.IEventManagerStatic; /** * Reference to the Compat injectable. */ protected _compat: Compat; /** * Reference to the Regex injectable. */ protected _regex: expressions.Regex; /** * Reference to the Window injectable. */ protected _window: Window; /** * Reference to the Location injectable. */ protected _location: Location; /** * Reference to the History injectable. */ protected _history: History; /** * Reference to the Dom injectable. */ protected _dom: ui.Dom; /** * Keeps a history stack if using a windows store app. */ protected _stack: string[]; /** * A unique string identifier. */ uid: string; /** * The browser's current URL. */ private __currentUrl; /** * The browser's last URL. */ private __lastUrl; /** * The local url protocol. */ private __protocol; /** * Whether or not the browser is in an initialization state. */ private __initializing; /** * The constructor for a Browser. Assigns a uid and subscribes to the 'beforeLoad' event. */ constructor(); /** * Initializes the Browser instance, trims the url, and * adds events for popstate and hashchange. */ initialize(): void; /** * Sets or gets the current _window.location * @param {string} url? The URL to set the location to. * @param {boolean} replace? Whether or not to replace the current URL in * the history. */ url(url?: string, replace?: boolean): string; /** * Navigates back in the browser history * @param {number} length=1 The length to go back */ back(length?: number): void; /** * Navigates forward in the browser history * @param {number} length=1 The length to go forward */ forward(length?: number): void; /** * Creates a new UrlUtils object. * @param url? The URL to associate with the new UrlUtils * instance. */ urlUtils(url?: string): UrlUtils; /** * Checks to see if the requested URL is cross domain. * @param url The URL to verify whether or not it's cross domain. */ isCrossDomain(url: string): boolean; /** * Formats the URL in the case of HASH routing. * @param url The URL to format. */ formatUrl(url: string): string; /** * The event to fire in the case of a URL change. It kicks * off a 'urlChanged' direct event notification. * @param url The URL to verify whether or not it's cross domain. */ protected _urlChanged(): void; /** * Checks for the existence of pushState and * sets the browser URL accordingly. * @param {string} url The URL to set. * @param {boolean} replace? Whether or not to replace the * current URL in the history. */ protected _setUrl(url: string, replace?: boolean): void; /** * Determines if the url is equal to the last url * @param {string} url The URL to match */ protected _isLastUrl(url: string): boolean; /** * Trims trailing slashes from a url. * @param {string} url The URL to trim */ protected _trimSlashes(url: string): string; } /** */ function IBrowserConfig(): IBrowserConfig; /** * Specifies configuration properties for the Browser * injectable. */ interface IBrowserConfig { /** * Specifies that the application wants to use hash-based * routing. */ HASH: string; /** * Specifies that the application wants to use the HTML5 * popstate method for managing routing. If the browser * does not support HTML5 popstate events, hash routing * will be used instead. */ STATE: string; /** * Allows you to define how your app will route. There are * three modes, NONE ('none'), HASH ('hash'), and STATE ('state'). */ routingType: string; /** * If routingType is set to HASH ('hash'), this value will be * appended to the '#' at the beginning of every route. The * default prefix is '!', meaning each path will be '#!/'. */ hashPrefix: string; /** * Specifies the base URL used to normalize URL routing. */ baseUrl: string; } /** * Deals with obtaining detailed information about an * associated URL. */ class UrlUtils { protected static _inject: any; /** * Helps with URL initialization through it's href attribute. */ private static __urlUtilsElement; /** * Reference to the Document injectable. */ protected _document: Document; /** * Reference to the Window injectable. */ protected _window: Window; /** * Reference to the Compat injectable. */ protected _compat: Compat; /** * Reference to the Regex injectable. */ protected _regex: expressions.Regex; /** * Reference to the IBrowserConfig injectable. */ protected _browserConfig: IBrowserConfig; /** * The whole associated URL. */ href: string; /** * The protocol scheme of the URL, including the final ':' of the associated URL. */ protocol: string; /** * The hostname and port of the associated URL. */ host: string; /** * The domain of the associated URL. */ hostname: string; /** * The port number of the associated URL. */ port: string; /** * The additional path value in the associated URL preceded by a '/'. * Removes the query string. */ pathname: string; /** * A '?' followed by the included parameters in the associated URL. */ search: string; /** * A '#' followed by the included hash fragments in the associated URL. */ hash: string; /** * The username specified before the domain name in the associated URL. */ username: string; /** * The password specified before the domain name in the associated URL. */ password: string; /** * The origin of the associated URL (its protocol, domain, and port). */ origin: string; /** * An object containing keyed query arguments from the associated URL. */ query: any; /** * Creates a query object out of the URL's query search string. * @param {string} search The URL's query search string. */ private static __getQuery; /** * Obtains the base URL for the app/site for doing STATE type routing. * @param {string} url The initial URL passed into the Browser. */ private static __getBaseUrl; /** * The constructor for a UrlUtils instance. * Handles parsing the initial URL and obtain the base URL if necessary. */ constructor(); /** * Initializes and defines properties using * the input url. * @param {string} url The input to associate with this UrlUtils instance. */ initialize(url: string): void; /** * A toString function implementation for the UrlUtils class. */ toString(): string; } } /** * Holds all classes and interfaces related to async components in platypus. */ namespace async { /** * Takes in a generic type corresponding to the fulfilled success type. */ class Promise implements PromiseLike { /** * The configuration for creating asynchronous promise flushing. */ static config: { async(callback: (arg?: PromiseLike) => void, arg?: PromiseLike): void; }; /** * Returns a promise that fulfills when every item in the array is fulfilled. * Casts arguments to promises if necessary. The result argument of the * returned promise is an array containing the fulfillment result arguments * in-order. The rejection argument is the rejection argument of the * first-rejected promise. * @param {Array} promises An array of objects, if an object is not a promise, it will be cast. */ static all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; static all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; static all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; static all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; static all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; static all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; static all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; static all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; static all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; static all(values: (T | PromiseLike)[]): Promise; /** * Returns a promise that fulfills as soon as any of the promises fulfill, * or rejects as soon as any of the promises reject (whichever happens first). * @param {Array} promises An Array of anything to 'race'. Objects that aren't promises will * be cast. */ static race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; static race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; static race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; static race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; static race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; static race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; static race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; static race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; static race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; static race(values: (T | PromiseLike)[]): Promise; /** * Returns a promise that resolves with the input value. * @param {T} value The value to resolve. */ static resolve(): Promise; static resolve(value?: T | PromiseLike): Promise; /** * Returns a promise that rejects with the input value. * @param {any} error The value to reject. */ static reject(error?: any): Promise; static reject(error?: any): Promise; /** * Invokes the resolve function for a promise. Handles error catching. * @param * {(resolve : (value?: TResult | PromiseLike) => void, reject: (error?: any) => void) => void} resolveFunction The resolve function to invoke. * @param {plat.async.Promise} promise The promise on which to invoke the resolve function. */ private static __invokeResolveFunction; /** * Invokes a callback for a promise with the specified detail. * @param {plat.async.State} settled The state of the promise. * @param {any} promise The promise object. * @param {(response: any) => void} callback The callback to invoke. * @param {any} detail The details to pass to the callback. */ private static __invokeCallback; /** * Publishes the promise details to all the subscribers for a promise. * @param {any} promise The promise object. * @param {plat.async.State} settled The state of the promise. */ private static __publish; /** * Publishes a promises that has been fulfilled. * @param {any} promise The promise object. */ private static __publishFulfillment; /** * Publishes a promises that has been rejected. * @param {any} promise The promise object. */ private static __publishRejection; /** * Asynchronously rejects a promise * @param {any} promise The promise object. * @param {any} reason The detail of the rejected promise. */ private static __reject; /** * Asynchronously fulfills a promise * @param {plat.async.Promise} promise The promise object. * @param {any} value The detail of the fulfilled promise. */ private static __fulfill; /** * Asynchronously fulfills a promise, allowing for promise chaining. * @param {plat.async.Promise} promise The promise object. * @param {any} value The detail of the fulfilled promise. */ private static __resolve; /** * Handles chaining promises together, when a promise is returned from within a then handler. * @param {plat.async.Promise} promise The promise object. * @param {plat.async.Promise} value The next promise to await. */ private static __handleThenable; /** * Adds a child promise to the parent's subscribers. * @param {plat.async.Promise} parent The parent promise. * @param {plat.async.Promise} value The child promise. * @param {(success: any) => any} onfulfilled The fulfilled method for the child. * @param {(error: any) => any} onRejected The rejected method for the child. */ private static __subscribe; /** * An ES6 implementation of the Promise API. Useful for asynchronous programming. * Takes in 2 generic types corresponding to the fulfilled success and error types. * The error type (U) should extend Error in order to get proper stack tracing. * @param {(resolve : (value?: T | PromiseLike) => void, reject: (error?: any) => void) => void} resolveFunction * A function for fulfilling/rejecting the Promise. */ constructor(resolveFunction: (resolve: (value?: T | PromiseLike) => void, reject: (error?: any) => void) => void); /** * Takes in two methods, called when/if the promise fulfills/rejects. * @param {(success: T) => U} onFulfilled A method called when/if the promise fulfills. If undefined the next * onFulfilled method in the promise chain will be called. * @param {(error: any) => U} onRejected A method called when/if the promise rejects. If undefined the next * onRejected method in the promise chain will be called. */ then(onFulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onRejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; /** * A wrapper method for Promise.then(undefined, onRejected); * @param {(error: any) => U} onRejected A method called when/if the promise rejects. If undefined the next * onRejected method in the promise chain will be called. */ catch(onRejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; /** * Outputs the Promise as a readable string. */ toString(): string; } /** */ function IPromise(_window?: any): IPromise; /** */ interface IPromise { new (resolveFunction: (resolve: (value?: R | PromiseLike) => void, reject: (error?: any) => void) => void): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; resolve(): Promise; resolve(value?: T | PromiseLike): Promise; reject(error?: any): Promise; reject(error?: any): Promise; } /** * HttpRequest provides a wrapper for the XMLHttpRequest object. Allows for * sending AJAX requests to a server. This class does not support * synchronous requests. */ class HttpRequest { protected static _inject: any; /** * The timeout ID associated with the specified timeout */ clearTimeout: IRemoveListener; /** * The created XMLHttpRequest */ xhr: XMLHttpRequest; /** * The JSONP callback name */ jsonpCallback: string; /** * Reference to the Log injectable. */ protected _log: debug.Log; /** * The plat.web.Browser injectable instance */ protected _browser: web.Browser; /** * The injectable instance of type Window */ protected _window: Window; /** * The injectable instance of type Document */ protected _document: Document; /** * The configuration for an HTTP Request */ protected _config: IHttpConfig; /** * Whether or not the browser supports the File API. */ private __fileSupported; /** * The configuration for the specific HTTP Request */ private __options; /** * The constructor for a HttpRequest. */ constructor(); /** * Initializes the HttpRequest with options. * @param {plat.async.IHttpConfig} options The IHttpConfigStatic used to customize this HttpRequest. */ initialize(options: IHttpConfig): void; /** * Executes an XMLHttpRequest and resolves an IAjaxPromise upon completion. */ execute(): AjaxPromise>; /** * Executes an JSONP request and resolves an IAjaxPromise upon completion. */ executeJsonp(): AjaxPromise>; /** * A wrapper for the XMLHttpRequest's onReadyStateChanged callback. */ protected _xhrOnReadyStateChange(): boolean; /** * The function that initializes and sends the XMLHttpRequest. */ protected _sendXhrRequest(): AjaxPromise>; /** * Returns a promise that is immediately rejected due to an error. */ protected _invalidOptions(): AjaxPromise>; /** * The function that formats the response from the XMLHttpRequest. * @param {string} responseType The user designated responseType * @param {boolean} success Signifies if the response was a success */ protected _formatResponse(responseType: string, success: boolean): IAjaxResponse; /** * Sets the headers for an XMLHttpRequest */ private __setHeaders; /** * Serializes multipart form data in an XMLHttpRequest as a string. */ private __serializeFormData; /** * Creates FormData to add to the XMLHttpRequest. */ private __appendFormData; /** * Handles submitting multipart form data using an iframe. */ private __submitFramedFormData; /** * Creates input for form data submissions. */ private __createInput; } /** * Describes an object which contains Ajax configuration properties. */ interface IHttpConfig extends IJsonpConfig { /** * The HTTP method type of XmlHttpRequest such as 'GET', 'POST', 'PUT', * 'DELETE', etc. Ignored for non-HTTP urls. Defaults to 'GET'. */ method?: string; /** * The number of milliseconds a request can take before * automatically being terminated. A value of 0 * means there is no timeout. */ timeout?: number; /** * An optional user string for the XmlHttpRequest */ user?: string; /** * An optional password string for the XmlHttpRequest */ password?: string; /** * The XMLHttpRequestResponseType. The response should * still be checked when received due to browser * incompatibilities. If a browser does not support a * response type it will return the value as a string. * The response type does not affect JSONP callback * arguments. */ responseType?: string; /** * The Content-Type header for XMLHttpRequest when * data is being sent. The default is * 'application/json;charset=utf-8;'. */ contentType?: string; /** * A string to override the MIME type returned by the server. */ overrideMimeType?: string; /** * A key/value pair object where the key is a DOMString header key * and the value is the DOMString header value. */ headers?: IObject; /** * Indicates whether or not cross-site Access-Control requests * should be made using credentials such as cookies or * authorization headers. The default is false. */ withCredentials?: boolean; /** * The request payload */ data?: any; /** * An array of data transform functions that fire in order and consecutively * pass the returned result from one function to the next. */ transforms?: IHttpTransformFunction[]; /** * Forces a JSONP, cross-domain request when set to true. * The default is false. */ isCrossDomain?: boolean; } /** * A function that is used to transform XMLHttpRequest data. */ type IHttpTransformFunction = (data: any, xhr: XMLHttpRequest) => any; /** * Describes an object which contains JSONP configuration properties. */ interface IJsonpConfig { /** * The url for the JSONP callback * (without the `?{callback}={callback_name}` parameter in the url) * or for the XmlHttpRequest. */ url: string; /** * The identifier the server uses to get the name of the JSONP * callback. The default is 'callback' as seen in * http://platypi.io/data?callback=plat_fnName. */ jsonpIdentifier?: string; /** * A specified name for the JSONP callback (in case the server has * it hard-coded and/or does not get it from the given url). The * default is a unique plat id generated separately for * each JSONP callback seen as 'plat_callback00' in * http://platypi.io/data?callback=plat_callback00. */ jsonpCallback?: string; } /** * Describes an object that is the response to an AJAX request. */ interface IAjaxResponse { /** * The AJAX response or responseText. The response should * be checked when received due to browser * incompatibilities with responseType. If a browser does * not support a response type it will return the value as * a string. */ response: R; /** * The XHR status. Resolves as 200 for JSONP. */ status: number; /** * The XMLHttpRequest object associated with the AJAX call */ xhr?: XMLHttpRequest; /** * A method for getting the XHR response headers. */ getAllResponseHeaders?(): string; } /** * A class that forms an Error object with an IAjaxResponse. */ class AjaxError implements Error, IAjaxResponse { /** * The name of the Error ('AjaxError') */ name: string; /** * The Error message */ message: string; /** * The response from the XMLHttpRequest */ response: any; /** * The status code from the XMLHttpRequest */ status: number; /** * A method for getting the XHR response headers. */ getAllResponseHeaders: () => string; /** * The XMLHttpRequest object associated with the AJAX call */ xhr: XMLHttpRequest; /** * The constructor for an AjaxError. * @param {plat.async.IAjaxResponse} response The IAjaxResponse object. */ constructor(response: IAjaxResponse); /** * Outputs a formatted string describing the AjaxError. */ toString(): string; } /** * Describes a type of Promise that fulfills with an IAjaxResponse * and can be optionally cancelled. */ class AjaxPromise extends Promise { /** * The Window object. */ protected _window: Window; /** * The HttpRequest object. */ private __http; /** * The constructor method for the {@link plat.async.AjaxPromise}. * @param {plat.async.IAjaxResolveFunction} resolveFunction The promise resolve function. * @param {any} promise The promise object to allow for cancelling the {@link plat.async.AjaxPromise}. */ constructor(resolveFunction: (resolve: (value?: T | PromiseLike) => void, reject: (error?: any) => void) => void, promise?: any); /** * A method to initialize this AjaxPromise, passing it the * associated IHttpRequest. * @param {plat.async.HttpRequest} http The http request for this promise. */ initialize(http: HttpRequest): void; /** * A method to cancel the AJAX call associated with this AjaxPromise. */ cancel(): void; /** * Takes in two methods, called when/if the promise fulfills/rejects. * @param {(success: plat.async.IAjaxResponse) => T} onFulfilled A method called when/if the promise fulfills. * If undefined the next onFulfilled method in the promise chain will be called. * @param {(error: plat.async.AjaxError) => T} onRejected A method called when/if the promise rejects. * If undefined the next onRejected method in the promise chain will be called. */ then(onFulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onRejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): AjaxPromise; /** * A wrapper method for Promise.then(undefined, onRejected); * @param {(error: any) => TResult} onRejected A method called when/if the promise rejects. If undefined the next * onRejected method in the promise chain will be called. */ catch(onRejected?: ((reason: AjaxError) => TResult | PromiseLike) | undefined | null): AjaxPromise; } /** * Describes an object that provides value mappings for XMLHttpRequestResponseTypes */ interface IHttpResponseType { /** * The default response type (empty string) */ DEFAULT: string; /** * The arrayBuffer type ('arrayBuffer') */ ARRAYBUFFER: string; /** * The blob type ('blob') */ BLOB: string; /** * The document type ('document') */ DOCUMENT: string; /** * The json type ('json') */ JSON: string; /** * The text type ('text') */ TEXT: string; } /** * Describes an object that provides Content-Type mappings for Http POST requests. */ interface IHttpContentType { /** * Standard denotation for form encoded data. All objects are converted * to string key-value pairs. */ ENCODED_FORM: string; /** * Standard denotation for JavaScript Object Notation (JSON). */ JSON: string; /** * Standard denotation for a multi-part Webform. Associated with * a content-type of 'multipart/form-data'. */ MULTIPART_FORM: string; /** * Standard denotation for arbitrary binary data. */ OCTET_STREAM: string; /** * Standard denotation for XML files. */ XML: string; /** * Standard denotation for textual data. */ PLAIN_TEXT: string; /** * Standard denotation for HTML. */ HTML: string; } /** * The instantiated class of the injectable for making * AJAX requests. */ class Http { /** * Default Http config */ static config: IHttpConfig; /** * Provides value mappings for XMLHttpRequestResponseTypes */ responseType: IHttpResponseType; /** * Provides Content-Type mappings for Http POST requests. */ contentType: IHttpContentType; /** * A wrapper method for the Http class that creates and executes a new Http with * the specified IHttpConfig. This function will check if * XMLHttpRequest level 2 is present, and will default to JSONP if it isn't and * the request is cross-domain. * @param {plat.async.IHttpConfig} options The IHttpConfig for either the XMLHttpRequest * or the JSONP callback. */ ajax(options: IHttpConfig): AjaxPromise>; /** * A direct method to force a cross-domain JSONP request. * @param {plat.async.IJsonpConfig} options The IJsonpConfig */ jsonp(options: IJsonpConfig): AjaxPromise>; /** * Makes an ajax request, specifying responseType: 'json'. * @param {plat.async.IHttpConfig} options The IHttpConfig * for either the XMLHttpRequest or the JSONP callback. */ json(options: IHttpConfig): AjaxPromise>; } /** */ function IHttpConfig(): IHttpConfig; } /** * Holds classes and interfaces related to storage in platypus. */ namespace storage { /** * A Cache class, for use with the ICacheFactory injectable. * Used for storing objects. Takes in a generic type corresponding to the type of objects it contains. */ class Cache { /** * The size of this cache specified by its ID. */ private __size; /** * The ID of this cache. */ private __uid; /** * The options for this cache. */ private __options; /** * Method for creating a new cache object. Takes a generic type to denote the * type of objects stored in the new cache. If a cache with the same ID already exists * in the ICacheFactory, a new cache will not be created. * @param {string} uid The ID of the new Cache. * @param {plat.storage.ICacheOptions} options ICacheOptions * for customizing the Cache. */ static create(uid: string, options?: ICacheOptions): Cache; /** * Gets a cache out of the ICacheFactory if it exists. * @param {string} uid The identifier used to search for the cache. */ static fetch(uid: string): Cache; /** * Clears the ICacheFactory and all of its caches. */ static clear(): void; /** * The constructor for a Cache. * @param {string} id The id to use to retrieve the cache from the ICacheFactory. * @param {plat.storage.ICacheOptions} options The ICacheOptions for customizing the cache. */ constructor(uid: string, options?: ICacheOptions); /** * Retrieves the ICacheInfo about this cache * (i.e. ID, size, options) */ info(): ICacheInfo; /** * Method for inserting an object into an Cache. * @param {string} key The key to use for storage/retrieval of the object. * @param {T} value The value to store with the associated key. */ put(key: string, value: T): T; /** * Method for retrieving an object from an Cache. * @param key The key to search for in an Cache. */ read(key: string): T; /** * Method for removing an object from an Cache. * @param {string} key The key to remove from the Cache. */ remove(key: string): void; /** * Method for clearing an Cache, removing all of its keys. */ clear(): void; /** * Method for removing an ICache from the ICacheFactory. */ dispose(): void; } /** */ function ICacheFactory(): ICacheFactory; /** * Used to manage all the defined caches for the current application session. */ interface ICacheFactory { /** * Method for creating a new cache object. Takes a generic type to denote the * type of objects stored in the new cache. If a cache with the same ID already exists * in the ICacheFactory, a new cache will not be created. * @param {string} uid The ID of the new Cache. * @param {plat.storage.ICacheOptions} options ICacheOptions * for customizing the Cache. */ create(uid: string, options?: ICacheOptions): Cache; /** * Gets a cache out of the ICacheFactory if it exists. * @param {string} uid The identifier used to search for the cache. */ fetch(uid: string): Cache; /** * Clears the ICacheFactory and all of its caches. */ clear(): void; } /** */ let managerCache: Cache; /** */ function IManagerCache(): typeof managerCache; /** * Options for a cache. */ interface ICacheOptions { /** * Specifies a timeout for a cache value. When a value * is put in the cache, it will be valid for the given * period of time (in milliseconds). After the timeout * is reached, the value will automatically be removed * from the cache. */ timeout?: number; } /** * Contains information about an Cache. */ interface ICacheInfo { /** * A unique id for the Cache object, used to * retrieve the ICache out of the CacheFactory. */ uid: string; /** * Represents the number of items in the Cache. */ size: number; /** * Represents the ICacheOptions that the * Cache is using. */ options: ICacheOptions; } /** * Used for caching compiled nodes. This class will * clone a template when you put it in the cache. It will * also clone the template when you retrieve it. */ class TemplateCache extends Cache> { protected static _inject: any; /** * Reference to the IPromise injectable. */ protected _Promise: async.IPromise; /** * Reference to the Log injectable. */ protected _log: debug.Log; /** * The constructor for a TemplateCache. Creates a new Cache * with the ID "__templateCache". */ constructor(); /** * Stores a IPromise in the cache. * @param {string} key The key to use for storage/retrieval of the object. * @param {plat.async.Promise} value Promise that * should resolve with a Node. */ put(key: string, value?: string | DocumentFragment | Node | async.Promise): async.Promise; /** * Method for retrieving a Node from this cache. The DocumentFragment that resolves from the returned * Promise will be cloned to avoid manipulating the cached template. * @param {string} key The key to search for in this cache. */ read(key: string): async.Promise; } /** * A base class for storing data with a designated storage type. */ class BaseStorage { [key: string]: any; /** * Reference to HTML5 localStorage. */ protected _storage: Storage; /** * The constructor for a BaseStorage. */ constructor(storage: Storage); /** * Returns the number of items in storage. */ readonly length: number; /** * Clears storage, deleting all of its keys. */ clear(): void; /** * Gets an item out of storage with the assigned key. * @param {string} key The key of the item to retrieve from storage. */ getItem(key: string): string; /** * Allows for iterating over storage keys with an index. When * called with an index, it will return the key at that index in * storage. * @param {number} index The index used to retrieve the associated key. */ key(index: number): string; /** * Searches in storage for an item and removes it if it * exists. * @param {string} key The key of the item to remove from storage. */ removeItem(key: string): void; /** * Adds data to storage with the designated key. * @param {string} key The key of the item to store in storage. * @param {string} data The data to store in storage with the key. */ setItem(key: string, data: string): void; } /** * A class used to wrap HTML5 localStorage into an injectable. */ class LocalStorage extends BaseStorage { constructor(); } /** * A class for wrapping SessionStorage as an injectable. */ class SessionStorage extends BaseStorage { constructor(); } } /** * Holds all classes and interfaces related to observable components in platypus. */ namespace observable { /** * A class for managing both context inheritance and observable properties on controls and * facilitating in data-binding. */ class ContextManager { /** * Reference to the Log injectable. */ protected static _log: debug.Log; /** * A set of functions to be fired when a particular observed array is mutated. */ static arrayChangeListeners: IObject[]) => void)[]>>; /** * An object for quickly accessing a previously created ContextManager. */ private static __managers; /** * An object for storing functions to remove listeners for observed identifiers. */ private static __controls; /** * Reference to the Compat injectable. */ protected _compat: Compat; /** * The root context associated with and to be managed by this * ContextManager. */ context: any; /** * An object for quickly accessing callbacks associated with a given identifier. */ private __identifiers; /** * An object for quickly accessing child context associations (helps with * notifying child properties). */ private __identifierHash; /** * An object for storing listeners for Array length changes. */ private __lengthListeners; /** * An object for quickly accessing previously accessed or observed objects and properties. */ private __contextObjects; /** * Whether or not the property currently being modified is due to an observed array function. */ private __isArrayFunction; /** * If attempting to observe a property that is already being observed, this will be set to the * already observed identifier. */ private __observedIdentifier; /** * Gets the ContextManager associated to the given control. If no * ContextManager exists, one is created for that control. * @param {plat.Control} control The control on which to locate the ContextManager. */ static getManager(control: Control): ContextManager; /** * Removes all the listeners for a given control's unique ID. * @param {plat.Control} control The control whose manager is being disposed. */ static dispose(control: Control): void; /** * Removes all listeners for an Array associated with a given uid. * @param {string} absoluteIdentifier The identifier used to locate the array. * @param {string} uid The uid used to search for listeners. */ static removeArrayListeners(absoluteIdentifier: string, uid: string): void; /** * Safely retrieves the local context given a root context and an Array of * property strings. * @param {any} rootContext The root object in which to find a local context. * @param {Array} split The string array containing properties used to index into * the rootContext. */ static getContext(rootContext: any, split: string[]): any; /** * Defines an object property with the associated value. Useful for unobserving objects. * @param {any} obj The object on which to define the property. * @param {string} key The property key. * @param {any} value The value used to define the property. * @param {boolean} enumerable? Whether or not the property should be enumerable (able to be iterated * over in a loop) * @param {boolean} configurable? Whether or not the property is able to be reconfigured. * @param {boolean} writable? Whether or not assignment operators work on the property. */ static defineProperty(obj: any, key: string, value: any, enumerable?: boolean, configurable?: boolean, writable?: boolean): void; /** * Defines an object property with the associated value. Useful for unobserving objects. * @param {any} obj The object on which to define the property. * @param {string} key The property key. * @param {any} value The value used to define the property. * @param {boolean} enumerable? Whether or not the property should be enumerable (able to be iterated * over in a loop) * @param {boolean} configurable? Whether or not the property is able to be reconfigured. */ static defineGetter(obj: any, key: string, value: any, enumerable?: boolean, configurable?: boolean): void; /** * Pushes the function for removing an observed property upon adding the property. * @param {string} identifer The identifier for which the remove listener is being pushed. * @param {string} uid The unique ID of the control observing the identifier. * @param {plat.IRemoveListener} listener The function for removing the observed property. */ static pushRemoveListener(identifier: string, uid: string, listener: IRemoveListener): void; /** * Splices a given function for removing an observed property. * @param {string} identifer The identifier for which the remove listener is being spliced. * @param {string} uid The unique ID of the control observing the identifier. * @param {plat.IRemoveListener} listener The function for removing the observed property. */ static spliceRemoveListener(identifier: string, uid: string, listener: IRemoveListener): void; /** * Removes a specified identifier from being observed for a given set of control IDs. * @param {Array} uids The set of unique Ids for which to remove the specified identifier. * @param {string} identifier The identifier to stop observing. */ static removeIdentifier(uids: string[], identifier: string): void; /** * Ensures that an identifier path will exist on a given control. Will create * objects/arrays if necessary. * @param {plat.ui.TemplateControl} control The TemplateControl * on which to create the context. * @param {string} identifier The period-delimited identifier string used to create * the context path. */ static createContext(control: ui.TemplateControl, identifier: string): any; /** * Iterates through all the nested properties in an object and redefines the properties to not use getters/setters * @param {any} obj The object to stop observing. */ static unObserve(obj: any): void; /** * Safely retrieves the local context for this manager given an Array of * property strings and observes it if not found. * @param {Array} split The string array containing properties used to index into * the context. * @param {boolean} observe? Whether or not to observe the identifier indicated by the * split Array. */ getContext(split: string[], observe?: boolean): any; /** * Given a period-delimited identifier, observes an object and calls the given listener when the * object changes. * @param {string} absoluteIdentifier The period-delimited identifier noting the property to be observed. * @param {plat.observable.IListener} observableListener An object implementing IObservableListener. The listener will be * notified of object changes. */ observe(absoluteIdentifier: string, observableListener: IListener): IRemoveListener; /** * Observes an array and calls the listener when certain functions are called on * that array. The watched functions are push, pop, shift, splice, unshift, sort, * and reverse. * @param {string} uid The unique ID of the object observing the array. * @param {(changes: Array>) => void} listener The callback for after * when an observed Array function has been called. * @param {string} absoluteIdentifier The identifier from the root context used to find the array. * @param {Array} array The array to be observed. * @param {Array} oldArray The old array to stop observing. */ observeArrayMutation(uid: string, listener: (changes: IArrayChanges[]) => void, absoluteIdentifier: string, array: any[], oldArray: any[]): IRemoveListener; /** * Disposes the memory for an ContextManager. */ dispose(): void; /** * Pushes Array mutation listeners and removers. * @param {string} uid The unique identifier to store the callback. * @param {string} absoluteIdentifier The identifier of the Array being observed. * @param {(changes: Array>) => void} listener The Array mutation listener. */ protected _pushArrayListener(uid: string, absoluteIdentifier: string, listener: (changes: IArrayChanges[]) => void): IRemoveListener; /** * Restores an array to use Array.prototype instead of listener functions. * @param {Array} array The array to restore. */ protected _restoreArray(array: any[]): void; /** * Overwrites an Array's prototype to observe mutation functions. * @param {string} absoluteIdentifier The identifier for the Array off context. * @param {Array} array The array to overwrite. */ protected _overwriteArray(absoluteIdentifier: string, array: any[]): void; /** * Gets the context object of an identifier. * @param {string} identifier The identifier for which we're getting the context. * @param {Array} split The string array containing properties used to index into * the context. * @param {boolean} observe? Whether or not to observe the identifier indicated by the * split Array. */ protected _getContext(identifier: string, split: string[], observe?: boolean): any; /** * Gets the immediate context of identifier by splitting on ".". * @param {Array} split The string array containing properties used to index into * the context. */ protected _getImmediateContext(split: string[]): any; /** * Gets the immediate context of identifier by splitting on "." * and observes the objects along the way. * @param {Array} split The identifier split string array containing properties * used to index into the context. * @param {string} identifier The identifier being observed. */ protected _observeImmediateContext(split: string[], identifier: string): any; /** * Obtains the old value and new value of a given context * property on a property changed event. * @param {Array} split The split identifier of the property that changed. * @param {any} newRootContext The new context. * @param {any} oldRootContext The old context. */ protected _getValues(split: string[], newRootContext: any, oldRootContext: any): { newValue: any; oldValue: any; }; /** * Notifies all child properties being observed that a parent property * has changed. * @param {string} identifier The identifier for the property that changed. * @param {any} newValue The new value of the property. * @param {any} oldValue The old value of the property. * @param {Array} mappings? An array of mapped child identifier keys to notify. */ protected _notifyChildProperties(identifier: string, newValue: any, oldValue: any, mappings?: string[]): void; /** * Adds a listener to be fired for a particular identifier. * @param {string} absoluteIdentifier The identifier being observed. * @param {plat.observable.IListener} observableListener The function and associated unique ID to be fired * for this identifier. * @param {boolean} isLength? Indicates the property being observed is an Array's length. */ protected _addObservableListener(absoluteIdentifier: string, observableListener: IListener, isLength?: boolean): IRemoveListener; /** * Observes a property on a given context specified by an identifier. * @param {string} identifier The full identifier path for the property being observed. * @param {any} immediateContext The object whose property will be observed. * @param {string} key The property key for the value on the immediateContext that's * being observed. */ protected _define(identifier: string, immediateContext: any, key: string): void; /** * Intercepts an array function for observation. * @param {string} absoluteIdentifier The full identifier path for the observed array. * @param {string} method The array method being called. */ protected _overwriteArrayFunction(absoluteIdentifier: string, method: string): (...args: any[]) => any; /** * Removes a single listener callback * @param {string} identifier The identifier attached to the callbacks. * @param {plat.observable.IListener} listener The observable listener to remove. */ protected _removeCallback(identifier: string, listener: IListener): void; /** * Checks if the specified identifier is already being * observed in this context. * @param {string} identifier The identifier being observed. */ protected _hasIdentifier(identifier: string): boolean; /** * Executes the listeners for the specified identifier on * this context. * @param {string} identifier The identifier attached to the callbacks. * @param {any} value The new value on this context specified by * the identifier. * @param {any} oldValue The old value on this context specified by * the identifier. */ protected _execute(identifier: string, value: any, oldValue: any): void; /** * Defines a getter and setter for an object using Object.defineProperty. * @param {string} identifier The identifier of the object being defined. * @param {any} immediateContext The parent object of the object being defined. * @param {string} key The property key of the object being defined. */ private __defineObject; /** * Defines a getter and setter for a primitive using Object.defineProperty. * @param {string} identifier The identifier of the primitive being defined. * @param {any} immediateContext The parent object of the primitive being defined. * @param {string} key The property key of the primitive being defined. */ private __definePrimitive; /** * Adds and associates a listener with a given identifier. * @param {string} identifier The identifier to attach the listener. * @param {plat.observable.IListener} observableListener The listener being added. */ private __add; /** * Adds a mapping for an identifier which allows quick access to it * if a parent context is changed. * @param {string} identifier The identifier to map. */ private __addHashValues; } /** */ function IContextManagerStatic(_log?: debug.Log): IContextManagerStatic; /** * Creates and manages ContextManagers and has * additional helper functions for observing objects and primitives. */ interface IContextManagerStatic { /** * A set of functions to be fired when a particular observed array is mutated. */ arrayChangeListeners: IObject[]) => void)[]>>; /** * Gets the ContextManager associated to the given control. If no * ContextManager exists, one is created for that control. * @param {plat.Control} control The control on which to locate the ContextManager. */ getManager(control: Control): ContextManager; /** * Removes all the listeners for a given control's unique ID. * @param {plat.Control} control The control whose manager is being disposed. */ dispose(control: Control): void; /** * Removes all listeners for an Array associated with a given uid. * @param {string} absoluteIdentifier The identifier used to locate the array. * @param {string} uid The uid used to search for listeners. */ removeArrayListeners(absoluteIdentifier: string, uid: string): void; /** * Safely retrieves the local context given a root context and an Array of * property strings. * @param {any} rootContext The root object in which to find a local context. * @param {Array} split The string array containing properties used to index into * the rootContext. */ getContext(rootContext: any, split: string[]): any; /** * Defines an object property with the associated value. Useful for unobserving objects. * @param {any} obj The object on which to define the property. * @param {string} key The property key. * @param {any} value The value used to define the property. * @param {boolean} enumerable? Whether or not the property should be enumerable (able to be iterated * over in a loop) * @param {boolean} configurable? Whether or not the property is able to be reconfigured. * @param {boolean} writable? Whether or not assignment operators work on the property. */ defineProperty(obj: any, key: string, value: any, enumerable?: boolean, configurable?: boolean, writable?: boolean): void; /** * Defines an object property with the associated value. Useful for unobserving objects. * @param {any} obj The object on which to define the property. * @param {string} key The property key. * @param {any} value The value used to define the property. * @param {boolean} enumerable? Whether or not the property should be enumerable (able to be iterated * over in a loop) * @param {boolean} configurable? Whether or not the property is able to be reconfigured. */ defineGetter(obj: any, key: string, value: any, enumerable?: boolean, configurable?: boolean): void; /** * Pushes the function for removing an observed property upon adding the property. * @param {string} identifer The identifier for which the remove listener is being pushed. * @param {string} uid The unique ID of the control observing the identifier. * @param {plat.IRemoveListener} listener The function for removing the observed property. */ pushRemoveListener(identifier: string, uid: string, listener: IRemoveListener): void; /** * Splices a given function for removing an observed property. * @param {string} identifer The identifier for which the remove listener is being spliced. * @param {string} uid The unique ID of the control observing the identifier. * @param {plat.IRemoveListener} listener The function for removing the observed property. */ spliceRemoveListener(identifier: string, uid: string, listener: IRemoveListener): void; /** * Removes a specified identifier from being observed for a given set of control IDs. * @param {Array} uids The set of unique Ids for which to remove the specified identifier. * @param {string} identifier The identifier to stop observing. */ removeIdentifier(uids: string[], identifier: string): void; /** * Ensures that an identifier path will exist on a given control. Will create * objects/arrays if necessary. * @param {plat.ui.TemplateControl} control The TemplateControl * on which to create the context. * @param {string} identifier The period-delimited identifier string used to create * the context path. */ createContext(control: ui.TemplateControl, identifier: string): any; } /** * An object specifying a listener callback function and a unique id to use to manage the * listener. */ interface IListener { /** * A unique id used to manage the listener. */ uid: string; /** * A high priority means this listener wants to be notified earlier than other listeners. The * listeners will be fired in priority order when necessary. */ priority?: number; /** * A listener method called when the object it is observing is changed. * @param {any} value The new value of the object. * @param {any} oldValue The previous value of the object. */ listener(value: any, oldValue: any): void; } /** * An object denoting Array changes after the Array has been mutated. Takes a * generic type to denote the type of array it uses. */ interface IArrayChanges { /** * The new value of the array. */ object: T[]; /** * The method name that was called. Array mutation methods are: * 'push', 'pop', 'reverse', 'shift', 'sort', 'splice', * and 'unshift'. */ type: string; /** * The index at which the change occurred. Only available on Array mutation methods. */ index?: number; /** * An array of the removed elements. Only available on Array mutation methods. */ removed?: T[]; /** * The number of elements added. Only available on Array mutation methods. */ addedCount?: number; /** * The old Array prior to a 'reverse' or 'sort' mutation type. * Only available when the type is either 'reverse' or 'sort'. */ oldArray?: T[]; } /** * Defines the object added to a template control when its element * has an attribute control that extends ObservableAttributeControl. */ interface IObservableProperty { /** * The value obtained from evaluating the attribute's expression. */ value: T; /** * A method for observing the attribute for changes. * @param {(newValue: T, oldValue: T) => void} listener The listener callback which will be pre-bound to the * template control. */ observe(listener: (newValue: T, oldValue: T) => void): IRemoveListener; } /** * Defines methods that interact with a control that implements IImplementTwoWayBinding * (e.g. Bind. */ interface ISupportTwoWayBinding { /** * Adds a listener to be called when the bindable property changes. * @param {plat.IPropertyChangedListener} listener The function that acts as a listener. */ onInput(listener: (newValue: any, oldValue: any) => void): IRemoveListener; /** * A function that allows this control to observe both the bound property itself as well as * potential child properties if being bound to an object. * @param {plat.observable.IImplementTwoWayBinding} binder The control that facilitates the * data-binding. */ observeProperties(binder: IImplementTwoWayBinding): void; } /** * Defines methods that interact with a control that implements ISupportTwoWayBinding * (e.g. any control that extends BindControl. */ interface IImplementTwoWayBinding { /** * A function that allows a ISupportTwoWayBinding to observe both the * bound property itself as well as potential child properties if being bound to an object. * @param {plat.observable.IBoundPropertyChangedListener} listener The listener function. * @param {number | string} identifier? The path off of the bound object to listen to for changes if the bound object is an Array. * If undefined or empty the listener will listen for changes to the bound Array itself. * @param {boolean} autocast? Will cast a primitive value to whatever it was set to in code. */ observeProperty(listener: IBoundPropertyChangedListener, identifier?: number | string, autocast?: boolean): IRemoveListener; /** * A function that allows a ISupportTwoWayBinding to observe array mutations of the * bound property. * @param {(changes: Array>, identifier: string) => void} listener The listener function. * @param {string} identifier? The identifier off of the bound object to listen to for changes. If undefined or empty * the listener will listen for changes to the bound item itself. */ observeArrayChange(listener: (changes: IArrayChanges[], identifier: string) => void, identifier?: string): IRemoveListener; /** * A function that allows a ISupportTwoWayBinding to observe array mutations of the * bound property. * @param {(changes: Array>, identifier: number) => void} listener The listener function. * @param {number} index? The index off of the bound object to listen to for changes if the bound object is an Array. * If undefined or empty the listener will listen for changes to the bound Array itself. */ observeArrayChange(listener: (changes: IArrayChanges[], identifier: number) => void, index?: number): IRemoveListener; /** * Gets the current value of the bound property. */ evaluate(): any; } /** * Defines a function that will be called whenever a bound property specified by a given identifier has changed. */ type IBoundPropertyChangedListener = (newValue: T, oldValue: T, identifier: any, firstTime?: boolean) => void; } /** * Holds classes and interfaces related to event management components in platypus. */ namespace events { /** * An event class that propagates through a control tree. * Propagation of the event always starts at the sender, allowing a control to both * initialize and consume an event. If a consumer of an event throws an error while * handling the event it will be logged to the app using Log.debug. Errors will * not stop propagation of the event. */ class DispatchEvent { protected static _inject: any; /** * Reference to the IEventManagerStatic injectable. */ protected _EventManager: IEventManagerStatic; /** * Reference to the IContextManagerStatic injectable. */ protected _ContextManager: observable.IContextManagerStatic; /** * The object that initiated the event. */ sender: any; /** * The name of the event. */ name: string; /** * The event direction this object is using for propagation. */ direction: string; /** * Whether or not preventDefault() was called on the event. Senders of the * event can check this property to know if they should carry out a default * action as a result of the event. */ defaultPrevented: boolean; /** * Whether or not the event propagation was stopped. */ stopped: boolean; /** * Initializes the event, populating its public properties. * @param {string} name The name of the event. * @param {any} sender The object that initiated the event. * @param {string} direction The direction of propagation */ initialize(name: string, sender: any, direction?: 'up' | 'down' | 'direct' | string): void; /** * Cancels the default action (if there is one) for an event. Does not affect propagation. */ preventDefault(): void; /** * Call this method to halt the propagation of an upward-moving event. * Downward events cannot be stopped with this method. */ stopPropagation(): void; } /** * Represents a Lifecycle Event. Lifecycle Events are always direct events. */ class LifecycleEvent extends DispatchEvent { /** * Creates a new LifecycleEvent and fires it. * @param {string} name The name of the event. * @param {any} sender The sender of the event. */ static dispatch(name: string, sender: any): LifecycleEvent; /** * Initializes the event, populating its public properties. * @param {string} name The name of the event. * @param {any} sender The sender of the event. */ initialize(name: string, sender: any): void; } /** */ function ILifecycleEventStatic(): ILifecycleEventStatic; /** * Dispatches LifecycleEvent */ interface ILifecycleEventStatic { /** * Creates a new LifecycleEvent and fires it. * @param {string} name The name of the event. * @param {any} sender The sender of the event. */ dispatch(name: string, sender: any): LifecycleEvent; } /** * Manages dispatching events, handling all propagating events as well as any error handling. */ class EventManager { /** * Reference to the Log injectable. */ protected static _log: debug.Log; /** * Reference to the Compat injectable. */ protected static _compat: Compat; /** * Reference to the Document injectable. */ protected static _document: Document; /** * Reference to the Window injectable. */ protected static _window: Window; /** * Reference to the Dom injectable. */ protected static _dom: ui.Dom; /** * An upward-moving event will start at the sender and move * up the parent chain. */ static UP: 'up'; /** * A downward-moving event will start at the sender and move * to its children and beyond. */ static DOWN: 'down'; /** * Goes through all listeners for an event name, ignoring order. */ static DIRECT: 'direct'; /** * Keeps track of which events are currently propagating. */ static propagatingEvents: IObject; /** * Holds all the event listeners keyed by uid. */ private static __eventsListeners; /** * Holds all the event listeners for the application lifefycle events. */ private static __lifecycleEventListeners; /** * whether or not the event manager has been initialized. */ private static __initialized; /** * Initializes the EventManager, creating the initial ALM event listeners. */ static initialize(): void; /** * Removes all event listeners for a given uid. Useful for garbage collection when * certain objects that listen to events go out of scope. * @param {string} uid The uid for which the event listeners will be removed.' */ static dispose(uid: string): void; /** * Registers a listener for a DispatchEvent. * The listener will be called when a DispatchEvent is * propagating over the given uid. Any number of listeners can exist for a single event name. * @param {string} uid A unique id to associate with the object registering the listener. * @param {string} eventName The name of the event to listen to. * @param {(ev: DispatchEvent, ...args: any[]) => void} listener The method called when the event is fired. * @param {any} context? The context with which to call the listener method. */ static on(uid: string, eventName: string, listener: (ev: DispatchEvent, ...args: any[]) => void, context?: any): IRemoveListener; /** * Looks for listeners to a given event name, and fires the listeners using the specified * event direction. * @param {string} name The name of the event. * @param {any} sender The object sending the event. * @param {string} direction The direction in which to send the event. * @param {Array} args? The arguments to send to the listeners. */ static dispatch(name: string, sender: any, direction: 'down' | 'up' | 'direct', args?: any[]): DispatchEvent; /** * Returns whether or not the given string is a registered direction. * @param {string} direction The direction of the event */ static hasDirection(direction: string): boolean; /** * Determines the appropriate direction and dispatches the event accordingly. * @param {plat.events.DispatchEvent} event The DispatchEvent to send * @param {Array} args The arguments associated with the event */ static sendEvent(event: DispatchEvent, args?: any[]): void; /** * Dispatches the event up the control chain. * @param {plat.events.DispatchEvent} event The event being dispatched. * @param {Array} args The arguments associated with the event. */ protected static _dispatchUp(event: DispatchEvent, args: any[]): void; /** * Dispatches the event down the control chain. * @param {plat.events.DispatchEvent} event The event being dispatched. * @param {Array} args The arguments associated with the event. */ protected static _dispatchDown(event: DispatchEvent, args: any[]): void; /** * Dispatches the event directly to all listeners. * @param {plat.events.DispatchEvent} event The event being dispatched. * @param {Array} args The arguments associated with the event. */ protected static _dispatchDirect(event: DispatchEvent, args: any[]): void; /** * Dispatches the event to the listeners for the given uid. * @param {string} uid The uid used to find the event listeners. * @param {plat.events.DispatchEvent} The event. * @param {Array} args The arguments to send to the listeners. */ private static __executeEvent; /** * Calls event listeners with the given context, event, and arguments. * @param {any} context The context with which to call the listeners. * @param {plat.events.DispatchEvent} The event. * @param {Array<(ev: DispatchEvent, ...args: any[]) => void>} The event listeners. * @param {Array} args The arguments to send to the listeners. */ private static __callListeners; } /** */ function IEventManagerStatic(_log?: debug.Log, _compat?: Compat, _document?: Document, _window?: Window, _dom?: ui.Dom): IEventManagerStatic; /** * Manages dispatching events, handling all propagating events as well as any error handling. */ interface IEventManagerStatic { /** * An upward-moving event will start at the sender and move * up the parent chain. */ UP: string | 'up'; /** * A downward-moving event will start at the sender and move * to its children and beyond. */ DOWN: string | 'down'; /** * Goes through all listeners for an event name, ignoring order. */ DIRECT: string | 'direct'; /** * Keeps track of which events are currently propagating. */ propagatingEvents: IObject; /** * Initializes the EventManager, creating the initial ALM event listeners. */ initialize(): void; /** * Removes all event listeners for a given uid. Useful for garbage collection when * certain objects that listen to events go out of scope. * @param {string} uid The uid for which the event listeners will be removed.' */ dispose(uid: string): void; /** * Registers a listener for a DispatchEvent. The listener will be called when a DispatchEvent is * propagating over the given uid. Any number of listeners can exist for a single event name. * @param {string} uid A unique id to associate with the object registering the listener. * @param {string} eventName The name of the event to listen to. * @param {(ev: plat.events.DispatchEvent, ...args: any[]) => void} listener The method called when the event is fired. * @param {any} context? The context with which to call the listener method. */ on(uid: string, eventName: 'ready' | 'suspend' | 'resume' | 'online' | 'offline' | 'error' | string, listener: (ev: DispatchEvent | LifecycleEvent | ErrorEvent, ...args: any[]) => void, context?: any): IRemoveListener; /** * Looks for listeners to a given event name, and fires the listeners using the specified * event direction. * @param {string} name The name of the event. * @param {any} sender The object sending the event. * @param {string} direction The direction in which to send the event. * @param {Array} args? The arguments to send to the listeners. */ dispatch(name: string, sender: any, direction: 'up' | 'down' | 'direct' | string, args?: any[]): DispatchEvent; /** * Returns whether or not the given string is a registered direction. * @param {string} direction The direction of the event */ hasDirection(direction: string): boolean; /** * Determines the appropriate direction and dispatches the event accordingly. * @param {plat.events.DispatchEvent} event The DispatchEvent to send * @param {Array} args The arguments associated with the event */ sendEvent(event: DispatchEvent, args?: any[]): void; } /** * Represents an internal Error Event. This is used for any * internal errors (both fatal and warnings). All error events are * direct events. */ class ErrorEvent extends DispatchEvent { /** * Reference to the IEventManagerStatic injectable. */ protected static _EventManager: IEventManagerStatic; /** * The error being dispatched. */ error: E; /** * The severity level of the error. */ logLevel: number; /** * Creates a new ErrorEvent and fires it. * @param {string} name The name of the event. * @param {any} sender The sender of the event. * @param {E} error The error that occurred, resulting in the event. * @param {number} logLevel The severity level of the error */ static dispatch(name: string, sender: any, error: E, logLevel: number): ErrorEvent; /** * Initializes the event, populating its public properties. * @param {string} name The name of the event. * @param {any} sender The sender of the event. * @param {string} direction This is always a direct event. * @param {E} error The error that occurred, resulting in the event. */ initialize(name: string, sender: any, direction?: string | 'direct', error?: E): void; } /** */ function IErrorEventStatic(_EventManager?: IEventManagerStatic): IErrorEventStatic; /** * Dispatches ErrorEvents */ interface IErrorEventStatic { /** * Creates a new ErrorEvent and fires it. * @param {string} name The name of the event. * @param {any} sender The sender of the event. * @param {E} error The error that occurred, resulting in the event. * @param {number} logLevel The severity level of the error */ dispatch(name: string, sender: any, error: E, logLevel: number): ErrorEvent; } } /** * Used for facilitating data and DOM manipulation. Contains lifecycle events * as well as properties for communicating with other controls. This is the base * class for all types of controls. */ class Control { /** * Reference to the Log injectable. */ protected static _log: debug.Log; /** * Reference to the Dom injectable. */ protected static _dom: ui.Dom; /** * Reference to the Parser injectable. */ protected static _parser: expressions.Parser; /** * Reference to the ContextManagerStatic injectable. */ protected static _ContextManager: observable.IContextManagerStatic; /** * Reference to the IEventManagerStatic injectable. */ protected static _EventManager: events.IEventManagerStatic; /** * Reference to the IPromise injectable. */ protected static _Promise: async.IPromise; /** * An object containing all controls' registered event listeners. */ private static __eventListeners; /** * An object containing all controls' objects that are marked to be called on disposal. */ private static __disposables; /** * A unique id, created during instantiation and found on every Control. */ uid: string; /** * The type of a Control. */ type: string; /** * Specifies the priority of the control. The purpose of * this is so that controls like plat-bind can have a higher * priority than plat-tap. The plat-bind will be initialized * and loaded before plat-tap, meaning it has the first chance * to respond to events. */ priority: number; /** * The parent control that created this control. */ parent: ui.TemplateControl; /** * The HTMLElement that represents this Control. Should only be modified by controls that implement * TemplateControl. During initialize the control should populate this element with what it wishes * to render to the user. */ element: HTMLElement; /** * The attributes object representing all the attributes for a Control's element. All attributes are * converted from dash notation to camelCase. */ attributes: ui.Attributes; /** * Contains DOM helper methods for manipulating this control's element. */ dom: ui.Dom; /** * Contains helper methods for data manipulation. */ utils: Utils; /** * Reference to the Log injectable. */ protected _log: debug.Log; /** * Finds the ancestor control for the given control that contains the root * context. * @param {plat.Control} control The control with which to find the root. */ static getRootControl(control: Control): ui.TemplateControl; /** * Given a control, calls the loaded method for the control if it exists. * @param {plat.Control} control The control to load. */ static load(control: Control): async.Promise; /** * Disposes all the necessary memory for a control. Uses specific dispose * methods related to a control's constructor if necessary. * @param {plat.Control} control The Control to dispose. */ static dispose(control: Control): void; /** * Splices a control from its parent's controls list. Sets the control's parent * to null. * @param {plat.Control} control The control whose parent will be removed. */ static removeParent(control: Control): void; /** * Removes all event listeners for a control with the given uid. * @param {plat.Control} control The control having its event listeners removed. */ static removeEventListeners(control: Control): void; /** * calls all disposable functions for a control with the given uid. * @param {plat.Control} control The control having its disposables called. */ static callDisposables(control: Control): void; /** * Returns a new instance of Control. */ static getInstance(): Control; /** * Adds a function to remove an event listener for the control specified * by its uid. * @param {string} uid The uid of the control associated with the remove function. * @param {plat.IRemoveListener} listener The remove function to add. */ private static __addRemoveListener; /** * Removes a IRemoveListener from a control's listeners. * @param {string} uid The uid of the control associated with the remove function. * @param {plat.IRemoveListener} listener The remove function to add. */ private static __spliceRemoveListener; /** * Adds a function to remove an event listener for the control specified * by its uid. * @param {string} uid The uid of the control associated with the remove function. * @param {any} value The value to add. */ private static __addDisposable; /** * Removes a IRemoveListener from a control's listeners. * @param {string} uid The uid of the control associated with the remove function. * @param {any} value The value to add. */ private static __spliceDisposable; /** * Gets controls that have a specific key/value string pair. * @param {plat.Control} control The at which to start searching for key/value pairs. * @param {string} key The key to search for on all the controls in the tree. * @param {string} value The expected value used to find similar controls. */ private static __getControls; /** * The constructor for a control. Any injectables specified during control registration will be * passed into the constructor as arguments as long as the control is instantiated with its associated * injector. */ constructor(); /** * The initialize event method for a control. In this method a control should initialize all the necessary * variables. This method is typically only necessary for view controls. If a control does not implement * IBaseViewControl then it is not safe to access, observe, or modify * the context property in this method. A view control should call services/set context in this method in * order to fire the loaded event. No control will be loaded until the view control has specified a context. */ initialize(): void; /** * The loaded event method for a control. This event is fired after a control has been loaded, * meaning all of its children have also been loaded and initial DOM has been created and populated. It is now * safe for all controls to access, observe, and modify the context property. */ loaded(): void; /** * Retrieves all the controls with the specified name. * @param {string} name The string name with which to populate the returned controls array. */ getControlsByName(name: string): Control[]; /** * Retrieves all the controls of the specified type. * @param {new () => T} Constructor The constructor used to find controls. */ getControlsByType(type: string | (new () => T)): T[]; /** * Adds an event listener of the specified type to the specified element. Removal of the * event is handled automatically upon disposal. * @param {EventTarget} element The element to add the event listener to. * @param {string} type The type of event to listen to. * @param {EventListener} listener The listener to fire when the event occurs. * @param {boolean} useCapture? Whether to fire the event on the capture or the bubble phase * of event propagation. */ addEventListener(element: EventTarget, type: string, listener: ui.IGestureListener | EventListener, useCapture?: boolean): IRemoveListener; /** * Adds an event listener of the specified type to the specified element. Removal of the * event is handled automatically upon disposal. * @param {EventTarget} element The element to add the event listener to. * @param {string} type The type of event to listen to. * @param {EventListener} listener The listener to fire when the event occurs. * @param {boolean} useCapture? Whether to fire the event on the capture or the bubble phase * of event propagation. */ addDisposable(...values: (IRemoveListener | { cancel(): any; } | number)[]): IRemoveListener; /** * Allows a Control to observe any property on its context and receive updates when * the property is changed. * @param {plat.IIdentifierChangedListener} listener The method called when the property is changed. This method * will have its 'this' context set to the control instance. * @param {number} index? The index that denotes the item in the context if the context is an Array. */ observe(listener: (value: T, oldValue: T, identifier: number | string) => void, identifier?: number | string): IRemoveListener; /** * Allows a Control to observe an array and receive updates when certain array-changing methods are called. * The methods watched are push, pop, shift, sort, splice, reverse, and unshift. This method currently does not watch * every item in the array. * @param {(changes: Array>, identifier: string) => void} listener The method called * after an array-changing method is called. This method will have its 'this' context set to the control instance. * @param {string} identifier? The property string that denotes the array in the context. */ observeArray(listener: (changes: observable.IArrayChanges[], identifier: string) => void, identifier?: string): IRemoveListener; /** * Allows a Control to observe an array and receive updates when certain array-changing methods are called. * The methods watched are push, pop, shift, sort, splice, reverse, and unshift. This method currently does not watch * every item in the array. * @param {(changes: Array>, identifier: number) => void} listener The method called * after an array-changing method is called. This method will have its 'this' context set to the control instance. * @param {number} identifier? The index that denotes the array in the context if the context is an Array. */ observeArray(listener: (changes: observable.IArrayChanges[], identifier: number) => void, identifier?: number): IRemoveListener; /** * Using a IParsedExpression observes any associated identifiers. When an identifier * value changes, the listener will be called. * @param {plat.IIdentifierChangedListener} listener The listener to call when the expression identifer values change. * @param {plat.expressions.IParsedExpression} expression The expression string to watch for changes. */ observeExpression(listener: (value: T, oldValue: T, expression: expressions.IParsedExpression | string) => void, expression: expressions.IParsedExpression | string): IRemoveListener; /** * Evaluates an IParsedExpression using the control.parent.context. * @param {string} expression The expression string to evaluate. * @param {IObject} aliases Optional alias values to parse with the expression */ evaluateExpression(expression: string | expressions.IParsedExpression, aliases?: IObject): any; /** * Finds the first instance of the specified property * in the parent control chain. Returns undefined if not found. * @param {string} property The property identifer * @param {plat.Control} control? An optional control to use as a starting point to find the property. * If nothing is passed in, then the control calling the method will be the starting point. */ findProperty(property: string, control?: Control): IControlProperty; /** * Creates a new DispatchEvent and propagates it to controls based on the * provided direction mechanism. Controls in the propagation chain that registered * the event using the control.on() method will receive the event. Propagation will * always start with the sender, so the sender can both produce and consume the same * event. * @param {string} name The name of the event to send, coincides with the name used in the * control.on() method. * @param {string} direction The direction in which to send the event. * @param {Array} ...args Any number of arguments to send to all the listeners. */ dispatchEvent(name: string, direction?: 'up' | 'down' | 'direct' | string, ...args: any[]): void; /** * Registers a listener for a DispatchEvent. The listener will be called when a * DispatchEvent is propagating over the control. Any number of listeners can exist * for a single event name. * @param {string} name The name of the event, coinciding with the DispatchEvent name. * @param {(ev: plat.events.DispatchEvent, ...args: Array) => void} listener The method called when the * DispatchEvent is fired. */ on(name: string, listener: (ev: events.DispatchEvent, ...args: any[]) => void): IRemoveListener; /** * The dispose event is called when a control is being removed from memory. A control should release * all of the memory it is using, including DOM event and property listeners. */ dispose(): void; } /** */ function IControlFactory(_parser?: expressions.Parser, _ContextManager?: observable.IContextManagerStatic, _EventManager?: events.IEventManagerStatic, _Promise?: async.IPromise, _dom?: ui.Dom, _log?: debug.Log): IControlFactory; /** * Creates and manages instances of Control. */ interface IControlFactory { /** * Finds the ancestor control for the given control that contains the root * context. * @param {plat.Control} control The control with which to find the root. */ getRootControl(control: Control): ui.TemplateControl; /** * Given a control, calls the loaded method for the control if it exists. * @param {plat.Control} control The control to load. */ load(control: Control): async.Promise; /** * Disposes all the necessary memory for a control. Uses specific dispose * methods related to a control's constructor if necessary. * @param {plat.Control} control The Control to dispose. */ dispose(control: Control): void; /** * Splices a control from its parent's controls list. Sets the control's parent * to null. * @param {plat.Control} control The control whose parent will be removed. */ removeParent(control: Control): void; /** * Removes all event listeners for a control with the given uid. * @param {plat.Control} control The control having its event listeners removed. */ removeEventListeners(control: Control): void; /** * Returns a new instance of Control. */ getInstance(): Control; } /** * An object that links a property to a control. */ interface IControlProperty { /** * The parsed expression of the control property. */ expression: expressions.IParsedExpression; /** * The value of the property. */ value: any; /** * The control on which the property is found. */ control: Control; } /** * A type of control that can be used as an attribute but will * not be used to add, remove, or modify DOM. */ class AttributeControl extends Control { /** * Specifies the TemplateControl associated with this * control's element. Can be null if no TemplateControl * exists. */ templateControl: ui.TemplateControl; /** * Method for disposing an attribute control. Removes any * necessary objects from the control. * @param {plat.AttributeControl} control The AttributeControl to dispose. */ static dispose(control: AttributeControl): void; /** * Returns a new instance of AttributeControl. */ static getInstance(): AttributeControl; } /** */ function IAttributeControlFactory(): IAttributeControlFactory; /** * Creates and manages instances of AttributeControl. */ interface IAttributeControlFactory { /** * Method for disposing an attribute control. Removes any * necessary objects from the control. * @param {plat.AttributeControl} control The AttributeControl to dispose. */ dispose(control: AttributeControl): void; /** * Returns a new instance of AttributeControl. */ getInstance(): AttributeControl; } /** * Holds all the classes and interfaces related to UI components for platypus. */ namespace ui { /** * The base control for any control that affects the UI. They provide properties for the control to use * to manage its body HTML. */ class TemplateControl extends Control { /** * Reference to the IResourcesFactory injectable. */ protected static _ResourcesFactory: IResourcesFactory; /** * Reference to the IBindableTemplatesFactory injectable. */ protected static _BindableTemplatesFactory: IBindableTemplatesFactory; /** * Reference to a cache injectable that stores ElementManagers. */ protected static _managerCache: storage.Cache; /** * Reference to a cache injectable that stores and retrieves HTML templates. */ protected static _templateCache: storage.TemplateCache; /** * Reference to the Parser injectable. */ protected static _parser: expressions.Parser; /** * Reference to the Http injectable. */ protected static _http: async.Http; /** * Reference to the IPromise injectable. */ protected static _Promise: async.IPromise; /** * Reference to the Log injectable. */ protected static _log: debug.Log; /** * An object for quickly retrieving previously accessed resources. */ private static __resourceCache; /** * By default TemplateControls have a priority of 100. */ priority: number; /** * The context of an TemplateControl, used for inheritance and data-binding. */ context: any; /** * The name of a TemplateControl if a Name * control is involved. */ name: string; /** * Specifies the absolute path from where the context was created to this Control's context. * Used by the ContextManager for maintaining context parity * (e.g. 'context.childContextProperty.grandChildContextProperty'). */ absoluteContextPath: string; /** * Resources are used for providing aliases to use in markup expressions. They * are particularly useful when trying to access properties outside of the * current context, as well as reassigning context at any point in an app. */ resources: Resources; /** * Flag indicating whether or not the TemplateControl defines the context property. */ hasOwnContext: boolean; /** * A string representing the DOM template for this control. If this property is * defined on a TemplateControl then DOM will be created and put in the * control's element prior to calling the 'setTemplate' method. */ templateString: string; /** * A url containing a string representing the DOM template for this control. If this property is * defined on a TemplateControl then DOM will be created and put in the * control's element prior to calling the `setTemplate` method. This property takes * precedence over templateString. In the event that both are defined, templateString * will be ignored. */ templateUrl: string; /** * A DocumentFragment representing the innerHTML that existed when this control was instantiated. * This property will only contain the innerHTML when either a templateString or templateUrl is * defined. Its important to clone this property when injecting it somewhere, else its childNodes * will disappear. */ innerTemplate: DocumentFragment; /** * An BindableTemplates object used for binding a data context to a template. * This is an advanced function of a TemplateControl. */ bindableTemplates: BindableTemplates; /** * An array of child controls. Any controls created by this control can be found in this array. The controls in * this array will have reference to this control in their parent property. */ controls: Control[]; /** * A Node array for managing the TemplateControl's childNodes in the event that this control * replaces its element. This property will only exist/be of use for a TemplateControl that * implements the replaceWith property. This is an experimental API. */ elementNodes: Node[]; /** * The first node in the TemplateControl's body. This property allows an * TemplateControl to add nodes to its body in the event that it replaces its element. * This is an experimental API. */ startNode: Comment; /** * The last node in the TemplateControl's body. This property allows a * TemplateControl to add nodes to its body in the event that it replaces its element. * This is an experimental API. */ endNode: Comment; /** * Allows a TemplateControl to either swap its element with another element (e.g. plat-select), * or replace its element altogether. If null or empty string, the element will be removed from the DOM, and the * childNodes of the element will be in its place. In addition, when the element is placed startNode and endNode Comments * are created, and the childNodes are added to the elementNodes property on the control. The replaceWith * property can be any property that works with document.createElement(). If the control's element had * attributes (as well as attribute Controls), those attributes will be carried to the swapped element. The default * replaceWith is 'any,' meaning it will default to a 'div' in the case that the control type is used as the * element's nodename (e.g. ``), but will maintain whatever element type * is used otherwise (e.g. ``). */ replaceWith: string; /** * Set to the root ancestor control from which this control inherits its context. This value * can be equal to this control. */ root: TemplateControl; /** * Evaluates an expression string with a given control and optional control's context and aliases. * @param {plat.expressions.IParsedExpression} expression A parsed expression object created using the * plat.expressions.Parser injectable. * @param {plat.ui.TemplateControl} control? The control used for evaluation context. * @param {IObject} aliases? An optional alias object containing resource alias values (property keys should * not include the `@` character). */ static evaluateExpression(expression: string | expressions.IParsedExpression, control?: TemplateControl, aliases?: IObject): any; /** * Given a control and Array of aliases, finds the associated resources and builds a context object containing * the values. Returns the object. * @param {plat.ui.TemplateControl} control The control used as the starting point for finding resources. * @param {Array} aliases An array of aliases to search for. * @param {IObject} resources? An optional resources object to extend, if no resources object is passed in a * new one will be created. */ static getResources(control: TemplateControl, aliases: string[], resources?: IObject): IObject; /** * Starts at a control and searches up its parent chain for a particular resource alias. * If the resource is found, it will be returned along with the control instance on which * the resource was found. * @param {plat.ui.TemplateControl} control The control on which to start searching for the resource alias. * @param {string} alias The alias to search for. */ static findResource(control: TemplateControl, alias: string): { resource: IResource; control: TemplateControl; }; /** * Recursively disposes a control and its children. * @param {plat.ui.TemplateControl} control A control to dispose. */ static dispose(control: TemplateControl): void; /** * Loads the control tree depth first (visit children, then visit self). * @param {plat.ui.TemplateControl} control The control serving as the root control to load. */ static loadControl(control: TemplateControl): void; /** * Notifies a control that its context has been changed by * calling the `control.contextChanged` method if it exists. * @param {plat.ui.TemplateControl} control The control whose context changed. * @param {any} newValue The new value of the control's context. * @param {any} oldValue The old value of the control's context. */ static contextChanged(control: TemplateControl, newValue: any, oldValue: any): void; /** * Sets the `context` resource value on a TemplateControl. If the control specifies * hasOwnContext as true, the `rootContext` resource value will be set. * @param {plat.ui.TemplateControl} control The control whose context resources will be set. */ static setContextResources(control: TemplateControl): void; /** * Completely removes a control's element from its parentNode. * @param {plat.ui.TemplateControl} control The control whose element should be removed. */ static removeElement(control: TemplateControl): void; /** * Sets the absoluteContextPath read-only property on a control. * @param {plat.ui.TemplateControl} control The control on which to set the absoluteContextPath. * @param {string} path The path to set on the control. */ static setAbsoluteContextPath(control: TemplateControl, path: string): void; /** * Determines the template for a control by searching for a templateUrl, * using the provided templateUrl, or serializing the control's templateString. * @param {plat.ui.TemplateControl} control The control whose template is being determined. * @param {string} templateUrl? The potential template URL to use to grab the template. */ static determineTemplate(control: TemplateControl, templateUrl?: string): async.Promise; /** * Detaches a TemplateControl. Disposes its children, * but does not dispose the TemplateControl. * @param {plat.ui.TemplateControl} control The control to be detached. */ static detach(control: TemplateControl): void; /** * Returns a new instance of TemplateControl. */ static getInstance(): TemplateControl; /** * This event is fired when an TemplateControl's context property * is changed by an ancestor control. * @param {any} newValue? The new value of the context. * @param {any} oldValue The old value of the context. */ contextChanged(newValue: any, oldValue: any): void; /** * A method called for TemplateControls to set their template. * During this method a control should ready its template for compilation. Whatever is in the control's * element (or elementNodes if replaceWith is implemented) after this method's execution will be compiled * and appear on the DOM. */ setTemplate(): void; /** * Finds the associated resources and builds a context object containing * the values. * @param {Array} aliases An array of aliases to search for. * @param {IObject} resources? An optional resources object to extend, * if no resources object is passed in a new one will be created. */ getResources(aliases: string[], resources?: IObject): IObject; /** * Starts at a control and searches up its parent chain for a particular resource alias. * If the resource is found, it will be returned along with the control instance on which * the resource was found. * @param {string} alias The alias to search for. */ findResource(alias: string): { resource: IResource; control: TemplateControl; }; /** * Evaluates an expression string, using the input context or control.context. * @param {plat.expressions.IParsedExpression} expression The previously parsed expression to evaluate. * @param {any} context? An optional context with which to parse. If * no context is specified, the control.context will be used. */ evaluateExpression(expression: string | expressions.IParsedExpression, context?: any): any; } /** */ function ITemplateControlFactory(_ResourcesFactory?: IResourcesFactory, _BindableTemplatesFactory?: IBindableTemplatesFactory, _managerCache?: storage.Cache, _templateCache?: storage.TemplateCache, _parser?: expressions.Parser, _http?: async.Http, _Promise?: async.IPromise, _log?: debug.Log): ITemplateControlFactory; /** * Creates and manages TemplateControls. */ interface ITemplateControlFactory { /** * Evaluates an expression string with a given control and optional control's context and aliases. * @param {plat.expressions.IParsedExpression} expression A parsed expression object created using the * plat.expressions.Parser injectable. * @param {plat.ui.TemplateControl} control? The control used for evaluation context. * @param {IObject} aliases? An optional alias object containing resource alias values */ evaluateExpression(expression: string | expressions.IParsedExpression, control?: TemplateControl, aliases?: IObject): any; /** * Given a control and Array of aliases, finds the associated resources and builds a context object containing * the values. Returns the object. * @param {plat.ui.TemplateControl} control The control used as the starting point for finding resources. * @param {Array} aliases An array of aliases to search for. * @param {IObject} resources? An optional resources object to extend, * if no resources object is passed in a new one will be created. */ getResources(control: TemplateControl, aliases: string[], resources?: IObject): IObject; /** * Starts at a control and searches up its parent chain for a particular resource alias. * If the resource is found, it will be returned along with the control instance on which * the resource was found. * @param {plat.ui.TemplateControl} control The control on which to start searching for the resource alias. * @param {string} alias The alias to search for. */ findResource(control: TemplateControl, alias: string): { resource: IResource; control: TemplateControl; }; /** * Recursively disposes a control and its children. * @param {plat.ui.TemplateControl} control A control to dispose. */ dispose(control: TemplateControl): void; /** * Loads the control tree depth first (visit children, then visit self). * @param {plat.ui.TemplateControl} control The control serving as the root control to load. */ loadControl(control: TemplateControl): void; /** * Notifies a control that its context has been changed by * calling the `control.contextChanged` method if it exists. * @param {plat.ui.TemplateControl} control The control whose context changed. * @param {any} newValue The new value of the control's context. * @param {any} oldValue The old value of the control's context. */ contextChanged(control: TemplateControl, newValue: any, oldValue: any): void; /** * Sets the `context` resource value on a TemplateControl. If the control specifies * hasOwnContext as true, the `rootContext` resource value will be set. * @param {plat.ui.TemplateControl} control The control whose context resources will be set. */ setContextResources(control: TemplateControl): void; /** * Completely removes a control's element from its parentNode. * @param {plat.ui.TemplateControl} control The control whose element should be removed. */ removeElement(control: TemplateControl): void; /** * Sets the absoluteContextPath read-only property on a control. * @param {plat.ui.TemplateControl} control The control on which to set the absoluteContextPath. * @param {string} path The path to set on the control. */ setAbsoluteContextPath(control: TemplateControl, path: string): void; /** * Determines the template for a control by searching for a templateUrl, * using the provided templateUrl, or serializing the control's templateString. * @param {plat.ui.TemplateControl} control The control whose template is being determined. * @param {string} templateUrl? The potential template URL to use to grab the template. */ determineTemplate(control: TemplateControl, templateUrl?: string): async.Promise; /** * Detaches a TemplateControl. Disposes its children, * but does not dispose the TemplateControl. * @param {plat.ui.TemplateControl} control The control to be detached. */ detach(control: TemplateControl): void; /** * Returns a new instance of TemplateControl. */ getInstance(): TemplateControl; } /** * An extended TemplateControl that allows for the binding of a value to * another listening control (e.g. plat-bind control). */ class BindControl extends TemplateControl implements observable.ISupportTwoWayBinding { /** * Set to 120, higher than `plat-bind` to ensure that BinControls load * prior to the `plat-bind`. */ priority: number; /** * The set of functions added externally that listens * for property changes. */ protected _listeners: IPropertyChangedListener[]; /** * Adds a listener to be called when the bindable property changes. * @param {plat.IPropertyChangedListener} listener The function that acts as a listener. */ onInput(listener: (newValue: any, oldValue: any) => void): IRemoveListener; /** * A function that allows this control to observe both the bound property itself as well as * potential child properties if being bound to an object. * @param {plat.observable.IImplementTwoWayBinding} binder The control that facilitates the * data-binding. */ observeProperties(binder: observable.IImplementTwoWayBinding): void; /** * A function that signifies when this control's bindable property has changed. * @param {any} newValue The new value of the property after the change. * @param {any} oldValue? The old value of the property prior to the change. */ inputChanged(newValue: any, oldValue?: any): void; /** * Removes references to the listeners * defined externally. */ dispose(): void; } /** * A control used in a Viewport for page navigation. The * control has navigation events that are called when navigating to and from the control. A ViewControl * represents a routing component on a page (i.e. a piece of a page that is associated with a particular route). * It has the ability to initiate, approve, and reject navigation to/from itself. A ViewControl also has the * ability to inject a Router and configure sub-navigation. */ class ViewControl extends TemplateControl implements ISupportNavigation { /** * Specifies that this control will have its own context, and it should not inherit a context. */ hasOwnContext: boolean; /** * Every ViewControl inside a Viewport will have a navigator. The navigator is linked to * the router for the Viewport containing the ViewControl. */ navigator: routing.Navigator; /** * Recursively disposes a ViewControl and its children. * @param {plat.ui.ViewControl} control A control to dispose. */ static dispose(control: TemplateControl): void; /** * Returns a new instance of a ViewControl. */ static getInstance(): ViewControl; /** * Allows a ViewControl to asynchronously decide if the app is able to navigate away from the * current view. A possible use of this method might be to popup a confirmation modal. You can * return a boolean or Promise to accept/reject navigation. * A word of caution, this is a navigation-blocking function. It is best to avoid long-running functions. */ canNavigateFrom(): any; /** * Allows a ViewControl to asynchronously decide if it can be navigated to with the given parameters/query. * You can return a boolean or Promise to accept/reject navigation. * A word of caution, this is a navigation-blocking function. It is best to avoid long-running functions. */ canNavigateTo(parameters: any, query: any): any; /** * This method is called when the ViewControl is going out of scope as a result of a navigation. */ navigatingFrom(): any; /** * This method is called when the ViewControl has come into scope as a result of navigation. It can * receive the route parameters and query in order to set its context. */ navigatedTo(parameters: any, query: any): any; } /** * A control can implement this interface in order to support app navigation. This means the control can be linked to an * object that implements the ISupportRouteNavigation interface (e.g. a * Viewport). */ interface ISupportNavigation { /** * When a control is linked to a Viewport, it will have a navigator for facilitating * navigation. */ navigator?: routing.Navigator; /** * Allows a control to asynchronously decide if the app is able to navigate away from the * current view. A possible use of this method might be to popup a confirmation modal. You can * return a boolean or Promise to accept/reject navigation. * A word of caution, this is a navigation-blocking function. It is best to avoid long-running functions. */ canNavigateFrom(): any; /** * Allows a control to asynchronously decide if it can be navigated to with the given parameters/query. * You can return a boolean or Promise to accept/reject navigation. * A word of caution, this is a navigation-blocking function. It is best to avoid long-running functions. */ canNavigateTo(parameters: any, query: any): any; /** * This method is called when the control is going out of scope as a result of a navigation. */ navigatingFrom(): any; /** * This method is called when the control has come into scope as a result of navigation. It can * receive the route parameters and query in order to set its context. */ navigatedTo(parameters: any, query: any): any; } /** * An extensible class dealing with the creation, deletion, and modification * of DOM. */ class Dom { protected static _inject: any; /** * Reference to the DomEvents injectable. */ protected _domEvents: DomEvents; /** * Adds an event listener of the specified type to the specified element. * @param {Window} element The window object. * @param {string} type The type of event to listen to. * @param {EventListener} listener The listener to fire when the event occurs. * @param {boolean} useCapture? Whether to fire the event on the capture or the bubble phase * of event propagation. */ addEventListener(element: Window | Node, type: string, listener: IGestureListener | EventListener, useCapture?: boolean): IRemoveListener; /** * Takes a NodeList and either adds it to the passed in Node, * or creates a DocumentFragment and adds the NodeList to the * Fragment. * @param {NodeList} nodeList A NodeList to be appended to the root/DocumentFragment. * @param {Node} root? An optional Node to append the nodeList. */ appendChildren(nodeList: Node[] | NodeList, root?: Node): Node; /** * Takes a NodeList, clones the nodes, and either adds it to the passed in Node, * or creates a DocumentFragment and adds the NodeList to the * Fragment. * @param {NodeList} nodeList A NodeList to be appended to the root/DocumentFragment. * @param {Node} root? An optional Node to append the nodeList. */ cloneChildren(nodeList: Node[] | NodeList, root?: Node): Node; /** * Clears a DOM Node by removing all of its childNodes. * @param {Node} node The DOM Node to clear. */ clearNode(node: Node): void; /** * Removes all the Nodes in the NodeList from the parent Node. * @param {NodeList} nodeList The NodeList to remove from the parent Node. * @param {Node} parent? The parent Node used to remove the nodeList. */ clearNodeBlock(nodeList: Node[] | NodeList, parent?: Node): void; /** * Sets the innerHTML of a Node. Can take in a Node rather than an Element * because it does not use innerHTML on the passed-in Node (it appends its * childNodes). * @param {Node} node The Node to set innerHTML. * @param {string} html HTML string to be put inside the node. */ setInnerHtml(node: Node, html: string): Node; /** * Inserts a Node before the designated end Node. * @param {Node} parent The parent node into which to insert nodes. * @param {Node} node The Node to insert into the parent. * @param {Node} endNode? An optional endNode to use to insert nodes. */ insertBefore(parent: Node, nodes: Node[] | NodeList | DocumentFragment | Node, endNode?: Node): Node[]; /** * Takes the child nodes of the given node and places them above the node * in the DOM. Then removes the given node. * @param {Node} node The Node to replace. */ replace(node: Node): Node[]; /** * Takes the childNodes of the given element and appends them to the newElement. * Then replaces the element in its parent's tree with the newElement. * @param {Node} node The Node to remove from its parent. * @param {HTMLElement} newElement The HTMLElement to populate with childNodes and add to the * element's parent. */ replaceWith(node: Node, newElement: HTMLElement): HTMLElement; /** * Takes the childNodes of the given element and appends them to the newElement. * Then replaces the element in its parent's tree with the newElement. * @param {Node} node The Node to remove from its parent. * @param {Element} newElement The Element to populate with childNodes and add to the * element's parent. */ replaceWith(node: Node, newElement: Element): Element; /** * Takes the childNodes of the given element and appends them to the newElement. * Then replaces the element in its parent's tree with the newElement. * @param {Node} node The Node to remove from its parent. * @param {Node} newElement The Node to populate with childNodes and add to the * element's parent. */ replaceWith(node: Node, newNode: Node): Node; /** * Takes in a string representing innerHTML and returns a DocumentFragment * containing the serialized DOM. * @param {string} html The DOM string. */ serializeHtml(html: string): DocumentFragment; /** * Takes in a startNode and endNode, each having the same parentNode. * Removes every node in between the startNode. If endNode is not specified, * DOM will be removed until the end of the parentNode's children. * @param {Node} startNode The starting node, which will not be removed. * @param {Node} endNode The ending node, which will not be removed. */ removeBetween(startNode: Node, endNode?: Node): void; /** * Takes in a startNode and endNode, each having the same parentNode. * Removes every node in between the startNode and endNode as well as * the startNode and the endNode. If endNode is not specified, DOM * will be removed until the end of the parentNode's children. * @param {Node} startNode The first node to remove. * @param {Node} endNode The last node to remove. */ removeAll(startNode: Node, endNode?: Node): void; /** * Adds a class or multiple classes to the specified element. * @param {Element} element The element to which the class name is being added. * @param {string} className The class name or space delimited class names to add to the element. */ addClass(element: Element, className: string): void; /** * Removes a class or multiple classes from the specified element. * @param {Element} element The element from which the class name is being removed. * @param {string} className The class name or space delimited class names to remove from the element. */ removeClass(element: Element, className: string): void; /** * Toggles a class or multiple classes from the specified element. * @param {Element} element The element on which the class name is being toggled. * @param {string} className The class name or space delimited class names to toggle on the element. */ toggleClass(element: Element, className: string): void; /** * Replaces a single class with another class. * @param {Element} element The element on which the class name is being toggled. * @param {string} oldClass The class name being replaced. * @param {string} newClass The class name doing the replacing. */ replaceClass(element: Element, oldClass: string, newClass: string): void; /** * Returns whether or not an element has a particular class or classes assigned to it. * @param {Element} element The element on which the class name is being checked. * @param {string} className The class name or space delimited class names to check on the element. */ hasClass(element: Element, className: string): boolean; /** * Retrieves and serializes HTML from an HTML template file using ajax. Will facilitate caching the template * as well. * @param {string} templateUrl The url where the HTML template is stored. */ getTemplate(templateUrl: string): async.Promise; /** * Inspects the Element and resolves when the Element is present in the DOM body. * @param {() => void} cb A callback that will fire when the element is present in the DOM body. * @param {Element} element The element whose presence is being inspected. */ whenPresent(cb: () => void, element: Element): IRemoveListener; /** * Inspects the Element and resolves when the Element is visible in the DOM. * @param {() => void} cb A callback that will fire when the element is visible in the DOM. * @param {Element} element The element whose visibility is being inspected. */ whenVisible(cb: () => void, element: Element): IRemoveListener; } /** * An object describing custom element properties added to elements for hashing purposes. */ interface ICustomElementProperty extends IObject { /** * A unique id given to the element if it's registered for a custom DOM event. */ domEvent?: string; /** * A unique id given to the element if it's registered for an animation. */ animation?: string; } /** * An interface for describing an Element with an ICustomElementProperty attached. Primarily * used for element interaction with DomEvents and the * Animator. */ interface ICustomElement extends HTMLElement { /** * The PlatypusTS custom element property. */ __plat: ICustomElementProperty; } /** * The class which provides a way for TemplateControls to bind a template * to a context. Useful for narrowing context without needing another * TemplateControl. In addition, this object provides a performance increase because * it will only compile the template once. This object is also useful when a * TemplateControls expects multiple configuration templates in its innerHTML. It can * separate those templates and reuse them accordingly. */ class BindableTemplates { /** * Reference to the IResourcesFactory injectable. */ protected _ResourcesFactory: IResourcesFactory; /** * Reference to the IControlFactory injectable. */ protected _ControlFactory: IControlFactory; /** * Reference to the ITemplateControlFactory injectable. */ protected _TemplateControlFactory: ITemplateControlFactory; /** * Reference to the IContextManagerStatic injectable. */ protected _ContextManager: observable.IContextManagerStatic; /** * Reference to the IPromise injectable. */ protected _Promise: async.IPromise; /** * Reference to a cache injectable that stores ElementManagers. */ protected _managerCache: storage.Cache; /** * Reference to the Document injectable. */ protected _document: Document; /** * Reference to the IElementManagerFactory injectable. */ protected _ElementManagerFactory: processing.IElementManagerFactory; /** * Reference to the BindableTemplatesFactory injectable. */ protected _BindableTemplatesFactory: IBindableTemplatesFactory; /** * Reference to the Log injectable. */ protected _log: debug.Log; /** * The control containing this BindableTemplates object. */ control: TemplateControl; /** * Stores promises that resolve to all the compiled templates for this object, ready to be bound to a data context. * All created templates are DocumentFragments, allowing an TemplateControl to * easily insert the template into the DOM (without iterating over childNodes). */ templates: IObject>; /** * A keyed cache of ElementManagers that represent the roots of compiled templates * created by this instance. */ cache: IObject; /** * A collection of all the controls created while compiling an added template. Useful during disposal. */ private __compiledControls; /** * Creates a new instance of BindableTemplates and returns it. If a BindableTemplates is * passed in, it will use the properties on the original BindableTemplates. * @param {plat.ui.TemplateControl} control The TemplateControl * containing the new BindableTemplates object, used for data * context inheritance for templates. * @param {plat.ui.BindableTemplates} original? An optional BindableTemplates * object to copy. */ static create(control: TemplateControl, original?: BindableTemplates): BindableTemplates; /** * Clears the memory being held by control's bindableTemplates. * @param {plat.ui.TemplateControl} control The control whose bindableTemplates will be disposed. */ static dispose(control: TemplateControl): void; /** * Determines whether or not a control was created using bindableTemplates. * @param {plat.ui.TemplateControl} control The potential bound control. */ static isBoundControl(control: TemplateControl): boolean; /** * Adds a template to this object. The template will be stored with the key, * and it will be transformed into a DocumentFragment. * @param {string} template A template string representing the DOM template. * @param {number} relativeIdentifier? The identifier number relative to this control's context * (e.g. '1' would signify the object this.context[1]). Only necessary when context is an array. * @param {plat.IObject} resources? An object used as the resources for any top-level * controls created in the template. * @param {plat.IObject} resources? An object used as the resources for any top-level * controls created in the template. */ once(template: Element | Node | DocumentFragment | Node[] | NodeList | string, relativeIdentifier?: string | number, resources?: IObject): async.Promise; /** * Method for linking a compiled template to a data context and returning a clone of the template, * with all new Controls created if the template contains controls. If no data context * is specified, it will be inherited. * @param {string} key The key used to retrieve the template. * @param {number} relativeIdentifier? The identifier number relative to this control's context * (e.g. '1' would signify the object this.context[1]). Only necessary when context is an array. * @param {plat.IObject} resources? An object used as the resources for any top-level * controls created in the template. */ bind(key: any, relativeIdentifier?: string | number, resources?: IObject): async.Promise; /** * Adds a template to this object. The template will be stored with the key, * and it will be transformed into a DocumentFragment. * @param {string} key The key used to store the template. * @param {string} template A template string representing the DOM template. * @param {boolean} overwrite Specifies whether an already-existing template should be overwritten. */ add(key: string, template: Element | Node[] | NodeList | DocumentFragment | Node | string, overwrite?: boolean): void; /** * Replaces the bound TemplateControl in the child control Array * specified by the index with another bound control generated by the template key, relative context * identifier, and resources. * @param {number} index The index of the bound TemplateControl * in the child control Array to replace. * @param {string} key The key used to retrieve the template. * @param {number} relativeIdentifier? The identifier number relative to this control's context * (e.g. '1' would signify the object this.context[1]). Only necessary when context is an array. * @param {plat.IObject} resources? An object used as the resources for any top-level * controls created in the template. */ replace(index: number, key: string, relativeIdentifier?: number | string, resources?: IObject): async.Promise; /** * Clears the memory being held by this instance. */ dispose(): void; /** * Method for linking a template to a data context and returning a clone of the template, * with all new Controls created if the template contains controls. If no data context * is specified, it will be inherited. * @param {string} key The key used to retrieve the template. * @param {string} relativeIdentifier? The identifier string relative to this control's context * (e.g. 'foo.bar.baz' would signify the object this.context.foo.bar.baz). This is the * most efficient way of specifying context, else the framework has to search for the * object. * @param {plat.IObject} resources? An object used as the resources for any top-level * controls created in the template. * @param {number} index? An optional index only to be used if the newly bound template is intended to * replace an existing Control in the child controls Array and its element in the DOM. */ protected _bind(key: any, relativeIdentifier?: any, resources?: IObject, index?: number): async.Promise; /** * Creates the template's bound control and INodeMap and initiates * the binding of the INodeMap for a cloned template. * @param {string} key The template key. * @param {plat.processing.INodeMap} nodeMap The node map to bind. */ protected _bindTemplate(key: string, nodeMap: processing.INodeMap): async.Promise; /** * Clones the compiled ElementManager using the newly created * INodeMap and binds and loads this control's * ElementManager. * @param {string} key The template key used to grab the ElementManager. * @param {plat.processing.INodeMap} nodeMap The node map to bind. */ protected _bindNodeMap(key: string, nodeMap: processing.INodeMap): async.Promise; /** * Creates the template's compiled, bound control and INodeMap and initiates * the compilation of the template. * @param {string} key The template key. * @param {DocumentFragment} template The HTML template being bound. */ protected _compile(key: string, template: DocumentFragment): void; /** * Instantiates a new ElementManager for the root of this * template and resolves any asynchronous url templates within the template being compiled. * @param {plat.ui.TemplateControl} control The newly created control used to bind the template. * @param {plat.processing.INodeMap} nodeMap The newly created node map to bind. * @param {string} key The template key. */ protected _compileNodeMap(control: TemplateControl, nodeMap: processing.INodeMap, key: string): void; /** * Creates an INodeMap for either a template being compiled or a * template being bound. * @param {plat.ui.TemplateControl} uiControl The newly created control used to bind the template. * @param {Node} template The template being compiled. * @param {string} childContext? A potential child context string identifier. */ protected _createNodeMap(uiControl: TemplateControl, template: Node, childContext?: string | number): processing.INodeMap; /** * Creates a TemplateControl used for binding either a template being compiled * or a template being bound. * @param {string} key The template key. * @param {DocumentFragment} template The template being compiled or being bound. * @param {plat.IObject} resources? A set of resources to add to the control used to * compile/bind this template. */ protected _createBoundControl(key: string, template: DocumentFragment, childContext?: string | number, resources?: IObject): TemplateControl; } /** */ function IBindableTemplatesFactory(): IBindableTemplatesFactory; /** * Creates and manages BindableTemplates. */ interface IBindableTemplatesFactory { /** * Creates a new instance of BindableTemplates and returns it. If a BindableTemplates is * passed in, it will use the properties on the original BindableTemplates. * @param {plat.ui.TemplateControl} control The TemplateControl * containing the new BindableTemplates object, used for data * context inheritance for templates. * @param {plat.ui.BindableTemplates} original? An optional BindableTemplates * object to copy. */ create(control: TemplateControl, original?: BindableTemplates): BindableTemplates; /** * Creates a new instance of BindableTemplates and returns it. If a BindableTemplates is * passed in, it will use the properties on the original BindableTemplates. * @param {plat.ui.TemplateControl} control The TemplateControl * containing the new BindableTemplates object, used for data * context inheritance for templates. * @param {plat.ui.BindableTemplates} original? An optional BindableTemplates * object to copy. */ create(control: TemplateControl, original?: BindableTemplates): BindableTemplates; /** * Clears the memory being held by control's bindableTemplates. * @param {plat.ui.TemplateControl} control The control whose bindableTemplates will be disposed. */ dispose(control: TemplateControl): void; /** * Determines whether or not a control was created using bindableTemplates. * @param {plat.ui.TemplateControl} control The potential bound control. */ isBoundControl(control: TemplateControl): boolean; } /** * The class that stores the information about an Element's attributes (NamedNodeMap). * Methods are implemented to allow you to observe for changes on an attribute. */ class Attributes { [property: string]: any; /** * The set of functions added externally that listens * for attribute changes. */ private __listeners; /** * The control tied to this instance. */ private __control; static getInstance(): Attributes; /** * Initializes this instance with a Control and the camelCased * attribute properties and their values. * @param {plat.Control} control The function that acts as a listener. * @param {plat.IObject} attributes The camelCased attribute properties and their values. */ initialize(control: Control, attributes: IObject): void; /** * Provides a way to observe an attribute for changes. * @param {plat.IPropertyChangedListener} listener The listener function to be called when the attribute changes. * @param {string} key The attribute to observe for changes (e.g. 'src'). */ observe(listener: (newValue: any, oldValue: any) => void, key: string): IRemoveListener; /** * Used to show an attribute has been changed and forces listeners to be fired. * @param {string} key The attribute being observed for changes (e.g. 'src'). * @param {any} newValue The new value of the attribute. * @param {any} oldValue The previous value of the attribute. */ protected _attributeChanged(key: string, newValue: any, oldValue: any): void; } function IAttributesFactory(): typeof Attributes; /** * Resources are used for providing aliases to use in markup expressions. They * are particularly useful when trying to access properties outside of the * current context, as well as reassigning context at any point in an app. */ class Resources { [property: string]: any; /** * The injectable resource type token. */ static INJECTABLE: string; /** * The object resource type token. Objects should be literal objects and won't be observed. */ static OBJECT: string; /** * The observable resource type token. Observable resources are expected to be * string identifiers and will be observed. */ static OBSERVABLE: string; /** * The literal resource type token. Literals will be observed on the resource object, * so if you change `resources..value` it will be reflected everywhere it is * observed. */ static LITERAL: string; /** * The function resource type token. */ static FUNCTION: string; /** * Reference to the ContextManagerStatic injectable. */ protected static _ContextManager: observable.IContextManagerStatic; /** * Reference to the Regex injectable. */ protected static _regex: expressions.Regex; /** * Reference to the Log injectable. */ protected static _log: debug.Log; /** * A list of resources to place on a control. */ private static __controlResources; /** * A list of all resource types. */ private static __resourceTypes; /** * An object consisting of keyed arrays containing functions for removing observation listeners. */ private static __observableResourceRemoveListeners; /** * An object representing all of the currently available resources. */ private __resources; /** * Whether this Resources instance has been bound yet. */ private __bound; /** * The control that these resources are for. */ private __controlInstance; /** * Populates an IResource value if necessary, and adds it to the given * control's resources. * @param {plat.ui.TemplateControl} control The control for which to create a resource. * @param {plat.ui.IResource} resource The object used to set the resource values. */ static create(control: TemplateControl, resource: IResource): IResource; /** * Adds resource aliases for `@control` and `@context`. The resources are * aliases for the control instance and the control.context. * @param {plat.ui.TemplateControl} control The control on which to add the resources. */ static addControlResources(control: TemplateControl): void; /** * Binds the resources in a resource instance. This involves injecting * the injectable resources, creating object/observable resources, and * binding functions to the associated control's instance. * @param {plat.ui.Resources} resourcesInstance The instance of the * Resources object to bind. */ static bindResources(resourcesInstance: Resources): void; /** * Disposes a resource instance, removing its reference * from a control and breaking references to all resource * objects. * @param {plat.ui.TemplateControl} control The control whose resources will be disposed. * @param {boolean} persist? Whether or not to persist a resource object post * disposal or set it to null. */ static dispose(control: TemplateControl, persist?: boolean): void; /** * Parses a resources Element (``) and creates * an IObject with its element children. * @param {Element} element The resources element to parse. */ static parseElement(element: Element): IObject; /** * Returns a new instance with type Resources. */ static getInstance(): Resources; /** * Observes the resource if the type is `observable`. * @param {plat.ui.TemplateControl} control The control in charge of the observable resource. * @param {plat.ui.IResource} resource The resource to observe. */ protected static _observeResource(control: TemplateControl, resource: IResource): void; /** * Removes observable resource listeners for a specified control. * @param {plat.ui.TemplateControl} control The control whose listeners are being removed. */ protected static _removeListeners(control: TemplateControl): void; /** * Adds a `@root` alias and `@rootContext` to a control, specifying that it contains the root * and root context. Root controls are generally the root ViewControl. * @param {plat.ui.TemplateControl} control The root control. */ private static __addRoot; /** * Initializes this Resources instance. * @param {plat.ui.TemplateControl} control The control containing this Resources instance. * @param {plat.ui.Resources} resources? An optional Resources object used to populate initial * IResource objects. */ initialize(controlInstance: TemplateControl, resources?: Element | IObject | Resources): void; /** * Used for programmatically adding IResource objects. * @param {Element} element An Element containing resource element children. */ add(resources: IObject | Element): void; } /** */ function IResourcesFactory(_ContextManager?: observable.IContextManagerStatic, _regex?: expressions.Regex, _log?: debug.Log): IResourcesFactory; /** * Creates and manages Resources for TemplateControls. */ interface IResourcesFactory { /** * The injectable resource type token. */ INJECTABLE: string; /** * The object resource type token. */ OBJECT: string; /** * The observable resource type token. Observable resources are expected to be * string identifiers and will be observed. */ OBSERVABLE: string; /** * The literal resource type token. Literals will be observed on the resource object, * so if you change `resources..value` it will be reflected everywhere it is * observed. */ LITERAL: string; /** * The function resource type token. */ FUNCTION: string; /** * Populates an IResource value if necessary, and adds it to the given * control's resources. * @param {plat.ui.TemplateControl} control The control for which to create a resource. * @param {plat.ui.IResource} resource The object used to set the resource values. */ create(control: TemplateControl, resource: IResource): IResource; /** * Adds resource aliases for `@control` and `@context`. The resources are * aliases for the control instance and the control.context. * @param {plat.ui.TemplateControl} control The control on which to add the resources. */ addControlResources(control: TemplateControl): void; /** * Binds the resources in a resource instance. This involves injecting * the injectable resources, creating object/observable resources, and * binding functions to the associated control's instance. * @param {plat.ui.Resources} resourcesInstance The instance of the Resources object. */ bindResources(resourcesInstance: Resources): void; /** * Disposes a resource instance, removing its reference * from a control and breaking references to all resource * objects. * @param {plat.ui.TemplateControl} control The control whose resources will be disposed. * @param {boolean} persist? Whether or not to persist a resource object post * disposal or set it to null. */ dispose(control: TemplateControl, persist?: boolean): void; /** * Parses a resources Element (``) and creates * an IObject with its element children. * @param {Element} element The resources element to parse. */ parseElement(element: Element): IObject; /** * Returns a new instance with type Resources. */ getInstance(): Resources; } /** * Defines a single resource on the Resources object. */ interface IResource { /** * The type of resource. * - injectable * - observable * - object * - function */ type: string; /** * The alias used to reference the resource. */ alias?: string; /** * The value of the resource. */ value?: any; /** * The initial value of the resource prior to it being observed. */ initialValue?: any; } /** * A class for managing DOM event registration and handling. */ class DomEvents { protected static _inject: any; /** * A configuration object for all DOM events. */ static config: IDomEventsConfig; /** * An object containing the event types for all of the * supported gestures. */ static gestures: IGestures; /** * An object containing the event types for all of the * supported gestures. */ protected _gestures: IGestures; /** * Reference to the Document injectable. */ protected _document: Document; /** * Reference to the Compat injectable. */ protected _compat: Compat; /** * The version of android, or -1 if not on android. */ protected _androidVersion: number; /** * Whether or not we're on Android 4.4.x or below. */ protected _android44orBelow: boolean; /** * Whether or not the DomEvents are currently active. * They become active at least one element on the current * page is listening for a custom event. */ protected _isActive: boolean; /** * Whether or not the user is currently touching the screen. */ protected _inTouch: boolean; /** * Whether or not the user is using mouse when touch events are present. */ protected _inMouse: boolean; /** * An object with keyed subscribers that keep track of all of the * events registered on a particular element. */ protected _subscribers: IObject; /** * The space delimited touch start events defined by this browser. */ protected _startEvents: string; /** * The space delimited touch move events defined by this browser. */ protected _moveEvents: string; /** * The space delimited touch end events defined by this browser. */ protected _endEvents: string; /** * An object containing the number of currently active * events of each base type. */ protected _gestureCount: IBaseGestures; /** * Whether or not the user moved while in touch. */ private __hasMoved; /** * Whether or not their is a registered "release" event. */ private __hasRelease; /** * Whether or not we should be detecting move events. */ private __detectingMove; /** * The current tap count to help distinguish single from double taps. */ private __tapCount; /** * The total number of touches on the screen. */ private __touchCount; /** * A function to remove a deferred tap given the case that a tap delay was needed for * something such as a double tap to zoom feature. */ private __cancelDeferredTap; /** * A function for removing a deferred hold event. */ private __cancelDeferredHold; /** * A regular expression for determining a "cancel" event. */ private __cancelRegex; /** * A regular expression for determining a pointer end event. */ private __pointerEndRegex; /** * The user's last touch down. */ private __lastTouchDown; /** * The starting place of an initiated swipe gesture. */ private __swipeOrigin; /** * Whether or not there are any swipe subscribers for the current target during touch move events. */ private __haveSwipeSubscribers; /** * The user's last move while in touch. */ private __lastMoveEvent; /** * The user's last touch up. */ private __lastTouchUp; /** * The captured target that the user first initiated a gesture on. */ private __capturedTarget; /** * The currently focused or active element. */ private __focusedElement; /** * A function to stop listening for blur events on the currently focused element. */ private __blurRemover; /** * A function to stop listening for the phantom click event removal. */ private __delayedClickRemover; /** * A set of flags signifying whether we should ignore native events or not. */ private __ignoreEvent; /** * A function with a bound context that prevents default and stops propagation for delayed or phantom clicks. */ private __boundPreventDefaultClick; /** * A hash map for mapping custom events to standard events. */ private __reverseMap; /** * An object containing the number of currently active mapped touch * events of each type. */ private __mappedCount; /** * A hash of the current pointer touch points on the page. */ private __pointerHash; /** * An array containing all current pointer touch points on the page. */ private __pointerEvents; /** * A set of touch start, move, and end listeners to be place on the document. */ private __listeners; /** * Retrieve the type of touch events for this browser and create the default gesture style. */ constructor(); /** * Add an event listener for the specified event type on the specified element. * @param {Window} element The window object. * @param {string} type The type of event being listened to. * @param {EventListener} listener The listener to be fired. * @param {boolean} useCapture? Whether to fire the event on the capture or bubble phase of propagation. */ addEventListener(element: Node | Window, type: string, listener: EventListener | IGestureListener, useCapture?: boolean): IRemoveListener; /** * If DomEvents is inactive, will initialize behavior and * begin listening for events. */ initialize(): void; /** * Stops listening for touch events and resets the DomEvents * instance. */ dispose(): void; /** * A listener for touch/mouse start events. * @param {plat.ui.IPointerEvent} ev The touch start event object. */ protected _onTouchStart(ev: IPointerEvent): boolean; /** * A listener for touch/mouse move events. * @param {plat.ui.IPointerEvent} ev The touch move event object. */ protected _onTouchMove(ev: IPointerEvent): boolean; /** * A listener for touch/mouse end events. * @param {plat.ui.IPointerEvent} ev The touch end event object. */ protected _onTouchEnd(ev: IPointerEvent): boolean; /** * Clears all temporary states like move and hold events. */ private __clearTempStates; /** * A function for resetting all values potentially modified during the touch event sequence. */ private __resetTouchEnd; /** * A function for handling when gestures are canceled via the Browser. * @param {plat.ui.IPointerEvent} ev The touch cancel event object. */ private __handleCanceled; /** * A function for handling and firing mapped events. * @param {string} type The event type. * @param {plat.ui.IPointerEvent} ev The touch end event object. * @param {plat.ui.IPointerEvent} payload The trigger payload. */ private __handleMappedEvents; /** * A function for handling and firing tap events. * @param {plat.ui.IPointerEvent} ev The touch end event object. */ private __handleTap; /** * A function for handling and firing double tap events. * @param {plat.ui.IPointerEvent} ev The touch end event object. */ private __handleDbltap; /** * A function for handling and firing release events. * @param {plat.ui.IPointerEvent} ev The touch end event object. */ private __handleRelease; /** * A function for handling and firing swipe events. */ private __handleSwipe; /** * A function for handling and firing track events. * @param {plat.ui.IPointerEvent} ev The touch move event object. * @param {plat.ui.IPointerEvent} originalEv The original touch move event object * used for preventing default in the case of an ANDROID device. */ private __handleTrack; /** * A function for handling and firing track end events. * @param {plat.ui.IPointerEvent} ev The touch end event object. */ private __handleTrackEnd; /** * A function for determining the proper touch events. */ private __getTypes; /** * Registers for and starts listening to start and end touch events on the document. */ private __registerTypes; /** * Un-registers for and stops listening to all touch events on the document. */ private __unregisterTypes; /** * Registers for and begins listening to a particular touch event type. * @param {string} events The events to begin listening for. */ private __registerType; /** * Un-registers for and stops listening to a particular touch event type. * @param {string} events The events to stop listening for. */ private __unregisterType; /** * Registers for and begins listening to touch move event types if any moving events are registered. * @param {string} eventType The current event's type. */ private __registerMove; /** * Registers and associates an element with an event. * @param {plat.ui.ICustomElement} element The element being tied to a custom event. * @param {string} type The type of event. */ private __registerElement; /** * Un-registers and disassociates an element with an event. * @param {plat.ui.ICustomElement} element The element being disassociated with the given custom event. * @param {string} type The type of event. */ private __unregisterElement; /** * Sets the current touch point and helps standardize the given event object. * @param {plat.ui.IPointerEvent} ev The current point being touched. */ private __setTouchPoint; /** * Sets the captured target. * @param {EventTarget} target The target to capture. */ private __setCapture; /** * Sets the captured target. * @param {plat.ui.IPointerEvent} ev The current touch point. * @param {boolean} remove Whether to remove the touch point or add it. */ private __updatePointers; /** * Searches from the EventTarget up the DOM tree looking for an element with the * registered event type. * @param {plat.ui.ICustomElement} eventTarget The current target of the touch event. * @param {string} type The type of event being searched for. */ private __findFirstSubscriber; /** * Searches from the EventTarget up the DOM tree looking for all elements with the * registered event types. * @param {plat.ui.ICustomElement} eventTarget The current target of the touch event. * @param {Array} types An array of the types of events being searched for. */ private __findFirstSubscribers; /** * Removes an event listener for a given event type. * @param {plat.ui.ICustomElement} element The element to remove the listener from. * @param {string} type The type of event being removed. * @param {plat.ui.IGestureListener} listener The listener being removed. * @param {boolean} useCapture? Whether the listener is fired on the capture or bubble phase. */ private __removeEventListener; /** * Removes an element from the subscriber object. * @param {plat.ui.ICustomElement} element The element being removed. */ private __removeElement; /** * Standardizes certain properties on the event object for custom events. * @param {plat.ui.IExtendedEvent} ev The event object to be standardized. */ private __standardizeEventObject; /** * Normalizes the 'buttons' property on an IExtendedEvent. * @param {plat.ui.IExtendedEvent} ev The event. */ private __normalizeButtons; /** * Searches through the input array looking for the primary * touch down index. * @param {Array} ev The array of touch event objects * to search through. */ private __getTouchIndex; /** * Grabs the x and y offsets of an event object's target. * @param {plat.ui.IExtendedEvent} ev The current event object. */ private __getOffset; /** * Calculates the distance between two (x, y) coordinate points. * @param {number} x1 The x-coordinate of the first point. * @param {number} x2 The x-coordinate of the second point. * @param {number} y1 The y-coordinate of the first point. * @param {number} y2 The y-coordinate of the second point. */ private __getDistance; /** * Calculates the velocity between two (x, y) coordinate points over a given time. * @param {number} dx The change in x position. * @param {number} dy The change in y position. * @param {number} dtx The change in time in x direction. * @param {number} dty The change in time in y direction. */ private __getVelocity; /** * Calculates the direction of movement. * @param {number} dx The change in x position. * @param {number} dy The change in y position. */ private __getDirection; /** * Checks to see if a swipe direction has changed to recalculate * an origin point. * @param {plat.ui.IDirection} direction The current vertical and horizontal directions of movement. */ private __handleOriginChange; /** * Checks to see if a swipe event has been registered. * @param {plat.ui.IDirection} direction The current horizontal and vertical directions of movement. * @param {plat.ui.IVelocity} velocity The current horizontal and vertical velocities. * @param {number} dx The distance in the x direction. * @param {number} dy The distance in the y direction. */ private __getRegisteredSwipes; /** * Checks to see if a swipe event has been registered. * @param {string} direction The current direction of movement. */ private __isHorizontal; /** * Appends CSS to the head for gestures if needed. */ private __appendGestureStyle; /** * Creates a style text to append to the document head. * @param {plat.ui.IDefaultStyle} styleClass The object containing the custom styles for * gestures. */ private __createStyle; /** * Blurs the currently focused element. */ private __blurFocusedElement; /** * Listens for blur and then sets the focused element back to null for the next case. * @param {HTMLInputElement} target The target to listen for the blur event on. */ private __waitForBlur; /** * Handles a click target case. * @param {HTMLInputElement} target The target to handle click functionality for. */ private __clickTarget; /** * Handles HTMLInputElements in WebKit based touch applications. * @param {HTMLInputElement} target The target to handle functionality for. */ private __handleInput; /** * Handles the phantom click in WebKit based touch applications. */ private __preventClickFromTouch; /** * Prevents default and stops propagation for delayed or phantom clicks. * @param {Event} ev The event object. */ private __preventDefaultClick; /** * Removes selection capability from the element. * @param {Node} element The element to remove selections on. */ private __removeSelections; /** * Returns selection capability from the element. * @param {Node} element The element to return selections on. */ private __returnSelections; /** * Prevents default and stops propagation in all elements other than * inputs and textareas. * @param {Event} ev The event object. */ private __preventDefault; } /** */ function IDomEventsConfig(): IDomEventsConfig; /** * A class for managing a single custom event. */ class DomEvent { /** * Reference to the Document injectable. */ protected _document: Document; /** * The node or window object associated with this DomEvent object. */ element: any; /** * The event type associated with this DomEvent object. */ event: string; /** * The event type to dispatch. Defaults to 'CustomEvent'. */ eventType: string; /** * Initializes the element and event of this DomEvent object. * @param {Window} element The window object. * @param {string} event The event associated with this DomEvent object. * @param {string} eventType? The event type associated with this DomEvent object. * If not specified, it will default to 'CustomEvent'. */ initialize(element: Node | Window, event: string, eventType?: string): void; /** * Triggers its event on its element. * @param {Object} eventExtension? An event extension to extend the dispatched CustomEvent. * @param {any} detailArg? The detail arg to include in the event object * @param {Node} dispatchElement? The element to dispatch the Event from. If not specified, * this instance's element will be used. */ trigger(eventExtension?: Object, detailArg?: any, dispatchElement?: Node): boolean; } /** * An extended event object containing coordinate, time, and target info. */ interface ITouchStartEventProperties { /** * Indicates which mouse button is being pressed in a mouse event. */ _buttons?: number; /** * The x-coordinate of the event on the screen relative to the upper left corner of the * browser window. This value cannot be affected by scrolling. */ clientX?: number; /** * The y-coordinate of the event on the screen relative to the upper left corner of the * browser window. This value cannot be affected by scrolling. */ clientY?: number; /** * A unique touch identifier. */ identifier?: number; /** * A timestamp. */ timeStamp?: number; /** * The target of an Event object. */ target?: EventTarget; } /** * An extended event object containing coordinate, time, and target info for a swipe origin. */ interface ISwipeOriginProperties { /** * The x-coordinate of the event on the screen relative to the upper left corner of the * browser window. This value cannot be affected by scrolling. */ clientX?: number; /** * The y-coordinate of the event on the screen relative to the upper left corner of the * browser window. This value cannot be affected by scrolling. */ clientY?: number; /** * A timestamp. */ xTimestamp?: number; /** * A timestamp. */ yTimestamp?: number; /** * The target of an Event object. */ xTarget?: EventTarget; /** * The target of an Event object. */ yTarget?: EventTarget; } /** * An extended event object potentially containing coordinate and movement information. */ interface IExtendedEvent extends Event { _buttons?: number; /** * Indicates which mouse button is being pressed in a mouse event. */ buttons?: number; /** * The x-coordinate of the event on the screen relative to the upper left corner of the * browser window. This value cannot be affected by scrolling. */ clientX?: number; /** * The y-coordinate of the event on the screen relative to the upper left corner of the * browser window. This value cannot be affected by scrolling. */ clientY?: number; /** * The x-coordinate of the event on the screen relative to the upper left corner of the * physical screen or monitor. */ screenX?: number; /** * The y-coordinate of the event on the screen relative to the upper left corner of the * physical screen or monitor. */ screenY?: number; /** * The x-coordinate of the event on the screen relative to the upper left corner of the * fully rendered content area in the browser window. This value can be altered and/or affected by * embedded scrollable pages when the scroll bar is moved. */ pageX?: number; /** * The y-coordinate of the event on the screen relative to the upper left corner of the * fully rendered content area in the browser window. This value can be altered and/or affected by * embedded scrollable pages when the scroll bar is moved. */ pageY?: number; /** * The x-coordinate of the event relative to the top-left corner of the * offsetParent element that fires the event. */ offsetX?: number; /** * The y-coordinate of the event relative to the top-left corner of the * offsetParent element that fires the event. */ offsetY?: number; /** * The x and y-coordinates of the event as an object relative to the top-left corner of the * offsetParent element that fires the event. */ offset: IPoint; /** * The horizontal and vertical directions associated with this event. */ direction?: IDirection; /** * The potential velocity associated with the event. */ velocity?: IVelocity; _touches?: IExtendedEvent[]; /** * An array containing all current touch points. The IExtendedEvents * may slightly differ depending on the browser implementation. */ touches?: IExtendedEvent[]; /** * An array containing all recently changed touch points. This should not be present on * the triggered custom event. */ changedTouches?: IExtendedEvent[]; /** * A unique touch identifier. */ identifier?: number; } /** * An extended event object potentially containing coordinate and movement information as * well as pointer type for pointer events. */ interface IPointerEvent extends IExtendedEvent { /** * The type of interaction associated with the touch event ('touch', 'pen', 'mouse', ''). */ pointerType?: string; /** * A unique touch identifier. */ pointerId?: number; } /** * The type of event object passed into the listeners for our custom events. */ interface IGestureEvent extends CustomEvent { /** * Indicates which mouse button is being pressed in a mouse event. */ buttons?: number; /** * The x-coordinate of the event on the screen relative to the upper left corner of the * browser window. This value cannot be affected by scrolling. */ clientX?: number; /** * The y-coordinate of the event on the screen relative to the upper left corner of the * browser window. This value cannot be affected by scrolling. */ clientY?: number; /** * The x-coordinate of the event on the screen relative to the upper left corner of the * physical screen or monitor. */ screenX?: number; /** * The y-coordinate of the event on the screen relative to the upper left corner of the * physical screen or monitor. */ screenY?: number; /** * The x-coordinate of the event on the screen relative to the upper left corner of the * fully rendered content area in the browser window. This value can be altered and/or affected by * embedded scrollable pages when the scroll bar is moved. */ pageX?: number; /** * The y-coordinate of the event on the screen relative to the upper left corner of the * fully rendered content area in the browser window. This value can be altered and/or affected by * embedded scrollable pages when the scroll bar is moved. */ pageY?: number; /** * The x-coordinate of the event relative to the top-left corner of the * offsetParent element that fires the event. */ offsetX?: number; /** * The y-coordinate of the event relative to the top-left corner of the * offsetParent element that fires the event. */ offsetY?: number; /** * The horizontal and vertical directions associated with this event. */ direction?: IDirection; /** * The potential velocity associated with the event. */ velocity?: IVelocity; /** * An array containing all current touch points. The IExtendedEvents * may slightly differ depending on the browser implementation. */ touches?: IExtendedEvent[]; /** * The type of interaction associated with the touch event ('touch', 'pen', 'mouse', ''). */ pointerType?: string; /** * A unique touch identifier. */ identifier?: number; } /** * The listener interface for our custom DOM events. */ type IGestureListener = (ev?: IGestureEvent) => void; /** * Describes an object containing information * regarding our base custom events. */ interface IBaseGestures { /** * The string type|number of events associated with the tap event. */ $tap?: T; /** * The string type|number of events associated with the dbltap event. */ $dbltap?: T; /** * The string type|number of events associated with the hold event. */ $hold?: T; /** * The string type|number of events associated with the release event. */ $release?: T; /** * The string type|number of events associated with the swipe event. */ $swipe?: T; /** * The string type|number of events associated with the track event. */ $track?: T; /** * The string type|number of events associated with the trackend event. */ $trackend?: T; } /** * Describes an object containing information * regarding all our custom events. */ interface IGestures extends IBaseGestures { /** * The string type|number of events associated with the swipeleft event. */ $swipeleft?: T; /** * The string type|number of events associated with the swiperight event. */ $swiperight?: T; /** * The string type|number of events associated with the swipeup event. */ $swipeup?: T; /** * The string type|number of events associated with the swipedown event. */ $swipedown?: T; /** * The string type|number of events associated with the trackleft event. */ $trackleft?: T; /** * The string type|number of events associated with the trackright event. */ $trackright?: T; /** * The string type|number of events associated with the trackup event. */ $trackup?: T; /** * The string type|number of events associated with the trackdown event. */ $trackdown?: T; } /** * Describes an object to keep track of a single * element's registered custom event types. */ interface IEventSubscriber extends IGestures { /** * The total registered gesture count for the associated element. */ gestureCount: number; } /** * Describes an object containing x and y coordinates. */ interface IPoint { /** * The x-coordinate. */ x: number; /** * The y-coordinate. */ y: number; } /** * Describes an object containing a direction in both the horizontal and vertical directions. */ interface IDirection { /** * The horizontal, x-direction */ x: string; /** * The vertical, y-direction. */ y: string; /** * The direction whose vector magnitude is the greatest. */ primary: string; } /** * Describes an object containing a speed in both the horizontal and vertical directions. */ interface IVelocity { /** * The horizontal, x velocity. */ x: number; /** * The vertical, y velocity. */ y: number; } /** * Describes an object containing time interval information that * governs the behavior of certain custom DOM events. */ interface IIntervals { /** * The max time in milliseconds a user can hold down on the screen * for a tap event to be fired. Defaults to 300 ms. */ tapInterval: number; /** * The max time in milliseconds a user can wait between consecutive * taps for a dbltap event to be fired. Defaults to 300 ms. */ dblTapInterval: number; /** * The time in milliseconds a user must hold down on the screen * before a hold event is fired or a release event can be fired. * Defaults to 400 ms. */ holdInterval: number; /** * The delay in milliseconds between the time a user taps to the time * the tap event fires. Used in the case where a double-tap-to-zoom * feature is required. Defaults to 0 ms. */ dblTapZoomDelay: number; /** * The delay in milliseconds we preventDefault on click events after a * successful touchend event. Defaults to 400 ms. */ delayedClickInterval: number; } /** * Describes an object containing distance information that * governs the behavior of certain custom DOM events. */ interface IDistances { /** * The minimum distance a user must move after touch down to register * it as a scroll instead of a tap. Defaults to 3. */ minScrollDistance: number; /** * The maximum distance between consecutive taps a user is allowed to * register a dbltap event. Defaults to 20. */ maxDblTapDistance: number; } /** * Describes an object containing velocity information that * governs the behavior of certain custom DOM events. */ interface IVelocities { /** * The minimum velocity a user must move after touch down to register * a swipe event. Defaults to 0.8. */ minSwipeVelocity: number; } /** * Describes an object used for creating a custom class for styling an element * listening for a custom DOM event. */ interface IDefaultStyle { /** * The className that will be used to define the custom style. */ className: string; /** * An array of string styles in the format: * CSS identifier : value * (e.g. 'width : 100px') */ styles: string[]; } /** * Describes a configuration object for all custom DOM events. */ interface IDomEventsConfig { /** * An object containing the different time intervals that govern the behavior of certain * custom DOM events. */ intervals: IIntervals; /** * An object containing the different minimum/maximum distances that govern the behavior of certain * custom DOM events. */ distances: IDistances; /** * An object containing the different minimum/maximum velocities that govern the behavior of certain * custom DOM events. */ velocities: IVelocities; /** * The default CSS styles applied to elements listening for custom DOM events. */ styleConfig: IDefaultStyle[]; } /** * Holds all the classes and interfaces related to UI animation components for platypus. */ namespace animations { /** * A class used for animating elements. */ class Animator { protected static _inject: any; /** * Reference to the Compat injectable. */ protected _compat: Compat; /** * Reference to the IPromise injectable. */ protected _Promise: async.IPromise; /** * Reference to the Document injectable. */ protected _document: Document; /** * Objects representing collections of all currently animated elements. */ protected _animatedElements: IObject; /** * Creates the defined animation denoted by the key but does not start the animation. * @param {Array} elements The Array of Nodes to be animated. All nodes in the Array must have * the same parent, otherwise the animation will not function correctly. * @param {string} key The identifier specifying the type of animation. * @param {any} options? Specified options for the animation. */ create(elements: Element | DocumentFragment | NodeList | Node[], key: string, options?: any): IAnimationCreation; /** * Animates the element with the defined animation denoted by the key. Similar to `create` but * immediately begins the animation. * @param {Array} elements The Array of Nodes to be animated. All nodes in the Array must have * the same parent, otherwise the animation will not function correctly. * @param {string} key The identifier specifying the type of animation. * @param {any} options? Specified options for the animation. */ animate(elements: Element | DocumentFragment | NodeList | Node[], key: string, options?: any): IAnimatingThenable; /** * Adds the elements to the DOM and animates them with the defined animation denoted by the key. * @param {Array} elements The Array of Nodes to be animated. All nodes in the Array must have * the same parent, otherwise the animation will not function correctly. * @param {string} key The identifier specifying the type of animation. * @param {Element} parent The parent element used for adding the elements to the DOM. * @param {Node} refChild? An optional reference node used for placing the element into the DOM * just before itself using the insertBefore function. If this argument is specified, the parent argument * is ignored. * @param {any} options? Specified options for the animation. */ enter(elements: Element | DocumentFragment | NodeList | Node[], key: string, parent: Element, refChild?: Node, options?: any): IAnimatingThenable; /** * Animates the elements with the defined animation denoted by the key and removes them from the DOM when * the animation is finished. * @param {Array} elements The Array of Nodes to be animated. All nodes in the Array must have * the same parent, otherwise the animation will not function correctly. * @param {string} key The identifier specifying the type of animation. * @param {any} options? Specified options for the animation. */ leave(elements: Element | DocumentFragment | NodeList | Node[], key: string, options?: any): IAnimatingThenable; /** * Removes the elements from the DOM based on the parent argument, initializes them, adds them back to the * DOM using either the refChild or the parent, and animates them with the defined animation denoted by the key. * @param {Array} elements The Array of Nodes to be animated. All nodes in the Array must have * the same parent, otherwise the animation will not function correctly. * @param {string} key The identifier specifying the type of animation. * @param {Element} parent The parent element used for placing the element back into the DOM at its end if a * refChild is not specified. * @param {Node} refChild? An optional reference node used for placing the element into the DOM * just before itself using the insertBefore function. If this argument is specified, the parent argument * is ignored during DOM insertion. * @param {any} options? Specified options for the animation. */ move(elements: Element | DocumentFragment | NodeList | Node[], key: string, parent: Element, refChild?: Node, options?: any): IAnimatingThenable; /** * Shows the elements just after initialization by removing the `plat-hide` attribute and animates them * with the defined animation denoted by the key. * @param {Array} elements The Array of Nodes to be animated. All nodes in the Array must have * the same parent, otherwise the animation will not function correctly. * @param {string} key The identifier specifying the type of animation. * @param {any} options? Specified options for the animation. */ show(elements: Element | DocumentFragment | NodeList | Node[], key: string, options?: any): IAnimatingThenable; /** * Animates the elements with the defined animation denoted by the key and hides them by adding the * `plat-hide` attribute after the animation is finished. * @param {Array} elements The Array of Nodes to be animated. All nodes in the Array must have * the same parent, otherwise the animation will not function correctly. * @param {string} key The identifier specifying the type of animation. * @param {any} options? Specified options for the animation. */ hide(elements: Element | DocumentFragment | NodeList | Node[], key: string, options?: any): IAnimatingThenable; /** * Returns a promise that fulfills when every animation promise in the input array is fulfilled. */ all(values: [T1 | IAnimationThenable, T2 | IAnimationThenable, T3 | IAnimationThenable, T4 | IAnimationThenable, T5 | IAnimationThenable, T6 | IAnimationThenable, T7 | IAnimationThenable, T8 | IAnimationThenable, T9 | IAnimationThenable, T10 | IAnimationThenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | IAnimationThenable, T2 | IAnimationThenable, T3 | IAnimationThenable, T4 | IAnimationThenable, T5 | IAnimationThenable, T6 | IAnimationThenable, T7 | IAnimationThenable, T8 | IAnimationThenable, T9 | IAnimationThenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | IAnimationThenable, T2 | IAnimationThenable, T3 | IAnimationThenable, T4 | IAnimationThenable, T5 | IAnimationThenable, T6 | IAnimationThenable, T7 | IAnimationThenable, T8 | IAnimationThenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | IAnimationThenable, T2 | IAnimationThenable, T3 | IAnimationThenable, T4 | IAnimationThenable, T5 | IAnimationThenable, T6 | IAnimationThenable, T7 | IAnimationThenable]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | IAnimationThenable, T2 | IAnimationThenable, T3 | IAnimationThenable, T4 | IAnimationThenable, T5 | IAnimationThenable, T6 | IAnimationThenable]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | IAnimationThenable, T2 | IAnimationThenable, T3 | IAnimationThenable, T4 | IAnimationThenable, T5 | IAnimationThenable]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | IAnimationThenable, T2 | IAnimationThenable, T3 | IAnimationThenable, T4 | IAnimationThenable]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | IAnimationThenable, T2 | IAnimationThenable, T3 | IAnimationThenable]): Promise<[T1, T2, T3]>; all(values: [T1 | IAnimationThenable, T2 | IAnimationThenable]): Promise<[T1, T2]>; all(values: [T1 | IAnimationThenable]): Promise<[T1]>; /** * Immediately resolves an empty AnimationPromise. */ resolve(): IAnimatingThenable; /** * Animates the passed in elements with the given key and handles special animation functionality. * @param {any} elements The Nodes to be animated. All nodes in the Array must have * the same parent, otherwise the animation will not function correctly. * @param {string} key The identifier specifying the type of animation. * @param {any} options? Specified options for the animation. * @param {plat.ui.animations.IAnimationFunction} functionality An object containing detailed information about * special animation functionality. */ protected _animate(elements: any, key: string, options: any, functionality: IAnimationFunction): IAnimatingThenable; /** * Animates the passed in elements with the given key and handles special animation functionality. Returns both * the previous and current animations for the given element(s). * @param {any} elements The Nodes to be animated. All nodes in the Array must have * the same parent, otherwise the animation will not function correctly. * @param {string} key The identifier specifying the type of animation. * @param {any} options? Specified options for the animation. * @param {plat.ui.animations.IAnimationFunction} functionality An object containing detailed information about * special animation functionality. */ protected _create(elements: any, key: string, options: any, functionality: IAnimationFunction): IAnimationCreation; /** * Handles different specialized functionalities immediately before the init portion of the animation cycle. * @param {Array} nodes All the nodes being animated. * @param {Array} elementNodes The animatable nodes being animated (only of type Node.ELEMENT_NODE). * @param {plat.ui.animations.IAnimationFunction} functionality The specialized animation function attributes. */ protected _handlePreInitFunctionality(nodes: Node[], elementNodes: Element[], functionality: IAnimationFunction): void; /** * Handles different specialized functionalities immediately after the init portion of the animation cycle. * @param {Array} nodes All the nodes being animated. * @param {Array} elementNodes The animatable nodes being animated (only of type Node.ELEMENT_NODE). * @param {plat.ui.animations.IAnimationFunction} functionality The specialized animation function attributes. */ protected _handlePostInitFunctionality(nodes: Node[], elementNodes: Element[], functionality: IAnimationFunction): void; /** * Handles different specialized functionalities at the end portion of the animation cycle. * @param {Array} nodes All the nodes being animated. * @param {Array} elementNodes The animatable nodes being animated (only of type Node.ELEMENT_NODE). * @param {plat.ui.animations.IAnimationFunction} functionality The specialized animation function attributes. */ protected _handleEndFunctionality(nodes: Node[], elementNodes: Element[], functionality: IAnimationFunction): void; /** * Sets a new, unique animation ID and denotes the elements as currently being animated. * @param {string} id The animation ID. * @param {Array} elements The Array of Elements being animated. */ private __setAnimationId; /** * Generates a new animated element for the Animator to easily reference and be able * to end later on. * @param {string} id The animation ID. * @param {Array} elements The Array of Elements being animated. * @param {plat.ui.animations.AnimationPromise} animationPromise The animation's associated promise. */ private __generateAnimatedElement; /** * Checks whether or not any parent elements are animating. * @param {Array} elements The Elements whose parents we need to check. */ private __isParentAnimating; /** * Forces child nodes of an animating element to stop animating. * @param {Element} element The element being animated. */ private __stopChildAnimations; /** * Sifts through an Array of Nodes and finds all animatable Elements and creates * BaseAnimations for them. * @param {any} elements The Array of Nodes, DocumentFragment, or element to sift through. * @param {plat.dependency.Injector} animationInjector The injector to instantiate * BaseAnimations. * @param {Array} elementNodes The Array of only animatable elements. * @param {Array>} animationInstances An empty Array of animation instances to add to. */ private __constructAnimatableElements; } /** * Describes an object representing a special animation functionality. */ interface IAnimationFunction { /** * The special functionality key. */ key: string; /** * The parent Element of the Element being animated. */ parent?: Element; /** * The reference child for placing the animated Element just before * it in the DOM. */ refChild?: Node; } /** * Describes an object representing a currently animated element. */ interface IAnimatedElement { /** * A promise representing an element's current state of animation. */ promise?: IAnimationThenable; /** * The function called at the conclusion of the animation. * @param {boolean} cancel? Specifies whether the animation is being cancelled. */ animationEnd(cancel?: boolean): void; } /** * Describes a function used to obtain an animating parent element's animation thenable. */ type IGetAnimatingThenable = () => IAnimationThenable; /** * Describes a type of Promise that can be optionally cancelled. * Further, in the case where it may have a parent that is animating (which will cause it to immediately cancel and fulfill * itself, it resolves with a IGetAnimatingThenable for accessing * the IAnimationThenable of the animating parent element. */ class AnimationPromise extends async.Promise implements IAnimationEssentials, IAnimatingThenable { /** * Reference to the IPromise injectable. */ protected _Promise: async.IPromise; /** * The state of the animation. 0 prior to start, 1 if started, and * 2 if canceled. */ private __animationState; /** * An Array of animation instances linked to this promise. */ private __animationInstances; /** * The constructor method for the {@link plat.async.AjaxPromise}. * @param {(resolve: (value?: plat.ui.animations.IParentAnimationFn) => any) => void} resolveFunction A resolve function * that only allows for a resolve of void and no reject. * @param {any} promise? The promise object to allow for cancelling the {@link plat.ui.animations.AnimationPromise}. */ constructor(resolveFunction: (resolve: (value?: IGetAnimatingThenable) => any) => void, promise?: any); /** * Initializes the promise, providing it with the {@link plat.ui.animations.BaseAnimation} instance. * @param {Array} instances The animation instances or * animation promises for this promise. */ initialize(instances: IAnimationEssentials | IAnimationEssentials[]): void; /** * Gets the associated animation instances or animated promises. */ getInstances(): IAnimationEssentials[]; /** * Fires the start method on the animation instances to kickoff the animations. */ start(): void; /** * Fires the pause method on the animation instance. */ pause(): async.Promise; /** * Fires the resume method on the animation instance. */ resume(): async.Promise; /** * A method to cancel the associated animation. */ cancel(): AnimationPromise; /** * A method to determine whether or not this promise has been canceled. */ isCanceled(): boolean; /** * Takes in two methods, called when/if the promise fulfills. * @param {(success: plat.ui.animations.IGetAnimatingThenable) => plat.async.Promise} onFulfilled * A method called when/if the promise fulfills. * If undefined the next onFulfilled method in the promise chain will be called. */ then(onFulfilled?: (value: any) => TResult1 | IAnimatingThenable | undefined | null, onRejected?: (error: any) => TResult2 | IAnimatingThenable | undefined | null): AnimationPromise; /** * A wrapper method for Promise.then(undefined, onRejected); * @param {(error: any) => U} onRejected A method called when/if the promise rejects. If undefined the next * onRejected method in the promise chain will be called. */ catch(onRejected?: (error: any) => TResult | IAnimatingThenable | undefined | null): AnimationPromise; } /** * Describes a chaining function that fulfills when the previous link is complete and is * able to be caught in the case of an error. */ interface IAnimationThenable extends async.Promise, IAnimationEssentials { /** * Initializes the promise, providing it with the {@link plat.ui.animations.BaseAnimation} instance. * @param {plat.ui.animations.BaseAnimation} instance The animation instance for this promise. */ initialize(instance: BaseAnimation): void; /** * Gets the associated animation instances or animated promises. */ getInstances(): IAnimationEssentials[]; /** * Fires the start method on the animation instances to kickoff the animations. */ start(): void; /** * Fires the pause method on the animation instance. */ pause(): async.Promise; /** * Fires the resume method on the animation instance. */ resume(): async.Promise; /** * A method to cancel the associated animation. */ cancel(): AnimationPromise; /** * A method to determine whether or not this promise has been canceled. */ isCanceled(): boolean; /** * Takes in two methods, called when/if the promise fulfills/rejects. * @param {(success: T) => U} onFulfilled A method called when/if the promise fulfills. * If undefined the next onFulfilled method in the promise chain will be called. * @param {(error: any) => U} onRejected? A method called when/if the promise rejects. * If undefined the next onRejected method in the promise chain will be called. */ then(onFulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onRejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): IAnimationThenable; /** * A wrapper method for Promise.then(undefined, onRejected); * @param {(error: any) => U} onRejected A method called when/if the promise rejects. If undefined the next * onRejected method in the promise chain will be called. */ catch(onRejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): IAnimationThenable; } /** * Describes a type of IPromise that resolves when an animation is * finished. It can be optionally cancelled. Further, in the case where it may have * a parent that is animating (which will cause it to immediately cancel and fulfill itself, it resolves * with a IGetAnimatingThenable for accessing * the IAnimationThenable of the animating parent element. */ interface IAnimatingThenable extends IAnimationThenable { } /** * Describes an object containing two promises. One that resolves when the previous animation is finished, the * other that resolves when the current animation is finished. */ interface IAnimationCreation { /** * A promise that resolves when a potential previous animation is done. */ previous: async.Promise; /** * An animation promise that resolves when the current animation is complete. */ current: IAnimatingThenable; } /** * Describes base functional requirements for externally referenced animations. */ interface IAnimationEssentials { /** * Fires the start method on the animation instances to kickoff the animations. */ start(): void; /** * Fires the pause method on the animation instances. */ pause(): async.Promise; /** * Fires the resume method on the animation instances. */ resume(): async.Promise; /** * A method to cancel the associated animations. */ cancel(): any; /** * A method to denote the end of an animation. */ end?(): void; } /** * A class representing a single animation for a single element. */ class BaseAnimation implements IAnimationEssentials { protected static _inject: any; /** * The node having the animation performed on it. */ element: HTMLElement; /** * Contains DOM helper methods for manipulating this control's element. */ dom: Dom; /** * Contains helper methods for data manipulation. */ utils: Utils; /** * Specified options for the animation. */ options: any; /** * Reference to the Log injectable. */ protected _log: debug.Log; /** * Reference to the Window injectable. */ protected _window: Window; /** * Reference to the Compat injectable. */ protected _compat: Compat; /** * Reference to the IPromise injectable. */ protected _Promise: async.IPromise; /** * The resolve function for the end of the animation. */ protected _resolve: () => void; /** * An Array of remove functions to dispose of event listeners. */ private __eventListeners; /** * A function for initializing the animation or any of its properties before start. */ initialize(): void; /** * A function denoting the start of the animation. */ start(): void; /** * A function to be called when the animation is over. */ end(): void; /** * A function to be called to pause the animation. */ pause(): async.Promise; /** * A function to be called to resume a paused animation. */ resume(): async.Promise; /** * A function to be called to let it be known the animation is being cancelled. Although not * necessary, we call end() in this function as well for safe measure. */ cancel(): void; /** * Adds an event listener of the specified type to this animation's element. Removal of the * event is handled automatically upon animation end. * @param {string} type The type of event to listen to. * @param {EventListener} listener The listener to fire when the event occurs. * @param {boolean} useCapture? Whether to fire the event on the capture or the bubble phase * of event propagation. */ addEventListener(type: string, listener: EventListener, useCapture?: boolean): IRemoveListener; /** * Initializes the element and key properties of this animation and grabs a * reference to its resolve function. * @param {Element} element The element on which the animation will occur. * @param {any} options Specified options for the animation. */ instantiate(element: Element, options?: any): IAnimatingThenable; } /** * A class representing a single CSS animation for a single element. */ class CssAnimation extends BaseAnimation { /** * A set of browser compatible CSS animation events capable of being listened to. */ protected _animationEvents: IAnimationEvents; /** * A function to listen to the start of an animation event. * @param {() => void} listener The function to call when the animation begins. */ animationStart(listener: (ev?: AnimationEvent) => void): IRemoveListener; /** * A function to listen to the end of an animation event. * @param {(ev?: AnimationEvent) => void} listener The function to call when the animation ends. */ animationEnd(listener: (ev?: AnimationEvent) => void): IRemoveListener; /** * A function to listen to the completion of an animation iteration. * @param {(ev?: AnimationEvent) => void} listener The function to call when the animation iteration completes. */ animationIteration(listener: (ev?: AnimationEvent) => void): IRemoveListener; /** * A function to listen to the start of a transition event. * @param {(ev?: TransitionEvent) => void} listener The function to call when the transition begins. */ transitionStart(listener: (ev?: TransitionEvent) => void): IRemoveListener; /** * A function to listen to the end of a transition event. * @param {(ev?: TransitionEvent) => void} listener The function to call when the transition ends. */ transitionEnd(listener: (ev?: TransitionEvent) => void): IRemoveListener; } /** * A simple CSS Animation class that places the 'plat-animation' class on an * element, checks for animation properties, and waits for the animation to end. */ class SimpleCssAnimation extends CssAnimation { /** * The class name added to the animated element. */ className: string; /** * An optional options object that can denote a pseudo element animation. */ options: ISimpleCssAnimationOptions; /** * A function for stopping a potential callback in the animation chain. */ protected _cancelAnimation: IRemoveListener; /** * Adds the class to initialize the animation. */ initialize(): void; /** * A function denoting the start of the animation. */ start(): void; /** * A function to be called to pause the animation. */ pause(): async.Promise; /** * A function to be called to resume a paused animation. */ resume(): async.Promise; /** * A function to be called to let it be known the animation is being cancelled. * Removes the animation class and the animation "-init" class. */ cancel(): void; /** * Removes the animation class and the animation "-init" class. */ protected _dispose(): void; } /** * An interface describing the options for SimpleCssAnimation. */ interface ISimpleCssAnimationOptions { /** * The pseudo element identifier (i.e. '::before' if defined as .red::before). */ pseudo?: string; /** * A boolean specifying whether or not to leave the '*-init' class on the element * after the animation has started. Defaults to false as we want to remove * any initial state after an animation has kicked off. */ preserveInit?: boolean; } /** * An animation control that fades in an element as defined by the included CSS. */ class FadeIn extends SimpleCssAnimation { /** * The class name added to the element fading in. */ className: string; } /** * An animation control that fades out an element as defined by the included CSS. */ class FadeOut extends SimpleCssAnimation { /** * The class name added to the element fading out. */ className: string; } /** * An animation control that causes an element to enter as defined by the included CSS. */ class Enter extends SimpleCssAnimation { /** * The class name added to the entering element. */ className: string; } /** * An animation control that causes an element to leave as defined by the included CSS. */ class Leave extends SimpleCssAnimation { /** * The class name added to the leaving element. */ className: string; } /** * An animation control that causes an element to move as defined by the included CSS. */ class Move extends SimpleCssAnimation { /** * The class name added to the leaving element. */ className: string; } /** * A simple CSS Animation class that places the 'plat-transition' class on an * element, checks for transition properties, and waits for the transition to end. */ class SimpleCssTransition extends CssAnimation { /** * An optional options object that can denote a pseudo element animation and specify * properties to modify during the transition. */ options: ISimpleCssTransitionOptions; /** * The class name added to the animated element. */ className: string; /** * A function for stopping a potential callback in the animation chain. */ protected _animationCanceled: IRemoveListener; /** * An Array of all the properties the transition will be affecting. */ protected _properties: string[]; /** * A regular expression to normalize modified property keys. */ protected _normalizeRegex: RegExp; /** * A regular expression grab everything that is not a number. */ protected _nonNumRegex: RegExp; /** * An Object whose keys are the normalized keys of modified properties. */ protected _normalizedKeys: IObject; /** * The "transitionend" event handler call count. */ protected _transitionCount: number; /** * The user defined "transitionend" event handler call count. */ protected _count: number; /** * Denotes whether or not the transition was ever started. */ protected _started: boolean; /** * Denotes whether or not the transition changes are being performed * with CSS or with JS through this.options. */ protected _usingCss: boolean; /** * Adds the class to enable the transition. */ initialize(): void; /** * A function denoting the start of the animation. */ start(): void; /** * A function to be called to let it be known the animation is being cancelled. */ cancel(): void; /** * Removes the animation class and the animation "-init" class. */ protected _dispose(): void; /** * A handler for the "transitionend" event. Will clean up the class and resolve the * promise when necessary based on the options that were input. * @param {TransitionEvent} ev? The transition event object. * @param {boolean} immediate? Whether clean up should be immediate or conditional. */ protected _done(ev: TransitionEvent): void; /** * Animate the element based on the options passed in. */ protected _animate(): boolean; /** * A function that converts a string value expressed as either seconds or milliseconds * to a numerical millisecond value. * @param {string} duration The transition duration specified by the computed style. */ protected _toMs(duration: string): number; /** * Handles element transitions that are defined with CSS. * @param {CSSStyleDeclaration} computedStyle The computed style of the * element. * @param {Array} durations The array of declared transition duration values. */ private __cssTransition; } /** * An interface describing the options for SimpleCssTransition. */ interface ISimpleCssTransitionOptions extends ISimpleCssAnimationOptions { /** * A JavaScript object with key value pairs for adjusting transition values. * (e.g. { width: '800px' } would set the element's width to 800px. */ properties?: IObject; /** * A boolean specifying whether or not to leave the '*-init' class on the element * after the transition has started. Defaults to true as we want to keep all * initial states and definitions throughout the transition * (and/or initial transition states will be overwritten upon start). */ preserveInit?: boolean; /** * A defined transition count number. Useful when the transition property name 'all' * is used in conjunction with another transition property and transitions are being * performed through CSS. */ count?: number; } } /** * Holds classes and interfaces related to UI control components in platypus. */ namespace controls { /** * A control that facilitates routing between ViewControls. A Viewport is * the link between a ViewControl, a Navigator, and a Router. * It registers with a router and receives route change events. It then instantiates the proper viewcontrol and appends it * to the DOM. */ class Viewport extends TemplateControl implements routing.ISupportRouteNavigation { protected static _inject: any; /** * Viewports contain ViewControls. */ controls: ViewControl[]; /** * The options for the Viewport control. */ options: observable.IObservableProperty; /** * Used to grab the current Router instance. */ protected _Router: routing.IRouterStatic; /** * The Promise injectable. */ protected _Promise: async.IPromise; /** * The Injector for getting instances of ViewControls. */ protected _Injector: typeof dependency.Injector; /** * Used for compiling and linking a ViewControl's template. */ protected _ElementManagerFactory: processing.IElementManagerFactory; /** * The document. */ protected _document: Document; /** * Reference to an injectable that caches ElementManagers. */ protected _managerCache: storage.Cache; /** * Reference to the Animator injectable. */ protected _animator: animations.Animator; /** * The navigator associated with this Viewport. */ protected _navigator: routing.Navigator; /** * The router associated with this Viewport. */ protected _router: routing.Router; /** * The parent router associated with this Viewport. */ protected _parentRouter: routing.Router; /** * The next injector used to instantiate the next ViewControl during navigation. */ protected _nextInjector: dependency.Injector; /** * The next ViewControl to which to navigate. */ protected _nextView: ViewControl; /** * Whether or not to animate Array mutations. */ protected _animate: boolean; /** * Allows the viewport to initialize its navigator with the current * router. */ initialize(): void; /** * The viewport registers itself with its router, notifying the * router that it is ready to receive navigation events. */ loaded(): void; /** * The viewport's router has matched a route and is asking the viewport if it is safe to * navigate. Here the viewport can instantiate the new view and ask it if it is safe to * navigate to the view. * @param {plat.routing.IRouteInfo} routeInfo Contains the information necessary to instantiate * the view and feed it the route parameters/query. */ canNavigateTo(routeInfo: routing.IRouteInfo): async.Promise; /** * The viewport's router has matched a route and is asking the viewport if it is safe to * navigate from the current state. Here the viewport can query the current ViewControl and * ask it if it is safe to navigate from its current state. */ canNavigateFrom(): async.Promise; /** * The viewport's router has matched a route and determined that it is safe to navigate to the * next view. The viewport will now go through the steps to compile and link the next view then append * it to the DOM. * @param {plat.routing.IRouteInfo} routeInfo Contains the information necessary to instantiate * the view and feed it the route parameters/query. */ navigateTo(routeInfo: routing.IRouteInfo): async.Promise; /** * The viewport's router has matched a route and determined that it is safe to navigate to the * next view. It is now safe for the viewport to dispose of the current state. */ navigateFrom(): async.Promise; /** * The viewport is going out of scope, so it needs to unregister from its router in order to stop receiving routing * events. */ dispose(): void; /** * Creates an INodeMap for a ViewControl in order to compile it. * @param {plat.dependency.Injector} The injector used to instantiate the ViewControl. */ protected _createNodeMap(injector: dependency.Injector): processing.INodeMap; /** * Finds the first Viewport in the parent chain. This is useful in order to properly initialize the viewport's * router as a child of the parent viewport's router. */ protected _getParentViewport(): Viewport; } /** * The available options for the Viewport control. */ interface IViewportOptions { /** * Will allow for page transition animations if set to true. */ animate: boolean; } /** * A TemplateControl for easily reusing a * defined HTML template. */ class Template extends TemplateControl { protected static _inject: any; /** * Reference to the IPromise injectable. */ protected _Promise: async.IPromise; /** * Reference to an injectable for storing HTML templates. */ protected _templateCache: storage.TemplateCache; /** * Reference to the Document injectable. */ protected _document: Document; /** * Removes the `` node from the DOM */ replaceWith: string; /** * The evaluated plat-options object. */ options: observable.IObservableProperty; /** * The unique ID used to reference a particular * template. */ protected _id: string; /** * The optional URL associated with this * particular template. */ protected _url: string; /** * Whether or not this is the first instance of the control, * specifying that it defines the template to copy. */ private __isFirst; /** * A promise that resolves when the template is retrieved and ready. */ private __templatePromise; /** * HTML template storage for all instances of this control. */ private __templateControlCache; /** * The constructor for a Template. Creates the control cache. */ constructor(); /** * Initializes the creation of the template. */ initialize(): void; /** * Decides if this is a template definition or * a template instance. */ loaded(): void; /** * Removes the template from the template cache. */ dispose(): void; /** * Determines whether a URL or innerHTML is being used, * creates the bindable template, and stores the template * in a template cache for later use. */ protected _initializeTemplate(): void; /** * Waits for the template promise to resolve, then initializes * the binding of the bindable template and places it into the * DOM. * @param {plat.async.Promise} templatePromise The promise * associated with the first instance of the control with this ID. */ protected _waitForTemplateControl(templatePromise: async.Promise