Last active
August 29, 2015 14:23
-
-
Save mholtzhausen/3a557e73b252e902da44 to your computer and use it in GitHub Desktop.
VLWrmM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head></head> | |
<body> | |
<bn-quote><author>Mark</author><quote>Some Quote</quote></bn-quote> | |
<bn-quote><author>Mark</author><quote>Some Quote</quote></bn-quote> | |
<bn-quote><author>Mark</author><quote>Some Quote</quote></bn-quote> | |
<bn-quote><author>Mark</author><quote>Some Quote</quote></bn-quote> | |
<bn-quote><author>Mark</author><quote>Some Quote</quote></bn-quote> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.clear(); | |
var Component = function(tagName, template, controller){ | |
var Controller = function(elem){ | |
this.element = elem; | |
this.content = this.element.children; | |
this.init = function(){}; | |
}; | |
var proto = Object.create(HTMLElement.prototype); | |
proto.createdCallback = function(){ | |
var elem=this; | |
controller = typeof controller == 'function' ? controller : function(){} | |
elem.controller = new controller(); | |
elem.controller.__proto__=new Controller(elem); | |
//console.log(elem.controller); | |
elem.controller.init(); | |
var shadow = elem.createShadowRoot();; | |
shadow.innerHTML = template; | |
}; | |
return document.registerElement(tagName,{prototype:proto}); | |
}; | |
var bnQuote = Component('bn-quote','<style>.bn-quote{ display: block; margin: 5px; padding:5px; border: 1px solid #ccc; position: relative} .author{position:absolute; bottom:0px; right: 0px; font-style: italic}</style><div class="bn-quote">{{quote}}<span class="author">{{author}}</span></div>',function(){ | |
this.init=function(){ | |
this.element.addEventListener('click',function(){ console.log('click triggered');}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VLWrmM | |
------ | |
A [Pen](http://codepen.io/Nemesarial/pen/VLWrmM) by [Mark Holtzhausen](http://codepen.io/Nemesarial) on [CodePen](http://codepen.io/). | |
[License](http://codepen.io/Nemesarial/pen/VLWrmM/license). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment