Skip to content

Commit

Permalink
more samples
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmachuca committed May 29, 2015
1 parent 3b97b8f commit 773cddc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
38 changes: 18 additions & 20 deletions QCObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,37 +118,35 @@ var Class = function(name, type, definition) {
}
};
}

Element.prototype.append = function QC_Append(child){
if (typeof child.__definition != 'undefined' && typeof child.__definition.__classType != 'undefined' && typeof child.body){
this.appendChild(child.body);
} else{
this.appendChild(child);
}
};

if (typeof definition != 'undefined' && !definition.hasOwnProperty('append')){
definition['append'] = function QC_Append(){
if (typeof this['body'] != 'undefined' && this['body'].hasOwnProperty('appendChild')){
child = (arguments.length>0)?(arguments[0]):(this);
child = (arguments.length>0)?(arguments[0]):(this['body']);
if (typeof this['body'] != 'undefined'){
console.log('append element');
if (typeof this['childs'] == 'undefined'){
this['childs'] = [];
}
if (arguments.length>0){
console.log('append & push');
this['body'].appendChild(child.body);
if (arguments.lenght>0){
console.log('append to element');
this['body'].append(child);
if (typeof this['childs']=='undefined'){
this['childs']=[];
}
this['childs'].push(child);
} else {
console.log('append to body');
document.body.appendChild(child.body);
}
} else {
if (typeof this['body'] != 'undefined' ){
document.body.appendChild(this['body']);
document.body.append(child);
}
}
};
}

Element.prototype.append = function QC_Append(child){
if (typeof child.__definition != 'undefined' && typeof child.__definition.__classType != 'undefined' && typeof child.body){
this.appendChild(child.body);
} else{
this.appendChild(child);
}
};

if (typeof definition != 'undefined' && !definition.hasOwnProperty('attachIn')){
definition['attachIn'] = function QC_AttachIn(tag){
Expand Down
18 changes: 10 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
height:100,
});

body = New(MyOwnBody); // binds to body
body.css({backgroundColor:'#ccc'});

container = document.getElementsByTagName('container')[0].Cast(MyContainer); // cast any javascript dom object to QC_Object class
container.css({backgroundColor:'red'}); // access binding in two directions to dom objects

/**
* Instance a new custom canvas
*/
Expand All @@ -57,17 +63,13 @@
canvas2.body.style.backgroundColor='#0044AA'; // standard javascript style access
canvas3.body.style.backgroundColor='green'; // standard javascript style access

canvas1.append(); //append to body
canvas1.append(); //append canvas1 to body
canvas2.attachIn('container'); // attach or append to specific tag containers
canvas3.attachIn('container');
container.append(canvas3); // append canvas3 to custom tag binding

container = document.getElementsByTagName('container')[0].Cast(MyContainer); // cast any javascript dom object to QC_Object class
container.css({backgroundColor:'red',
}); // access binding in two directions to dom objects
container.body.width=300;
canvas1.body.remove(); // remove canvas1 from dom
body.append(canvas1); // append canvas1 to body

body = New(MyOwnBody); // binds to body
body.css({backgroundColor:'#ccc'});
});

</script>
Expand Down

0 comments on commit 773cddc

Please sign in to comment.