consistent ordering of columns and rows
This commit is contained in:
parent
d30eddf2f2
commit
a3254a2619
@ -13,6 +13,9 @@ define([
|
|||||||
], function (Config, Messages, Table, TextPatcher, Listmap, Crypto, Cryptpad, Visible, Notify) {
|
], function (Config, Messages, Table, TextPatcher, Listmap, Crypto, Cryptpad, Visible, Notify) {
|
||||||
var $ = window.jQuery;
|
var $ = window.jQuery;
|
||||||
|
|
||||||
|
Cryptpad.styleAlerts();
|
||||||
|
console.log("Initializing your realtime session...");
|
||||||
|
|
||||||
/* TODO
|
/* TODO
|
||||||
* set range of dates/times
|
* set range of dates/times
|
||||||
* (pair of date pickers)
|
* (pair of date pickers)
|
||||||
@ -95,6 +98,11 @@ define([
|
|||||||
var coluid = Uid('x');
|
var coluid = Uid('x');
|
||||||
var rowuid = Uid('y');
|
var rowuid = Uid('y');
|
||||||
|
|
||||||
|
var addIfAbsent = function (A, e) {
|
||||||
|
if (A.indexOf(e) !== -1) { return; }
|
||||||
|
A.push(e);
|
||||||
|
};
|
||||||
|
|
||||||
var makeUser = function (proxy, id, value) {
|
var makeUser = function (proxy, id, value) {
|
||||||
var $user = Input({
|
var $user = Input({
|
||||||
id: id,
|
id: id,
|
||||||
@ -103,7 +111,9 @@ define([
|
|||||||
}).on('keyup', function () {
|
}).on('keyup', function () {
|
||||||
proxy.table.cols[id] = $user.val() || "";
|
proxy.table.cols[id] = $user.val() || "";
|
||||||
});
|
});
|
||||||
|
|
||||||
proxy.table.cols[id] = value || "";
|
proxy.table.cols[id] = value || "";
|
||||||
|
addIfAbsent(proxy.table.colsOrder, id);
|
||||||
table.addColumn($user, Checkbox, id);
|
table.addColumn($user, Checkbox, id);
|
||||||
return $user;
|
return $user;
|
||||||
};
|
};
|
||||||
@ -124,6 +134,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
proxy.table.rows[id] = value || "";
|
proxy.table.rows[id] = value || "";
|
||||||
|
addIfAbsent(proxy.table.rowsOrder, id);
|
||||||
|
|
||||||
table.addRow($option, Checkbox, id);
|
table.addRow($option, Checkbox, id);
|
||||||
return $option;
|
return $option;
|
||||||
@ -153,36 +164,47 @@ define([
|
|||||||
|
|
||||||
var ready = function (info) {
|
var ready = function (info) {
|
||||||
console.log("Your realtime object is ready");
|
console.log("Your realtime object is ready");
|
||||||
setEditable(true);
|
|
||||||
|
|
||||||
var proxy = module.rt.proxy;
|
var proxy = module.rt.proxy;
|
||||||
|
|
||||||
|
// ensure that proxy.info and proxy.table exist
|
||||||
['info', 'table'].forEach(function (k) {
|
['info', 'table'].forEach(function (k) {
|
||||||
if (typeof(proxy[k]) === 'undefined') { proxy[k] = {}; }
|
if (typeof(proxy[k]) === 'undefined') { proxy[k] = {}; }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// table{cols,rows,cells}
|
||||||
['cols', 'rows', 'cells'].forEach(function (k) {
|
['cols', 'rows', 'cells'].forEach(function (k) {
|
||||||
if (typeof(proxy.table[k]) === 'undefined') { proxy.table[k] = {}; }
|
if (typeof(proxy.table[k]) === 'undefined') { proxy.table[k] = {}; }
|
||||||
});
|
});
|
||||||
|
|
||||||
var each = function (o, f) {
|
// table{rowsOrder,colsOrder}
|
||||||
Object.keys(o).forEach(f);
|
['rows', 'cols'].forEach(function (k) {
|
||||||
};
|
var K = k + 'Order';
|
||||||
|
|
||||||
|
if (typeof(proxy.table[K]) === 'undefined') {
|
||||||
|
console.log("Creating %s", K);
|
||||||
|
proxy.table[K] = [];
|
||||||
|
|
||||||
|
Object.keys(proxy.table[k]).forEach(function (uid) {
|
||||||
|
addIfAbsent(proxy.table[K], uid);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// cols
|
// cols
|
||||||
each(proxy.table.cols, function (uid) {
|
proxy.table.colsOrder.forEach(function (uid) {
|
||||||
var val = proxy.table.cols[uid];
|
var val = proxy.table.cols[uid];
|
||||||
makeUser(proxy, uid, val).val(val);
|
makeUser(proxy, uid, val).val(val);
|
||||||
});
|
});
|
||||||
|
|
||||||
// rows
|
// rows
|
||||||
each(proxy.table.rows, function (uid) {
|
proxy.table.rowsOrder.forEach(function (uid) {
|
||||||
var val = proxy.table.rows[uid];
|
var val = proxy.table.rows[uid];
|
||||||
makeOption(proxy, uid, val).val(val);
|
makeOption(proxy, uid, val).val(val);
|
||||||
});
|
});
|
||||||
|
|
||||||
// cells
|
// cells
|
||||||
each(proxy.table.cells, function (uid) {
|
Object.keys(proxy.table.cells).forEach(function (uid) {
|
||||||
var p = parseXY(uid);
|
var p = parseXY(uid);
|
||||||
document.getElementById(uid).checked = proxy.table.cells[uid] ? true : false;
|
document.getElementById(uid).checked = proxy.table.cells[uid] ? true : false;
|
||||||
});
|
});
|
||||||
@ -200,6 +222,7 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// listen for visibility changes
|
||||||
if (Visible.isSupported()) {
|
if (Visible.isSupported()) {
|
||||||
Visible.onChange(function (yes) {
|
Visible.onChange(function (yes) {
|
||||||
if (yes) { unnotify(); }
|
if (yes) { unnotify(); }
|
||||||
@ -286,8 +309,6 @@ define([
|
|||||||
|
|
||||||
var title = document.title = Cryptpad.getPadTitle();
|
var title = document.title = Cryptpad.getPadTitle();
|
||||||
Cryptpad.rememberPad(title);
|
Cryptpad.rememberPad(title);
|
||||||
Cryptpad.styleAlerts();
|
|
||||||
|
|
||||||
|
|
||||||
var $toolbar = $('#toolbar');
|
var $toolbar = $('#toolbar');
|
||||||
|
|
||||||
@ -305,6 +326,19 @@ define([
|
|||||||
return document.title || $title.val() || hash;
|
return document.title || $title.val() || hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$toolbar.append(Button({
|
||||||
|
id: 'forget',
|
||||||
|
'class': 'forget button action',
|
||||||
|
title: Messages.forgetButtonTitle,
|
||||||
|
}).text(Messages.forgetButton).click(function () {
|
||||||
|
var href = window.location.href;
|
||||||
|
Cryptpad.confirm(Messages.forgetPrompt, function (yes) {
|
||||||
|
if (!yes) { return; }
|
||||||
|
Cryptpad.forgetPad(href);
|
||||||
|
document.title = window.location.hash.slice(1, 9);
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
$toolbar.append(Button({
|
$toolbar.append(Button({
|
||||||
id: 'rename',
|
id: 'rename',
|
||||||
'class': 'rename button action',
|
'class': 'rename button action',
|
||||||
@ -323,18 +357,7 @@ define([
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
$toolbar.append(Button({
|
setEditable(true);
|
||||||
id: 'forget',
|
|
||||||
'class': 'forget button action',
|
|
||||||
title: Messages.forgetButtonTitle,
|
|
||||||
}).text(Messages.forgetButton).click(function () {
|
|
||||||
var href = window.location.href;
|
|
||||||
Cryptpad.confirm(Messages.forgetPrompt, function (yes) {
|
|
||||||
if (!yes) { return; }
|
|
||||||
Cryptpad.forgetPad(href);
|
|
||||||
document.title = window.location.hash.slice(1, 9);
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user