From 05a956879a7764d94a4115b72e7207df0b37a3e0 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 4 Jan 2017 15:48:50 +0100 Subject: [PATCH] prepare new poll app for release move old poll into poll/old --- customize.dist/translations/messages.js | 2 +- www/poll/index.html | 42 +++++++++++++++++++----- www/poll/main.js | 43 +++++++++++++++++++++---- www/{Poll => poll/old}/index.html | 2 +- www/{Poll => poll/old}/main.js | 3 +- www/{Poll => poll/old}/table.js | 0 www/{Poll => poll/old}/wizard.js | 0 www/poll/render.js | 6 +++- 8 files changed, 78 insertions(+), 20 deletions(-) rename www/{Poll => poll/old}/index.html (99%) rename www/{Poll => poll/old}/main.js (99%) rename www/{Poll => poll/old}/table.js (100%) rename www/{Poll => poll/old}/wizard.js (100%) diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 6db002e7e..36c48315b 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -167,7 +167,7 @@ define(function () { out.poll_editUserTitle = "Edit the column"; 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 diff --git a/www/poll/index.html b/www/poll/index.html index 9a95b071d..17f951997 100644 --- a/www/poll/index.html +++ b/www/poll/index.html @@ -16,6 +16,7 @@ padding: 0px; border: 0px; } + .cryptpad-toolbar h2 { font: normal normal normal 12px Arial, Helvetica, Tahoma, Verdana, Sans-Serif; color: #000; @@ -37,8 +38,6 @@ width: 400px; } - /*input#title, textarea { wiidth: 50px; }*/ - input[type="text"][disabled], textarea[disabled] { background-color: transparent; font: white; @@ -64,6 +63,11 @@ #publish { display: none; } + + #publish, #admin { + margin-top: 15px; + margin-bottom: 15px; + } #create-user { position: absolute; display: inline-block; @@ -78,15 +82,34 @@ #tableScroll { 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] { resize: none; + color: #bbb; + border: 1px solid #444; } - #description { - padding: 5px; - } + #commit { width: 100%; } + #howItWorks { + width: 80%; + margin: auto; + } + div.upper { + width: 80%; + margin: auto; + } + @@ -101,13 +124,16 @@

- - - +
+ + +

+

+
diff --git a/www/poll/main.js b/www/poll/main.js index a4d976901..e689d33a4 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -12,9 +12,11 @@ define([ '/common/notify.js', '/bower_components/file-saver/FileSaver.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 unlockHTML = ''; + var lockHTML = ''; var HIDE_INTRODUCTION_TEXT = "hide_poll_text"; var defaultName; @@ -26,6 +28,8 @@ define([ Cryptpad.errorLoadingScreen(Messages.websocketError); }; + var Render = Renderer(Cryptpad); + var APP = window.APP = { Toolbar: Toolbar, Hyperjson: Hyperjson, @@ -88,6 +92,7 @@ define([ $('input[data-rt-id^="' + id + '"]').attr('disabled', 'disabled'); }; + var styleUncommittedColumn = function () { var id = APP.userid; @@ -95,7 +100,7 @@ define([ $('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled'); $('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled'); $('[data-rt-id="' + id + '"] ~ .edit').css('visibility', 'hidden'); - $('.lock[data-rt-id="' + id + '"]').html('🔓'); + $('.lock[data-rt-id="' + id + '"]').html(unlockHTML); if (isOwnColumnCommitted()) { return; } $('[data-rt-id^="' + id + '"]').closest('td').addClass("uncommitted"); @@ -113,7 +118,7 @@ define([ $('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled'); $('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled'); $('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(); updateTableButtons(); 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) { @@ -173,7 +183,7 @@ define([ }; /* 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) { console.log("Change from [%s] to [%s] at [%s]", 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 */ + + 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 () { var displayedObj2 = mergeUncommitted(APP.proxy, APP.uncommitted); Render.updateTable(table, displayedObj2, conf); @@ -227,7 +249,7 @@ define([ console.log("text[rt-id='%s'] [%s]", id, input.value); if (!input.value) { return void console.log("Hit enter?"); } Render.setValue(object, id, input.value); - change(); + change(null, null, null, 50); break; case 'checkbox': console.log("checkbox[tr-id='%s'] %s", id, input.checked); @@ -287,7 +309,7 @@ define([ if ($(e.target).is('[type="text"]')) { 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'); $cells.find('[type="text"][data-rt-id!="' + APP.userid + '"]').attr('disabled', true); $('.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 $createRow = APP.$createRow = $('#create-option').click(function () { - console.error("BUTTON CLICKED! LOL"); + //console.error("BUTTON CLICKED! LOL"); Render.createRow(proxy, function () { 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, //readOnly: readOnly, crypto: Crypto.createEncryptor(secret.keys), + userName: 'poll', }; // don't initialize until the store is ready. diff --git a/www/Poll/index.html b/www/poll/old/index.html similarity index 99% rename from www/Poll/index.html rename to www/poll/old/index.html index 10dd07fc4..01b6f6b76 100644 --- a/www/Poll/index.html +++ b/www/poll/old/index.html @@ -1,5 +1,5 @@ - + diff --git a/www/Poll/main.js b/www/poll/old/main.js similarity index 99% rename from www/Poll/main.js rename to www/poll/old/main.js index 7417ad10b..a702028bd 100644 --- a/www/Poll/main.js +++ b/www/poll/old/main.js @@ -11,7 +11,6 @@ define([ '/common/notify.js', '/bower_components/file-saver/FileSaver.min.js', '/bower_components/jquery/dist/jquery.min.js', - '/customize/pad.js' ], function (Config, Messages, Table, Wizard, TextPatcher, Listmap, Crypto, Cryptpad, Visible, Notify) { var $ = window.jQuery; var saveAs = window.saveAs; @@ -169,7 +168,7 @@ define([ items.forEach(function ($item) { $item.attr('disabled', !bool); - }); + }); if (!bool) { $('input[id^="y"]').each(function (i, e) { diff --git a/www/Poll/table.js b/www/poll/old/table.js similarity index 100% rename from www/Poll/table.js rename to www/poll/old/table.js diff --git a/www/Poll/wizard.js b/www/poll/old/wizard.js similarity index 100% rename from www/Poll/wizard.js rename to www/poll/old/wizard.js diff --git a/www/poll/render.js b/www/poll/render.js index d70cd2067..ce2f67518 100644 --- a/www/poll/render.js +++ b/www/poll/render.js @@ -268,7 +268,11 @@ var Renderer = function (Cryptpad) { return ['SPAN', { 'data-rt-id': id, class: 'lock', - }, ['🔒']]; + }, [['i', { + class: 'fa fa-lock', + 'aria-hidden': true, + }, []] + ]]; }; var makeHeadingCell = Render.makeHeadingCell = function (cell, readOnly) {