Update UI in poll and remove old code
This commit is contained in:
parent
3337689630
commit
5cf86bf74a
@ -570,15 +570,12 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
var appToolbar = function () {
|
var appToolbar = function () {
|
||||||
return h('div#toolbar.cryptpad-toolbar');
|
|
||||||
};
|
|
||||||
var appToolbar3 = function () {
|
|
||||||
return h('div#cp-toolbar.cp-toolbar-container');
|
return h('div#cp-toolbar.cp-toolbar-container');
|
||||||
};
|
};
|
||||||
|
|
||||||
Pages['/whiteboard/'] = Pages['/whiteboard/index.html'] = function () {
|
Pages['/whiteboard/'] = Pages['/whiteboard/index.html'] = function () {
|
||||||
return [
|
return [
|
||||||
appToolbar3(),
|
appToolbar(),
|
||||||
h('div#cp-app-whiteboard-canvas-area', h('canvas#cp-app-whiteboard-canvas', {
|
h('div#cp-app-whiteboard-canvas-area', h('canvas#cp-app-whiteboard-canvas', {
|
||||||
width: 600,
|
width: 600,
|
||||||
height: 600
|
height: 600
|
||||||
@ -638,7 +635,7 @@ define([
|
|||||||
|
|
||||||
Pages['/poll/'] = Pages['/poll/index.html'] = function () {
|
Pages['/poll/'] = Pages['/poll/index.html'] = function () {
|
||||||
return [
|
return [
|
||||||
appToolbar3(),
|
appToolbar(),
|
||||||
h('div#cp-app-poll-content', [
|
h('div#cp-app-poll-content', [
|
||||||
h('div#cp-app-poll-form', [
|
h('div#cp-app-poll-form', [
|
||||||
h('div#cp-app-poll-help', [
|
h('div#cp-app-poll-help', [
|
||||||
@ -647,18 +644,6 @@ define([
|
|||||||
h('p', Msg.poll_p_save),
|
h('p', Msg.poll_p_save),
|
||||||
h('p', Msg.poll_p_encryption)
|
h('p', Msg.poll_p_encryption)
|
||||||
]),
|
]),
|
||||||
h('div.cp-app-poll-upper', [
|
|
||||||
h('button#cp-app-poll-action-publish.btn.btn-success', {
|
|
||||||
style: { display: 'none' }
|
|
||||||
}, Msg.poll_publish_button),
|
|
||||||
h('button#cp-app-poll-action-admin.btn.btn-primary', {
|
|
||||||
style: { display: 'none' },
|
|
||||||
title: Msg.poll_admin_button
|
|
||||||
}, Msg.poll_admin_button),
|
|
||||||
h('button#cp-app-poll-action-help.btn.btn-secondary', {
|
|
||||||
title: Msg.poll_show_help_button
|
|
||||||
}, Msg.poll_show_help_button)
|
|
||||||
]),
|
|
||||||
h('div.cp-app-poll-realtime', [
|
h('div.cp-app-poll-realtime', [
|
||||||
h('br'),
|
h('br'),
|
||||||
h('center', [
|
h('center', [
|
||||||
|
|||||||
@ -256,6 +256,10 @@ define(function () {
|
|||||||
out.poll_show_help_button = "Afficher l'aide";
|
out.poll_show_help_button = "Afficher l'aide";
|
||||||
out.poll_hide_help_button = "Cacher l'aide";
|
out.poll_hide_help_button = "Cacher l'aide";
|
||||||
|
|
||||||
|
out.poll_bookmark_col = "Marquer cette colonne comme favorite pour qu'elle soit toujours déverouillée et affichée en première position.";
|
||||||
|
out.poll_bookmarked_col = "Voici votre colonne favorite; elle sera toujours dévérouillée et affichée en première position.";
|
||||||
|
out.poll_total = 'TOTAL';
|
||||||
|
|
||||||
// Canvas
|
// Canvas
|
||||||
out.canvas_clear = "Nettoyer";
|
out.canvas_clear = "Nettoyer";
|
||||||
out.canvas_delete = "Supprimer la sélection";
|
out.canvas_delete = "Supprimer la sélection";
|
||||||
|
|||||||
@ -258,6 +258,10 @@ define(function () {
|
|||||||
out.poll_show_help_button = "Show help";
|
out.poll_show_help_button = "Show help";
|
||||||
out.poll_hide_help_button = "Hide help";
|
out.poll_hide_help_button = "Hide help";
|
||||||
|
|
||||||
|
out.poll_bookmark_col = 'Bookmark this column so that it is always unlocked and displayed at the beginning for you';
|
||||||
|
out.poll_bookmarked_col = 'This is your bookmarked column. It will always be unlocked and displayed at the beginning for you.';
|
||||||
|
out.poll_total = 'TOTAL';
|
||||||
|
|
||||||
// Canvas
|
// Canvas
|
||||||
out.canvas_clear = "Clear";
|
out.canvas_clear = "Clear";
|
||||||
out.canvas_delete = "Delete selection";
|
out.canvas_delete = "Delete selection";
|
||||||
|
|||||||
@ -62,6 +62,7 @@ define([
|
|||||||
Cryptpad.ready(waitFor());
|
Cryptpad.ready(waitFor());
|
||||||
}));
|
}));
|
||||||
}).nThen(function (waitFor) {
|
}).nThen(function (waitFor) {
|
||||||
|
$('#sbox-iframe').focus();
|
||||||
|
|
||||||
sframeChan.on('EV_CACHE_PUT', function (x) {
|
sframeChan.on('EV_CACHE_PUT', function (x) {
|
||||||
Object.keys(x).forEach(function (k) {
|
Object.keys(x).forEach(function (k) {
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
@import (once) '../../customize/src/less2/include/fileupload.less';
|
@import (once) '../../customize/src/less2/include/fileupload.less';
|
||||||
@import (once) '../../customize/src/less2/include/alertify.less';
|
@import (once) '../../customize/src/less2/include/alertify.less';
|
||||||
@import (once) '../../customize/src/less2/include/tokenfield.less';
|
@import (once) '../../customize/src/less2/include/tokenfield.less';
|
||||||
|
@import (once) '../../customize/src/less2/include/tools.less';
|
||||||
|
|
||||||
.toolbar_main();
|
.toolbar_main();
|
||||||
.fileupload_main();
|
.fileupload_main();
|
||||||
@ -93,13 +94,6 @@ table#cp-app-poll-table {
|
|||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
#cp-app-poll-publish {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
#cp-app-poll-action-publish, #cp-app-poll-action-admin {
|
|
||||||
margin-top: 15px;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
}
|
|
||||||
#cp-app-poll-create-user {
|
#cp-app-poll-create-user {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
@ -128,29 +122,24 @@ table#cp-app-poll-table {
|
|||||||
min-width: 80%;
|
min-width: 80%;
|
||||||
width: 80%;
|
width: 80%;
|
||||||
min-height: 7em;
|
min-height: 7em;
|
||||||
font-size: 20px;
|
font: @colortheme_app-font;
|
||||||
font-weight: bold;
|
//font-size: 20px;
|
||||||
|
/*font-weight: bold;*/
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
|
|
||||||
}
|
}
|
||||||
#cp-app-poll-description[disabled] {
|
#cp-app-poll-description[disabled] {
|
||||||
resize: none;
|
resize: none;
|
||||||
color: #000;
|
color: #000;
|
||||||
border: 1px solid #444;
|
border: 1px solid transparent;
|
||||||
|
background-color: #eeeeee;
|
||||||
|
font: @colortheme_app-font;
|
||||||
}
|
}
|
||||||
|
|
||||||
#cp-app-poll-help {
|
#cp-app-poll-help {
|
||||||
width: 80%;
|
width: 80%;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
div.cp-app-poll-upper {
|
|
||||||
width: 80%;
|
|
||||||
margin: auto;
|
|
||||||
|
|
||||||
& > * {
|
|
||||||
margin-right: 1em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// from cryptpad.less
|
// from cryptpad.less
|
||||||
|
|
||||||
@ -169,6 +158,7 @@ tbody {
|
|||||||
}
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
|
.tools_unselectable();
|
||||||
border-right: 1px solid @poll-border-color;
|
border-right: 1px solid @poll-border-color;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
padding-top: 0px;
|
padding-top: 0px;
|
||||||
@ -274,7 +264,7 @@ div.cp-app-poll-realtime {
|
|||||||
margin: 0px;
|
margin: 0px;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
min-width: 150px;
|
min-width: 100px;
|
||||||
|
|
||||||
div.cp-app-poll-table-checkbox-contain {
|
div.cp-app-poll-table-checkbox-contain {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
@ -387,6 +377,8 @@ div.cp-app-poll-realtime {
|
|||||||
}
|
}
|
||||||
input {
|
input {
|
||||||
&[type="text"] {
|
&[type="text"] {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
break-after: always;
|
break-after: always;
|
||||||
width: ~"calc(100% - 2px)"; // borders...
|
width: ~"calc(100% - 2px)"; // borders...
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|||||||
@ -2,7 +2,6 @@ define([
|
|||||||
'jquery',
|
'jquery',
|
||||||
'/bower_components/textpatcher/TextPatcher.js',
|
'/bower_components/textpatcher/TextPatcher.js',
|
||||||
'/common/toolbar3.js',
|
'/common/toolbar3.js',
|
||||||
'json.sortify',
|
|
||||||
'/common/cryptpad-common.js',
|
'/common/cryptpad-common.js',
|
||||||
'/common/common-util.js',
|
'/common/common-util.js',
|
||||||
'/common/cryptget.js',
|
'/common/cryptget.js',
|
||||||
@ -23,7 +22,6 @@ define([
|
|||||||
$,
|
$,
|
||||||
TextPatcher,
|
TextPatcher,
|
||||||
Toolbar,
|
Toolbar,
|
||||||
JSONSortify,
|
|
||||||
Cryptpad,
|
Cryptpad,
|
||||||
Util,
|
Util,
|
||||||
Cryptget,
|
Cryptget,
|
||||||
@ -51,36 +49,16 @@ define([
|
|||||||
|
|
||||||
var debug = $.noop; //console.log;
|
var debug = $.noop; //console.log;
|
||||||
|
|
||||||
var stringify = function (obj) {
|
|
||||||
return JSONSortify(obj);
|
|
||||||
};
|
|
||||||
|
|
||||||
var onConnectError = function () {
|
|
||||||
Cryptpad.errorLoadingScreen(Messages.websocketError);
|
|
||||||
};
|
|
||||||
|
|
||||||
var HIDE_INTRODUCTION_TEXT = "hide-text";
|
var HIDE_INTRODUCTION_TEXT = "hide-text";
|
||||||
|
|
||||||
var metadataMgr;
|
var metadataMgr;
|
||||||
var Title;
|
var Title;
|
||||||
var defaultName;
|
|
||||||
var common;
|
var common;
|
||||||
var readOnly;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var copyObject = function (obj) {
|
var copyObject = function (obj) {
|
||||||
return JSON.parse(JSON.stringify(obj));
|
return JSON.parse(JSON.stringify(obj));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Make sure that the realtime data structure has all the required fields
|
Make sure that the realtime data structure has all the required fields
|
||||||
*/
|
*/
|
||||||
@ -102,8 +80,9 @@ define([
|
|||||||
proxy.type = 'poll';
|
proxy.type = 'poll';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Set the user id (user column) in the pad attributes
|
||||||
|
*/
|
||||||
var setUserId = function (id, cb) {
|
var setUserId = function (id, cb) {
|
||||||
cb =cb || $.noop;
|
cb =cb || $.noop;
|
||||||
APP.userid = id;
|
APP.userid = id;
|
||||||
@ -128,8 +107,11 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
var isUncommitted = function (id) {
|
var isUncommitted = function (id) {
|
||||||
return APP.uncommitted.content.colsOrder.indexOf(id) !== -1 ||
|
var idArr = id.split('_');
|
||||||
APP.uncommitted.content.rowsOrder.indexOf(id) !== -1;
|
var idx = idArr[0];
|
||||||
|
var idy = idArr[1] || idArr[0]; // if id is y-{...} (no 'x'), use idArr[0] as 'y' coordinate
|
||||||
|
return APP.uncommitted.content.colsOrder.indexOf(idx) !== -1 ||
|
||||||
|
APP.uncommitted.content.rowsOrder.indexOf(idy) !== -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
var mergeUncommitted = function (proxy, uncommitted, commit) {
|
var mergeUncommitted = function (proxy, uncommitted, commit) {
|
||||||
@ -175,10 +157,9 @@ define([
|
|||||||
return newObj;
|
return newObj;
|
||||||
};
|
};
|
||||||
|
|
||||||
var styleUncommittedColumn = function () {
|
var styleUserColumn = function () {
|
||||||
var userid = APP.userid;
|
var userid = APP.userid;
|
||||||
|
|
||||||
// TODO: move?
|
|
||||||
// Enable input for the userid column
|
// Enable input for the userid column
|
||||||
$('input[disabled="disabled"][data-rt-id^="' + userid + '"]').removeAttr('disabled')
|
$('input[disabled="disabled"][data-rt-id^="' + userid + '"]').removeAttr('disabled')
|
||||||
.attr('placeholder', Messages.poll_userPlaceholder);
|
.attr('placeholder', Messages.poll_userPlaceholder);
|
||||||
@ -188,10 +169,9 @@ define([
|
|||||||
.addClass("cp-app-poll-table-own");
|
.addClass("cp-app-poll-table-own");
|
||||||
$('.cp-app-poll-table-bookmark[data-rt-id="' + userid + '"]').css('visibility', '')
|
$('.cp-app-poll-table-bookmark[data-rt-id="' + userid + '"]').css('visibility', '')
|
||||||
.removeClass('fa-bookmark-o').addClass('fa-bookmark')
|
.removeClass('fa-bookmark-o').addClass('fa-bookmark')
|
||||||
.attr('title', 'TODO: this is your bookmarked column. It will always be unlocked and displayed at the beginning for you');
|
.attr('title', Messages.poll_bookmarked_col);
|
||||||
//.addClass('fa-unlock').removeClass('fa-lock').attr('title', Messages.poll_unlocked);
|
};
|
||||||
//$('.cp-app-poll-table-remove[data-rt-id="' + userid + '"]').remove();
|
var styleUncommittedColumn = function () {
|
||||||
|
|
||||||
var $scroll = $('#cp-app-poll-table-scroll');
|
var $scroll = $('#cp-app-poll-table-scroll');
|
||||||
var hasScroll = $scroll.width() < $scroll[0].scrollWidth;
|
var hasScroll = $scroll.width() < $scroll[0].scrollWidth;
|
||||||
APP.uncommitted.content.colsOrder.forEach(function(id) {
|
APP.uncommitted.content.colsOrder.forEach(function(id) {
|
||||||
@ -222,7 +202,6 @@ define([
|
|||||||
//$('.uncommitted input[type="text"]').attr("placeholder", Messages.poll_userPlaceholder);
|
//$('.uncommitted input[type="text"]').attr("placeholder", Messages.poll_userPlaceholder);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var unlockElements = function () {
|
var unlockElements = function () {
|
||||||
APP.unlocked.row.forEach(function (id) {
|
APP.unlocked.row.forEach(function (id) {
|
||||||
var $input = $('input[type="text"][disabled="disabled"][data-rt-id="' + id + '"]').removeAttr('disabled');
|
var $input = $('input[type="text"][disabled="disabled"][data-rt-id="' + id + '"]').removeAttr('disabled');
|
||||||
@ -238,7 +217,6 @@ define([
|
|||||||
.removeClass('fa-lock').attr('title', Messages.poll_unlocked);
|
.removeClass('fa-lock').attr('title', Messages.poll_unlocked);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var updateTableButtons = function () {
|
var updateTableButtons = function () {
|
||||||
var uncomColId = APP.uncommitted.content.colsOrder[0];
|
var uncomColId = APP.uncommitted.content.colsOrder[0];
|
||||||
var uncomRowId = APP.uncommitted.content.rowsOrder[0];
|
var uncomRowId = APP.uncommitted.content.rowsOrder[0];
|
||||||
@ -264,7 +242,6 @@ define([
|
|||||||
//$('#create-user').css('left', width + 30 + 'px');
|
//$('#create-user').css('left', width + 30 + 'px');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var setTablePublished = function (bool) {
|
var setTablePublished = function (bool) {
|
||||||
if (bool) {
|
if (bool) {
|
||||||
if (APP.$publish) { APP.$publish.hide(); }
|
if (APP.$publish) { APP.$publish.hide(); }
|
||||||
@ -276,7 +253,6 @@ define([
|
|||||||
$('#cp-app-poll-form').removeClass('cp-app-poll-published');
|
$('#cp-app-poll-form').removeClass('cp-app-poll-published');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var addCount = function () {
|
var addCount = function () {
|
||||||
var $scroll = $('#cp-app-poll-table-scroll');
|
var $scroll = $('#cp-app-poll-table-scroll');
|
||||||
var hasScroll = $scroll.width() < $scroll[0].scrollWidth;
|
var hasScroll = $scroll.width() < $scroll[0].scrollWidth;
|
||||||
@ -292,7 +268,7 @@ define([
|
|||||||
'text-align': 'center',
|
'text-align': 'center',
|
||||||
'line-height': $thead.height()+'px'
|
'line-height': $thead.height()+'px'
|
||||||
})
|
})
|
||||||
.text('TOTAL'); // TODO
|
.text(Messages.poll_total);
|
||||||
var winner = {
|
var winner = {
|
||||||
v: 0,
|
v: 0,
|
||||||
ids: []
|
ids: []
|
||||||
@ -322,16 +298,12 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
var updateDisplayedTable = function () {
|
var updateDisplayedTable = function () {
|
||||||
|
styleUserColumn();
|
||||||
styleUncommittedColumn();
|
styleUncommittedColumn();
|
||||||
unlockElements();
|
unlockElements();
|
||||||
updateTableButtons();
|
updateTableButtons();
|
||||||
setTablePublished(APP.proxy.published);
|
setTablePublished(APP.proxy.published);
|
||||||
addCount();
|
addCount();
|
||||||
|
|
||||||
/*
|
|
||||||
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) {
|
||||||
@ -386,7 +358,7 @@ define([
|
|||||||
var colsOrder = sortColumns(displayedObj.content.colsOrder, APP.userid);
|
var colsOrder = sortColumns(displayedObj.content.colsOrder, APP.userid);
|
||||||
var conf = {
|
var conf = {
|
||||||
cols: colsOrder,
|
cols: colsOrder,
|
||||||
readOnly: readOnly
|
readOnly: APP.readOnly
|
||||||
};
|
};
|
||||||
|
|
||||||
common.notify();
|
common.notify();
|
||||||
@ -530,7 +502,6 @@ define([
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else if (isEdit) {
|
} else if (isEdit) {
|
||||||
//hideInputs(span);
|
|
||||||
unlockRow(id, function () {
|
unlockRow(id, function () {
|
||||||
change(null, null, null, null, function() {
|
change(null, null, null, null, function() {
|
||||||
$('input[data-rt-id="' + id + '"]').focus();
|
$('input[data-rt-id="' + id + '"]').focus();
|
||||||
@ -546,10 +517,8 @@ define([
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else if (isBookmark) {
|
} else if (isBookmark) {
|
||||||
//hideInputs(span);
|
|
||||||
handleBookmark(id);
|
handleBookmark(id);
|
||||||
} else if (isLock && isLocked) {
|
} else if (isLock && isLocked) {
|
||||||
//hideInputs(span);
|
|
||||||
unlockColumn(id, function () {
|
unlockColumn(id, function () {
|
||||||
change(null, null, null, null, function() {
|
change(null, null, null, null, function() {
|
||||||
$('input[data-rt-id="' + id + '"]').focus();
|
$('input[data-rt-id="' + id + '"]').focus();
|
||||||
@ -581,12 +550,6 @@ define([
|
|||||||
if (!target) { return void debug("NO TARGET"); }
|
if (!target) { return void debug("NO TARGET"); }
|
||||||
|
|
||||||
var nodeName = target && target.nodeName;
|
var nodeName = target && target.nodeName;
|
||||||
//var shouldLock = $(target).hasClass('fa-unlock');
|
|
||||||
|
|
||||||
/*if ((!$(target).parents('#cp-app-poll-table tbody').length &&
|
|
||||||
$(target).hasClass('cp-app-poll-table-lock'))) {
|
|
||||||
//hideInputs(e);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
switch (nodeName) {
|
switch (nodeName) {
|
||||||
case 'INPUT':
|
case 'INPUT':
|
||||||
@ -619,9 +582,6 @@ define([
|
|||||||
handleInput(input[0]);
|
handleInput(input[0]);
|
||||||
break;
|
break;
|
||||||
case 'SPAN':
|
case 'SPAN':
|
||||||
/*if (shouldLock) {
|
|
||||||
break;
|
|
||||||
}*/
|
|
||||||
handleSpan(target);
|
handleSpan(target);
|
||||||
break;
|
break;
|
||||||
case undefined:
|
case undefined:
|
||||||
@ -636,17 +596,45 @@ define([
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
var updatePublishButton = function () {
|
||||||
|
if (!APP.ready || !APP.proxy || !APP.$publishButton) { return; }
|
||||||
|
var p = APP.proxy.published;
|
||||||
|
var msg = (p ? Messages.poll_admin_button : Messages.poll_publish_button);
|
||||||
|
APP.$publishButton.attr('title', msg);
|
||||||
|
if (p) {
|
||||||
|
APP.$publishButton.removeClass('fa-check').addClass('fa-pencil');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
APP.$publishButton.addClass('fa-check').removeClass('fa-pencil');
|
||||||
|
};
|
||||||
var publish = APP.publish = function (bool) {
|
var publish = APP.publish = function (bool) {
|
||||||
if (!APP.ready) { return; }
|
if (!APP.readOnly) {
|
||||||
if (APP.proxy.published !== bool) {
|
if (!APP.ready) { return; }
|
||||||
APP.proxy.published = bool;
|
if (APP.proxy.published !== bool) {
|
||||||
|
APP.proxy.published = bool;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// If readOnly, always put the app in published mode
|
||||||
|
bool = true;
|
||||||
}
|
}
|
||||||
setTablePublished(bool);
|
setTablePublished(bool);
|
||||||
['textarea'].forEach(function (sel) {
|
['textarea'].forEach(function (sel) {
|
||||||
$(sel).attr('disabled', bool);
|
$(sel).attr('disabled', bool);
|
||||||
});
|
});
|
||||||
|
updatePublishButton();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var updateHelpButton = function () {
|
||||||
|
if (!APP.$helpButton) { return; }
|
||||||
|
var help = $('#cp-app-poll-help').is(':visible');
|
||||||
|
var msg = (help ? Messages.poll_hide_help_button : Messages.poll_show_help_button);
|
||||||
|
APP.$helpButton.attr('title', msg);
|
||||||
|
if (help) {
|
||||||
|
APP.$helpButton.addClass('cp-toolbar-button-active');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
APP.$helpButton.removeClass('cp-toolbar-button-active');
|
||||||
|
};
|
||||||
var showHelp = function(help) {
|
var showHelp = function(help) {
|
||||||
if (typeof help === 'undefined') {
|
if (typeof help === 'undefined') {
|
||||||
help = !$('#cp-app-poll-help').is(':visible');
|
help = !$('#cp-app-poll-help').is(':visible');
|
||||||
@ -656,22 +644,9 @@ define([
|
|||||||
|
|
||||||
$('#cp-app-poll-help').toggle(help);
|
$('#cp-app-poll-help').toggle(help);
|
||||||
$('#cp-app-poll-action-help').text(msg);
|
$('#cp-app-poll-action-help').text(msg);
|
||||||
|
updateHelpButton();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var setEditable = function (editable) {
|
var setEditable = function (editable) {
|
||||||
APP.readOnly = !editable;
|
APP.readOnly = !editable;
|
||||||
|
|
||||||
@ -710,7 +685,7 @@ define([
|
|||||||
APP.proxy.description = n;
|
APP.proxy.description = n;
|
||||||
};
|
};
|
||||||
|
|
||||||
var onReady = function (info, userid, readOnly) {
|
var onReady = function (info, userid) {
|
||||||
var proxy = APP.proxy;
|
var proxy = APP.proxy;
|
||||||
|
|
||||||
var isNew = false;
|
var isNew = false;
|
||||||
@ -750,7 +725,7 @@ define([
|
|||||||
var uncommitted = APP.uncommitted = {};
|
var uncommitted = APP.uncommitted = {};
|
||||||
prepareProxy(proxy, copyObject(Render.Example));
|
prepareProxy(proxy, copyObject(Render.Example));
|
||||||
prepareProxy(uncommitted, copyObject(Render.Example));
|
prepareProxy(uncommitted, copyObject(Render.Example));
|
||||||
if (!readOnly) {
|
if (!APP.readOnly) {
|
||||||
var coluid = Render.coluid();
|
var coluid = Render.coluid();
|
||||||
if (proxy.content.colsOrder.indexOf(userid) === -1 &&
|
if (proxy.content.colsOrder.indexOf(userid) === -1 &&
|
||||||
uncommitted.content.colsOrder.indexOf(userid) === -1) {
|
uncommitted.content.colsOrder.indexOf(userid) === -1) {
|
||||||
@ -772,7 +747,7 @@ define([
|
|||||||
|
|
||||||
var colsOrder = sortColumns(displayedObj.content.colsOrder, userid);
|
var colsOrder = sortColumns(displayedObj.content.colsOrder, userid);
|
||||||
|
|
||||||
var $table = APP.$table = $(Render.asHTML(displayedObj, null, colsOrder, readOnly));
|
var $table = APP.$table = $(Render.asHTML(displayedObj, null, colsOrder, APP.readOnly));
|
||||||
|
|
||||||
var getUncommitted = function (type) {
|
var getUncommitted = function (type) {
|
||||||
var ret = {}, toRemove;
|
var ret = {}, toRemove;
|
||||||
@ -830,23 +805,7 @@ define([
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// #publish button is removed in readonly
|
if (!APP.readOnly) {
|
||||||
APP.$publish = $('#cp-app-poll-action-publish')
|
|
||||||
.click(function () {
|
|
||||||
publish(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
APP.$admin = $('#cp-app-poll-action-admin')
|
|
||||||
.click(function () {
|
|
||||||
publish(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
APP.$help = $('#cp-app-poll-action-help')
|
|
||||||
.click(function () {
|
|
||||||
showHelp();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!readOnly) {
|
|
||||||
setUserId(userid);
|
setUserId(userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -899,19 +858,18 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
Cryptpad.removeLoadingScreen();
|
Cryptpad.removeLoadingScreen();
|
||||||
|
if (isNew) {
|
||||||
|
common.openTemplatePicker();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var onDisconnect = function () {
|
var onDisconnect = function () {
|
||||||
setEditable(false);
|
setEditable(false);
|
||||||
// TODO toolar.failed?
|
|
||||||
APP.toolbar.failed();
|
|
||||||
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
|
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
var onReconnect = function (info) {
|
var onReconnect = function () {
|
||||||
setEditable(true);
|
setEditable(true);
|
||||||
// TODO: reconnecting??
|
|
||||||
APP.toolbar.reconnecting(info.myId);
|
|
||||||
Cryptpad.findOKButton().click();
|
Cryptpad.findOKButton().click();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -934,14 +892,14 @@ define([
|
|||||||
displayed: ['title', 'useradmin', 'spinner', 'share', 'userlist', 'newpad', 'limit'],
|
displayed: ['title', 'useradmin', 'spinner', 'share', 'userlist', 'newpad', 'limit'],
|
||||||
title: Title.getTitleConfig(),
|
title: Title.getTitleConfig(),
|
||||||
metadataMgr: metadataMgr,
|
metadataMgr: metadataMgr,
|
||||||
readOnly: readOnly,
|
readOnly: APP.readOnly,
|
||||||
realtime: info.realtime,
|
realtime: info.realtime,
|
||||||
common: Cryptpad,
|
common: Cryptpad,
|
||||||
sfCommon: common,
|
sfCommon: common,
|
||||||
$container: APP.$bar,
|
$container: APP.$bar,
|
||||||
$contentContainer: APP.$content
|
$contentContainer: APP.$content
|
||||||
};
|
};
|
||||||
var toolbar = APP.toolbar = Toolbar.create(configTb);
|
APP.toolbar = Toolbar.create(configTb);
|
||||||
|
|
||||||
Title.setToolbar(APP.toolbar);
|
Title.setToolbar(APP.toolbar);
|
||||||
|
|
||||||
@ -951,32 +909,35 @@ define([
|
|||||||
var md = copyObject(metadataMgr.getMetadata());
|
var md = copyObject(metadataMgr.getMetadata());
|
||||||
APP.proxy.metadata = md;
|
APP.proxy.metadata = md;
|
||||||
});
|
});
|
||||||
return; // TODO
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* add a forget button */
|
/* add a forget button */
|
||||||
var forgetCb = function (err) {
|
var forgetCb = function (err) {
|
||||||
if (err) { return; }
|
if (err) { return; }
|
||||||
setEditable(false);
|
setEditable(false);
|
||||||
};
|
};
|
||||||
var $forgetPad = Cryptpad.createButton('forget', true, {}, forgetCb);
|
var $forgetPad = common.createButton('forget', true, {}, forgetCb);
|
||||||
$rightside.append($forgetPad);
|
$rightside.append($forgetPad);
|
||||||
|
|
||||||
// set the hash
|
|
||||||
if (!readOnly) { Cryptpad.replaceHash(editHash); }
|
|
||||||
|
|
||||||
/* save as template */
|
/* save as template */
|
||||||
if (!Cryptpad.isTemplate(window.location.href)) {
|
if (!metadataMgr.getPrivateData().isTemplate) {
|
||||||
var templateObj = {
|
var templateObj = {
|
||||||
rt: info.realtime,
|
rt: info.realtime,
|
||||||
Crypt: Cryptget,
|
getTitle: function () { return metadataMgr.getMetadata().title; }
|
||||||
getTitle: function () { return document.title; }
|
|
||||||
};
|
};
|
||||||
var $templateButton = Cryptpad.createButton('template', true, templateObj);
|
var $templateButton = common.createButton('template', true, templateObj);
|
||||||
$rightside.append($templateButton);
|
$rightside.append($templateButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var $help = common.createButton().click(function () { showHelp(); }).appendTo($rightside);
|
||||||
|
APP.$helpButton = $help;
|
||||||
|
updateHelpButton();
|
||||||
|
|
||||||
|
if (APP.readOnly) { publish(true); return; }
|
||||||
|
var $publish = common.createButton()
|
||||||
|
.removeClass('fa-question').addClass('fa-check')
|
||||||
|
.click(function () { publish(!APP.proxy.published); }).appendTo($rightside);
|
||||||
|
APP.$publishButton = $publish;
|
||||||
|
updatePublishButton();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -998,7 +959,7 @@ define([
|
|||||||
}
|
}
|
||||||
metadataMgr.onChange(function () {
|
metadataMgr.onChange(function () {
|
||||||
if (typeof(metadataMgr.getPrivateData().readOnly) === 'boolean') {
|
if (typeof(metadataMgr.getPrivateData().readOnly) === 'boolean') {
|
||||||
readOnly = metadataMgr.getPrivateData().readOnly;
|
APP.readOnly = metadataMgr.getPrivateData().readOnly;
|
||||||
privReady();
|
privReady();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1018,11 +979,10 @@ define([
|
|||||||
logLevel: 1
|
logLevel: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
if (readOnly) {
|
if (APP.readOnly) {
|
||||||
$('#cp-app-poll-create-user, #cp-app-poll-create-option, #cp-app-poll-action-publish, #cp-app-poll-action-admin').remove();
|
$('#cp-app-poll-create-user, #cp-app-poll-create-option').remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
var metadataMgr;
|
|
||||||
var rt = APP.rt = Listmap.create(listmapConfig);
|
var rt = APP.rt = Listmap.create(listmapConfig);
|
||||||
APP.proxy = rt.proxy;
|
APP.proxy = rt.proxy;
|
||||||
|
|
||||||
@ -1032,7 +992,7 @@ define([
|
|||||||
if (e) { console.error(e); }
|
if (e) { console.error(e); }
|
||||||
if (!userid) { userid = Render.coluid(); }
|
if (!userid) { userid = Render.coluid(); }
|
||||||
APP.userid = userid;
|
APP.userid = userid;
|
||||||
onReady(info, userid, readOnly);
|
onReady(info, userid);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.on('disconnect', onDisconnect)
|
.on('disconnect', onDisconnect)
|
||||||
@ -1049,13 +1009,6 @@ define([
|
|||||||
showHelp(false);
|
showHelp(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*Cryptpad.onError(function (info) {
|
|
||||||
if (info && info.type === "store") {
|
|
||||||
onConnectError();
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
//Cryptpad.onLogout(function () { setEditable(false); });
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
main();
|
main();
|
||||||
|
|||||||
@ -5,7 +5,7 @@ define([
|
|||||||
'jquery',
|
'jquery',
|
||||||
'/common/requireconfig.js',
|
'/common/requireconfig.js',
|
||||||
'/common/sframe-common-outer.js',
|
'/common/sframe-common-outer.js',
|
||||||
], function (nThen, ApiConfig, $, RequireConfig, SFCommonO, Cryptpad, Netflux) {
|
], function (nThen, ApiConfig, $, RequireConfig, SFCommonO) {
|
||||||
var requireConfig = RequireConfig();
|
var requireConfig = RequireConfig();
|
||||||
|
|
||||||
// Loaded in load #2
|
// Loaded in load #2
|
||||||
|
|||||||
@ -287,7 +287,7 @@ var Renderer = function (Cryptpad) {
|
|||||||
var makeBookmarkElement = Render.makeBookmarkElement = function (id) {
|
var makeBookmarkElement = Render.makeBookmarkElement = function (id) {
|
||||||
return ['SPAN', {
|
return ['SPAN', {
|
||||||
'data-rt-id': id,
|
'data-rt-id': id,
|
||||||
'title': 'TODO: Bookmark this column so that it is always unlocked and displayed at the beginning for you.',
|
'title': Cryptpad.Messages.poll_bookmark_col,
|
||||||
'style': 'visibility: hidden;',
|
'style': 'visibility: hidden;',
|
||||||
class: 'cp-app-poll-table-bookmark fa fa-bookmark-o',
|
class: 'cp-app-poll-table-bookmark fa fa-bookmark-o',
|
||||||
}, []];
|
}, []];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user