Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | 29x 29x 29x 29x 29x 13x 13x 13x 13x 13x 13x 1x 11x | import { customAttribute } from '../decorator/exported';
import { IAttribute, IBindingContext } from '../interface/exported';
import { BindingEngine } from '../binding/exported';
import { connectBehavior } from '../utils/exported';
import { createBindingContext } from '../binding/createBindingContext';
/**
* uses what ever name it gets with ".trigger" and uses the name as event listener
*
*/
@customAttribute('#VARIABLE#.trigger')
export class TriggerEventsAttribute implements IAttribute {
// public
public $element: HTMLInputElement;
public $attribute: Attr;
public $bindingContext: IBindingContext;
public eventHandlerBinded: any;
// private
private expressionValue: string;
private value: string;
private name: string;
/**
* created
*
*/
public created() {
this.name = this.$attribute.name.replace('.trigger', '');
this.value = this.$attribute.value;
this.expressionValue = (this.$attribute as any).value;
this.eventHandlerBinded = this.eventHandler.bind(this);
connectBehavior(this.expressionValue, this);
(this.$element as any).addEventListener(this.name, (this.eventHandlerBinded as EventListenerOrEventListenerObject), false);
}
/**
* attached
*
*/
public attached() {
// nothing atm
}
/**
* detached
*
*/
public detached() {
this.$element.removeEventListener(this.name, this.eventHandlerBinded);
}
/**
* when event triggers it uses the value with ast
*
*/
public eventHandler(event: any) {
BindingEngine.tokenizeParseAndTraverseAST(this.value, createBindingContext(
this.$bindingContext.$context,
this.$bindingContext.$overrideContext,
event
));
}
}
|