checkboxSet
This commit is contained in:
parent
c4802bcac7
commit
a193addf91
@ -220,7 +220,7 @@ div.etableInputDiv {
|
|||||||
margin-top: -8px;
|
margin-top: -8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.etableInputDiv .cannotInOutCheckbox {
|
.etableInputDiv .checkboxSetMember {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|||||||
@ -8,7 +8,7 @@ editor_table_wrapper = function (editor) {
|
|||||||
// HTML模板
|
// HTML模板
|
||||||
|
|
||||||
editor_table.prototype.select = function (value, values) {
|
editor_table.prototype.select = function (value, values) {
|
||||||
let content = editor.table.option(value) +
|
var content = editor.table.option(value) +
|
||||||
values.map(function (v) {
|
values.map(function (v) {
|
||||||
return editor.table.option(v)
|
return editor.table.option(v)
|
||||||
}).join('')
|
}).join('')
|
||||||
@ -26,12 +26,24 @@ editor_table_wrapper = function (editor) {
|
|||||||
editor_table.prototype.textarea = function (value, indent) {
|
editor_table.prototype.textarea = function (value, indent) {
|
||||||
return /* html */`<textarea spellcheck='false'>${JSON.stringify(value, null, indent || 0)}</textarea>\n`
|
return /* html */`<textarea spellcheck='false'>${JSON.stringify(value, null, indent || 0)}</textarea>\n`
|
||||||
}
|
}
|
||||||
editor_table.prototype.cannotInOutCheckbox = function (value) {
|
editor_table.prototype.checkboxSet = function (value, keys, prefixStrings) {
|
||||||
if (!(value instanceof Array)) value = [];
|
if (!(value instanceof Array)) value = [];
|
||||||
return /* html */`上:<input type='checkbox' class='cannotInOutCheckbox' ${value.indexOf('up')>=0 ? 'checked ' : ''} />
|
keys=Array.from(keys)
|
||||||
下:<input type='checkbox' class='cannotInOutCheckbox' ${value.indexOf('down')>=0 ? 'checked ' : ''} /><br/>
|
prefixStrings=Array.from(prefixStrings)
|
||||||
左:<input type='checkbox' class='cannotInOutCheckbox' ${value.indexOf('left')>=0 ? 'checked ' : ''} />
|
for (var index = 0; index < value.length; index++) {
|
||||||
右:<input type='checkbox' class='cannotInOutCheckbox' ${value.indexOf('right')>=0 ? 'checked ' : ''} /><br/>`;
|
if (keys.indexOf(value[index])==-1) {
|
||||||
|
keys.push(value[index])
|
||||||
|
prefixStrings.push('<br>'+value[index]+': ')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var content=[]
|
||||||
|
for (var index = 0; index < keys.length; index++) {
|
||||||
|
content.push(editor.table.checkboxSetMember(value.indexOf(keys[index])!=-1,keys[index],prefixStrings[index]))
|
||||||
|
}
|
||||||
|
return /* html */`<div class='checkboxSet'>${content.join('')}</div>\n`;
|
||||||
|
}
|
||||||
|
editor_table.prototype.checkboxSetMember = function (value,key,prefixString) {
|
||||||
|
return /* html */`${prefixString}<input key='${key}' type='checkbox' class='checkboxSetMember' onchange='editor.table.checkboxSetMemberOnchange(this)' ${(value ? 'checked ' : '')}/>\n`;
|
||||||
}
|
}
|
||||||
editor_table.prototype.editGrid = function (showComment) {
|
editor_table.prototype.editGrid = function (showComment) {
|
||||||
var html = "";
|
var html = "";
|
||||||
@ -58,6 +70,25 @@ editor_table_wrapper = function (editor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* checkboxset中checkbox的onchange
|
||||||
|
*/
|
||||||
|
editor_table.prototype.checkboxSetMemberOnchange = function (onemember) {
|
||||||
|
var thisset=onemember.parentNode
|
||||||
|
var inputs=thisset.children
|
||||||
|
var value=[]
|
||||||
|
for (var i in inputs) {
|
||||||
|
if (inputs[i].nodeName == 'INPUT') {
|
||||||
|
if (inputs[i].checked) value.push(inputs[i].getAttribute('key'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
thiseval = value;
|
||||||
|
// if (value.length == 0) thiseval = null;
|
||||||
|
thisset.value=JSON.stringify(thiseval)
|
||||||
|
thisset.onchange()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// 表格生成的控制
|
// 表格生成的控制
|
||||||
|
|
||||||
@ -232,8 +263,8 @@ editor_table_wrapper = function (editor) {
|
|||||||
return editor.table.select(thiseval, cobj._select.values);
|
return editor.table.select(thiseval, cobj._select.values);
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
return editor.table.checkbox(thiseval);
|
return editor.table.checkbox(thiseval);
|
||||||
case 'cannotInOutCheckbox':
|
case 'checkboxSet':
|
||||||
return editor.table.cannotInOutCheckbox(thiseval);
|
return editor.table.checkboxSet(thiseval, cobj._checkboxSet.key, cobj._checkboxSet.prefix);
|
||||||
default:
|
default:
|
||||||
return editor.table.textarea(thiseval, cobj.indent || 0);
|
return editor.table.textarea(thiseval, cobj.indent || 0);
|
||||||
}
|
}
|
||||||
@ -269,24 +300,15 @@ editor_table_wrapper = function (editor) {
|
|||||||
// >td[title=comment,cobj=cobj:json]
|
// >td[title=comment,cobj=cobj:json]
|
||||||
// >td>div>input[value=thiseval]
|
// >td>div>input[value=thiseval]
|
||||||
var thisTr = document.getElementById(guid);
|
var thisTr = document.getElementById(guid);
|
||||||
var inputs = thisTr.children[2].children[0].children;
|
var input = thisTr.children[2].children[0].children[0];
|
||||||
var field = thisTr.children[0].getAttribute('title');
|
var field = thisTr.children[0].getAttribute('title');
|
||||||
var cobj = JSON.parse(thisTr.children[1].getAttribute('cobj'));
|
var cobj = JSON.parse(thisTr.children[1].getAttribute('cobj'));
|
||||||
var modeNode = thisTr.parentNode;
|
var modeNode = thisTr.parentNode;
|
||||||
while (!editor_mode._ids.hasOwnProperty(modeNode.getAttribute('id'))) {
|
while (!editor_mode._ids.hasOwnProperty(modeNode.getAttribute('id'))) {
|
||||||
modeNode = modeNode.parentNode;
|
modeNode = modeNode.parentNode;
|
||||||
}
|
}
|
||||||
for (var i = 0; i < inputs.length; ++i) {
|
input.onchange = function () {
|
||||||
var input = inputs[i];
|
editor.table.onchange(guid, obj, commentObj, thisTr, input, field, cobj, modeNode)
|
||||||
if (input.nodeName == 'INPUT' || input.nodeName == 'SELECT' || input.nodeName == 'TEXTAREA') {
|
|
||||||
input.onchange = function () {
|
|
||||||
if (cobj._type == 'cannotInOutCheckbox') {
|
|
||||||
editor.table.onCannotInOutChange(guid, obj, commentObj, thisTr, inputs, field, cobj, modeNode);
|
|
||||||
} else {
|
|
||||||
editor.table.onchange(guid, obj, commentObj, thisTr, input, field, cobj, modeNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 用检测两次单击的方式来实现双击(以支持手机端的双击)
|
// 用检测两次单击的方式来实现双击(以支持手机端的双击)
|
||||||
var doubleClickCheck = [0];
|
var doubleClickCheck = [0];
|
||||||
|
|||||||
@ -262,12 +262,20 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
|||||||
},
|
},
|
||||||
"cannotOut": {
|
"cannotOut": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
"_type": "cannotInOutCheckbox",
|
"_type": "checkboxSet",
|
||||||
|
"_checkboxSet": {
|
||||||
|
"prefix":["上: ","下: ","<br>左: ","右: "],
|
||||||
|
"key":["up","down","left","right"]
|
||||||
|
},
|
||||||
"_data": "该图块的不可出方向\n可以在这里定义在该图块时不能前往哪个方向,可以达到悬崖之类的效果\n例如 [\"up\", \"left\"] 代表在该图块时不能往上和左走\n此值对背景层、事件层、前景层上的图块均有效"
|
"_data": "该图块的不可出方向\n可以在这里定义在该图块时不能前往哪个方向,可以达到悬崖之类的效果\n例如 [\"up\", \"left\"] 代表在该图块时不能往上和左走\n此值对背景层、事件层、前景层上的图块均有效"
|
||||||
},
|
},
|
||||||
"cannotIn": {
|
"cannotIn": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
"_type": "cannotInOutCheckbox",
|
"_type": "checkboxSet",
|
||||||
|
"_checkboxSet": {
|
||||||
|
"prefix":["上: ","下: ","<br>左: ","右: "],
|
||||||
|
"key":["up","down","left","right"]
|
||||||
|
},
|
||||||
"_data": "该图块的不可入方向\n可以在这里定义不能朝哪个方向进入该图块,可以达到悬崖之类的效果\n例如 [\"down\"] 代表不能从该图块的上方点朝向下进入此图块\n此值对背景层、事件层、前景层上的图块均有效"
|
"_data": "该图块的不可入方向\n可以在这里定义不能朝哪个方向进入该图块,可以达到悬崖之类的效果\n例如 [\"down\"] 代表不能从该图块的上方点朝向下进入此图块\n此值对背景层、事件层、前景层上的图块均有效"
|
||||||
},
|
},
|
||||||
"canBreak": {
|
"canBreak": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user