Skip to content

Commit 561ba6b

Browse files
committed
[#3] Added iterator for DOM nodes & scaffold
1 parent 3fc1a6b commit 561ba6b

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

src/x-carousel.html

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,53 @@
66
xtag.register('x-carousel', {
77
lifecycle: {
88
// Fires when an instance of the element is created
9-
created: function() {},
9+
created: function() {
10+
this._items = [];
11+
},
1012

1113
// Fires when an instance was inserted into the document
12-
inserted: function() {},
14+
inserted: function() {
15+
this.loadItems();
16+
this.loadTheme();
17+
},
18+
19+
loadTheme: function(){
20+
21+
},
22+
23+
options: function(){
24+
// TODO: refactor into
25+
if(this.lazyload !== undefined && this.lazyload !== null){
26+
// load items lazy
27+
}
28+
if(this.wrap !== undefined && this.wrap !== null) {
29+
// wrap items
30+
}
31+
32+
// controls
33+
},
34+
35+
loadItems: function(){
36+
if(this.items !== undefined && this.items !== null && this.items !== ""){
37+
// load JSON based on path
38+
}
39+
40+
if(this.childNodes('li').length > 0) {
41+
[].forEach.call(this.querySelectorAll('li'), function (carouselItem) {
42+
this._items.push({"item" : carouselItem, "content" : carouselItem.innerHTML })
43+
}.bind(this));
44+
}
45+
},
1346

1447
// Fires when an instance was removed from the document
15-
removed: function() {},
48+
removed: function() {
49+
50+
},
1651

1752
// Fires when an attribute was added, removed, or updated
18-
attributeChanged: function(attr, oldVal, newVal) {}
53+
attributeChanged: function(attr, oldVal, newVal) {
54+
55+
}
1956
},
2057
events: {},
2158
accessors: {},

0 commit comments

Comments
 (0)