Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / polymer / components / core-list / demo.html
1 <!doctype html>\r
2 <!--\r
3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.\r
4 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\r
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\r
6 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\r
7 Code distributed by Google as part of the polymer project is also\r
8 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\r
9 -->\r
10 <html>\r
11 <head>\r
12   <title>core-list</title>\r
13   <meta name="viewport" content="width=device-width">\r
14   <script src="../platform/platform.js"></script>\r
15   <link rel="import" href="core-list.html">\r
16   <style>\r
17     html, body {\r
18       height: 100%;\r
19       margin: 0;\r
20     }\r
21     \r
22     list-test {\r
23       display: block;\r
24       height: 100%;\r
25       margin: 0 auto;\r
26     }\r
27 \r
28     .stuff {\r
29       min-height: 60px;\r
30       background: red !important;\r
31       border-bottom: 1px solid black;\r
32     }\r
33   </style>\r
34 </head>\r
35 <body>\r
36 \r
37 <list-test></list-test>\r
38 \r
39 <polymer-element name="list-test">\r
40 <template>\r
41   <style>\r
42     core-list {\r
43       height: 100%;\r
44     }\r
45 \r
46     .item {\r
47       box-sizing: border-box;\r
48       height: 80px;\r
49       border-bottom: 1px solid #ddd;\r
50       padding: 4px;\r
51       cursor: default;\r
52       background-color: white;\r
53       overflow: hidden;\r
54     }\r
55 \r
56     .selected {\r
57       background: silver;\r
58     }\r
59 \r
60     .message {\r
61       padding-left: 77px;\r
62       line-height: 167%;\r
63       background-repeat: no-repeat;\r
64       background-position: 10px 10px;\r
65       background-size: 60px;\r
66     }\r
67     \r
68     .from {\r
69       display: inline;\r
70       font-weight: bold;\r
71     }\r
72     \r
73     .timestamp {\r
74       margin-left: 10px;\r
75       font-size: 12px;\r
76       opacity: 0.8;\r
77     }\r
78     \r
79     .body {\r
80       font-size: 12px;\r
81     }\r
82   </style>\r
83   <core-list id="list" data="{{data}}" height="80">\r
84     <template>\r
85       <div class="item {{ {selected: selected} | tokenList }}">\r
86         <div class="message" style="background-image: url(images/{{index % 4}}.png);">\r
87           <span class="from">{{name}}</span>\r
88           <span class="timestamp">{{time}}</span>\r
89           <div class="subject">Infinite List. {{index}}</div>\r
90           <div class="body">{{details}}</div>\r
91         </div>\r
92       </div>\r
93     </template>\r
94   </core-list>\r
95 \r
96 </template>\r
97 <script>\r
98 (function() {\r
99   var strings = [\r
100     "PARKOUR!",\r
101     "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...",\r
102     "Lorem Ipsum is simply dummy text of the printing and typesetting industry."\r
103   ];\r
104 \r
105   var namegen = {\r
106     generateString: function(inLength) {\r
107       var s = '';\r
108       for (var i=0; i<inLength; i++) {\r
109         s += String.fromCharCode(Math.floor(Math.random() * 26) + 97);\r
110       }\r
111       return s;\r
112     },\r
113     generateName: function(inMin, inMax) {\r
114       return this.generateString(Math.floor(Math.random() * (inMax - inMin + 1) + inMin));\r
115     }\r
116   };\r
117 \r
118   Polymer('list-test', {\r
119     count: 50000,\r
120     ready: function() {\r
121       this.data = this.generateData();\r
122     },\r
123     generateData: function() {\r
124       var names = [], data = [];\r
125       for (var i=0; i<this.count; i++) {\r
126         names.push(namegen.generateName(4, 8));\r
127       }\r
128       names.sort();\r
129       for (var i=0; i<this.count; i++) {\r
130         var name = names[i];\r
131         var divider = name.charAt(0);\r
132         if (divider === (names[i-1] || '').charAt(0)) {\r
133           divider = null;\r
134         }\r
135         data.push({\r
136           index: i,\r
137           name: name,\r
138           divider: divider,\r
139           details: strings[i % 3],\r
140           time: '8:29pm'\r
141         });\r
142       }\r
143       return data;\r
144     },\r
145     tapAction: function(e) {\r
146       console.log('tap', e);\r
147     }\r
148   });\r
149 })();  \r
150 </script>\r
151 </polymer-element>\r
152 \r
153 </body>\r
154 </html>\r