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

Side by Side Diff: sky/examples/file-browser.sky

Issue 788943003: Make SkyElement more classy. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Don't change indent. Created 6 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
« no previous file with comments | « sky/examples/city-list/city-list.sky ('k') | sky/examples/flights-app/app-header.sky » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!-- 1 <!--
2 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Copyright 2014 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 --> 5 -->
6 <import src="../framework/sky-element/sky-element.sky" as="SkyElement" /> 6 <import src="../framework/sky-element/sky-element.sky" as="SkyElement" />
7 <import src="../framework/xmlhttprequest.sky" as="XMLHttpRequest" /> 7 <import src="../framework/xmlhttprequest.sky" as="XMLHttpRequest" />
8 8
9 <sky-element name="file-browser">
9 <template> 10 <template>
10 <style> 11 <style>
11 heading { 12 heading {
12 font-size: 16px; 13 font-size: 16px;
13 } 14 }
14 </style> 15 </style>
15 <heading>File browser for {{ url }}</heading> 16 <heading>File browser for {{ url }}</heading>
16 <template repeat="{{ directories }}"> 17 <template repeat="{{ directories }}">
17 <a href="{{}}">{{}}</a> 18 <a href="{{}}">{{}}</a>
18 </template> 19 </template>
19 <template repeat="{{ files }}"> 20 <template repeat="{{ files }}">
20 <a href="{{}}">{{}}</a> 21 <a href="{{}}">{{}}</a>
21 </template> 22 </template>
22 </template> 23 </template>
23 <script> 24 <script>
24 SkyElement({ 25 module.exports = class extends SkyElement {
25 name: 'file-browser', 26 created() {
26 url: '', 27 this.url = '';
27 files: [], 28 this.files = [];
28 directories: [], 29 this.directories = [];
29 attached: function() { 30 }
31 attached() {
30 this.url = this.ownerDocument.URL; 32 this.url = this.ownerDocument.URL;
31 var xhr = new XMLHttpRequest(); 33 var xhr = new XMLHttpRequest();
32 xhr.open('GET', this.url + '?format=json'); 34 xhr.open('GET', this.url + '?format=json');
33 xhr.onload = (function() { 35 xhr.onload = (function() {
34 var listing = JSON.parse(xhr.responseText); 36 var listing = JSON.parse(xhr.responseText);
35 this.files = listing.files; 37 this.files = listing.files;
36 this.directories = listing.directories; 38 this.directories = listing.directories;
37 }).bind(this); 39 }).bind(this);
38 xhr.send(); 40 xhr.send();
39 } 41 }
40 }); 42 }.register();
41 </script> 43 </script>
44 </sky-element>
OLDNEW
« no previous file with comments | « sky/examples/city-list/city-list.sky ('k') | sky/examples/flights-app/app-header.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698