Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging

pull/1/head
yflory 8 years ago
commit 2032c08066

@ -452,6 +452,9 @@ define(function () {
out.poll_locked = "Cerrado"; out.poll_locked = "Cerrado";
out.poll_unlocked = "Abierto"; out.poll_unlocked = "Abierto";
out.poll_show_help_button = "Mostrar ayuda";
out.poll_hide_help_button = "Esconder ayuda";
// 1.8.0 - Idopogo // 1.8.0 - Idopogo
out.common_connectionLost = "<b>Connexión perdida</b><br>El documento está ahora en modo solo lectura hasta que la conexión vuelva."; out.common_connectionLost = "<b>Connexión perdida</b><br>El documento está ahora en modo solo lectura hasta que la conexión vuelva.";

@ -207,6 +207,9 @@ define(function () {
out.poll_locked = "Verrouillé"; out.poll_locked = "Verrouillé";
out.poll_unlocked = "Déverrouillé"; out.poll_unlocked = "Déverrouillé";
out.poll_show_help_button = "Afficher l'aide";
out.poll_hide_help_button = "Cacher l'aide";
// Canvas // Canvas
out.canvas_clear = "Nettoyer"; out.canvas_clear = "Nettoyer";
out.canvas_delete = "Supprimer la sélection"; out.canvas_delete = "Supprimer la sélection";
@ -214,6 +217,8 @@ define(function () {
out.canvas_enable = "Activer le dessin"; out.canvas_enable = "Activer le dessin";
out.canvas_width = "Épaisseur"; out.canvas_width = "Épaisseur";
out.canvas_opacity = "Opacité"; out.canvas_opacity = "Opacité";
out.canvas_opacityLabel = "opacité: {0}";
out.canvas_widthLabel = "taille: {0}";
// File manager // File manager

@ -209,6 +209,9 @@ define(function () {
out.poll_locked = "Locked"; out.poll_locked = "Locked";
out.poll_unlocked = "Unlocked"; out.poll_unlocked = "Unlocked";
out.poll_show_help_button = "Show help";
out.poll_hide_help_button = "Hide help";
// Canvas // Canvas
out.canvas_clear = "Clear"; out.canvas_clear = "Clear";
out.canvas_delete = "Delete selection"; out.canvas_delete = "Delete selection";
@ -216,6 +219,9 @@ define(function () {
out.canvas_enable = "Enable draw"; out.canvas_enable = "Enable draw";
out.canvas_width = "Width"; out.canvas_width = "Width";
out.canvas_opacity = "Opacity"; out.canvas_opacity = "Opacity";
out.canvas_opacityLabel = "opacity: {0}";
out.canvas_widthLabel = "Width: {0}";
// File manager // File manager

@ -336,8 +336,13 @@ var getMultipleFileSize = function (Env, channels, cb) {
channels.forEach(function (channel) { channels.forEach(function (channel) {
getFileSize(Env, channel, function (e, size) { getFileSize(Env, channel, function (e, size) {
if (e) { if (e) {
WARN('getFileSize', e); // most likely error here is that a file no longer exists
counts[channel] = -1; // but a user still has it in their drive, and wants to know
// its size. We should find a way to inform them of this in
// the future. For now we can just tell them it has no size.
//WARN('getFileSize', e);
counts[channel] = 0;
return done(); return done();
} }
counts[channel] = size; counts[channel] = size;

@ -20,16 +20,25 @@ define([], function () {
}; };
} }
if (!localStorage || typeof(localStorage.getItem) !== 'function') { var failStore = function () {
require('jquery', function ($) { console.error(new Error('wut'));
require(['jquery'], function ($) {
$.ajax({ $.ajax({
type: 'HEAD', type: 'HEAD',
url: '/common/feedback.html?NO_LOCALSTORAGE=' + (+new Date()), url: '/common/feedback.html?NO_LOCALSTORAGE=' + (+new Date()),
}); });
}); });
window.alert("CryptPad needs localStorage to work, try a different browser"); window.alert("CryptPad needs localStorage to work, try a different browser");
return; };
}
try {
var test_key = 'localStorage_test';
var testval = Math.random().toString();
localStorage.setItem(test_key, testval);
if (localStorage.getItem(test_key) !== testval) {
failStore();
}
} catch (e) { console.error(e); failStore(); }
require([document.querySelector('script[data-bootload]').getAttribute('data-bootload')]); require([document.querySelector('script[data-bootload]').getAttribute('data-bootload')]);
}); });

File diff suppressed because one or more lines are too long

@ -29,6 +29,7 @@
<div class="upper"> <div class="upper">
<button id="publish" data-localization-title="poll_publish_button" data-localization="poll_publish_button" style="display: none;">publish poll</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> <button id="admin" data-localization-title="poll_admin_button" data-localization="poll_admin_button" style="display: none;">admin</button>
<button id="help" data-localization-title="poll_show_help_button" data-localization="poll_show_help_button">help</button>
</div> </div>
<div class="realtime"> <div class="realtime">

@ -46,7 +46,8 @@ define([
editable: { editable: {
row: [], row: [],
col: [] col: []
} },
locked: false
}; };
var sortColumns = function (order, firstcol) { var sortColumns = function (order, firstcol) {
@ -97,7 +98,7 @@ define([
// Enable the checkboxes for the user's column (committed or not) // Enable the checkboxes for the user's column (committed or not)
$('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="number"][data-rt-id^="' + id + '"]').addClass('enabled');
$('.lock[data-rt-id="' + id + '"]').addClass('fa-unlock').removeClass('fa-lock').attr('title', Messages.poll_unlocked); $('.lock[data-rt-id="' + id + '"]').addClass('fa-unlock').removeClass('fa-lock').attr('title', Messages.poll_unlocked);
if (isOwnColumnCommitted()) { return; } if (isOwnColumnCommitted()) { return; }
@ -108,12 +109,14 @@ define([
var unlockElements = function () { var unlockElements = function () {
APP.editable.row.forEach(function (id) { APP.editable.row.forEach(function (id) {
$('input[type="text"][disabled="disabled"][data-rt-id="' + id + '"]').removeAttr('disabled'); var $input = $('input[type="text"][disabled="disabled"][data-rt-id="' + id + '"]').removeAttr('disabled');
$input.parent().parent().addClass('editing');
$('span.edit[data-rt-id="' + id + '"]').css('visibility', 'hidden'); $('span.edit[data-rt-id="' + id + '"]').css('visibility', 'hidden');
}); });
APP.editable.col.forEach(function (id) { APP.editable.col.forEach(function (id) {
$('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled'); var $input = $('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled');
$('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled'); $input.parent().addClass('editing');
$('input[type="number"][data-rt-id^="' + id + '"]').addClass('enabled');
$('.lock[data-rt-id="' + id + '"]').addClass('fa-unlock').removeClass('fa-lock').attr('title', Messages.poll_unlocked); $('.lock[data-rt-id="' + id + '"]').addClass('fa-unlock').removeClass('fa-lock').attr('title', Messages.poll_unlocked);
}); });
}; };
@ -274,10 +277,17 @@ define([
Render.setValue(object, id, input.value); Render.setValue(object, id, input.value);
change(null, null, null, 50); change(null, null, null, 50);
break; break;
case 'checkbox': case 'number':
debug("checkbox[tr-id='%s'] %s", id, input.checked); debug("checkbox[tr-id='%s'] %s", id, input.value);
if (APP.editable.col.indexOf(x) >= 0 || x === APP.userid) { if (APP.editable.col.indexOf(x) >= 0 || x === APP.userid) {
Render.setValue(object, id, input.checked); var value = parseInt(input.value);
if (isNaN(value)) {
console.error("Got NaN?!");
break;
}
Render.setValue(object, id, value);
change(); change();
} else { } else {
debug('checkbox locked'); debug('checkbox locked');
@ -290,12 +300,14 @@ define([
}; };
var hideInputs = function (target, isKeyup) { var hideInputs = function (target, isKeyup) {
if (APP.locked) { return; }
if (!isKeyup && $(target).is('[type="text"]')) { if (!isKeyup && $(target).is('[type="text"]')) {
return; return;
} }
$('.lock[data-rt-id!="' + APP.userid + '"]').addClass('fa-lock').removeClass('fa-unlock').attr('title', Messages.poll_locked); $('.lock[data-rt-id!="' + APP.userid + '"]').addClass('fa-lock').removeClass('fa-unlock').attr('title', Messages.poll_locked);
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);
$cells.removeClass('editing');
$('.edit[data-rt-id!="' + APP.userid + '"]').css('visibility', 'visible'); $('.edit[data-rt-id!="' + APP.userid + '"]').css('visibility', 'visible');
APP.editable.col = [APP.userid]; APP.editable.col = [APP.userid];
APP.editable.row = []; APP.editable.row = [];
@ -349,9 +361,13 @@ define([
}; };
var handleClick = function (e, isKeyup) { var handleClick = function (e, isKeyup) {
if (APP.locked) { return; }
e.stopPropagation(); e.stopPropagation();
if (!APP.ready) { return; } if (!APP.ready) { return; }
if (!isKeyup && e.which !== 1) { return; } // only allow left clicks
var target = e && e.target; var target = e && e.target;
if (!target) { return void debug("NO TARGET"); } if (!target) { return void debug("NO TARGET"); }
@ -369,10 +385,19 @@ define([
hideInputs(target, isKeyup); hideInputs(target, isKeyup);
break; break;
} }
if ($(target).is('input[type="number"]')) { console.error("number input focused?"); break; }
handleInput(target); handleInput(target);
break; break;
case 'LABEL':
var input = $('input[type="number"][id=' + $(target).attr('for') + ']');
var value = parseInt(input.val());
input.val((value + 1) % 4);
handleInput(input[0]);
break;
case 'SPAN': case 'SPAN':
//case 'LABEL':
if (shouldLock) { if (shouldLock) {
break; break;
} }
@ -421,6 +446,15 @@ define([
}); });
}; };
var showHelp = function(help) {
if (typeof help === 'undefined') { help = !$('#howItWorks').is(':visible'); }
var msg = (help ? Messages.poll_hide_help_button : Messages.poll_show_help_button);
$('#howItWorks').toggle(help);
$('#help').text(msg).attr('title', msg);
};
var Title; var Title;
var UserList; var UserList;
@ -486,12 +520,16 @@ var ready = function (info, userid, readOnly) {
publish(true); publish(true);
}); });
// #publish button is removed in readonly
APP.$admin = $('#admin') APP.$admin = $('#admin')
.click(function () { .click(function () {
publish(false); publish(false);
}); });
APP.$help = $('#help')
.click(function () {
showHelp();
});
// Title // Title
if (APP.proxy.info.defaultTitle) { if (APP.proxy.info.defaultTitle) {
Title.updateDefaultTitle(APP.proxy.info.defaultTitle); Title.updateDefaultTitle(APP.proxy.info.defaultTitle);
@ -527,7 +565,10 @@ var ready = function (info, userid, readOnly) {
.click(handleClick) .click(handleClick)
.on('keyup', function (e) { handleClick(e, true); }); .on('keyup', function (e) { handleClick(e, true); });
$(window).click(hideInputs); $(window).click(function(e) {
if (e.which !== 1) { return; }
hideInputs();
});
proxy proxy
.on('change', ['info'], function (o, n, p) { .on('change', ['info'], function (o, n, p) {
@ -570,14 +611,33 @@ var ready = function (info, userid, readOnly) {
UserList.getLastName(APP.toolbar.$userNameButton, isNew); UserList.getLastName(APP.toolbar.$userNameButton, isNew);
}; };
var setEditable = function (editable) {
APP.locked = !editable;
if (editable === false) {
// disable all the things
$('.realtime input, .realtime button, .upper button, .realtime textarea').attr('disabled', APP.locked);
$('span.edit, span.remove').hide();
$('span.lock').addClass('fa-lock').removeClass('fa-unlock')
.attr('title', Messages.poll_locked)
.css({'cursor': 'default'});
} else {
// enable
$('span.edit, span.remove').show();
$('span.lock').css({'cursor': ''});
$('.realtime button, .upper button, .realtime textarea').attr('disabled', APP.locked);
unlockElements();
}
};
var disconnect = function () { var disconnect = function () {
//setEditable(false); // TODO setEditable(false);
APP.toolbar.failed(); APP.toolbar.failed();
Cryptpad.alert(Messages.common_connectionLost, undefined, true); Cryptpad.alert(Messages.common_connectionLost, undefined, true);
}; };
var reconnect = function (info) { var reconnect = function (info) {
//setEditable(true); // TODO setEditable(true);
APP.toolbar.reconnecting(info.myId); APP.toolbar.reconnecting(info.myId);
Cryptpad.findOKButton().click(); Cryptpad.findOKButton().click();
}; };
@ -632,7 +692,7 @@ var create = function (info) {
/* add a forget button */ /* add a forget button */
var forgetCb = function (err) { var forgetCb = function (err) {
if (err) { return; } if (err) { return; }
disconnect(); setEditable(false);
}; };
var $forgetPad = Cryptpad.createButton('forget', true, {}, forgetCb); var $forgetPad = Cryptpad.createButton('forget', true, {}, forgetCb);
$rightside.append($forgetPad); $rightside.append($forgetPad);
@ -698,12 +758,13 @@ var create = function (info) {
Cryptpad.setAttribute(HIDE_INTRODUCTION_TEXT, "1", function (e) { Cryptpad.setAttribute(HIDE_INTRODUCTION_TEXT, "1", function (e) {
if (e) { console.error(e); } if (e) { console.error(e); }
}); });
} else if (value === "1") { showHelp(true);
$('#howItWorks').hide(); } else {
showHelp(false);
} }
}); });
//Cryptpad.onLogout(function () { setEditable(false); }); TODO Cryptpad.onLogout(function () { setEditable(false); });
}); });
Cryptpad.onError(function (info) { Cryptpad.onError(function (info) {
if (info) { if (info) {

@ -170,6 +170,10 @@ div.realtime table {
border-collapse: collapse; border-collapse: collapse;
width: calc(100% - 1px); width: calc(100% - 1px);
} }
form.realtime table .editing,
div.realtime table .editing {
background-color: #88b8cc;
}
form.realtime table tr td:first-child, form.realtime table tr td:first-child,
div.realtime table tr td:first-child { div.realtime table tr td:first-child {
position: absolute; position: absolute;
@ -225,40 +229,63 @@ div.realtime table tr td.checkbox-cell div.checkbox-contain label {
height: 100%; height: 100%;
width: 100%; width: 100%;
} }
form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable), form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable),
div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) { div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) {
display: none; display: none;
} }
form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover, form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover,
div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover { div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover {
font-weight: bold; font-weight: bold;
background-color: #FA5858;
color: #000; color: #000;
display: block; display: block;
} }
form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover:after, form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover:after,
div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover:after { div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover:after {
height: 100%; height: 100%;
} }
form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover:after, form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover.yes,
div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover:after { div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover.yes {
background-color: #46E981;
}
form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover.uncommitted,
div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover.uncommitted {
background: #ddd;
}
form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover.mine,
div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover.mine {
display: none;
}
form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="0"] ~ .cover,
div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="0"] ~ .cover {
background-color: #FA5858;
}
form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="0"] ~ .cover:after,
div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="0"] ~ .cover:after {
content: "✖"; content: "✖";
} }
form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.yes, form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="1"] ~ .cover,
div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.yes { div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="1"] ~ .cover {
background-color: #46E981; background-color: #46E981;
} }
form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.yes:after, form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="1"] ~ .cover:after,
div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.yes:after { div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="1"] ~ .cover:after {
content: "✔"; content: "✔";
} }
form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.uncommitted, form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="2"] ~ .cover,
div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.uncommitted { div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="2"] ~ .cover {
background: #ddd; background-color: #ff5;
} }
form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.mine, form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="2"] ~ .cover:after,
div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.mine { div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="2"] ~ .cover:after {
display: none; content: "~";
}
form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="3"] ~ .cover,
div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="3"] ~ .cover {
background-color: #ccc;
}
form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="3"] ~ .cover:after,
div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="3"] ~ .cover:after {
content: "?";
} }
form.realtime table input[type="text"], form.realtime table input[type="text"],
div.realtime table input[type="text"] { div.realtime table input[type="text"] {
@ -298,8 +325,8 @@ div.realtime table thead td input[type="text"][disabled] {
color: #000; color: #000;
border: 1px solid transparent; border: 1px solid transparent;
} }
form.realtime table tbody .text-cell, form.realtime table tbody td:not(.editing) .text-cell,
div.realtime table tbody .text-cell { div.realtime table tbody td:not(.editing) .text-cell {
background: #aaa; background: #aaa;
} }
form.realtime table tbody .text-cell input[type="text"], form.realtime table tbody .text-cell input[type="text"],

@ -4,10 +4,13 @@
@poll-th-bg: #aaa; @poll-th-bg: #aaa;
@poll-th-user-bg: #999; @poll-th-user-bg: #999;
@poll-td-bg: #aaa; @poll-td-bg: #aaa;
@poll-editing: #88b8cc;
@poll-placeholder: #666; @poll-placeholder: #666;
@poll-border-color: #555; @poll-border-color: #555;
@poll-cover-color: #000; @poll-cover-color: #000;
@poll-fg: #000; @poll-fg: #000;
@poll-option-yellow: #ff5;
@poll-option-gray: #ccc;
html, body { html, body {
width: 100%; width: 100%;
@ -195,6 +198,9 @@ form.realtime, div.realtime {
table { table {
border-collapse: collapse; border-collapse: collapse;
width: ~"calc(100% - 1px)"; width: ~"calc(100% - 1px)";
.editing {
background-color: @poll-editing;
}
tr { tr {
td:first-child { td:first-child {
position:absolute; position:absolute;
@ -247,7 +253,7 @@ form.realtime, div.realtime {
} }
input { input {
&[type="checkbox"] { &[type="number"] {
&:not(.editable) { &:not(.editable) {
display: none; display: none;
@ -255,26 +261,21 @@ form.realtime, div.realtime {
display: block; display: block;
font-weight: bold; font-weight: bold;
background-color: @cp-red;
color: @poll-cover-color; color: @poll-cover-color;
&:after { &:after {
height: 100%; height: 100%;
} }
&:after { content: "✖"; }
display: block; display: block;
&.yes { &.yes {
background-color: @cp-green; background-color: @cp-green;
&:after { content: "✔"; }
} }
&.uncommitted { &.uncommitted {
background: #ddd; background: #ddd;
} }
&.mine { &.mine {
display: none; display: none;
} }
@ -282,6 +283,31 @@ form.realtime, div.realtime {
} }
} }
} }
input[type="number"][value="0"] {
~ .cover {
background-color: @cp-red;
&:after { content: "✖"; }
}
}
input[type="number"][value="1"] {
~ .cover {
background-color: @cp-green;
&:after { content: "✔"; }
}
}
input[type="number"][value="2"] {
~ .cover {
background-color: @poll-option-yellow;
&:after { content: "~"; }
}
}
input[type="number"][value="3"] {
~ .cover {
background-color: @poll-option-gray;
&:after { content: "?"; }
}
}
} }
} }
} }
@ -327,8 +353,12 @@ form.realtime, div.realtime {
} }
tbody { tbody {
td:not(.editing) {
.text-cell {
background: @poll-td-bg;
}
}
.text-cell { .text-cell {
background: @poll-td-bg;
//border-radius: 20px 0 0 20px; //border-radius: 20px 0 0 20px;
input[type="text"] { input[type="text"] {
width: ~"calc(100% - 50px)"; width: ~"calc(100% - 50px)";

@ -70,7 +70,12 @@ var Renderer = function (Cryptpad) {
}; };
var getCellValue = Render.getCellValue = function (obj, cellId) { var getCellValue = Render.getCellValue = function (obj, cellId) {
return Cryptpad.find(obj, ['table', 'cells'].concat([cellId])); var value = Cryptpad.find(obj, ['table', 'cells'].concat([cellId]));
if (typeof value === 'boolean') {
return (value === true ? 1 : 0);
} else {
return value;
}
}; };
var setRowValue = Render.setRowValue = function (obj, rowId, value) { var setRowValue = Render.setRowValue = function (obj, rowId, value) {
@ -234,16 +239,20 @@ var Renderer = function (Cryptpad) {
disabled: 'disabled' disabled: 'disabled'
}].concat(cols.map(function (col) { }].concat(cols.map(function (col) {
var id = [col, rows[i-1]].join('_'); var id = [col, rows[i-1]].join('_');
var val = cells[id] || false; var val = cells[id];
var result = { var result = {
'data-rt-id': id, 'data-rt-id': id,
type: 'checkbox', type: 'number',
autocomplete: 'nope', autocomplete: 'nope',
value: '3',
}; };
if (readOnly) { if (readOnly) {
result.disabled = "disabled"; result.disabled = "disabled";
} }
if (val) { result.checked = true; } if (typeof val !== 'undefined') {
if (typeof val === 'boolean') { val = (val ? '1' : '0'); }
result.value = val;
}
return result; return result;
})); }));
}); });
@ -297,9 +306,6 @@ var Renderer = function (Cryptpad) {
attrs.id = cell['data-rt-id']; attrs.id = cell['data-rt-id'];
var labelClass = 'cover'; var labelClass = 'cover';
if (cell.checked) {
labelClass += ' yes';
}
// TODO implement Yes/No/Maybe/Undecided // TODO implement Yes/No/Maybe/Undecided
return ['TD', {class:"checkbox-cell"}, [ return ['TD', {class:"checkbox-cell"}, [
@ -326,7 +332,7 @@ var Renderer = function (Cryptpad) {
]]; ]];
} }
if (cell && cell.type === 'checkbox') { if (cell && cell.type === 'number') {
return makeCheckbox(cell); return makeCheckbox(cell);
} }
return ['TD', cell, []]; return ['TD', cell, []];
@ -399,7 +405,7 @@ var Renderer = function (Cryptpad) {
preDiffApply: function (info) { preDiffApply: function (info) {
if (!diffIsInput(info)) { return; } if (!diffIsInput(info)) { return; }
switch (getInputType(info)) { switch (getInputType(info)) {
case 'checkbox': case 'number':
//console.log('checkbox'); //console.log('checkbox');
//console.log("[preDiffApply]", info); //console.log("[preDiffApply]", info);
break; break;

@ -25,7 +25,7 @@
<button id="toggleDraw" data-localization="canvas_disable"></button> <button id="toggleDraw" data-localization="canvas_disable"></button>
<button id="delete" style="display: none;" data-localization="canvas_delete"></button> <button id="delete" style="display: none;" data-localization="canvas_delete"></button>
<input id="width" data-localization-title="canvas_width" type="range" value="5" min="1" max="100"></input><label for="width">5</label> <input id="width" data-localization-title="canvas_width" type="range" value="5" min="1" max="100"></input><label for="width">5</label>
<input id="opacity" data-localization-title="canvas_opacity" type="range" value="1" min="0" max="1" step="0.1"></input><label for="opacity">1</label> <input id="opacity" data-localization-title="canvas_opacity" type="range" value="1" min="0.1" max="1" step="0.1"></input><label for="opacity">1</label>
<span class="selected"></span> <span class="selected"></span>
</div> </div>
<div id="colors">&nbsp;</div> <div id="colors">&nbsp;</div>

@ -97,7 +97,7 @@ window.canvas = canvas;
var updateBrushWidth = function () { var updateBrushWidth = function () {
var val = $width.val(); var val = $width.val();
canvas.freeDrawingBrush.width = Number(val); canvas.freeDrawingBrush.width = Number(val);
$widthLabel.text(val); $widthLabel.text(Cryptpad.Messages._getKey("canvas_widthLabel", [val]));
createCursor(); createCursor();
}; };
updateBrushWidth(); updateBrushWidth();
@ -108,7 +108,7 @@ window.canvas = canvas;
var val = $opacity.val(); var val = $opacity.val();
brush.opacity = Number(val); brush.opacity = Number(val);
canvas.freeDrawingBrush.color = Colors.hex2rgba(brush.color, brush.opacity); canvas.freeDrawingBrush.color = Colors.hex2rgba(brush.color, brush.opacity);
$opacityLabel.text(val); $opacityLabel.text(Cryptpad.Messages._getKey("canvas_opacityLabel", [val]));
createCursor(); createCursor();
}; };
updateBrushOpacity(); updateBrushOpacity();

Loading…
Cancel
Save