OLD | NEW |
1 part of effects; | 1 part of effects; |
2 | 2 |
3 /** | 3 /** |
4 * [ModalManager] is inspired by the [modal helper](http://twitter.github.com/bo
otstrap/javascript.html#modals) in Bootstrap. | 4 * [ModalManager] is inspired by the [modal helper](http://twitter.github.com/bo
otstrap/javascript.html#modals) in Bootstrap. |
5 * | 5 * |
6 * It has two static methods `show` and `hide` that both take the same parameter
s as corresponding methods in [ShowHide]. | 6 * It has two static methods `show` and `hide` that both take the same parameter
s as corresponding methods in [ShowHide]. |
7 * | 7 * |
8 * [ModalManager] controls the display of the provided element while also creati
ng a dark backdrop on the page. | 8 * [ModalManager] controls the display of the provided element while also creati
ng a dark backdrop on the page. |
9 * Any element used should have a fixed position, a z-index greater than 1040, a
nd an initial display of none. | 9 * Any element used should have a fixed position, a z-index greater than 1040, a
nd an initial display of none. |
10 */ | 10 */ |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 final backDropElement = _getBackdrop(element.document, false); | 34 final backDropElement = _getBackdrop(element.document, false); |
35 | 35 |
36 final futures = [ShowHide.hide(element, effect: effect, duration: duration,
effectTiming: effectTiming)]; | 36 final futures = [ShowHide.hide(element, effect: effect, duration: duration,
effectTiming: effectTiming)]; |
37 | 37 |
38 if(backDropElement != null) { | 38 if(backDropElement != null) { |
39 futures.add(ShowHide.hide(backDropElement, effect: new FadeEffect())); | 39 futures.add(ShowHide.hide(backDropElement, effect: new FadeEffect())); |
40 } | 40 } |
41 | 41 |
42 return Future.wait(futures) | 42 return Future.wait(futures) |
43 .catchError((AsyncError err) { | 43 .catchError((err) { |
44 print(err); | 44 print(err); |
45 }, test: (v) => false) | 45 }, test: (v) => false) |
46 ..whenComplete(() => _clearOutBackdrop(element.document)); | 46 ..whenComplete(() => _clearOutBackdrop(element.document)); |
47 } | 47 } |
48 | 48 |
49 static void _clearOutBackdrop(HtmlDocument doc) { | 49 static void _clearOutBackdrop(HtmlDocument doc) { |
50 final backdrop = _getBackdrop(doc, false); | 50 final backdrop = _getBackdrop(doc, false); |
51 if(backdrop != null) { | 51 if(backdrop != null) { |
52 backdrop.remove(); | 52 backdrop.remove(); |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 static Element _getBackdrop(HtmlDocument parentDocument, bool addIfMissing) { | 56 static Element _getBackdrop(HtmlDocument parentDocument, bool addIfMissing) { |
57 assert(parentDocument != null); | 57 assert(parentDocument != null); |
58 | 58 |
59 | 59 |
60 Element element = parentDocument.body.query('.$_backdropClass'); | 60 Element element = parentDocument.body.query('.$_backdropClass'); |
61 if(element == null && addIfMissing) { | 61 if(element == null && addIfMissing) { |
62 element = new DivElement() | 62 element = new DivElement() |
63 ..classes.add(_backdropClass) | 63 ..classes.add(_backdropClass) |
64 ..attributes['style'] = _backdropStyle; | 64 ..attributes['style'] = _backdropStyle; |
65 parentDocument.body.children.add(element); | 65 parentDocument.body.children.add(element); |
66 } | 66 } |
67 | 67 |
68 return element; | 68 return element; |
69 } | 69 } |
70 } | 70 } |
OLD | NEW |