Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / polymer / components-chromium / core-list / demo-divider.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: divider</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       font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;\r
19       height: 100%;\r
20       margin: 0;\r
21     }\r
22     \r
23     list-test {\r
24       display: block;\r
25       height: 100%;\r
26       margin: 0 auto;\r
27     }\r
28 \r
29     .stuff {\r
30       min-height: 60px;\r
31       background: red !important;\r
32       border-bottom: 1px solid black;\r
33     }\r
34   </style>\r
35 </head>\r
36 <body>\r
37 \r
38 <list-test></list-test>\r
39 \r
40 <polymer-element name="list-test">\r
41 <template>\r
42   <style>\r
43     core-list {\r
44       height: 100%;\r
45     }\r
46 \r
47     .item {\r
48       box-sizing: border-box;\r
49       height: 80px;\r
50       border-bottom: 1px solid #ddd;\r
51       cursor: default;\r
52       overflow: hidden;\r
53     }\r
54 \r
55     .selected {\r
56       background: silver;\r
57     }\r
58 \r
59     .message {\r
60       padding-left: 77px;\r
61       line-height: 167%;\r
62       background-repeat: no-repeat;\r
63       background-position: 10px 10px;\r
64       background-size: 60px;\r
65     }\r
66     \r
67     .from {\r
68       display: inline;\r
69       font-weight: bold;\r
70     }\r
71     \r
72     .timestamp {\r
73       margin-left: 10px;\r
74       font-size: 12px;\r
75       opacity: 0.8;\r
76     }\r
77     \r
78     .body {\r
79       font-size: 12px;\r
80     }\r
81 \r
82     .hidden {\r
83       display: none;\r
84     }\r
85 \r
86     .divider {\r
87       height: 80px;\r
88       box-sizing: border-box;\r
89       box-shadow: inset 0 8px 40px 0 rgba(0, 0, 0, 0.1);\r
90       text-transform: uppercase;\r
91       padding: 36px 20px 0;\r
92       font-size: 40px;\r
93     }\r
94 \r
95     .main {\r
96       padding: 4px;\r
97       background-color: white;\r
98     }\r
99   </style>\r
100   <core-list id="list" data="{{data}}" height="80">\r
101     <template repeat>\r
102       <div class="item {{ {selected: selected} | tokenList }}">\r
103         <div class="divider {{ {hidden: !divider} |tokenList}}">{{divider}}</div>\r
104         <div class="message {{ {hidden: divider} |tokenList}}" style="background-image: url(images/{{index % 4}}.png);">\r
105           <span class="from">{{name}}</span>\r
106           <span class="timestamp">{{time}}</span>\r
107           <div class="subject">Infinite List. {{index}}</div>\r
108           <div class="body">{{details}}</div>\r
109         </div>\r
110       </div>\r
111     </template>\r
112   </core-list>\r
113 \r
114 </template>\r
115 <script>\r
116 (function() {\r
117   var strings = [\r
118     "PARKOUR!",\r
119     "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...",\r
120     "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."\r
121   ];\r
122 \r
123   var namegen = {\r
124     generateString: function(inLength) {\r
125       var s = '';\r
126       for (var i=0; i<inLength; i++) {\r
127         s += String.fromCharCode(Math.floor(Math.random() * 26) + 97);\r
128       }\r
129       return s;\r
130     },\r
131     generateName: function(inMin, inMax) {\r
132       return this.generateString(Math.floor(Math.random() * (inMax - inMin + 1) + inMin));\r
133     }\r
134   };\r
135 \r
136   Polymer('list-test', {\r
137     count: 1000,\r
138     ready: function() {\r
139       this.data = this.generateData();\r
140     },\r
141     generateData: function() {\r
142       var names = [], data = [];\r
143       for (var i=0; i<this.count; i++) {\r
144         names.push(namegen.generateName(4, 8));\r
145       }\r
146       names.sort();\r
147       for (var i=0, o; i<this.count; i++) {\r
148         var name = names[i];\r
149         var divider = name.charAt(0);\r
150         if (divider === (names[i-1] || '').charAt(0)) {\r
151           divider = null;\r
152         }\r
153         o = {\r
154           index: i,\r
155           name: name,\r
156           divider: divider,\r
157           details: strings[i % 3],\r
158           time: '8:29pm'\r
159         };\r
160         data.push(o);\r
161         if (divider) {\r
162           o = Object.create(o);\r
163           o.divider = false;\r
164           data.push(o);\r
165         }\r
166       }\r
167       return data;\r
168     },\r
169     tapAction: function(e) {\r
170       console.log('tap', e);\r
171     }\r
172   });\r
173 })();  \r
174 </script>\r
175 </polymer-element>\r
176 \r
177 </body>\r
178 </html>\r