move buttons out of form

pull/1/head
ansuz 8 years ago
parent eb50177201
commit e5ff7020fb

@ -4,6 +4,7 @@
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title data-localization="poll_title">Zero Knowledge Date Picker</title>
<link rel="stylesheet" href="/customize/main.css" />
<script data-main="main" src="/bower_components/requirejs/require.js"></script>
<script> require.config({ waitSeconds: 60, }); </script>
<style>
@ -12,39 +13,49 @@
height: 100%;
margin: 0px;
padding: 0px;
maargin-top: 1.25em;
border: 0px;
}
.realtime {
border: 1px solid black;
display: block;
overflow: auto;
margin: auto;
max-height: 100%;
max-width: 100%;
}
.realtime input[type="text"] {
width: 5em;
height: 1em;
margin: 0px;
}
.text-cell input[type="text"] {
width: 400px;
}
table, table * {
border: 1px solid red;
padding: 15px;
/*input#title, textarea { wiidth: 50px; }*/
input[type="text"][disabled], textarea[disabled] {
background-color: transparent;
font: white;
border: 0px;
}
table thead tr td {
boorder-bottom: 5px solid black;
td label {
border: .5px solid black;
}
</style>
</head>
<body>
<div class="realtime">
<button id="create-user">create user</button>
<button id="create-option">create option</button>
</div>
<button id="create-option">create option</button>
<button id="create-user">create user</button>
<button id="publish" style="display: none;">publish poll</button>
<form class="realtime">
<br />
<input type="text" id="title"><br />
<textarea rows=5 cols=50></textarea><br />
</form>

@ -21,6 +21,7 @@ define([
//$bar: $('#toolbar').css({ border: '1px solid white', background: 'grey', 'margin-bottom': '1vh', }),
};
/* Any time the realtime object changes, call this function */
var change = function (o, n, path) {
if (path && path.join) {
console.log("Change from [%s] to [%s] at [%s]",
@ -45,6 +46,7 @@ define([
return input.getAttribute && input.getAttribute('data-rt-id');
};
/* Called whenever an event is fired on an input element */
var handleInput = function (input) {
var type = input.type.toLowerCase();
var id = getRealtimeId(input);
@ -64,6 +66,7 @@ define([
}
};
/* Called whenever an event is fired on a span */
var handleSpan = function (span) {
var id = span.getAttribute('data-rt-id');
var type = Render.typeofId(id);
@ -75,6 +78,10 @@ define([
Render.removeColumn(APP.proxy, id, function () {
change();
});
} else if (type === 'cell') {
change();
} else {
console.log("UNHANDLED");
}
};
@ -91,6 +98,7 @@ define([
handleInput(target);
break;
case 'SPAN':
case 'LABEL':
handleSpan(target);
break;
case undefined:
@ -102,6 +110,9 @@ define([
}
};
/*
Make sure that the realtime data structure has all the required fields
*/
var prepareProxy = function (proxy, schema) {
if (proxy && proxy.version === 1) { return; }
console.log("Configuring proxy schema...");
@ -111,8 +122,22 @@ define([
proxy.version = 1;
};
var ready = function (info) {
/*
*/
var publish = APP.publish = function (bool) {
if (!APP.ready || APP.proxy.published) { return; }
APP.proxy.published = true;
APP.$publish.hide();
['textarea', '#title'].forEach(function (sel) {
$(sel).attr('disabled', bool);
});
};
var ready = function (info, userid) {
console.log("READY");
console.log('userid: %s', userid);
var proxy = APP.proxy;
@ -141,6 +166,14 @@ define([
.on('change', [], change)
.on('remove', [], change);
if (!proxy.published) {
var $publish = APP.$publish = $('#publish')
.show()
.click(function () {
publish(true);
});
}
APP.ready = true;
};
@ -180,7 +213,15 @@ define([
APP.proxy = rt.proxy;
rt.proxy
.on('create', create)
.on('ready', ready)
.on('ready', function (info) {
Cryptpad.getPadAttribute('userid', function (e, userid) {
if (e) { console.error(e); }
if (userid === null) { userid = Render.coluid(); }
Cryptpad.setPadAttribute('userid', userid, function (e) {
ready(info, userid);
});
});
})
.on('disconnect', disconnect);
});
});

@ -222,7 +222,10 @@ by maintaining indexes in rowsOrder and colsOrder
};
var makeRemoveElement = Render.makeRemoveElement = function (id) {
return ['SPAN', { 'data-rt-id': id, }, ['x']];
return ['SPAN', {
'data-rt-id': id,
class: 'remove',
}, ['✖']];
};
var makeHeadingCell = Render.makeHeadingCell = function (cell) {
@ -236,16 +239,45 @@ by maintaining indexes in rowsOrder and colsOrder
return ['TD', cell, []];
};
var clone = function (o) {
return JSON.parse(JSON.stringify(o));
};
var makeCheckbox = Render.makeCheckbox = function (cell) {
var attrs = clone(cell);
// FIXME
attrs.id = cell['data-rt-id'];
var labelClass = 'cover';
if (cell.checked) {
labelClass += ' yes';
}
return ['TD', {class:"checkbox-cell"}, [
['DIV', {class: 'checkbox-contain'}, [
['INPUT', attrs, []],
['SPAN', {class: labelClass}, []],
['LABEL', {
for: attrs.id,
'data-rt-id': attrs.id,
}, []]
]]
]];
};
var makeBodyCell = Render.makeBodyCell = function (cell) {
if (cell.type === 'text') {
return ['TD', {}, [
['DIV', {class: 'text-cell'}, [
['INPUT', cell, []],
makeRemoveElement(cell['data-rt-id'])
]]
]];
}
if (cell.type === 'checkbox') {
return ['TD', {}, [ ['INPUT', cell, []] ]];
return makeCheckbox(cell);
}
return ['TD', cell, []];
};
@ -258,7 +290,7 @@ by maintaining indexes in rowsOrder and colsOrder
if (!matrix || !matrix.length) { return; }
var head = ['THEAD', {}, [ ['TR', {}, matrix[0].map(makeHeadingCell)] ]];
var body = ['TBODY', {}, matrix.slice(1).map(makeBodyRow)];
return ['TABLE', {}, [head, body]];
return ['TABLE', {id:'table'}, [head, body]];
};
var asHTML = Render.asHTML = function (obj) {
@ -278,12 +310,15 @@ by maintaining indexes in rowsOrder and colsOrder
var preserveCursor = Render.preserveCursor = function (info) {
if (['modifyValue', 'modifyAttribute'].indexOf(info.diff.action) !== -1) {
var element = info.node;
if (typeof(element.selectionStart) !== 'number') { return; }
var o = info.oldValue || '';
var n = info.newValue || '';
var op = TextPatcher.diff(o, n);
info.selection = ['selectionStart', 'selectionEnd'].map(function (attr) {
var before = info.node[attr];
var before = element[attr];
var after = TextPatcher.transformCursor(element[attr], op);
return after;
});
@ -291,10 +326,15 @@ by maintaining indexes in rowsOrder and colsOrder
};
var recoverCursor = Render.recoverCursor = function (info) {
try {
if (info.selection && info.node) {
info.node.selectionStart = info.selection[0];
info.node.selectionEnd = info.selection[1];
}
} catch (err) {
//console.log(info.node);
//console.error(err);
}
};
var diffOptions = {

Loading…
Cancel
Save