2 Star 8 Fork 0

书生小道士 / CherryJs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Cherry.js 55.65 KB
一键复制 编辑 原始数据 按行查看 历史
书生小道士 提交于 2021-03-31 12:07 . 修改onkeydown CHE_InputTextarea
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809
//样式配置
const CHE_STYLE = {
BorderRadius:"5px",
AnimSpeed:"all 0.2s linear",
Background:{
Default:["#e4e4e4","#d6d6d6"],
Primary:["#77d3fd","#69b7db"],
Success:["#43d3af","#3ab697"],
Info: ["#474747","#252525"],
Warning:["#fdc672","#c29551"],
Danger: ["#fd7272","#cf5a5a"],
Cherry: ["#fa6daa","#fa4895"],
Disabled:["#f1f1f1","#f1f1f1"],
Link:["#57b7ec","#295e7b"]
},
Color:{
Default:"#757575",
Primary:"#4e86a0",
Success:"#25886f",
Info: "#bdbdbd",
Warning:"#705834",
Danger: "#7e3737",
Cherry: "#631c3b",
Disabled:"#c7c7c7",
Link:"#57b7ec"
},
size:{
Mini:{
Padding:"4px 12px",
FontSize:"12px"
},
Default:{
Padding:"6px 15px",
FontSize:"14px"
},
Big:{
Padding:"8px 17px",
FontSize:"17px"
},
}
};
//所有添加了idname 的控件类
/*
* {
* key:控件
* }
* */
let ALLWIDGET = {};
//所有添加了groupname的控件类
/*
* {
* key:[控件,控件,控件]
* }
* */
let ALLWIDGETLIST = {};
//是否添加了<style> 可以多次运行CherryUIRun
let ISSTYLE = false;
//控件插入的父节点的ID,为了js控件做准备
let NODECHILD = "";
function $GET(name){
let code = name.substr(0,1);
let id = name.substr(1,name.length);
switch(code){
case "#":
return ALLWIDGET[id];
case ".":
return ALLWIDGETLIST[id];
}
}
class CherryMain{
constructor(style) {
let cuiStyleText = "<style>" +
"*{margin: 0;padding: 0;}\n"+
".cui_scrollbar{-webkit-overflow-scrolling : touch;}\n" +
".cui_scrollbar::-webkit-scrollbar{width:8px;height:8px;}\n" +
".cui_scrollbar::-webkit-scrollbar-thumb{background-color: #696969;border-radius:6px;}\n" +
".cui_scrollbar::-webkit-scrollbar-track{background-color:#ddd;border-radius:6px;}" +
" input::-webkit-outer-spin-button,input::-webkit-inner-spin-button{-webkit-appearance: none !important;}" +
"</style>";
let cuiStyle = document.createElement("style");
cuiStyle.innerHTML = cuiStyleText;
if(style.hasOwnProperty("app")){
let dom = document.getElementById(style.app);
NODECHILD = dom;
if (ISSTYLE === false) {
dom.append(cuiStyle);
ISSTYLE = true;
}
if(style.hasOwnProperty("child")){
for (let i in style.child) {
let Data = style.child[i];
dom.append(Data);
}
}
if (style.hasOwnProperty("Created")) {
style.Created();
}
}
}
}
//基础类型处理 基础类
class CHE_Widget {
constructor(style) {
this.style = style;
this.Dom = null;
this.ChildDom = null;
}
setStyle(){
this.Dom.style.transition = CHE_STYLE.AnimSpeed;
if(this.style.hasOwnProperty("name")){
ALLWIDGET[this.style.name] = this;
}
if(this.style.hasOwnProperty("group")){
if (ALLWIDGETLIST.hasOwnProperty(this.style.group)) {
ALLWIDGETLIST[this.style.group].push(this);
} else {
ALLWIDGETLIST[this.style.group] = [this];
}
}
if(this.style.hasOwnProperty("id")){
this.Dom.id = this.style.id;
}
if(this.style.hasOwnProperty("class")){
if (typeof this.style.class == "string") {
this.Dom.className = this.style.class;
}
if (typeof this.style.class == "object") {
for (let i in this.style.class) {
this.Dom.className += this.style.class[i] + " ";
}
}
}
if (this.style.hasOwnProperty("position")) {
this.Dom.style.position = this.style.position
}
if (this.style.hasOwnProperty("height")) {
if (this.style.height.toString().indexOf("%") != -1) {
this.Dom.style.height = this.style.height;
} else {
this.Dom.style.height = this.style.height + "px";
}
}
if (this.style.hasOwnProperty("width")) {
if (this.style.width.toString().indexOf("%") != -1) {
this.Dom.style.width = this.style.width;
} else {
this.Dom.style.width = this.style.width + "px";
}
}
if (this.style.hasOwnProperty("backgroundColor")) {
this.Dom.style.backgroundColor = this.style.backgroundColor;
}
// number object
if (this.style.hasOwnProperty("padding")) {
if (typeof this.style.padding == "number") {
this.Dom.style.padding = this.style.padding + "px";
}
if (typeof this.style.padding == "string") {
this.Dom.style.padding = this.style.padding;
}
if (typeof this.style.padding == "object") {
this.Dom.style.paddingTop = this.style.padding[0] + "px";
this.Dom.style.paddingRight = this.style.padding[1] + "px";
this.Dom.style.paddingBottom = this.style.padding[2] + "px";
this.Dom.style.paddingLeft = this.style.padding[3] + "px";
}
}
if (this.style.hasOwnProperty("margin")) {
if (typeof this.style.margin == "number") {
this.Dom.style.margin = this.style.margin + "px";
}
if (typeof this.style.margin == "string") {
this.Dom.style.margin = this.style.margin;
}
if (typeof this.style.margin == "object") {
this.Dom.style.marginTop = this.style.margin[0] + "px";
this.Dom.style.marginRight = this.style.margin[1] + "px";
this.Dom.style.marginBottom = this.style.margin[2] + "px";
this.Dom.style.marginLeft = this.style.margin[3] + "px";
}
}
if (this.style.hasOwnProperty("child")) {
for (let i in this.style.child) {
let Data = this.style.child[i]
this.ChildDom.append(Data)
}
}
if (this.style.hasOwnProperty("visible")) {
if (this.style.visible) {
this.Dom.style.visibility = "visible";
} else {
this.Dom.style.visibility = "hidden";
}
}
if (this.style.hasOwnProperty("cookie")) {
this.Cookie = this.style.cookie
}
if (this.style.hasOwnProperty("zindex")) {
this.Dom.style.zIndex = this.style.zindex;
}
if (this.style.hasOwnProperty("opacity")) {
this.Dom.style.opacity = this.style.opacity;
}
if (this.style.hasOwnProperty("display")) {
this.Dom.style.display = this.style.display;
}
}
setPosition(pos) {
this.style.position = pos;
this.Dom.style.position = pos;
}
setHeight(height) {
this.style.height = height;
if (height.toString().indexOf("%") != -1) {
this.Dom.style.height = height;
} else {
this.Dom.style.height = height + "px";
}
}
getHeight() {
return {
DomHeight:this.Dom.style.height,
StyleHeight:this.style.height
}
}
setWidth(width) {
this.style.width = width;
if (width.toString().indexOf("%") != -1) {
this.Dom.style.width = width;
} else {
this.Dom.style.width = width + "px";
}
}
getWidth() {
return {
DomWidth:this.Dom.style.width,
StyleWidth:this.style.width
}
}
setPadding(padding) {
this.style.padding = padding;
if (typeof padding == "number") {
this.Dom.style.padding = padding + "px";
}
if (typeof padding == "string") {
this.Dom.style.padding = padding;
}
if (typeof padding == "object") {
this.Dom.style.paddingTop = padding[0] + "px";
this.Dom.style.paddingRight = padding[1] + "px";
this.Dom.style.paddingBottom = padding[2] + "px";
this.Dom.style.paddingLeft = padding[3] + "px";
}
}
getPadding() {
return {
DomPadding:{
Top: this.Dom.style.paddingTop,
Right: this.Dom.style.paddingRight,
Bottom: this.Dom.style.paddingBottom,
Left: this.Dom.style.paddingLeft
},
StylePadding:this.style.padding
};
}
setMargin(margin) {
this.style.margin = margin;
if (typeof margin == "number") {
this.Dom.style.margin = margin + "px";
}
if (typeof margin == "string") {
this.Dom.style.margin = margin;
}
if (typeof margin == "object") {
this.Dom.style.marginTop = margin[0] + "px";
this.Dom.style.marginRight = margin[1] + "px";
this.Dom.style.marginBottom = margin[2] + "px";
this.Dom.style.marginLeft = margin[3] + "px";
}
}
getMargin() {
return {
DomMargin:{
Top: this.Dom.style.marginTop,
Right: this.Dom.style.marginRight,
Bottom: this.Dom.style.marginBottom,
Left: this.Dom.style.marginLeft,
},
StyleMargin:this.style.margin
};
}
setBackgroundColor(color) {
this.style.backgroundColor = color;
this.Dom.style.backgroundColor = color;
}
getBackgroundColor() {
return {
DomBackgroundColor:this.Dom.style.backgroundColor,
StyleBackgroundColor:this.style.backgroundColor,
};
}
setCookie(Cookie) {
this.Cookie = Cookie;
}
getCookie() {
return this.Cookie;
}
removeMe() {
if(this.style.hasOwnProperty("name")){
delete ALLWIDGET[this.style.name];
}
if(this.style.hasOwnProperty("group")){
if(ALLWIDGETLIST.hasOwnProperty(this.style.group)){
for(let i in ALLWIDGETLIST[this.style.group]){
if(this === ALLWIDGETLIST[this.style.group][i]){
ALLWIDGETLIST[this.style.group].splice(i,1);
break;
}
}
if(ALLWIDGETLIST[this.style.group].length === 0){
delete ALLWIDGETLIST[this.style.group];
}
}
}
this.Dom.remove();
}
removeChild() {
this.Dom.innerHTML = "";
}
addChildList(list) {
for (let i in list) {
let Data = list[i];
this.ChildDom.append(Data);
}
}
setVisible(vis) {
this.style.visible = vis;
if (vis) {
this.Dom.style.visibility = "visible";
} else {
let dom = this.Dom
let display = this.Dom.style.display
if (display == null) {
display = "block"
}
this.Dom.style.display = "none"
setTimeout(function () {
dom.style.visibility = "hidden";
dom.style.display = display;
}, 200)
}
}
setZindex(zindex) {
this.style.zindex = zindex;
this.Dom.style.zIndex = zindex;
}
setOpacity(opacity) {
this.style.opacity = opacity;
this.Dom.style.opacity = opacity;
}
setDisplay(display) {
this.style.display = display;
this.Dom.style.display = display;
}
getDisplay(){
return this.style.display;
}
}
class CHE_Container extends CHE_Widget {
constructor(style) {
super(style);
this.Dom = document.createElement("div");
this.ChildDom = this.Dom;
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
let self = this;
this.isboxShadow = false;
this.isboxShadowHover = false;
this.ismousego = false;
this.ismouseout = false;
this.isclick = false;
if (this.style.hasOwnProperty("rotate")) {
this.Dom.style.transform = "rotate(" + this.style.rotate + "deg)";
}
if (this.style.hasOwnProperty("box")) {
let border = this.style.box;
if (border.hasOwnProperty("borderRadius")) {
this.Dom.style.borderRadius = border.borderRadius + "px";
}
if (border.hasOwnProperty("borderWidth")) {
this.Dom.style.borderWidth = border.borderWidth + "px";
}
if (border.hasOwnProperty("borderStyle")) {
this.Dom.style.borderStyle = border.borderStyle;
}
if (border.hasOwnProperty("borderColor")) {
this.Dom.style.borderColor = border.borderColor;
}
if (border.hasOwnProperty("boxShadow")) {
this.isboxShadow = true;
this.Dom.style.boxShadow = border.boxShadow;
}
if (border.hasOwnProperty("boxShadowHover")) {
this.isboxShadowHover = true;
}
}
if (this.style.hasOwnProperty("methods")) {
let methods = this.style.methods;
if (methods.hasOwnProperty("mousego")) {
this.ismousego = true;
}
if (methods.hasOwnProperty("mouseout")) {
this.ismouseout = true;
}
if (methods.hasOwnProperty("click")) {
this.isclick = true;
}
if (methods.hasOwnProperty("mousedown")) {
this.Dom.onmousedown = function (e) {
methods.mousedown(e, self)
};
}
if (methods.hasOwnProperty("mouseup")) {
this.Dom.onmouseup = function (e) {
methods.mouseup(e, self)
};
}
}
if (this.ismousego || this.ismouseout || this.isboxShadowHover) {
this.Dom.onmouseenter = function (e) {
if (self.isboxShadowHover) {
self.Dom.style.boxShadow = self.style.box.boxShadowHover;
}
if (self.ismousego) {
self.style.methods.mousego(e, self);
}
}
this.Dom.onmouseout = function (e) {
if (self.isboxShadow) {
self.Dom.style.boxShadow = self.style.box.boxShadow;
} else {
self.Dom.style.boxShadow = "none";
}
if (self.ismouseout) {
self.style.methods.mouseout(e, self);
}
}
}
if (this.isclick) {
this.Dom.onclick = function (e) {
self.style.methods.click(e, self)
};
}
}
setBox(box) {
let self = this;
if (box.hasOwnProperty("borderRadius")) {
this.Dom.style.borderRadius = box.borderRadius + "px";
this.style.box.borderRadius = box.borderRadius;
}
if (box.hasOwnProperty("borderWidth")) {
this.Dom.style.borderWidth = box.borderWidth + "px";
this.style.box.borderWidth = box.borderWidth;
}
if (box.hasOwnProperty("borderStyle")) {
this.Dom.style.borderStyle = box.borderStyle;
this.style.box.borderStyle = box.borderStyle;
}
if (box.hasOwnProperty("borderColor")) {
this.Dom.style.borderColor = box.borderColor;
this.style.box.borderColor = box.borderColor;
}
if (box.hasOwnProperty("boxShadow")) {
this.isboxShadow = true;
this.Dom.style.boxShadow = box.boxShadow;
this.style.box.boxShadow = box.boxShadow;
}
if (box.hasOwnProperty("boxShadowHover")) {
this.style.box.boxShadowHover = box.boxShadowHover;
this.Dom.onmouseenter = function () {
self.Dom.style.boxShadow = box.boxShadowHover;
if (self.ismousego) {
self.style.methods.mousego();
}
}
this.Dom.onmouseout = function () {
if (self.isboxShadow) {
self.Dom.style.boxShadow = self.styles.box.boxShadow;
} else {
self.Dom.style.boxShadow = "none";
}
if (self.ismouseout) {
self.style.methods.mouseout();
}
}
}
}
getBox() {
return this.style.box;
}
setRotate(rotate) {
this.Dom.style.transform = "rotate(" + rotate + "deg)";
}
}
class CHE_Scrollbox extends CHE_Container {
constructor(style) {
super(style);
}
setStyle() {
super.setStyle();
this.Dom.className += " cui_scrollbar "
this.Dom.style.overflow = "auto";
if (this.style.hasOwnProperty("overflowH")) {
if (this.style.overflowH) {
this.Dom.style.overflowX = "auto"
} else {
this.Dom.style.overflowX = "hidden"
}
}
if (this.style.hasOwnProperty("overflowV")) {
if (this.style.overflowV) {
this.Dom.style.overflowY = "auto"
} else {
this.Dom.style.overflowY = "hidden"
}
}
}
setOverflowH(over) {
if (over) {
this.Dom.style.overflowX = "auto"
} else {
this.Dom.style.overflowX = "hidden"
}
}
setOverflowV(over) {
if (over) {
this.Dom.style.overflowY = "auto"
} else {
this.Dom.style.overflowY = "hidden"
}
}
}
class CHE_Flexlayout extends CHE_Widget {
constructor(style) {
super(style);
this.Dom = document.createElement("div");
this.ChildDom = this.Dom;
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
let self = this;
this.Dom.style.display = "flex"
let styles = this.style;
if (styles.hasOwnProperty("rotate")) {
this.Dom.style.transform = "rotate(" + styles.rotate + "deg)";
}
if (styles.hasOwnProperty("type")) {
if (styles.type == "V") {
this.Dom.style.flexDirection = "column";
}
if (styles.type == "H") {
this.Dom.style.flexDirection = "row";
}
}
if (styles.hasOwnProperty("wrap")) {
if (styles.wrap) {
this.Dom.style.flexWrap = "wrap";
} else {
this.Dom.style.flexWrap = "nowrap";
}
}
}
setType(type) {
this.style = type;
if (type == "V") {
this.Dom.style.flexDirection = "column";
}
if (type == "H") {
this.Dom.style.flexDirection = "row";
}
}
setWrap(wrap) {
this.style.wrap = wrap;
if (wrap) {
this.Dom.style.flexWrap = "wrap";
} else {
this.Dom.style.flexWrap = "nowrap";
}
}
setRotate(rotate) {
this.Dom.style.transform = "rotate(" + rotate + "deg)";
}
}
class CHE_FlexlayoutItem extends CHE_Widget {
constructor(style) {
super(style);
this.Dom = document.createElement("div");
this.ChildDom = this.Dom;
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
let self = this;
if (this.style.hasOwnProperty("flex")) {
this.Dom.style.flex = this.style.flex;
}
}
setFlex(flex) {
this.Dom.style.flex = flex;
}
}
class CHE_Staticlayout extends CHE_Widget {
constructor(style) {
super(style);
this.Dom = document.createElement("div");
this.ChildDom = this.Dom;
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
let self = this;
let styles = this.style;
if (styles.hasOwnProperty("xy")) {
let xy = styles.xy
if (xy.hasOwnProperty("left")) {
if (typeof xy.left == "number") {
this.Dom.style.left = xy.left + "px";
}
if (typeof xy.left == "string") {
this.Dom.style.left = xy.left;
}
}
if (xy.hasOwnProperty("top")) {
if (typeof xy.top == "number") {
this.Dom.style.top = xy.top + "px";
}
if (typeof xy.top == "string") {
this.Dom.style.top = xy.top;
}
}
if (xy.hasOwnProperty("right")) {
if (typeof xy.right == "number") {
this.Dom.style.right = xy.right + "px";
}
if (typeof xy.right == "string") {
this.Dom.style.right = xy.right;
}
}
if (xy.hasOwnProperty("bottom")) {
if (typeof xy.bottom == "number") {
this.Dom.style.bottom = xy.bottom + "px";
}
if (typeof xy.bottom == "string") {
this.Dom.style.bottom = xy.bottom;
}
}
}
if (styles.hasOwnProperty("rotate")) {
this.Dom.style.transform = "rotate(" + styles.rotate + "deg)";
}
if (styles.hasOwnProperty("methods")) {
let methods = styles.methods;
if (methods.hasOwnProperty("mousego")) {
this.Dom.onmouseenter = function (e) {
methods.mousego(e, self)
};
}
if (methods.hasOwnProperty("mouseout")) {
this.Dom.onmouseout = function (e) {
methods.mouseout(e, self)
};
}
if (methods.hasOwnProperty("click")) {
this.Dom.onclick = function (e) {
methods.click(e, self)
};
}
if (methods.hasOwnProperty("mousedown")) {
this.Dom.onmousedown = function (e) {
methods.mousedown(e, self)
};
}
if (methods.hasOwnProperty("mouseup")) {
this.Dom.onmouseup = function (e) {
methods.mouseup(e, self)
};
}
}
}
setXY(xy) {
this.style.xy = xy;
if (xy.hasOwnProperty("left")) {
if (typeof xy.left == "number") {
this.Dom.style.left = xy.left + "px";
}
if (typeof xy.left == "string") {
this.Dom.style.left = xy.left;
}
}
if (xy.hasOwnProperty("top")) {
if (typeof xy.top == "number") {
this.Dom.style.top = xy.top + "px";
}
if (typeof xy.top == "string") {
this.Dom.style.top = xy.top;
}
}
if (xy.hasOwnProperty("right")) {
if (typeof xy.right == "number") {
this.Dom.style.right = xy.right + "px";
}
if (typeof xy.right == "string") {
this.Dom.style.right = xy.right;
}
}
if (xy.hasOwnProperty("bottom")) {
if (typeof xy.bottom == "number") {
this.Dom.style.bottom = xy.bottom + "px";
}
if (typeof xy.bottom == "string") {
this.Dom.style.bottom = xy.bottom;
}
}
}
setRotate(rotate) {
this.Dom.style.transform = "rotate(" + rotate + "deg)";
}
}
class CHE_Button extends CHE_Widget{
constructor(style) {
super(style);
this.Dom = document.createElement("button");
this.ChildDom = this.Dom;
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
let self = this;
this.Dom.style.border = "0";
if(this.style.hasOwnProperty("outline")){
if(this.style.outline){}else{
this.Dom.style.outline = "none";
}
}else{
this.Dom.style.outline = "none";
}
if(this.style.hasOwnProperty("text")){
this.ChildDom.innerHTML = this.style.text;
}
let ButtonType = this.style.type;
let SizeType = this.style.size;
if(!this.style.hasOwnProperty("type")){ButtonType = "Default";}
if(!this.style.hasOwnProperty("size")){SizeType = "Default";}
if(this.style.type === "Link"){
this.Dom.style.background = "none";
this.Dom.style.textDecoration = "underline";
this.Dom.style.color = CHE_STYLE.Color.Link;
this.Dom.style.cursor = "pointer";
}else
{
this.Dom.style.cursor = "pointer";
this.Dom.style.background = 'linear-gradient('+CHE_STYLE.Background[ButtonType][0]+','+CHE_STYLE.Background[ButtonType][1]+')';
this.Dom.style.color = CHE_STYLE.Color[ButtonType];
this.Dom.style.padding = CHE_STYLE.size[SizeType]["Padding"];
this.Dom.style.fontSize = CHE_STYLE.size[SizeType]["FontSize"];
this.Dom.style.borderRadius = CHE_STYLE.BorderRadius;
}
if(this.style.type === "Disabled"){
this.Dom.style.cursor = "wait";
return false;
}
if(this.style.hasOwnProperty("methods")){
let method = this.style.methods;
this.Dom.onmousedown = function (e){
if(ButtonType === "Link"){
self.Dom.style.color = CHE_STYLE.Background[ButtonType][1];
}else{
self.Dom.style.background = 'linear-gradient('+CHE_STYLE.Background[ButtonType][1]+','+CHE_STYLE.Background[ButtonType][0]+')';
}
if(method.hasOwnProperty("mousedown")){
method.mousedown(e,self);
}
}
this.Dom.onmouseup = function (e){
if(ButtonType === "Link"){
self.Dom.style.color = CHE_STYLE.Background[ButtonType][0];
}else{
self.Dom.style.background = 'linear-gradient('+CHE_STYLE.Background[ButtonType][0]+','+CHE_STYLE.Background[ButtonType][1]+')';
}
if(method.hasOwnProperty("mouseup")){
method.mouseup(e,self);
}
}
if(method.hasOwnProperty("mousego")){
this.Dom.onmouseenter = function (e){
method.mousego(e,self);
}
}
this.Dom.onmouseout = function (e){
if(ButtonType === "Link"){
self.Dom.style.color = CHE_STYLE.Background[ButtonType][0];
}else{
self.Dom.style.background = 'linear-gradient('+CHE_STYLE.Background[ButtonType][0]+','+CHE_STYLE.Background[ButtonType][1]+')';
}
if(method.hasOwnProperty("mouseout")){
method.mouseout(e,self);
}
}
if(method.hasOwnProperty("click")){
this.Dom.onclick = function (e){
method.click(e,self);
}
}
}else{
this.Dom.onmousedown = function (e){
if(ButtonType === "Link"){
self.Dom.style.color = CHE_STYLE.Background[ButtonType][1];
}else{
self.Dom.style.background = 'linear-gradient('+CHE_STYLE.Background[ButtonType][1]+','+CHE_STYLE.Background[ButtonType][0]+')';
}
}
this.Dom.onmouseup = function (e){
if(ButtonType === "Link"){
self.Dom.style.color = CHE_STYLE.Background[ButtonType][0];
}else{
self.Dom.style.background = 'linear-gradient('+CHE_STYLE.Background[ButtonType][0]+','+CHE_STYLE.Background[ButtonType][1]+')';
}
}
this.Dom.onmouseout = function (e){
if(ButtonType === "Link"){
self.Dom.style.color = CHE_STYLE.Background[ButtonType][0];
}else{
self.Dom.style.background = 'linear-gradient('+CHE_STYLE.Background[ButtonType][0]+','+CHE_STYLE.Background[ButtonType][1]+')';
}
}
}
}
}
class CHE_Text extends CHE_Widget {
constructor(style) {
super(style);
this.Dom = document.createElement("div");
this.Dom.style.display = "flex";
this.Dom.style.flexDirection = "column";
this.topContainer = document.createElement("div");
this.centerContainer = document.createElement("div");
this.bottomContainer = document.createElement("div");
this.Dom.append(this.topContainer);
this.Dom.append(this.centerContainer);
this.Dom.append(this.bottomContainer);
let textalign = "left";
if (style.hasOwnProperty("textAlign")) {
textalign = style.textAlign;
}
this.textDiv = document.createElement("div");
if (style.hasOwnProperty("text")) {
this.textDiv.innerText = style.text;
}
this.textDiv.style.textAlign = textalign;
this.textDiv.style.wordBreak = "break-all";
if (style.hasOwnProperty("ellipsis")) {
if (style.ellipsis) {
this.textDiv.style.overflow = "hidden";
this.textDiv.style.textOverflow = "ellipsis";
this.textDiv.style.whiteSpace = "nowrap";
}
}
this.centerContainer.append(this.textDiv);
this.ChildDom = this.textDiv;
if (style.hasOwnProperty("colorStyle")) {
let font = style.colorStyle;
if (font.hasOwnProperty("size")) {
this.textDiv.style.fontSize = font.size + "px";
}
if (font.hasOwnProperty("bold")) {
if (font.bold) {
this.textDiv.style.fontWeight = "bold";
} else {
this.textDiv.style.fontWeight = "normal";
}
}
if (font.hasOwnProperty("italic")) {
if (font.italic) {
this.textDiv.style.fontStyle = "italic";
} else {
this.textDiv.style.fontStyle = "normal";
}
}
if (font.hasOwnProperty("disabled")) {
if (font.disabled) {
this.textDiv.style.textDecoration = "line-through";
} else {
this.textDiv.style.textDecoration = "none";
}
}
if (font.hasOwnProperty("color")) {
this.textDiv.style.color = font.color;
}
}
if (style.hasOwnProperty("lineAlign")) {
if (style.lineAlign == "top") {
this.topContainer.style.flex = "0";
this.bottomContainer.style.flex = "1";
}
if (style.lineAlign == "center") {
this.topContainer.style.flex = "1";
this.bottomContainer.style.flex = "1";
}
if (style.lineAlign == "bottom") {
this.topContainer.style.flex = "1";
this.bottomContainer.style.flex = "0";
}
}
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
}
setText(text) {
this.style.text = text;
this.textDiv.innerText = text;
}
getText() {
return {
StyleText:this.style.text,
DomText:this.textDiv.innerText,
DomHtml:this.textDiv.innerHTML
};
}
setTextalign(talign) {
this.textDiv.style.textAlign = talign;
}
setLinealign(lalign) {
switch (lalign) {
case "top":
this.topContainer.style.flex = "0";
this.bottomContainer.style.flex = "1";
break;
case "center":
this.topContainer.style.flex = "1";
this.bottomContainer.style.flex = "1";
break;
case "bottom":
this.topContainer.style.flex = "1";
this.bottomContainer.style.flex = "0";
break;
}
}
setColorstyle(font) {
if (font.hasOwnProperty("size")) {
this.textDiv.style.fontSize = font.size + "px";
}
if (font.hasOwnProperty("bold")) {
if (font.bold) {
this.textDiv.style.fontWeight = "bold";
} else {
this.textDiv.style.fontWeight = "normal";
}
}
if (font.hasOwnProperty("italic")) {
if (font.italic) {
this.textDiv.style.fontStyle = "italic";
} else {
this.textDiv.style.fontStyle = "normal";
}
}
if (font.hasOwnProperty("disabled")) {
if (font.disabled) {
this.textDiv.style.textDecoration = "line-through";
} else {
this.textDiv.style.textDecoration = "none";
}
}
if (font.hasOwnProperty("color")) {
this.textDiv.style.color = font.color;
}
}
setEllipsis(ell) {
if (ell) {
this.textDiv.style.overflow = "hidden";
this.textDiv.style.textOverflow = "ellipsis";
this.textDiv.style.whiteSpace = "nowrap";
} else {
this.textDiv.style.overflow = "";
this.textDiv.style.textOverflow = "";
this.textDiv.style.whiteSpace = "";
}
}
}
class CHE_TextItem extends CHE_Widget {
constructor(style) {
super(style);
this.Dom = document.createElement("span");
this.ChildDom = this.Dom;
if (style.hasOwnProperty("text")) {
this.Dom.innerText = style.text;
}
if (style.hasOwnProperty("colorStyle")) {
let font = style.colorStyle;
if (font.hasOwnProperty("size")) {
this.Dom.style.fontSize = font.size + "px";
}
if (font.hasOwnProperty("bold")) {
if (font.bold) {
this.Dom.style.fontWeight = "bold";
} else {
this.Dom.style.fontWeight = "normal";
}
}
if (font.hasOwnProperty("italic")) {
if (font.italic) {
this.Dom.style.fontStyle = "italic";
} else {
this.Dom.style.fontStyle = "normal";
}
}
if (font.hasOwnProperty("disabled")) {
if (font.disabled) {
this.Dom.style.textDecoration = "line-through";
} else {
this.Dom.style.textDecoration = "none";
}
}
if (font.hasOwnProperty("color")) {
this.Dom.style.color = font.color;
}
}
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
}
setText(text) {
this.style.text = text;
this.Dom.innerText = text;
}
getText() {
return {
StyleText:this.style.text,
DomText:this.Dom.innerText,
DomHtml:this.Dom.innerHTML
};
}
setColorstyle(font) {
if (font.hasOwnProperty("size")) {
this.Dom.style.fontSize = font.size + "px";
}
if (font.hasOwnProperty("bold")) {
if (font.bold) {
this.Dom.style.fontWeight = "bold";
} else {
this.Dom.style.fontWeight = "normal";
}
}
if (font.hasOwnProperty("italic")) {
if (font.italic) {
this.Dom.style.fontStyle = "italic";
} else {
this.Dom.style.fontStyle = "normal";
}
}
if (font.hasOwnProperty("disabled")) {
if (font.disabled) {
this.Dom.style.textDecoration = "line-through";
} else {
this.Dom.style.textDecoration = "none";
}
}
if (font.hasOwnProperty("color")) {
this.Dom.style.color = font.color;
}
}
}
class CHE_Tag extends CHE_Widget{
constructor(style) {
super(style);
this.Dom = document.createElement("span");
this.ChildDom = this.Dom;
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
if(!this.style.hasOwnProperty("type")){
this.style.type = "Default";
}
if(!this.style.hasOwnProperty("size")){
this.style.type = "Default";
}
if(this.style.hasOwnProperty("text")){
this.Dom.innerHTML = this.style.text;
}
this.Dom.style.backgroundColor = CHE_STYLE.Background[this.style.type][0];
this.Dom.style.color = CHE_STYLE.Color[this.style.type];
this.Dom.style.padding = CHE_STYLE.size[this.style.size].Padding;
this.Dom.style.fontSize = CHE_STYLE.size[this.style.size].FontSize;
this.Dom.style.borderRadius = CHE_STYLE.BorderRadius;
}
setText(text){
this.style.text = text;
this.Dom.innerHTML = text;
}
getText(){
return {
StyleText:this.style.text,
DomText:this.Dom.innerText,
DomHtml:this.Dom.innerHTML,
};
}
setType(type){
this.Dom.style.backgroundColor = CHE_STYLE.Background[type][0];
this.Dom.style.color = CHE_STYLE.Color[type];
}
setSize(size){
this.Dom.style.padding = CHE_STYLE.size[size].Padding;
this.Dom.style.fontSize = CHE_STYLE.size[size].FontSize;
}
}
class CHE_Image extends CHE_Widget{
constructor(style) {
super(style);
this.Dom = document.createElement("img");
this.ChildDom = this.Dom;
if(this.style.hasOwnProperty("child")){
this.style.child = [];
}
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
if(this.style.hasOwnProperty("src")){
this.Dom.src = this.style.src;
}
}
setSrc(src) {
this.style.src = src;
this.Dom.src = src;
}
getSrc(){
return this.style.src;
}
}
class CHE_ImageMode extends CHE_Widget {
//照搬老代码
constructor(style) {
super(style);
this.Dom = document.createElement("div");
this.ChildDom = this.Dom;
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
let styles = this.style;
if (styles.hasOwnProperty("src")) {
this.Dom.style.backgroundImage = "url(" + styles.src + ")";
}
if (styles.hasOwnProperty("full")) {
if (styles.full === true) {
this.Dom.style.backgroundSize = "cover";
}
if (styles.full === false) {
this.Dom.style.backgroundSize = "auto";
}
if (typeof styles.full == "string") {
this.Dom.style.backgroundSize = styles.full;
}
if (typeof styles.full == "object") {
let a = styles.full[0];
let b = styles.full[1];
if (typeof a == "number") {
a = a + "px"
}
if (typeof b == "number") {
b = b + "px"
}
this.Dom.style.backgroundSize = a + " " + b;
}
}
if (styles.hasOwnProperty("repeat")) {
if (styles.repeat == "none") {
this.Dom.style.backgroundRepeat = "no-repeat";
} else if (styles.repeat == "x") {
this.Dom.style.backgroundRepeat = "repeat-x";
} else if (styles.repeat == "y") {
this.Dom.style.backgroundRepeat = "repeat-y";
} else {
this.Dom.style.backgroundRepeat = "repeat";
}
}
if (styles.hasOwnProperty("xy")) {
let a = styles.xy[0];
let b = styles.xy[1];
if (typeof a == "number") {
a = a + "px"
}
if (typeof b == "number") {
b = b + "px"
}
this.Dom.style.backgroundPosition = a + " " + b;
}
}
setSrc(src) {
this.Dom.style.backgroundImage = "url(" + src + ")";
}
setFull(full) {
if (full === true) {
this.Dom.style.backgroundSize = "cover";
}
if (full === false) {
this.Dom.style.backgroundSize = "auto";
}
if (typeof full == "string") {
this.Dom.style.backgroundSize = full;
}
if (typeof full == "object") {
let a = full[0];
let b = full[1];
if (typeof a == "number") {
a = a + "px"
}
if (typeof b == "number") {
b = b + "px"
}
this.Dom.style.backgroundSize = a + " " + b;
}
}
setRepeat(repeat) {
if (repeat == "none") {
this.Dom.style.backgroundRepeat = "no-repeat";
} else if (repeat == "x") {
this.Dom.style.backgroundRepeat = "repeat-x";
} else if (repeat == "y") {
this.Dom.style.backgroundRepeat = "repeat-y";
} else {
this.Dom.style.backgroundRepeat = "repeat";
}
}
setXY(xy) {
let a = xy[0];
let b = xy[1];
if (typeof a == "number") {
a = a + "px"
}
if (typeof b == "number") {
b = b + "px"
}
this.Dom.style.backgroundPosition = a + " " + b;
}
}
class CHE_Input extends CHE_Widget{
constructor(style) {
super(style);
this.Dom = document.createElement("input");
this.ChildDom = this.Dom;
if(this.style.hasOwnProperty("child")){
this.style.child = [];
}
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
let self = this;
if(!this.style.hasOwnProperty("type")){
this.style.type = "Default";
}
this.Dom.style.border = "1px solid "+CHE_STYLE.Background[this.style.type][0];
this.Dom.style.backgroundColor = CHE_STYLE.Background[this.style.type][1] ;
this.Dom.style.position = "relative";
this.Dom.style.padding = CHE_STYLE.size.Mini.Padding;
this.Dom.style.borderRadius = CHE_STYLE.BorderRadius;
this.Dom.style.border = "0";
this.Dom.style.outline = "none";
this.Dom.style.color = CHE_STYLE.Color[this.style.type];
if(this.style.hasOwnProperty("title")){
this.Dom.placeholder = this.style.title;
}
if(this.style.hasOwnProperty("value")){
this.Dom.value = this.style.value;
}
if(this.style.hasOwnProperty("Itype")){
switch (this.style.Itype){
case "text":
break;
case "pwd":
this.Dom.type = "password";
break;
case "number":
this.Dom.type = "number";
break;
default:
this.Dom.type = this.style.Itype;
break;
}
}
if(this.style.hasOwnProperty("methods")){
let methods = this.style.methods;
if(methods.hasOwnProperty("click")){
this.Dom.onclick = function (e){
methods.click(e,self)
}
}
if(methods.hasOwnProperty("change")){
this.Dom.onchange = function (e){
methods.change(e,self)
}
}
}
}
setTitle(title){
this.style.title = title;
this.Dom.placeholder = title;
}
setText(text){
this.style.text = text;
this.Dom.value = text;
}
getText(){
return this.Dom.value;
}
getValue(){
return this.Dom.value;
}
}
class CHE_InputTextarea extends CHE_Widget{
constructor(style) {
super(style);
this.Dom = document.createElement("textarea");
this.ChildDom = this.Dom;
if(this.style.hasOwnProperty("child")){
this.style.child = [];
}
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
let self = this;
this.Dom.className += " cui_scrollbar";
if(!this.style.hasOwnProperty("type")){
this.style.type = "Default";
}
this.Dom.style.border = "1px solid "+CHE_STYLE.Background[this.style.type][0];
this.Dom.style.backgroundColor = CHE_STYLE.Background[this.style.type][1] ;
this.Dom.style.position = "relative";
this.Dom.style.borderRadius = CHE_STYLE.BorderRadius;
this.Dom.style.border = "0";
this.Dom.style.outline = "none";
this.Dom.style.color = CHE_STYLE.Color[this.style.type];
if(this.style.hasOwnProperty("title")){
this.Dom.placeholder = this.style.title;
}
if(this.style.hasOwnProperty("value")){
this.Dom.innerText = this.style.value;
}
if(this.style.hasOwnProperty("methods")){
let methods = this.style.methods;
if(methods.hasOwnProperty("click")){
this.Dom.onclick = function (e){
methods.click(e,self)
}
}
if(methods.hasOwnProperty("change")){
this.Dom.onchange = function (e){
methods.change(e,self)
}
}
}
this.Dom.onkeydown = function (e){
if(e.key === "Tab"){
self.Dom.value += "\t";
self.Dom.focus();
e.stopPropagation();
return false;
}
}
}
setTitle(title){
this.style.title = title;
this.Dom.placeholder = title;
}
setText(text){
this.style.text = text;
this.Dom.innerText = text;
}
getText(){
return this.Dom.value;
}
}
class CHE_Select extends CHE_Widget{
constructor(style) {
super(style);
this.Dom = document.createElement("select");
this.ChildDom = this.Dom;
if(this.style.hasOwnProperty("child")){
this.style.child = [];
}
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
let self = this;
if(!this.style.hasOwnProperty("type")){
this.style.type = "Default";
}
if(!this.style.hasOwnProperty("size")){
this.style.size = "Mini";
}
if(!this.style.hasOwnProperty("multiple")){
this.style.multiple = false;
}
this.Dom.style.border = "0";
this.Dom.style.outline = "none";
this.Dom.style.borderRadius = CHE_STYLE.BorderRadius;
this.Dom.style.backgroundColor = CHE_STYLE.Background[this.style.type][0];
this.Dom.style.color = CHE_STYLE.Color[this.style.type];
this.Dom.style.padding = CHE_STYLE.size[this.style.size].Padding;
this.Dom.style.fontSize = CHE_STYLE.size[this.style.size].FontSize;
if(this.style.multiple){
this.Dom.multiple = "multiple";
}
if(this.style.hasOwnProperty("init")){
let option = document.createElement("option");
option.value = this.style.init.value;
option.innerText = this.style.init.label;
option.style.color = CHE_STYLE.Color[this.style.type];
if(this.style.init.hasOwnProperty("disabled")){
if(this.style.init.disabled){
option.disabled = "disabled";
}
}
let initOption = document.createElement("option");
initOption.innerText = "——————————";
initOption.disabled = "disabled";
this.Dom.append(option);
this.Dom.append(initOption);
}
if(this.style.hasOwnProperty("value")){
for(let i in this.style.value){
let data = this.style.value[i];
switch (data.type) {
case "single":
let option = document.createElement("option");
option.value = data.value.value;
option.innerText = data.value.label;
if (data.value.hasOwnProperty("disabled")) {
if (data.value.init.disabled) {
option.disabled = "disabled";
}
}
this.Dom.append(option);
break;
case "group":
let optgroup = document.createElement("optgroup");
if (data.hasOwnProperty("label")) {
optgroup.label = data.label;
for (let i2 in data.value) {
let tmp = data.value[i2];
let option = document.createElement("option");
option.value = tmp.value;
option.innerText = tmp.label;
option.style.color = CHE_STYLE.Color[this.style.type];
if (tmp.hasOwnProperty("disabled")) {
if (tmp.disabled) {
option.disabled = "disabled";
}
}
optgroup.append(option);
}
this.Dom.append(optgroup);
break;
}
}
}
}
if(this.style.hasOwnProperty("methods")){
if(this.style.methods.hasOwnProperty("change")){
this.Dom.onchange = function (e){
self.style.methods.change(e,self);
}
}
}
}
setValue(value){
this.style.value = value;
this.Dom.innerHTML = "";
for(let i in value){
let data = value[i];
switch (data.type) {
case "single":
let option = document.createElement("option");
option.value = data.value.value;
option.innerText = data.value.label;
if (data.value.hasOwnProperty("disabled")) {
if (data.value.init.disabled) {
option.disabled = "disabled";
}
}
this.Dom.append(option);
break;
case "group":
let optgroup = document.createElement("optgroup");
if (data.hasOwnProperty("label")) {
optgroup.label = data.label;
for (let i2 in data.value) {
let tmp = data.value[i2];
let option = document.createElement("option");
option.value = tmp.value;
option.innerText = tmp.label;
if (tmp.hasOwnProperty("disabled")) {
if (tmp.disabled) {
option.disabled = "disabled";
}
}
optgroup.append(option);
}
this.Dom.append(optgroup);
break;
}
}
}
}
getValue(){
return this.Dom.value;
}
}
class CHE_Radio extends CHE_Widget{
constructor(style) {
super(style);
this.Dom = document.createElement("label");
this.ChildDom = this.Dom;
if(this.style.hasOwnProperty("child")){
this.style.child = [];
}
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
if(!this.type){
this.type = "radio";
}
let self = this;
this.radio = document.createElement("input");
this.radio.type = this.type;
this.radio.onclick = function (e){e.stopPropagation();}
if(this.style.hasOwnProperty("text")){
this.Dom.innerHTML = this.style.text;
}
if(this.style.hasOwnProperty("form")){
this.radio.name = this.style.form;
}
if(this.style.hasOwnProperty("init")){
if(this.style.init){
this.radio.checked = "checked";
}
}
// if(this.style.hasOwnProperty("methods")){
// if(this.style.methods.hasOwnProperty("click")){
// this.Dom.onclick = function (e){
// self.style.methods.click(e,self);
// }
// }
// }
this.Dom.prepend(this.radio);
}
getValue(){
return this.radio.checked;
}
setValue(val){
if(val){
this.radio.checked = true;
}else{
this.radio.checked = false;
}
}
}
class CHE_Checkbox extends CHE_Radio{
constructor(style) {
super(style);
}
setStyle() {
this.type = "checkbox";
super.setStyle();
}
}
class CHE_Iframe extends CHE_Widget{
constructor(style) {
super(style);
this.Dom = document.createElement("iframe");
this.ChildDom = this.Dom;
if(this.style.hasOwnProperty("child")){
this.style.child = [];
}
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
this.Dom.style.border = "0";
if(this.style.hasOwnProperty("src")){
this.Dom.src = this.style.src
}
}
setSrc(src){
this.style.src = src;
this.Dom.src = src;
}
getSrc(){
return this.Dom.src;
}
}
class CHE_Media extends CHE_Widget{
constructor(style) {
super(style);
if(this.style.hasOwnProperty("child")){
this.style.child = [];
}
if(this.style.type === "audio"){
this.Dom = document.createElement("audio")
}
if(this.style.type === "video"){
this.Dom = document.createElement("video")
}
this.ChildDom = this.Dom;
this.setStyle();
return this.Dom;
}
setStyle() {
super.setStyle();
if(this.style.hasOwnProperty("src")){
this.Dom.src = this.style.src;
}
if(this.style.hasOwnProperty("autoplay")){
this.Dom.autoplay = this.style.autoplay;
}
if(this.style.hasOwnProperty("controls")){
if(this.style.controls){
this.Dom.controls = "controls";
}
}
if(this.style.hasOwnProperty("muted")){
if(this.style.muted){
this.Dom.muted = "muted";
}
}
if(this.style.hasOwnProperty("preload")){
if(this.style.preload){
this.Dom.preload = "preload";
}
}
if(this.style.hasOwnProperty("loop")){
if(this.style.loop){
this.Dom.loop = "loop";
}
}
}
getDom(){
return this.Dom;
}
}
JavaScript
1
https://gitee.com/andyxiaqi/cherry-js.git
git@gitee.com:andyxiaqi/cherry-js.git
andyxiaqi
cherry-js
CherryJs
master

搜索帮助