prepare new poll app for release

move old poll into poll/old
This commit is contained in:
ansuz 2017-01-04 15:48:50 +01:00
parent 6c4e070c82
commit 05a956879a
8 changed files with 78 additions and 20 deletions

View file

@ -167,7 +167,7 @@ define(function () {
out.poll_editUserTitle = "Edit the column"; out.poll_editUserTitle = "Edit the column";
out.poll_titleHint = "Title"; out.poll_titleHint = "Title";
out.poll_descriptionHint = "Description"; out.poll_descriptionHint = "Describe your poll, and use the 'publish' button when you're done. Anyone with the link can change the description, but this is discouraged.";
// File manager // File manager

View file

@ -16,6 +16,7 @@
padding: 0px; padding: 0px;
border: 0px; border: 0px;
} }
.cryptpad-toolbar h2 { .cryptpad-toolbar h2 {
font: normal normal normal 12px Arial, Helvetica, Tahoma, Verdana, Sans-Serif; font: normal normal normal 12px Arial, Helvetica, Tahoma, Verdana, Sans-Serif;
color: #000; color: #000;
@ -37,8 +38,6 @@
width: 400px; width: 400px;
} }
/*input#title, textarea { wiidth: 50px; }*/
input[type="text"][disabled], textarea[disabled] { input[type="text"][disabled], textarea[disabled] {
background-color: transparent; background-color: transparent;
font: white; font: white;
@ -64,6 +63,11 @@
#publish { #publish {
display: none; display: none;
} }
#publish, #admin {
margin-top: 15px;
margin-bottom: 15px;
}
#create-user { #create-user {
position: absolute; position: absolute;
display: inline-block; display: inline-block;
@ -78,15 +82,34 @@
#tableScroll { #tableScroll {
overflow-x: auto; margin-left: calc(30% - 50px + 29px); max-width: 70%; width: auto; display: inline-block; overflow-x: auto; margin-left: calc(30% - 50px + 29px); max-width: 70%; width: auto; display: inline-block;
} }
#description {
padding: 15px;
margin: auto;
min-width: 80%;
min-height: 5em;
font-size: 20px;
font-weight: bold;
}
#description[disabled] { #description[disabled] {
resize: none; resize: none;
color: #bbb;
border: 1px solid #444;
} }
#description {
padding: 5px;
}
#commit { #commit {
width: 100%; width: 100%;
} }
#howItWorks {
width: 80%;
margin: auto;
}
div.upper {
width: 80%;
margin: auto;
}
</style> </style>
</head> </head>
<body> <body>
@ -101,13 +124,16 @@
<p data-localization="poll_p_encryption"></p> <p data-localization="poll_p_encryption"></p>
</div> </div>
<button id="publish" data-localization-title="poll_publish_button" data-localization="poll_publish_button" style="display: none;">publish poll</button> <div class="upper">
<button id="admin" data-localization-title="poll_admin_button" data-localization="poll_admin_button" style="display: none;">admin</button> <button id="publish" data-localization-title="poll_publish_button" data-localization="poll_publish_button" style="display: none;">publish poll</button>
<button id="admin" data-localization-title="poll_admin_button" data-localization="poll_admin_button" style="display: none;">admin</button>
</div>
<div class="realtime"> <div class="realtime">
<br /> <br />
<center>
<textarea rows=5 cols=50 disabled="disabled" id="description"></textarea><br /> <textarea rows=5 cols=50 disabled="disabled" id="description"></textarea><br />
</center>
<div id="tableContainer"> <div id="tableContainer">
<div id="tableScroll"></div> <div id="tableScroll"></div>
<button data-localization-title="poll_create_user" id="create-user"><span class="fa fa-plus"></span></button> <button data-localization-title="poll_create_user" id="create-user"><span class="fa fa-plus"></span></button>

View file

@ -12,9 +12,11 @@ define([
'/common/notify.js', '/common/notify.js',
'/bower_components/file-saver/FileSaver.min.js', '/bower_components/file-saver/FileSaver.min.js',
'/bower_components/jquery/dist/jquery.min.js', '/bower_components/jquery/dist/jquery.min.js',
], function (Config, Messages, TextPatcher, Listmap, Crypto, Cryptpad, Hyperjson, Render, Toolbar) { ], function (Config, Messages, TextPatcher, Listmap, Crypto, Cryptpad, Hyperjson, Renderer, Toolbar) {
var $ = window.jQuery; var $ = window.jQuery;
var unlockHTML = '<i class="fa fa-unlock" aria-hidden="true"></i>';
var lockHTML = '<i class="fa fa-lock" aria-hidden="true"></i>';
var HIDE_INTRODUCTION_TEXT = "hide_poll_text"; var HIDE_INTRODUCTION_TEXT = "hide_poll_text";
var defaultName; var defaultName;
@ -26,6 +28,8 @@ define([
Cryptpad.errorLoadingScreen(Messages.websocketError); Cryptpad.errorLoadingScreen(Messages.websocketError);
}; };
var Render = Renderer(Cryptpad);
var APP = window.APP = { var APP = window.APP = {
Toolbar: Toolbar, Toolbar: Toolbar,
Hyperjson: Hyperjson, Hyperjson: Hyperjson,
@ -88,6 +92,7 @@ define([
$('input[data-rt-id^="' + id + '"]').attr('disabled', 'disabled'); $('input[data-rt-id^="' + id + '"]').attr('disabled', 'disabled');
}; };
var styleUncommittedColumn = function () { var styleUncommittedColumn = function () {
var id = APP.userid; var id = APP.userid;
@ -95,7 +100,7 @@ define([
$('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled'); $('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled');
$('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled'); $('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled');
$('[data-rt-id="' + id + '"] ~ .edit').css('visibility', 'hidden'); $('[data-rt-id="' + id + '"] ~ .edit').css('visibility', 'hidden');
$('.lock[data-rt-id="' + id + '"]').html('🔓'); $('.lock[data-rt-id="' + id + '"]').html(unlockHTML);
if (isOwnColumnCommitted()) { return; } if (isOwnColumnCommitted()) { return; }
$('[data-rt-id^="' + id + '"]').closest('td').addClass("uncommitted"); $('[data-rt-id^="' + id + '"]').closest('td').addClass("uncommitted");
@ -113,7 +118,7 @@ define([
$('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled'); $('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled');
$('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled'); $('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled');
$('span.edit[data-rt-id="' + id + '"]').css('visibility', 'hidden'); $('span.edit[data-rt-id="' + id + '"]').css('visibility', 'hidden');
$('.lock[data-rt-id="' + id + '"]').html('🔓'); $('.lock[data-rt-id="' + id + '"]').html(unlockHTML);
}); });
}; };
@ -153,6 +158,11 @@ define([
unlockElements(); unlockElements();
updateTableButtons(); updateTableButtons();
setTablePublished(APP.proxy.published); setTablePublished(APP.proxy.published);
/*
APP.proxy.table.rowsOrder.forEach(function (rowId) {
$('[data-rt-id="' + rowId +'"]').val(APP.proxy.table.rows[rowId] || '');
});*/
}; };
var unlockColumn = function (id, cb) { var unlockColumn = function (id, cb) {
@ -173,7 +183,7 @@ define([
}; };
/* Any time the realtime object changes, call this function */ /* Any time the realtime object changes, call this function */
var change = function (o, n, path) { var change = function (o, n, path, throttle) {
if (path && path.join) { if (path && path.join) {
console.log("Change from [%s] to [%s] at [%s]", console.log("Change from [%s] to [%s] at [%s]",
o, n, path.join(', ')); o, n, path.join(', '));
@ -197,6 +207,18 @@ define([
https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
*/ */
if (throttle) {
if (APP.throttled) { window.clearTimeout(APP.throttled); }
var displayedObj2 = mergeUncommitted(APP.proxy, APP.uncommitted);
Render.updateTable(table, displayedObj2, conf);
updateDisplayedTable();
APP.throttled = window.setTimeout(function () {
updateDisplayedTable();
}, throttle);
return;
}
window.setTimeout(function () { window.setTimeout(function () {
var displayedObj2 = mergeUncommitted(APP.proxy, APP.uncommitted); var displayedObj2 = mergeUncommitted(APP.proxy, APP.uncommitted);
Render.updateTable(table, displayedObj2, conf); Render.updateTable(table, displayedObj2, conf);
@ -227,7 +249,7 @@ define([
console.log("text[rt-id='%s'] [%s]", id, input.value); console.log("text[rt-id='%s'] [%s]", id, input.value);
if (!input.value) { return void console.log("Hit enter?"); } if (!input.value) { return void console.log("Hit enter?"); }
Render.setValue(object, id, input.value); Render.setValue(object, id, input.value);
change(); change(null, null, null, 50);
break; break;
case 'checkbox': case 'checkbox':
console.log("checkbox[tr-id='%s'] %s", id, input.checked); console.log("checkbox[tr-id='%s'] %s", id, input.checked);
@ -287,7 +309,7 @@ define([
if ($(e.target).is('[type="text"]')) { if ($(e.target).is('[type="text"]')) {
return; return;
} }
$('.lock[data-rt-id!="' + APP.userid + '"]').html('🔒 '); $('.lock[data-rt-id!="' + APP.userid + '"]').html(lockHTML);
var $cells = APP.$table.find('thead td:not(.uncommitted), tbody td'); var $cells = APP.$table.find('thead td:not(.uncommitted), tbody td');
$cells.find('[type="text"][data-rt-id!="' + APP.userid + '"]').attr('disabled', true); $cells.find('[type="text"][data-rt-id!="' + APP.userid + '"]').attr('disabled', true);
$('.edit[data-rt-id!="' + APP.userid + '"]').css('visibility', 'visible'); $('.edit[data-rt-id!="' + APP.userid + '"]').css('visibility', 'visible');
@ -469,9 +491,15 @@ define([
var $table = APP.$table = $(Render.asHTML(displayedObj, null, colsOrder, readOnly)); var $table = APP.$table = $(Render.asHTML(displayedObj, null, colsOrder, readOnly));
var $createRow = APP.$createRow = $('#create-option').click(function () { var $createRow = APP.$createRow = $('#create-option').click(function () {
console.error("BUTTON CLICKED! LOL"); //console.error("BUTTON CLICKED! LOL");
Render.createRow(proxy, function () { Render.createRow(proxy, function () {
change(); change();
var order = APP.proxy.table.rowsOrder;
var last = order[order.length - 1];
var $newest = $('[data-rt-id="' + last + '"]');
$newest.val('');
window.setTimeout(change);
}); });
}); });
@ -679,6 +707,7 @@ define([
validateKey: secret.keys.validateKey || undefined, validateKey: secret.keys.validateKey || undefined,
//readOnly: readOnly, //readOnly: readOnly,
crypto: Crypto.createEncryptor(secret.keys), crypto: Crypto.createEncryptor(secret.keys),
userName: 'poll',
}; };
// don't initialize until the store is ready. // don't initialize until the store is ready.

View file

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html class="cp">
<head> <head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/> <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

View file

@ -11,7 +11,6 @@ define([
'/common/notify.js', '/common/notify.js',
'/bower_components/file-saver/FileSaver.min.js', '/bower_components/file-saver/FileSaver.min.js',
'/bower_components/jquery/dist/jquery.min.js', '/bower_components/jquery/dist/jquery.min.js',
'/customize/pad.js'
], function (Config, Messages, Table, Wizard, TextPatcher, Listmap, Crypto, Cryptpad, Visible, Notify) { ], function (Config, Messages, Table, Wizard, TextPatcher, Listmap, Crypto, Cryptpad, Visible, Notify) {
var $ = window.jQuery; var $ = window.jQuery;
var saveAs = window.saveAs; var saveAs = window.saveAs;
@ -169,7 +168,7 @@ define([
items.forEach(function ($item) { items.forEach(function ($item) {
$item.attr('disabled', !bool); $item.attr('disabled', !bool);
}); });
if (!bool) { if (!bool) {
$('input[id^="y"]').each(function (i, e) { $('input[id^="y"]').each(function (i, e) {

View file

@ -268,7 +268,11 @@ var Renderer = function (Cryptpad) {
return ['SPAN', { return ['SPAN', {
'data-rt-id': id, 'data-rt-id': id,
class: 'lock', class: 'lock',
}, ['🔒']]; }, [['i', {
class: 'fa fa-lock',
'aria-hidden': true,
}, []]
]];
}; };
var makeHeadingCell = Render.makeHeadingCell = function (cell, readOnly) { var makeHeadingCell = Render.makeHeadingCell = function (cell, readOnly) {