Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: samples/total/client/PopupHandler.dart

Issue 10635015: Delete proxy and total samples, which have bit-rotted. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/total/client/Picker.dart ('k') | samples/total/client/Reader.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 class PopupHandler {
6 // references to CSS classes for fade in and fade out transitions
7 static final String _fadeInClass = "fadeIn";
8 static final String _fadeOutClass = "fadeOut";
9 static PopupHandler _instance; // singleton
10
11 Element _activePopup;
12
13 factory PopupHandler(Document doc) {
14 if (_instance == null) {
15 _instance = new PopupHandler._internal(doc);
16 }
17 return _instance;
18 }
19
20 PopupHandler._internal(Document doc) {
21 Element body = doc.body;
22
23 body.on.click.add((Event e) {
24 if (_activePopup == null) {
25 return;
26 }
27 Element target = e.target;
28 while (target != null && target != body && target != _activePopup) {
29 target = target.parent;
30 }
31 if (target != _activePopup) {
32 deactivatePopup();
33 }
34 }, true);
35 }
36
37 void activatePopup(Element popup, int x, int y) {
38 if (_activePopup != null) {
39 deactivatePopup();
40 }
41
42 _activePopup = popup;
43 _activePopup.style.setProperty("left", HtmlUtils.toPx(x));
44 _activePopup.style.setProperty("top", HtmlUtils.toPx(y));
45
46 Set<String> classes = _activePopup.classes;
47 classes.remove(_fadeOutClass);
48 classes.add(_fadeInClass);
49 }
50
51 void deactivatePopup() {
52 if (_activePopup == null) {
53 return;
54 }
55 Set<String> classes = _activePopup.classes;
56 classes.remove(_fadeInClass);
57 classes.add(_fadeOutClass);
58 _activePopup = null;
59 }
60 }
OLDNEW
« no previous file with comments | « samples/total/client/Picker.dart ('k') | samples/total/client/Reader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698