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

Side by Side Diff: samples/webcomponents/contactifier/ContactsWidget.dart

Issue 10964030: A variety of cleanups to bring our samples up-to-date. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
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 /** A contacts widget demonstrating the Shadow DOM. */
6 class ContactsWidget {
7
8 // Statically populated for demo purposes.
9 static const _contacts = const ['Gertrude Stein', 'Ezra Pound',
10 'T.S. Elliot', 'James Joyce',
11 'F. Scott Fitzgerald', 'Ernest Hemmingway'];
12 static const _contactStyle =
13 """
14 <style scoped>
15 ul {
16 font-family: "Comic Sans MS", sans-serif;
17 color: purple;
18 list-style: none;
19 }
20
21 #userContent {
22 text-align: right;
23 margin: 20px;
24 }
25 </style>
26 """;
27
28 /**
29 * User-supplied element in the external DOM that is the
30 * Shadow host for the contacts widget.
31 */
32 final Element _shadowHost;
33 final ShadowRoot _shadowRoot;
34
35 ContactsWidget(shadowHost) :
36 _shadowHost = shadowHost,
37 _shadowRoot = new ShadowRoot(shadowHost) {
38 _shadowRoot.nodes.add(new Element.html(_contactStyle));
39 _shadowRoot.nodes.add(contactsDOM());
40
41 var userContent = new DivElement();
42 userContent.id = 'userContent';
43 userContent.nodes.add(new Element.tag('content'));
44 _shadowRoot.nodes.add(userContent);
45 }
46
47 /** Returns a DOM tree fragment containing a list of contacts. */
48 Element contactsDOM() {
49 var ul = new UListElement();
50 // TODO(samhop): set class names in contact list DOM
51 _contacts.forEach((contact) {
52 ul.nodes.add(new Element.html('<li>$contact</li>'));
53 });
54 return ul;
55 }
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698