OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of swarmlib; | 5 part of swarmlib; |
6 | 6 |
7 // This file contains View framework classes. | 7 // This file contains View framework classes. |
8 // As it grows, it may need to be split into multiple files. | 8 // As it grows, it may need to be split into multiple files. |
9 | 9 |
10 /** A factory that creates a view from a data model. */ | 10 /** A factory that creates a view from a data model. */ |
(...skipping 29 matching lines...) Expand all Loading... |
40 } | 40 } |
41 | 41 |
42 void fire(var event) { | 42 void fire(var event) { |
43 for (final listener in listeners) { | 43 for (final listener in listeners) { |
44 listener(event); | 44 listener(event); |
45 } | 45 } |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 /** | 49 /** |
50 * Private view class used to store placeholder views for detatched ListView | 50 * Private view class used to store placeholder views for detached ListView |
51 * elements. | 51 * elements. |
52 */ | 52 */ |
53 class _PlaceholderView extends View { | 53 class _PlaceholderView extends View { |
54 _PlaceholderView() : super() {} | 54 _PlaceholderView() : super() {} |
55 | 55 |
56 Element render() => new Element.tag('div'); | 56 Element render() => new Element.tag('div'); |
57 } | 57 } |
58 | 58 |
59 /** | 59 /** |
60 * Class providing all metrics required to layout a data driven list view. | 60 * Class providing all metrics required to layout a data driven list view. |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 void _addViewHelper(View view, int index) { | 489 void _addViewHelper(View view, int index) { |
490 _positionSubview(view.node, index); | 490 _positionSubview(view.node, index); |
491 // The view might already be attached. | 491 // The view might already be attached. |
492 if (view.node.parent != _containerElem) { | 492 if (view.node.parent != _containerElem) { |
493 _containerElem.nodes.add(view.node); | 493 _containerElem.nodes.add(view.node); |
494 } | 494 } |
495 } | 495 } |
496 | 496 |
497 /** | 497 /** |
498 * Detach a subview from the view replacing it with an empty placeholder view. | 498 * Detach a subview from the view replacing it with an empty placeholder view. |
499 * The detatched subview can be safely reparented. | 499 * The detached subview can be safely reparented. |
500 */ | 500 */ |
501 View detachSubview(D itemData) { | 501 View detachSubview(D itemData) { |
502 int index = findIndex(itemData); | 502 int index = findIndex(itemData); |
503 View view = _itemViews[index]; | 503 View view = _itemViews[index]; |
504 if (view == null) { | 504 if (view == null) { |
505 // Edge case: add the view so we can detatch as the view is currently | 505 // Edge case: add the view so we can detach as the view is currently |
506 // outside but might soon be inside the visible area. | 506 // outside but might soon be inside the visible area. |
507 assert(!_activeInterval.contains(index)); | 507 assert(!_activeInterval.contains(index)); |
508 _addView(index); | 508 _addView(index); |
509 view = _itemViews[index]; | 509 view = _itemViews[index]; |
510 } | 510 } |
511 final placeholder = new _PlaceholderView(); | 511 final placeholder = new _PlaceholderView(); |
512 view.node.replaceWith(placeholder.node); | 512 view.node.replaceWith(placeholder.node); |
513 _itemViews[index] = placeholder; | 513 _itemViews[index] = placeholder; |
514 return view; | 514 return view; |
515 } | 515 } |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 | 988 |
989 container = node.querySelector('.dialog-body'); | 989 container = node.querySelector('.dialog-body'); |
990 container.nodes.add(_content.node); | 990 container.nodes.add(_content.node); |
991 | 991 |
992 return node; | 992 return node; |
993 } | 993 } |
994 | 994 |
995 /** Override to handle dialog done. */ | 995 /** Override to handle dialog done. */ |
996 void onDone() {} | 996 void onDone() {} |
997 } | 997 } |
OLD | NEW |