cleanup help

This commit is contained in:
Stewart Allen 2020-06-07 10:43:07 -04:00
commit 52eca70376
6 changed files with 171 additions and 115 deletions

View file

@ -1167,12 +1167,12 @@
extOffsetY: UC.newInput(LANG.dv_exoy_s, {title:LANG.dv_exoy_l, convert:UC.toFloat, modes:FDM, expert:true}),
extSelect: UC.newText(LANG.dv_exts_s, {title:LANG.dv_exts_l, modes:FDM, size:14, height:3, modes:FDM, expert:true, area:gcode}),
extrudeAbs: UC.newBoolean(LANG.dv_xtab_s, onBooleanClick, {title:LANG.dv_xtab_l, modes:FDM}),
extActions: UC.newTableRow([[
UI.extPrev = UC.newButton("<"),
UI.extAdd = UC.newButton("+"),
UI.extDel = UC.newButton("-"),
UI.extNext = UC.newButton(">")
]], {modes:FDM, expert:true}),
extActions: UC.newRow([
UI.extPrev = UC.newButton(undefined, undefined, {icon:'<i class="fas fa-less-than"></i>'}),
UI.extAdd = UC.newButton(undefined, undefined, {icon:'<i class="fas fa-plus"></i>'}),
UI.extDel = UC.newButton(undefined, undefined, {icon:'<i class="fas fa-minus"></i>'}),
UI.extNext = UC.newButton(undefined, undefined, {icon:'<i class="fas fa-greater-than"></i>'})
], {modes:FDM, expert:true, class:"ext-buttons"}),
gcode: UC.newGroup(LANG.dv_gr_gco, $('device'), {group:"dgco", inline:true, modes:GCODE}),
gcodeFan: UC.newInput(LANG.dv_fanp_s, {title:LANG.dv_fanp_l, modes:FDM, size:"40%", text:true}),

View file

@ -1807,14 +1807,13 @@
}
ajax(local, function(html) {
UI.help.innerHTML = html;
$('kiri-version').innerHTML = `<i>${LANG.version} ${KIRI.version}</i>`;
$('kiri-version').innerHTML = `${LANG.version} ${KIRI.version}`;
showModal('help');
});
API.event.emit('help.show', local);
}
function showLocal() {
// $('local-close').onclick = hideModal;
showModal('local');
fetch("/api/grid_local")
.then(r => r.json())
@ -1901,7 +1900,7 @@
}
function setExpert(bool) {
UC.setExpert(UI.expert.checked = control.expert = bool);
UC.setExpert(UI.expert.checked = bool);
}
function getMode() {

View file

@ -267,6 +267,7 @@
return div;
}
let lastTxt = null;
let lastPop = null;
let savePop = null;
@ -289,7 +290,6 @@
let opt = options || {},
row = newDiv(options),
btn = DOC.createElement("button"),
box = DOC.createElement("div"),
pop = DOC.createElement("div"),
txt = DOC.createElement("textarea"),
area = opt.area;
@ -298,7 +298,6 @@
txt.setAttribute("spellcheck", "false");
txt.setAttribute("style", "resize: none");
box.appendChild(pop);
btn.appendChild(DOC.createTextNode("edit"));
btn.onclick = function(ev) {
@ -311,7 +310,6 @@
if (fc) area.removeChild(fc);
area.appendChild(txt);
// first time, button click / show
btn.parentNode.appendChild(box);
btn.parentNode.onclick = btn.onclick;
txt.scrollTop = 0;
txt.scrollLeft = 0;
@ -327,9 +325,14 @@
let showing = pop === lastPop;
hidePop();
if (!showing) {
if (lastTxt) {
lastTxt.classList.remove('txt-sel');
}
row.classList.add('txt-sel');
savePop = inputAction;
pop.style.display = "flex";
lastPop = pop;
lastTxt = row;
txt.focus();
} else {
inputAction();
@ -510,24 +513,27 @@
}
function newButton(label, action, options) {
let b = DOC.createElement('button'),
t = DOC.createTextNode(label);
let opt = options || {},
b = DOC.createElement('button');
b.onclick = function() {
hidePoppers();
if (action) action();
};
if (options) {
if (options.class) b.classList.add(options.class);
if (options.icon) {
let d = DOC.createElement('div');
d.innerHTML = options.icon;
b.appendChild(d);
}
if (opt.class) {
opt.class.split(' ').forEach(ce => {
b.classList.add(ce);
});
}
if (opt.icon) {
let d = DOC.createElement('div');
d.innerHTML = opt.icon;
b.appendChild(d);
}
if (label) {
b.appendChild(DOC.createTextNode(label));
}
b.appendChild(t);
addModeControls(b, options);
addId(b, options);
@ -560,6 +566,11 @@
let row = addCollapsableElement((options && options.noadd) ? null : addTo);
if (children) children.forEach(function (c) { row.appendChild(c) });
addModeControls(row, options);
if (options && options.class) {
options.class.split(' ').forEach(ce => {
row.classList.add(ce);
});
}
return row;
}