From 561ba6bdb0d0ca4e4dd26617c4841fad84e69b53 Mon Sep 17 00:00:00 2001 From: Erik Isaksen Date: Mon, 23 Feb 2015 06:15:25 -0500 Subject: [PATCH] [#3] Added iterator for DOM nodes & scaffold --- src/x-carousel.html | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/src/x-carousel.html b/src/x-carousel.html index 9d788f8..93c6f8a 100755 --- a/src/x-carousel.html +++ b/src/x-carousel.html @@ -6,16 +6,53 @@ xtag.register('x-carousel', { lifecycle: { // Fires when an instance of the element is created - created: function() {}, + created: function() { + this._items = []; + }, // Fires when an instance was inserted into the document - inserted: function() {}, + inserted: function() { + this.loadItems(); + this.loadTheme(); + }, + + loadTheme: function(){ + + }, + + options: function(){ + // TODO: refactor into + if(this.lazyload !== undefined && this.lazyload !== null){ + // load items lazy + } + if(this.wrap !== undefined && this.wrap !== null) { + // wrap items + } + + // controls + }, + + loadItems: function(){ + if(this.items !== undefined && this.items !== null && this.items !== ""){ + // load JSON based on path + } + + if(this.childNodes('li').length > 0) { + [].forEach.call(this.querySelectorAll('li'), function (carouselItem) { + this._items.push({"item" : carouselItem, "content" : carouselItem.innerHTML }) + }.bind(this)); + } + }, // Fires when an instance was removed from the document - removed: function() {}, + removed: function() { + + }, // Fires when an attribute was added, removed, or updated - attributeChanged: function(attr, oldVal, newVal) {} + attributeChanged: function(attr, oldVal, newVal) { + + } }, events: {}, accessors: {},