File tree Expand file tree Collapse file tree 1 file changed +41
-4
lines changed Expand file tree Collapse file tree 1 file changed +41
-4
lines changed Original file line number Diff line number Diff line change 6
6
xtag . register ( 'x-carousel' , {
7
7
lifecycle : {
8
8
// Fires when an instance of the element is created
9
- created : function ( ) { } ,
9
+ created : function ( ) {
10
+ this . _items = [ ] ;
11
+ } ,
10
12
11
13
// 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
+ } ,
13
46
14
47
// Fires when an instance was removed from the document
15
- removed : function ( ) { } ,
48
+ removed : function ( ) {
49
+
50
+ } ,
16
51
17
52
// Fires when an attribute was added, removed, or updated
18
- attributeChanged : function ( attr , oldVal , newVal ) { }
53
+ attributeChanged : function ( attr , oldVal , newVal ) {
54
+
55
+ }
19
56
} ,
20
57
events : { } ,
21
58
accessors : { } ,
You can’t perform that action at this time.
0 commit comments