kino.base - javascript base tools
use on a webpage
<script type="text/javascript" src="kino.base.js"></script>
create a namespace
kino.namespace("myspace.hello.world");
create object's property
var obj = {myProp: "propval"};
kino.createProp(obj, "newProp.subProp", "hello world");
extend from Class
var MyClass = function () {
this.name = 'Tom';
};
MyClass.prototype.hello = function () {
return "hello " + this.name;
}
var obj = {name: 'James'};
kino.extend(obj, MyClass);
obj.hello(); //"hello James"
extend from obj
var obj = {};
var extendObj = {
text: 'hello'
};
kino.extend(obj, extendObj);
obj.text //'hello'
use observer model to trigger event
var obj = {};
kino.extend(obj, kino.Events);
obj.on("test", function (obj) {
//obj.name "kino"
});
obj.on("test.a", function (obj) {
//obj.name "kino"
});
obj.trigger("test", { name: "kino" });
obj.off("test.a");