updated by GasGit automation
This commit is contained in:
parent
9317041efb
commit
fe531809fd
1 changed files with 257 additions and 147 deletions
|
@ -19,7 +19,8 @@ function Elementer() {
|
||||||
classes: {
|
classes: {
|
||||||
branch: "",
|
branch: "",
|
||||||
nav: {
|
nav: {
|
||||||
prevIcon: ""
|
prevIcon: "",
|
||||||
|
showTitle:false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,43 +43,51 @@ function Elementer() {
|
||||||
tdLabel: "",
|
tdLabel: "",
|
||||||
icon: "mui--text-dark-secondary material-icons",
|
icon: "mui--text-dark-secondary material-icons",
|
||||||
tdIcon: "mui--align-middle",
|
tdIcon: "mui--align-middle",
|
||||||
|
tdNextIcon:"mui--align-middle mui--text-right",
|
||||||
option:"",
|
option:"",
|
||||||
nav: {
|
nav: {
|
||||||
nextIcon: "chevron_right",
|
nextIcon: "chevron_right",
|
||||||
prevIcon: "chevron_left"
|
prevIcon: "", // chevron_left to enable back at top of page.
|
||||||
|
showTitle:true
|
||||||
},
|
},
|
||||||
hide: "mui--hide",
|
hide: "mui--hide",
|
||||||
show: "mui--show"
|
show: "mui--show"
|
||||||
};
|
};
|
||||||
|
|
||||||
var defStyles_ = {
|
var defStyles_ = {
|
||||||
td: "padding:3px",
|
td: "padding:3px;",
|
||||||
tdLabel: "padding:3px",
|
tdLabel: "padding:3px;",
|
||||||
tdIcon: "padding:3px;max-width:30px;",
|
tdIcon: "padding:3px;max-width:32px;",
|
||||||
tdElement: "padding:3px",
|
tdElement: "padding:3px;",
|
||||||
backLabel:"position:relative;vertical-align: middle;",
|
backLabel:"position:relative;vertical-align: middle;",
|
||||||
icon:"vertical-align: middle;",
|
icon:"vertical-align: middle;",
|
||||||
elementContainer:"padding:0px;margin:0;",
|
elementContainer:"padding:0px;margin:0;",
|
||||||
navCursor:"cursor: pointer; cursor: hand;",
|
navCursor:"cursor: pointer; cursor: hand;",
|
||||||
backLabel:"cursor: pointer; cursor: hand;"
|
backLabel:"cursor: pointer; cursor: hand;",
|
||||||
|
tdNextIcon: "padding:3px;",
|
||||||
};
|
};
|
||||||
|
|
||||||
var defDetail_ = {
|
var defDetail_ = {
|
||||||
selectTemplate: {
|
selectTemplate: {
|
||||||
tag: "SELECT",
|
tag: "SELECT",
|
||||||
classes:{
|
classes:{
|
||||||
elementContainer:"mui-select"
|
elementContainer:""
|
||||||
},
|
},
|
||||||
values:{
|
values:{
|
||||||
property:"value",
|
property:"value",
|
||||||
resetable:true
|
resetable:true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
textAreaTemplate: {
|
textAreaTemplate: {
|
||||||
tag: "TEXTAREA",
|
tag: "TEXTAREA",
|
||||||
label:"Input text area",
|
label:"Input text area",
|
||||||
classes:{
|
classes:{
|
||||||
elementContainer:"mui-textfield"
|
elementContainer:"",
|
||||||
|
tdElement:"mui-text-left",
|
||||||
|
},
|
||||||
|
styles:{
|
||||||
|
element:"width:100%;"
|
||||||
},
|
},
|
||||||
values:{
|
values:{
|
||||||
property:"value",
|
property:"value",
|
||||||
|
@ -86,21 +95,66 @@ function Elementer() {
|
||||||
value:"",
|
value:"",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
buttonTemplate:{
|
buttonTemplate:{
|
||||||
tag:"BUTTON",
|
tag:"BUTTON",
|
||||||
label:"",
|
label:"",
|
||||||
classes:{
|
classes:{
|
||||||
element:"mui-btn"
|
element:"",
|
||||||
|
tdElement:"button-item",
|
||||||
|
tr:"button-place",
|
||||||
|
cancel:""
|
||||||
},
|
},
|
||||||
properties:{
|
properties:{
|
||||||
type:"button"
|
type:"button"
|
||||||
},
|
},
|
||||||
|
styles:{
|
||||||
|
tdElement:"padding-top:10px;"
|
||||||
|
},
|
||||||
values:{
|
values:{
|
||||||
property:"innerHTML",
|
property:"innerHTML",
|
||||||
value:"Submit",
|
value:"SUBMIT",
|
||||||
resetable:false
|
resetable:false
|
||||||
|
},
|
||||||
|
custom:{
|
||||||
|
cancelButton:true,
|
||||||
|
cancelText:"BACK",
|
||||||
|
outside:true,
|
||||||
|
backListener:true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
resetButtonTemplate:{
|
||||||
|
tag:"BUTTON",
|
||||||
|
label:"",
|
||||||
|
classes:{
|
||||||
|
element:"action ",
|
||||||
|
tdElement:"button-item",
|
||||||
|
tr:"button-place",
|
||||||
|
cancel:""
|
||||||
|
},
|
||||||
|
properties:{
|
||||||
|
type:"button",
|
||||||
|
disabled:true
|
||||||
|
},
|
||||||
|
styles:{
|
||||||
|
tdElement:"padding-top:10px;"
|
||||||
|
},
|
||||||
|
values:{
|
||||||
|
property:"innerHTML",
|
||||||
|
value:"APPLY",
|
||||||
|
resetable:false
|
||||||
|
},
|
||||||
|
custom:{
|
||||||
|
cancelButton:true,
|
||||||
|
cancelText:"BACK",
|
||||||
|
outside:true,
|
||||||
|
backListener:true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
textTemplate: {
|
textTemplate: {
|
||||||
tag: "INPUT",
|
tag: "INPUT",
|
||||||
label: "Input text",
|
label: "Input text",
|
||||||
|
@ -109,10 +163,10 @@ function Elementer() {
|
||||||
type: "text"
|
type: "text"
|
||||||
},
|
},
|
||||||
styles: {
|
styles: {
|
||||||
element: "max-width:100px;"
|
element: "width:50px;"
|
||||||
},
|
},
|
||||||
classes:{
|
classes:{
|
||||||
elementContainer:"mui-textfield"
|
elementContainer:""
|
||||||
},
|
},
|
||||||
values: {
|
values: {
|
||||||
property:"value",
|
property:"value",
|
||||||
|
@ -129,8 +183,11 @@ function Elementer() {
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 100
|
max: 100
|
||||||
},
|
},
|
||||||
|
styles: {
|
||||||
|
element:"width:50px;"
|
||||||
|
},
|
||||||
classes:{
|
classes:{
|
||||||
elementContainer:"mui-textfield"
|
elementContainer:""
|
||||||
},
|
},
|
||||||
values: {
|
values: {
|
||||||
property:"value",
|
property:"value",
|
||||||
|
@ -144,7 +201,7 @@ function Elementer() {
|
||||||
type: "checkbox"
|
type: "checkbox"
|
||||||
},
|
},
|
||||||
classes:{
|
classes:{
|
||||||
elementContainer:"mui-checkbox"
|
elementContainer:""
|
||||||
},
|
},
|
||||||
values: {
|
values: {
|
||||||
property:"checked",
|
property:"checked",
|
||||||
|
@ -159,7 +216,7 @@ function Elementer() {
|
||||||
name: "radioGroup"
|
name: "radioGroup"
|
||||||
},
|
},
|
||||||
classes:{
|
classes:{
|
||||||
elementContainer:"mui-radio"
|
elementContainer:""
|
||||||
},
|
},
|
||||||
values: {
|
values: {
|
||||||
property:"checked",
|
property:"checked",
|
||||||
|
@ -177,6 +234,9 @@ function Elementer() {
|
||||||
label: "subhead",
|
label: "subhead",
|
||||||
classes: {
|
classes: {
|
||||||
label: "mui--text-accent"
|
label: "mui--text-accent"
|
||||||
|
},
|
||||||
|
styles: {
|
||||||
|
tdLabel:"padding:3px;padding-top:13px;"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
contentTemplate: {
|
contentTemplate: {
|
||||||
|
@ -354,9 +414,9 @@ function Elementer() {
|
||||||
|
|
||||||
// do the root
|
// do the root
|
||||||
doLayout(root_, layout_.settings.root, layout_, detail_);
|
doLayout(root_, layout_.settings.root, layout_, detail_);
|
||||||
|
|
||||||
// do the others
|
// do the others
|
||||||
Object.keys(layout_.pages).forEach(function(k) {
|
Object.keys(layout_.pages).forEach(function(k) {
|
||||||
|
|
||||||
if (k !== layout_.settings.root) {
|
if (k !== layout_.settings.root) {
|
||||||
doLayout(container_, k, layout_, detail_);
|
doLayout(container_, k, layout_, detail_);
|
||||||
}
|
}
|
||||||
|
@ -366,6 +426,7 @@ function Elementer() {
|
||||||
var rt = layout_.settings.root;
|
var rt = layout_.settings.root;
|
||||||
var onEnter = layout_.pages[rt].on ? layout_.pages[rt].on.enter : null;
|
var onEnter = layout_.pages[rt].on ? layout_.pages[rt].on.enter : null;
|
||||||
showThis(elements_.pages[rt], onEnter);
|
showThis(elements_.pages[rt], onEnter);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
function doLayout(parent, branchName, layout, details) {
|
function doLayout(parent, branchName, layout, details) {
|
||||||
|
@ -383,12 +444,8 @@ function Elementer() {
|
||||||
|
|
||||||
elements_.pages[branchName] = dv;
|
elements_.pages[branchName] = dv;
|
||||||
|
|
||||||
// prev icon - hide this and go back to whoever called
|
function backListener (elm) {
|
||||||
if (ec.nav.prevIcon) {
|
elm.addEventListener('click', function(e) {
|
||||||
var dvp = ea(dv, "div", "", ec.backLabel, es.backLabel);
|
|
||||||
var backIcon = ea(dvp, "span", ec.nav.prevIcon, ec.icon, es.icon);
|
|
||||||
ea(dvp, "span", "Back to ???", ec.backLabel, es.backLabel).id = layout.settings.prefix + "-" + branchName + "-backcomment";
|
|
||||||
dvp.addEventListener('click', function(e) {
|
|
||||||
|
|
||||||
// do exit processing
|
// do exit processing
|
||||||
var onExit = layout_.pages[branchName].on ? layout_.pages[branchName].on.exit : null;
|
var onExit = layout_.pages[branchName].on ? layout_.pages[branchName].on.exit : null;
|
||||||
|
@ -401,15 +458,24 @@ function Elementer() {
|
||||||
var onEnter = layout_.pages[elb.branchName].on ? layout_.pages[elb.branchName].on.enter : null;
|
var onEnter = layout_.pages[elb.branchName].on ? layout_.pages[elb.branchName].on.enter : null;
|
||||||
showThis(elb.element, onEnter);
|
showThis(elb.element, onEnter);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prev icon - hide this and go back to whoever called
|
||||||
|
if (ec.nav.prevIcon) {
|
||||||
|
|
||||||
|
var dvp = ea(dv, "div", "", ec.backLabel, es.backLabel);
|
||||||
|
var backIcon = ea(dvp, "span", ec.nav.prevIcon, ec.icon, es.icon);
|
||||||
|
ea(dvp, "span", "Back to ???", ec.backLabel, es.backLabel).id = layout.settings.prefix + "-" + branchName + "-backcomment";
|
||||||
|
backListener (dvp);
|
||||||
|
|
||||||
|
}
|
||||||
// use a table to lay out
|
// use a table to lay out
|
||||||
var tab = ea(dv, "table", "", ec.table, es.table);
|
var tab = ea(dv, "table", "", ec.table, es.table);
|
||||||
// the section title
|
// the section title
|
||||||
var tr = ea(tab, "tr", "", ec.tr, es.tr);
|
var tr = ea(tab, "tr", "", ec.tr, es.tr);
|
||||||
|
|
||||||
if (ec.nav.prevIcon) {
|
if (ec.nav.showTitle) {
|
||||||
|
|
||||||
var td = ea(tr, "td", "", ec.td, es.td);
|
var td = ea(tr, "td", "", ec.td, es.td);
|
||||||
td.colSpan = 3;
|
td.colSpan = 3;
|
||||||
ea(td, "span", DomUtils.fillLabel(lob.label), ec.title, es.title);
|
ea(td, "span", DomUtils.fillLabel(lob.label), ec.title, es.title);
|
||||||
|
@ -418,6 +484,7 @@ function Elementer() {
|
||||||
lob.items.forEach(function(d) {
|
lob.items.forEach(function(d) {
|
||||||
if (layout.pages[d]) {
|
if (layout.pages[d]) {
|
||||||
// its a reference to another section
|
// its a reference to another section
|
||||||
|
|
||||||
var ob = layout.pages[d];
|
var ob = layout.pages[d];
|
||||||
// bring in any override classes
|
// bring in any override classes
|
||||||
var fc = Utils.vanMerge([ec, ob.classes]);
|
var fc = Utils.vanMerge([ec, ob.classes]);
|
||||||
|
@ -437,8 +504,7 @@ function Elementer() {
|
||||||
if (!ob.icon) {
|
if (!ob.icon) {
|
||||||
td.colSpan = 2;
|
td.colSpan = 2;
|
||||||
}
|
}
|
||||||
// the next icon
|
|
||||||
var td = ea(tr, "td", "", fc.tdIcon, fs.tdIcon);
|
|
||||||
|
|
||||||
function clickPointer (elem , itemName, brName ) {
|
function clickPointer (elem , itemName, brName ) {
|
||||||
elem.addEventListener ('click', function () {
|
elem.addEventListener ('click', function () {
|
||||||
|
@ -460,12 +526,17 @@ function Elementer() {
|
||||||
|
|
||||||
// add navigation to next level
|
// add navigation to next level
|
||||||
if (fc.nav.nextIcon) {
|
if (fc.nav.nextIcon) {
|
||||||
|
var td = ea(tr, "td", "", fc.tdNextIcon, fs.tdNextIcon);
|
||||||
|
td.colSpan = 2;
|
||||||
ea(td, "i", fc.nav.nextIcon, fc.icon, fs.icon);
|
ea(td, "i", fc.nav.nextIcon, fc.icon, fs.icon);
|
||||||
clickPointer (tr,d, branchName);
|
clickPointer (tr,d, branchName);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
var td = ea(tr, "td", "", fc.tdIcon, fs.tdIcon);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// it should be some real stuff
|
// it should be some real stuff
|
||||||
|
|
||||||
if (!details[d]) {
|
if (!details[d]) {
|
||||||
throw d + ' layout reference not found in details';
|
throw d + ' layout reference not found in details';
|
||||||
}
|
}
|
||||||
|
@ -476,70 +547,109 @@ function Elementer() {
|
||||||
|
|
||||||
var fc = Utils.vanMerge([ec, ob.classes]);
|
var fc = Utils.vanMerge([ec, ob.classes]);
|
||||||
var fs = Utils.vanMerge([es, ob.styles]);
|
var fs = Utils.vanMerge([es, ob.styles]);
|
||||||
var tr = ea(tab, "tr", "", fc.tr, fs.tr);
|
|
||||||
|
|
||||||
|
// could be after the table
|
||||||
// the label
|
if (ob.custom && ob.custom.outside) {
|
||||||
if (ob.custom && ob.custom.spanCols) {
|
var tr = ea(dv , "div", "", fc.tr, fs.tr);
|
||||||
|
// the element container
|
||||||
// this element spans all columns
|
var td = ea(tr, "div", "", fc.tdElement, fs.tdElement);
|
||||||
var td = ea(tr, "td", "", fc.tdElement, fs.tdElement);
|
|
||||||
td.colSpan = 3;
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
|
||||||
// the icon
|
else {
|
||||||
|
var tr = ea(tab, "tr", "", fc.tr, fs.tr);
|
||||||
|
var used = 0;
|
||||||
|
|
||||||
|
// the icon is the first column
|
||||||
if (ob.icon) {
|
if (ob.icon) {
|
||||||
var td = ea(tr, "td", "", fc.tdIcon, fs.tdIcon);
|
var td = ea(tr, "td", "", fc.tdIcon, fs.tdIcon);
|
||||||
ea(td, "i", ob.icon, fc.icon);
|
ea(td, "i", ob.icon, fc.icon);
|
||||||
|
used++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// now the label
|
||||||
|
var label = null;
|
||||||
|
if (ob.label) {
|
||||||
var td = ea(tr, "td", "", fc.tdLabel, fs.tdLabel);
|
var td = ea(tr, "td", "", fc.tdLabel, fs.tdLabel);
|
||||||
var label = ob.label ? ea(td, "label", DomUtils.fillLabel(ob.label), fc.label, fs.label) : null;
|
var label = ea(td, "label", DomUtils.fillLabel(ob.label), fc.label, fs.label) ;
|
||||||
if (!ob.icon) {
|
used++;
|
||||||
td.colSpan = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// the element
|
|
||||||
var td = ea(tr, "td", "", fc.tdElement, fs.tdElement);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the element.. if there's a tag we'll need a space for it
|
||||||
if (ob.tag) {
|
if (ob.tag) {
|
||||||
|
used++;
|
||||||
|
var td = ea(tr, "td", "", fc.tdElement, fs.tdElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// now create an element
|
||||||
|
var elemCancel = null,elem = null;
|
||||||
|
if (ob.tag) {
|
||||||
|
if (!(ob.custom && ob.custom.cancelOnly)) {
|
||||||
var ediv = ea(td, "span", "", fc.elementContainer, fs.elementContainer);
|
var ediv = ea(td, "span", "", fc.elementContainer, fs.elementContainer);
|
||||||
var elem = ea(ediv, ob.tag, "", fc.element, fs.element);
|
var elem = ea(ediv, ob.tag, "", fc.element, fs.element);
|
||||||
elem.id = dv.id + "-" + d + "-elem";
|
elem.id = dv.id + "-" + d + "-elem";
|
||||||
if (label) label['for'] = elem.id;
|
if (label) label['for'] = elem.id;
|
||||||
|
}
|
||||||
|
// there may be a cancel button needed
|
||||||
|
if (ob.custom && ob.custom.cancelButton) {
|
||||||
|
var ediv = ea (tr, "span", "", fc.elementContainer , fs.elementContainer);
|
||||||
|
var elemCancel = ea (ediv , ob.tag , "", fc.cancel , fs.cancel );
|
||||||
|
elemCancel.id = dv.id + "-" + d + "-elem" + "-cancel";
|
||||||
|
if (ob.custom && ob.custom.backListener) {
|
||||||
|
backListener (elemCancel);
|
||||||
|
}
|
||||||
|
}
|
||||||
// this should only apply to selects
|
// this should only apply to selects
|
||||||
// but i'll leave it unchecked and just do it anyway
|
// but i'll leave it unchecked and just do it anyway
|
||||||
if (ob.options){
|
if (ob.options && elem){
|
||||||
ob.options.forEach(function(g){
|
ob.options.forEach(function(g){
|
||||||
ea (elem,"option",g,fc.option,fs.option).value = g;
|
ea (elem,"option",g,fc.option,fs.option).value = g;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (ob.properties) {
|
|
||||||
|
|
||||||
|
if (ob.properties && elem) {
|
||||||
Object.keys(ob.properties).forEach(function(e) {
|
Object.keys(ob.properties).forEach(function(e) {
|
||||||
|
// now its possible that the propertty doesnt exist for every browser
|
||||||
|
// for example input type="color" will throw exceptin
|
||||||
|
// when running on excel 2016 sidebar so just pass on error with a console.log
|
||||||
|
try {
|
||||||
elem[e] = ob.properties[e];
|
elem[e] = ob.properties[e];
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err + ':continuing and ignoring');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ob.values && ob.values.property) {
|
if (elemCancel){
|
||||||
|
elemCancel.innerHTML = ob.custom && ob.custom.cancelText ? ob.custom.cancelText : "Cancel";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elem && ob.values && ob.values.property) {
|
||||||
elem[ob.values.property] = ob.values.value;
|
elem[ob.values.property] = ob.values.value;
|
||||||
elements_.values[d] = ob.values;
|
elements_.values[d] = ob.values;
|
||||||
if(ob.values.resetable) {
|
if(ob.values.resetable) {
|
||||||
initial_[d] = ob.values.value;
|
initial_[d] = ob.values.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now apply any onchange/ click etc.
|
// now apply any onchange/ click etc.
|
||||||
if (ob.on) {
|
if (ob.on && elem) {
|
||||||
Object.keys (ob.on).forEach(function (o) {
|
Object.keys (ob.on).forEach(function (o) {
|
||||||
elem.addEventListener (o , function (e) {
|
elem.addEventListener (o , function (e) {
|
||||||
ob.on[o] (self , branchName , ob , e);
|
ob.on[o] (self , branchName , ob , e);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
elements_.controls[d] = elem;
|
|
||||||
|
if (!(ob.custom && ob.custom.outside)) {
|
||||||
|
// swallow up the rest
|
||||||
|
if (td)td.colSpan = 5 - used ;
|
||||||
|
}
|
||||||
|
elements_.controls[d] = elem || elemCancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue