66 lines
1.5 KiB
JavaScript
Executable File
66 lines
1.5 KiB
JavaScript
Executable File
var bricks = window.bricks || {};
|
|
bricks.Image = class oops extends bricks.JsWidget {
|
|
/*
|
|
{
|
|
url:
|
|
height:
|
|
width:
|
|
}
|
|
*/
|
|
constructor(opts){
|
|
super(opts);
|
|
this.opts = opts;
|
|
this.options_parse();
|
|
}
|
|
create(){
|
|
this.dom_element = document.createElement('img');
|
|
}
|
|
options_parse(){
|
|
if (this.opts.hasOwnProperty('url')){
|
|
this.set_url(this.opts.url);
|
|
}
|
|
if (this.opts.hasOwnProperty('width')){
|
|
this.width = this.opts.width;
|
|
this.dom_element.style.width = this.width;
|
|
}
|
|
if (this.opts.hasOwnProperty('height')){
|
|
this.height = this.opts.height;
|
|
this.dom_element.style.height = this.height;
|
|
}
|
|
}
|
|
set_url(url){
|
|
this.url = url;
|
|
this.dom_element.src = url;
|
|
}
|
|
}
|
|
|
|
bricks.Icon = class extends bricks.Image {
|
|
constructor(opts){
|
|
var rate = opts.rate || 1;
|
|
var siz = bricks.app.charsize * rate + 'px';
|
|
opts.width = siz;
|
|
opts.height = siz;
|
|
super(opts);
|
|
this.rate = rate;
|
|
this.cwidth = this.opts.cwidth || 1;
|
|
this.cheight = this.opts.cheight || 1;
|
|
this.dynsize = this.opts.dynsize || true;
|
|
this.charsize_sizing();
|
|
}
|
|
}
|
|
|
|
bricks.BlankIcon = class oops extends bricks.JsWidget {
|
|
constructor(opts){
|
|
super(opts);
|
|
this.rate = opts.rate || 1;
|
|
this.cwidth = this.opts.cwidth || 1;
|
|
this.cheight = this.opts.cheight || 1;
|
|
this.dynsize = this.opts.dynsize || true;
|
|
this.charsize_sizing();
|
|
}
|
|
}
|
|
|
|
bricks.Factory.register('Image', bricks.Image);
|
|
bricks.Factory.register('Icon', bricks.Icon);
|
|
bricks.Factory.register('BlankIcon', bricks.BlankIcon);
|