|
|
@ -27,7 +27,7 @@ define([
|
|
|
|
'/bower_components/sortablejs/Sortable.min.js',
|
|
|
|
'/bower_components/sortablejs/Sortable.min.js',
|
|
|
|
|
|
|
|
|
|
|
|
'cm/addon/display/placeholder',
|
|
|
|
'cm/addon/display/placeholder',
|
|
|
|
'cm/mode/markdown/markdown',
|
|
|
|
'cm/mode/gfm/gfm',
|
|
|
|
'css!cm/lib/codemirror.css',
|
|
|
|
'css!cm/lib/codemirror.css',
|
|
|
|
|
|
|
|
|
|
|
|
'css!/bower_components/codemirror/lib/codemirror.css',
|
|
|
|
'css!/bower_components/codemirror/lib/codemirror.css',
|
|
|
@ -88,6 +88,8 @@ define([
|
|
|
|
Messages.form_poll_time = "Time";
|
|
|
|
Messages.form_poll_time = "Time";
|
|
|
|
Messages.form_poll_switch = "Switch axes" // XXX DB
|
|
|
|
Messages.form_poll_switch = "Switch axes" // XXX DB
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Messages.form_pollYourAnswers = "Your answers";
|
|
|
|
|
|
|
|
|
|
|
|
Messages.form_textType = "Text type";
|
|
|
|
Messages.form_textType = "Text type";
|
|
|
|
Messages.form_text_text = "Text";
|
|
|
|
Messages.form_text_text = "Text";
|
|
|
|
Messages.form_text_url = "URL";
|
|
|
|
Messages.form_text_url = "URL";
|
|
|
@ -111,6 +113,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
Messages.form_duplicates = "Duplicate entries have been removed";
|
|
|
|
Messages.form_duplicates = "Duplicate entries have been removed";
|
|
|
|
Messages.form_maxOptions = "{0} answer(s) max";
|
|
|
|
Messages.form_maxOptions = "{0} answer(s) max";
|
|
|
|
|
|
|
|
Messages.form_maxLength = "Characters limit: {0}/{1}";
|
|
|
|
|
|
|
|
|
|
|
|
Messages.form_submit = "Submit";
|
|
|
|
Messages.form_submit = "Submit";
|
|
|
|
Messages.form_update = "Update";
|
|
|
|
Messages.form_update = "Update";
|
|
|
@ -702,9 +705,12 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
// Add answers
|
|
|
|
// Add answers
|
|
|
|
if (Array.isArray(answers)) {
|
|
|
|
if (Array.isArray(answers)) {
|
|
|
|
answers.forEach(function (answer) {
|
|
|
|
answers.forEach(function (answerObj) {
|
|
|
|
if (!answer.name || !answer.values) { return; }
|
|
|
|
var answer = answerObj.results;
|
|
|
|
var _name = answer.name;
|
|
|
|
if (!answer || !answer.values) { return; }
|
|
|
|
|
|
|
|
var name = Util.find(answerObj, ['user', 'name']) || answer.name || Messages.anonymous;
|
|
|
|
|
|
|
|
var avatar = h('span.cp-avatar');
|
|
|
|
|
|
|
|
APP.common.displayAvatar($(avatar), Util.find(answerObj, ['user', 'avatar']), name);
|
|
|
|
var values = answer.values || {};
|
|
|
|
var values = answer.values || {};
|
|
|
|
var els = opts.values.map(function (data) {
|
|
|
|
var els = opts.values.map(function (data) {
|
|
|
|
var res = values[data] || 0;
|
|
|
|
var res = values[data] || 0;
|
|
|
@ -714,7 +720,10 @@ define([
|
|
|
|
}, v);
|
|
|
|
}, v);
|
|
|
|
return cell;
|
|
|
|
return cell;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
els.unshift(h('div.cp-poll-cell.cp-poll-answer-name', _name));
|
|
|
|
els.unshift(h('div.cp-poll-cell.cp-poll-answer-name', [
|
|
|
|
|
|
|
|
avatar,
|
|
|
|
|
|
|
|
h('span', name)
|
|
|
|
|
|
|
|
]));
|
|
|
|
lines.push(h('div', els));
|
|
|
|
lines.push(h('div', els));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -748,7 +757,10 @@ define([
|
|
|
|
return Object.keys(answers || {}).map(function (user) {
|
|
|
|
return Object.keys(answers || {}).map(function (user) {
|
|
|
|
if (filterCurve && user === filterCurve) { return; }
|
|
|
|
if (filterCurve && user === filterCurve) { return; }
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
return answers[user].msg[uid];
|
|
|
|
return {
|
|
|
|
|
|
|
|
user: answers[user].msg._userdata,
|
|
|
|
|
|
|
|
results: answers[user].msg[uid]
|
|
|
|
|
|
|
|
};
|
|
|
|
} catch (e) { console.error(e); }
|
|
|
|
} catch (e) { console.error(e); }
|
|
|
|
}).filter(Boolean);
|
|
|
|
}).filter(Boolean);
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -923,23 +935,46 @@ define([
|
|
|
|
},
|
|
|
|
},
|
|
|
|
get: function (opts, a, n, evOnChange) {
|
|
|
|
get: function (opts, a, n, evOnChange) {
|
|
|
|
if (!opts) { opts = TYPES.textarea.defaultOpts; }
|
|
|
|
if (!opts) { opts = TYPES.textarea.defaultOpts; }
|
|
|
|
var tag = h('textarea', {maxlength: opts.maxLength});
|
|
|
|
var text = h('textarea', {maxlength: opts.maxLength});
|
|
|
|
var $tag = $(tag);
|
|
|
|
var $text = $(text);
|
|
|
|
$tag.on('change keypress', Util.throttle(function () {
|
|
|
|
var charCount = h('div.cp-form-type-textarea-charcount');
|
|
|
|
|
|
|
|
var updateChar = function () {
|
|
|
|
|
|
|
|
var l = $text.val().length;
|
|
|
|
|
|
|
|
if (l > opts.maxLength) {
|
|
|
|
|
|
|
|
$text.val($text.val().slice(0, opts.maxLength));
|
|
|
|
|
|
|
|
l = $text.val().length;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$(charCount).text(Messages._getKey('form_maxLength', [
|
|
|
|
|
|
|
|
$text.val().length,
|
|
|
|
|
|
|
|
opts.maxLength
|
|
|
|
|
|
|
|
]));
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
updateChar();
|
|
|
|
|
|
|
|
var tag = h('div.cp-form-type-textarea', [
|
|
|
|
|
|
|
|
text,
|
|
|
|
|
|
|
|
charCount
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var evChange = Util.throttle(function () {
|
|
|
|
evOnChange.fire();
|
|
|
|
evOnChange.fire();
|
|
|
|
}, 500));
|
|
|
|
}, 500);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$text.on('change keypress', function () {
|
|
|
|
|
|
|
|
setTimeout(updateChar);
|
|
|
|
|
|
|
|
evChange();
|
|
|
|
|
|
|
|
});
|
|
|
|
var cursorGetter;
|
|
|
|
var cursorGetter;
|
|
|
|
var setCursorGetter = function (f) { cursorGetter = f; };
|
|
|
|
var setCursorGetter = function (f) { cursorGetter = f; };
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
tag: tag,
|
|
|
|
tag: tag,
|
|
|
|
getValue: function () { return $tag.val(); },
|
|
|
|
getValue: function () { return $text.val().slice(0, opts.maxLength); },
|
|
|
|
setValue: function (val) { $tag.val(val); },
|
|
|
|
setValue: function (val) { $text.val(val); },
|
|
|
|
edit: function (cb, tmp) {
|
|
|
|
edit: function (cb, tmp) {
|
|
|
|
var v = Util.clone(opts);
|
|
|
|
var v = Util.clone(opts);
|
|
|
|
return editTextOptions(v, setCursorGetter, cb, tmp);
|
|
|
|
return editTextOptions(v, setCursorGetter, cb, tmp);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
getCursor: function () { return cursorGetter(); },
|
|
|
|
getCursor: function () { return cursorGetter(); },
|
|
|
|
reset: function () { $tag.val(''); }
|
|
|
|
reset: function () { $text.val(''); }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
printResults: function (answers, uid) {
|
|
|
|
printResults: function (answers, uid) {
|
|
|
@ -1395,7 +1430,8 @@ define([
|
|
|
|
return cell;
|
|
|
|
return cell;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// Name input
|
|
|
|
// Name input
|
|
|
|
var nameInput = h('input', { value: username || Messages.anonymous });
|
|
|
|
//var nameInput = h('input', { value: username || Messages.anonymous });
|
|
|
|
|
|
|
|
var nameInput = h('span.cp-poll-your-answers', Messages.form_pollYourAnswers)
|
|
|
|
addLine.unshift(h('div.cp-poll-cell', nameInput));
|
|
|
|
addLine.unshift(h('div.cp-poll-cell', nameInput));
|
|
|
|
lines.push(h('div', addLine));
|
|
|
|
lines.push(h('div', addLine));
|
|
|
|
|
|
|
|
|
|
|
@ -1408,13 +1444,11 @@ define([
|
|
|
|
tag: tag,
|
|
|
|
tag: tag,
|
|
|
|
getValue: function () {
|
|
|
|
getValue: function () {
|
|
|
|
var res = {};
|
|
|
|
var res = {};
|
|
|
|
var name = $(nameInput).val().trim() || Messages.anonymous;
|
|
|
|
|
|
|
|
$tag.find('.cp-form-poll-choice').each(function (i, el) {
|
|
|
|
$tag.find('.cp-form-poll-choice').each(function (i, el) {
|
|
|
|
var $el = $(el);
|
|
|
|
var $el = $(el);
|
|
|
|
res[$el.data('option')] = $el.attr('data-value');
|
|
|
|
res[$el.data('option')] = $el.attr('data-value');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
name: name,
|
|
|
|
|
|
|
|
values: res
|
|
|
|
values: res
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -1428,9 +1462,8 @@ define([
|
|
|
|
getCursor: function () { return cursorGetter(); },
|
|
|
|
getCursor: function () { return cursorGetter(); },
|
|
|
|
setValue: function (res) {
|
|
|
|
setValue: function (res) {
|
|
|
|
this.reset();
|
|
|
|
this.reset();
|
|
|
|
if (!res || !res.values || !res.name) { return; }
|
|
|
|
if (!res || !res.values) { return; }
|
|
|
|
var val = res.values;
|
|
|
|
var val = res.values;
|
|
|
|
$(nameInput).val(res.name);
|
|
|
|
|
|
|
|
$tag.find('.cp-form-poll-choice').each(function (i, el) {
|
|
|
|
$tag.find('.cp-form-poll-choice').each(function (i, el) {
|
|
|
|
if (!el._setValue) { return; }
|
|
|
|
if (!el._setValue) { return; }
|
|
|
|
var $el = $(el);
|
|
|
|
var $el = $(el);
|
|
|
@ -2014,7 +2047,7 @@ define([
|
|
|
|
framework._.cpNfInner.chainpad.onSettle(function () {
|
|
|
|
framework._.cpNfInner.chainpad.onSettle(function () {
|
|
|
|
$(editButtons).show();
|
|
|
|
$(editButtons).show();
|
|
|
|
UI.log(Messages.saved);
|
|
|
|
UI.log(Messages.saved);
|
|
|
|
var _answers = getBlockAnswers(APP.answers, uid);
|
|
|
|
_answers = getBlockAnswers(APP.answers, uid);
|
|
|
|
data = model.get(newOpts, _answers, null, evOnChange);
|
|
|
|
data = model.get(newOpts, _answers, null, evOnChange);
|
|
|
|
if (!data) { data = {}; }
|
|
|
|
if (!data) { data = {}; }
|
|
|
|
$oldTag.before(data.tag).remove();
|
|
|
|
$oldTag.before(data.tag).remove();
|
|
|
@ -2097,6 +2130,8 @@ define([
|
|
|
|
var right = h('button.btn.btn-secondary.cp-next', [
|
|
|
|
var right = h('button.btn.btn-secondary.cp-next', [
|
|
|
|
h('i.fa.fa-arrow-right'),
|
|
|
|
h('i.fa.fa-arrow-right'),
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
if (current === pages) { $(right).css('visibility', 'hidden'); }
|
|
|
|
|
|
|
|
if (current === 1) { $(left).css('visibility', 'hidden'); }
|
|
|
|
$(left).click(function () { refreshPage(current - 1); });
|
|
|
|
$(left).click(function () { refreshPage(current - 1); });
|
|
|
|
$(right).click(function () { refreshPage(current + 1); });
|
|
|
|
$(right).click(function () { refreshPage(current + 1); });
|
|
|
|
$page.append([left, state, right]);
|
|
|
|
$page.append([left, state, right]);
|
|
|
|