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

Side by Side Diff: client/samples/total/src/ContextMenu.dart

Issue 8835006: New version of dart:html (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typos Created 9 years 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
OLDNEW
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 typedef bool EnabledFunction(); 5 typedef bool EnabledFunction();
6 typedef void CallbackFunction(Element elmt, int value); 6 typedef void CallbackFunction(Element elmt, int value);
7 7
8 class ElementFunc { 8 class ElementFunc {
9 Element _element; 9 Element _element;
10 EnabledFunction _func; 10 EnabledFunction _func;
11 11
12 Element get element() => _element; 12 Element get element() => _element;
13 13
14 EnabledFunction get func() => _func; 14 EnabledFunction get func() => _func;
15 15
16 ElementFunc(this._element, this._func) { } 16 ElementFunc(this._element, this._func) { }
17 } 17 }
18 18
19 class ContextMenu { 19 class ContextMenu {
20 Element _contextMenu; 20 Element _contextMenu;
21 List<ElementFunc> _enableFunctions; 21 List<ElementFunc> _enableFunctions;
22 Element _parent; 22 Element _parent;
23 Spreadsheet _spreadsheet; 23 Spreadsheet _spreadsheet;
24 SpreadsheetPresenter _spreadsheetPresenter; 24 SpreadsheetPresenter _spreadsheetPresenter;
25 25
26 Element get parent() => _parent; 26 Element get parent() => _parent;
27 27
28 ContextMenu(this._spreadsheetPresenter) { 28 ContextMenu(this._spreadsheetPresenter) {
29 Document doc = _spreadsheetPresenter.window.document; 29 Document doc = _spreadsheetPresenter.window.document;
30 _contextMenu = doc.createElement("ul"); 30 _contextMenu = new Element.tag("ul");
31 _contextMenu.style.setProperty("left","0px"); 31 _contextMenu.style.setProperty("left","0px");
32 _contextMenu.style.setProperty("top", "0px"); 32 _contextMenu.style.setProperty("top", "0px");
33 _contextMenu.classes.add("contextMenu"); 33 _contextMenu.classes.add("contextMenu");
34 _contextMenu.classes.add("fadeOut"); 34 _contextMenu.classes.add("fadeOut");
35 35
36 // Parent off the document body to avoid problems when the menu 36 // Parent off the document body to avoid problems when the menu
37 // extends past the border of its owner spreadsheet 37 // extends past the border of its owner spreadsheet
38 _parent = doc.body; 38 _parent = doc.body;
39 _parent.nodes.add(_contextMenu); 39 _parent.nodes.add(_contextMenu);
40 _spreadsheet = _spreadsheetPresenter.spreadsheet; 40 _spreadsheet = _spreadsheetPresenter.spreadsheet;
41 } 41 }
42 42
43 Element addMenuItem(String label, int value, 43 Element addMenuItem(String label, int value,
44 EnabledFunction enabled, CallbackFunction callback) { 44 EnabledFunction enabled, CallbackFunction callback) {
45 Element item = _spreadsheetPresenter.window.document.createElement("li"); 45 Element item = new Element.tag("li");
46 item.classes.add("contextMenuItem"); 46 item.classes.add("contextMenuItem");
47 item.classes.add("contextMenuItem-enabled"); 47 item.classes.add("contextMenuItem-enabled");
48 item.innerHTML = label; 48 item.innerHTML = label;
49 item.on.click.add((Event e) { 49 item.on.click.add((Event e) {
50 _spreadsheetPresenter.popdownMenu(_contextMenu, value, callback); 50 _spreadsheetPresenter.popdownMenu(_contextMenu, value, callback);
51 }); 51 });
52 _contextMenu.nodes.add(item); 52 _contextMenu.nodes.add(item);
53 if (_enableFunctions == null) { 53 if (_enableFunctions == null) {
54 _enableFunctions = new List<ElementFunc>(); 54 _enableFunctions = new List<ElementFunc>();
55 } 55 }
(...skipping 14 matching lines...) Expand all
70 void _enableMenuItem(Element item, bool enabled) { 70 void _enableMenuItem(Element item, bool enabled) {
71 if (enabled) { 71 if (enabled) {
72 item.classes.remove("contextMenuItem-disabled"); 72 item.classes.remove("contextMenuItem-disabled");
73 item.classes.add("contextMenuItem-enabled"); 73 item.classes.add("contextMenuItem-enabled");
74 } else { 74 } else {
75 item.classes.remove("contextMenuItem-enabled"); 75 item.classes.remove("contextMenuItem-enabled");
76 item.classes.add("contextMenuItem-disabled"); 76 item.classes.add("contextMenuItem-disabled");
77 } 77 }
78 } 78 }
79 } 79 }
OLDNEW
« no previous file with comments | « client/samples/total/src/ColorPicker.dart ('k') | client/samples/total/src/ContextMenuBuilder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698