1 | import {Optional} from 'aurelia-dependency-injection';
|
2 | import {customAttribute, Animator} from 'aurelia-templating';
|
3 | import {DOM} from 'aurelia-pal';
|
4 | import {injectAureliaHideStyleAtBoundary, aureliaHideClassName} from './aurelia-hide-style';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | @customAttribute('show')
|
11 | export class Show {
|
12 |
|
13 |
|
14 | element: any;
|
15 |
|
16 | animator: any;
|
17 |
|
18 | domBoundary: any;
|
19 |
|
20 | value: any;
|
21 |
|
22 |
|
23 | static inject() {
|
24 | return [DOM.Element, Animator, Optional.of(DOM.boundary, true)];
|
25 | }
|
26 |
|
27 | |
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | constructor(element, animator, domBoundary) {
|
34 | this.element = element;
|
35 | this.animator = animator;
|
36 | this.domBoundary = domBoundary;
|
37 | }
|
38 |
|
39 | |
40 |
|
41 |
|
42 | created() {
|
43 | injectAureliaHideStyleAtBoundary(this.domBoundary);
|
44 | }
|
45 |
|
46 | |
47 |
|
48 |
|
49 |
|
50 | valueChanged(newValue) {
|
51 | let element = this.element;
|
52 | let animator = this.animator;
|
53 | if (newValue) {
|
54 | animator.removeClass(element, aureliaHideClassName);
|
55 | } else {
|
56 | animator.addClass(element, aureliaHideClassName);
|
57 | }
|
58 | }
|
59 |
|
60 | |
61 |
|
62 |
|
63 |
|
64 | bind(bindingContext) {
|
65 | this.valueChanged(this.value);
|
66 | }
|
67 | }
|