mofron-comp-appbase
Advanced tools
Comparing version 0.4.14 to 0.5.0
102
index.js
@@ -5,11 +5,11 @@ /** | ||
* it makes easy to build page. | ||
* @author simpart | ||
* @license MIT | ||
*/ | ||
const mf = require("mofron"); | ||
const Header = require('mofron-comp-appheader'); | ||
const Image = require('mofron-comp-image'); | ||
const Backgd = require('mofron-effect-backgd'); | ||
const Synwin = require('mofron-effect-syncwin'); | ||
const Header = require('mofron-comp-appheader'); | ||
const Image = require('mofron-comp-image'); | ||
const Backgd = require('mofron-effect-backgd'); | ||
const Synwin = require('mofron-effect-syncwin'); | ||
const comutl = mofron.util.common; | ||
mf.comp.AppBase = class extends mf.Component { | ||
module.exports = class extends mofron.class.Component { | ||
/** | ||
@@ -19,13 +19,16 @@ * initialize component | ||
* @param (mixed) title parameter | ||
* object: component option | ||
* dict: component config list | ||
* @param (component) child component | ||
* @pmap title,child | ||
* @short title,child | ||
* @type private | ||
*/ | ||
constructor (po, p2) { | ||
constructor (p1, p2) { | ||
try { | ||
super(); | ||
this.name('AppBase'); | ||
this.prmMap(['title', 'child']); | ||
this.prmOpt(po, p2); | ||
this.name("AppBase"); | ||
this.shortForm("title", "child"); | ||
if (0 < arguments.length) { | ||
this.config(p1,p2); | ||
} | ||
} catch (e) { | ||
@@ -46,10 +49,9 @@ console.error(e.stack); | ||
this.addChild(this.header()); | ||
/* background area */ | ||
this.addChild(this.bgwrap()); | ||
this.header(new Header()); | ||
this.bgwrap(new mofron.class.Component()); | ||
let conts = new mofron.class.Component({ width : '100%' }); | ||
this.child([this.header(), this.bgwrap(), conts]); | ||
this.childDom(conts.childDom()); | ||
/* contents */ | ||
let conts = new mf.Component({ width : '100%' }); | ||
this.addChild(conts); | ||
this.target(conts.target()); | ||
} catch (e) { | ||
@@ -70,9 +72,9 @@ console.error(e.stack); | ||
*/ | ||
title (prm, lg) { | ||
title (prm, img) { | ||
try { | ||
let ret = this.header().title(prm); | ||
if (undefined !== lg) { | ||
this.header().logo(lg); | ||
} | ||
return ret; | ||
if (undefined === prm) { | ||
return ret; | ||
} | ||
this.header().image(img); | ||
} catch (e) { | ||
@@ -83,3 +85,3 @@ console.error(e.stack); | ||
} | ||
/** | ||
@@ -93,3 +95,5 @@ * app header | ||
header (prm) { | ||
try { return this.innerComp('header', prm, Header); } catch (e) { | ||
try { | ||
return this.innerComp('header', prm); | ||
} catch (e) { | ||
console.error(e.stack); | ||
@@ -109,11 +113,6 @@ throw e; | ||
try { | ||
if (true === mf.func.isInclude(prm, 'Component')) { | ||
prm.option({ | ||
style : { | ||
'position' : 'relative', | ||
'z-index' : '-10' | ||
} | ||
}); | ||
if (true === comutl.isinc(prm, "Component")) { | ||
prm.style({ "position": "relative", "z-index": "-10" }); | ||
} | ||
return this.innerComp('bgwrap', prm, mf.Component); | ||
return this.innerComp("bgwrap", prm); | ||
} catch (e) { | ||
@@ -142,12 +141,6 @@ console.error(e.stack); | ||
this.bgwrap().child(prm); | ||
let hrd_ofs = mf.func.getSize(this.header().height()); | ||
if ( (true === mf.func.isInclude(hrd_ofs, 'Rem')) || | ||
(true === mf.func.isInclude(hrd_ofs, 'Pixel')) ) { | ||
hrd_ofs = parseInt('-' + hrd_ofs.toPxnum()); | ||
} else { | ||
hrd_ofs = 0; | ||
} | ||
prm.option({ | ||
effect : [ new Backgd(), new Synwin([true, true], ["0px", hrd_ofs + "px"]) ] | ||
}); | ||
cmputl.rstyle(prm, { 'position' : 'fixed' }); | ||
let off = comutl.getsize(this.header().height()); | ||
off = (null !== off) ? '-' + off.toPixel() + 'px' : undefined; | ||
prm.config({ effect : new Synwin({ y_offset: off }) }); | ||
} catch (e) { | ||
@@ -163,3 +156,3 @@ console.error(e.stack); | ||
* @param (string (size)) height size | ||
* @param (option) style option | ||
* @param (dict) style option | ||
* @return (string) height size | ||
@@ -172,7 +165,7 @@ * @type parameter | ||
/* getter */ | ||
return mf.func.sizeSum(this.header().height(), super.height()); | ||
return comutl.sizesum(this.header().height(), super.height()); | ||
} | ||
/* setter */ | ||
let set_hei = mf.func.getSize( | ||
mf.func.sizeDiff(prm, this.header().height()) | ||
let set_hei = comutl.getsize( | ||
comutl.sizediff(prm, this.header().height()) | ||
); | ||
@@ -196,3 +189,5 @@ super.height((0 > set_hei.value()) ? prm : set_hei,opt); | ||
mainColor (prm, opt) { | ||
try { return this.header().baseColor(prm,opt); } catch (e) { | ||
try { | ||
return this.header().baseColor(prm,opt); | ||
} catch (e) { | ||
console.error(e.stack); | ||
@@ -208,3 +203,3 @@ throw e; | ||
* array: [red, green, blue, alpha] | ||
* @param (option) style option | ||
* @param (dict) style option | ||
* @return (string) color | ||
@@ -214,3 +209,5 @@ * @type parameter | ||
baseColor (prm, opt) { | ||
try { return mf.func.cmpColor(this, 'background', [prm,opt]); } catch (e) { | ||
try { | ||
return cmputl.color(this, 'background', prm, opt) | ||
} catch (e) { | ||
console.error(e.stack); | ||
@@ -221,3 +218,2 @@ throw e; | ||
} | ||
module.exports = mofron.comp.AppBase; | ||
/* end of file */ |
{ | ||
"name": "mofron-comp-appbase", | ||
"version": "0.4.14", | ||
"version": "0.5.0", | ||
"description": "application base component for mofron", | ||
@@ -19,3 +19,3 @@ "main": "index.js", | ||
"keywords": [ | ||
"front-end" | ||
"front-end", "mofron" | ||
], | ||
@@ -22,0 +22,0 @@ "author": "simparts", |
8636
192