', { id: 'cp-creation-container' }).appendTo($body);
+ var urlArgs = (Config.requireConf && Config.requireConf.urlArgs) || '';
+ var l = h('div.cp-creation-logo', h('img', { src: '/customize/alt-favicon.png?' + urlArgs }));
+ $(l).appendTo($creationContainer);
var $creation = $('
', { id: 'cp-creation', tabindex: 1 }).appendTo($creationContainer);
// Title
- var colorClass = 'cp-icon-color-'+type;
- $creation.append(h('h2.cp-creation-title', Messages.newButtonTitle));
+ //var colorClass = 'cp-icon-color-'+type;
+ //$creation.append(h('h2.cp-creation-title', Messages.newButtonTitle));
+ $creation.append(h('h3.cp-creation-title', Messages['button_new'+type]));
//$creation.append(h('h2.cp-creation-title.'+colorClass, Messages.newButtonTitle));
// Deleted pad warning
@@ -1874,10 +1869,11 @@ define([
var origin = common.getMetadataMgr().getPrivateData().origin;
var createHelper = function (href, text) {
- var q = h('a.cp-creation-help.fa.fa-question', {
+ var q = h('a.cp-creation-help.fa.fa-question-circle', {
title: text,
href: origin + href,
- target: "_blank"
+ target: "_blank",
+ 'data-tippy-placement': "right"
});
return q;
};
@@ -1885,30 +1881,14 @@ define([
// Owned pads
// Default is Owned pad
var owned = h('div.cp-creation-owned', [
- h('label.cp-checkmark', [
- h('input', {
- type: 'checkbox',
- id: 'cp-creation-owned',
- checked: 'checked'
- }),
- h('span.cp-checkmark-mark'),
- Messages.creation_owned
- ]),
+ UI.createCheckbox('cp-creation-owned', Messages.creation_owned, true),
createHelper('/faq.html#keywords-owned', Messages.creation_owned1)
]);
// Life time
var expire = h('div.cp-creation-expire', [
- h('label.cp-checkmark', [
- h('input', {
- type: 'checkbox',
- id: 'cp-creation-expire'
- }),
- h('span.cp-checkmark-mark'),
- Messages.creation_expire
- ]),
- createHelper('/faq.html#keywords-expiring', Messages.creation_expire2),
- h('div.cp-creation-expire-picker.cp-creation-slider', [
+ UI.createCheckbox('cp-creation-expire', Messages.creation_expire, false),
+ h('span.cp-creation-expire-picker.cp-creation-slider', [
h('input#cp-creation-expire-val', {
type: "number",
min: 1,
@@ -1923,106 +1903,142 @@ define([
selected: 'selected'
}, Messages.creation_expireMonths)
])
- ])
+ ]),
+ createHelper('/faq.html#keywords-expiring', Messages.creation_expire2),
]);
- var createDiv = h('div.cp-creation-create');
- var $create = $(createDiv);
-
+ var right = h('span.fa.fa-chevron-right.cp-creation-template-more');
+ var left = h('span.fa.fa-chevron-left.cp-creation-template-more');
var templates = h('div.cp-creation-template', [
- h('h3.cp-creation-title.'+colorClass, Messages['button_new'+type]),
+ left,
h('div.cp-creation-template-container', [
h('span.fa.fa-circle-o-notch.fa-spin.fa-4x.fa-fw')
]),
- createDiv
+ right
]);
var settings = h('div.cp-creation-remember', [
- h('label.cp-checkmark', [
- h('input', {
- type: 'checkbox',
- id: 'cp-creation-remember'
- }),
- h('span.cp-checkmark-mark'),
- Messages.creation_saveSettings
- ]),
+ UI.createCheckbox('cp-creation-remember', Messages.creation_saveSettings, false),
createHelper('/settings/#creation', Messages.creation_settings),
- h('div.cp-creation-remember-help.cp-creation-slider', Messages.creation_rememberHelp)
+ h('div.cp-creation-remember-help.cp-creation-slider', [
+ h('span.fa.fa-exclamation-circle.cp-creation-warning'),
+ Messages.creation_rememberHelp
+ ])
]);
+ var createDiv = h('div.cp-creation-create');
+ var $create = $(createDiv);
+
$(h('div#cp-creation-form', [
owned,
expire,
settings,
- templates
+ templates,
+ createDiv
])).appendTo($creation);
// Display templates
- var selected = 0;
+
+ var selected = 0; // Selected template in the list (highlighted)
+ var TEMPLATES_DISPLAYED = 4; // Max templates displayed per page
+ var next = function () {}; // Function called when pressing tab to highlight the next template
+ var i = 0; // Index of the first template displayed in the current page
sframeChan.query("Q_CREATE_TEMPLATES", type, function (err, res) {
if (!res.data || !Array.isArray(res.data)) {
return void console.error("Error: get the templates list");
}
- var data = res.data.slice().sort(function (a, b) {
- if (a.name === b.name) { return 0; }
- return a.name < b.name ? -1 : 1;
- });
- data.unshift({
- name: Messages.creation_noTemplate,
- id: 0,
- icon: h('span.fa.fa-file')
+ var allData = res.data.slice().sort(function (a, b) {
+ if (a.used === b.used) {
+ // Sort by name
+ if (a.name === b.name) { return 0; }
+ return a.name < b.name ? -1 : 1;
+ }
+ return b.used - a.used;
});
- data.push({
+ allData.unshift({
name: Messages.creation_newTemplate,
id: -1,
icon: h('span.fa.fa-bookmark')
});
- var $container = $(templates).find('.cp-creation-template-container').html('');
- data.forEach(function (obj, idx) {
- var name = obj.name;
- var $span = $('
', {
- 'class': 'cp-creation-template-element',
- 'title': name,
- }).appendTo($container);
- $span.data('id', obj.id);
- if (idx === 0) { $span.addClass('cp-creation-template-selected'); }
- $span.append(obj.icon || UI.getFileIcon({type: type}));
- $('', {'class': 'cp-creation-template-element-name'}).text(name)
- .appendTo($span);
- $span.click(function () {
- $container.find('.cp-creation-template-selected')
- .removeClass('cp-creation-template-selected');
- $span.addClass('cp-creation-template-selected');
- selected = idx;
- });
+ allData.unshift({
+ name: Messages.creation_noTemplate,
+ id: 0,
+ icon: h('span.fa.fa-file')
+ });
+ var redraw = function (index) {
+ if (index < 0) { i = 0; }
+ else if (index > allData.length - 1) { return; }
+ else { i = index; }
+ var data = allData.slice(i, i + TEMPLATES_DISPLAYED);
+ var $container = $(templates).find('.cp-creation-template-container').html('');
+ data.forEach(function (obj, idx) {
+ var name = obj.name;
+ var $span = $('', {
+ 'class': 'cp-creation-template-element',
+ 'title': name,
+ }).appendTo($container);
+ $span.data('id', obj.id);
+ if (idx === selected) { $span.addClass('cp-creation-template-selected'); }
+ $span.append(obj.icon || UI.getFileIcon({type: type}));
+ $('', {'class': 'cp-creation-template-element-name'}).text(name)
+ .appendTo($span);
+ $span.click(function () {
+ $container.find('.cp-creation-template-selected')
+ .removeClass('cp-creation-template-selected');
+ $span.addClass('cp-creation-template-selected');
+ selected = idx;
+ });
- // Add thumbnail if it exists
- if (obj.thumbnail) {
- common.addThumbnail(obj.thumbnail, $span, function () {});
+ // Add thumbnail if it exists
+ if (obj.thumbnail) {
+ common.addThumbnail(obj.thumbnail, $span, function () {});
+ }
+ });
+ $(right).off('click').removeClass('hidden').click(function () {
+ selected = 0;
+ redraw(i + TEMPLATES_DISPLAYED);
+ });
+ if (i >= allData.length - TEMPLATES_DISPLAYED ) { $(right).addClass('hidden'); }
+ $(left).off('click').removeClass('hidden').click(function () {
+ selected = TEMPLATES_DISPLAYED - 1;
+ redraw(i - TEMPLATES_DISPLAYED);
+ });
+ if (i < TEMPLATES_DISPLAYED) { $(left).addClass('hidden'); }
+ };
+ redraw(0);
+
+ // Change template selection when Tab is pressed
+ next = function (revert) {
+ var max = $creation.find('.cp-creation-template-element').length;
+ if (selected + 1 === max && !revert) {
+ selected = i + TEMPLATES_DISPLAYED < allData.length ? 0 : max;
+ return void redraw(i + TEMPLATES_DISPLAYED);
}
- });
- });
- // Change template selection when Tab is pressed
- var next = function (revert) {
- var max = $creation.find('.cp-creation-template-element').length;
- selected = revert ?
- (--selected < 0 ? max-1 : selected) :
- ++selected % max;
- $creation.find('.cp-creation-template-element')
- .removeClass('cp-creation-template-selected');
- $($creation.find('.cp-creation-template-element').get(selected))
- .addClass('cp-creation-template-selected');
- };
+ if (selected === 0 && revert) {
+ selected = i - TEMPLATES_DISPLAYED >= 0 ? TEMPLATES_DISPLAYED - 1 : 0;
+ return void redraw(i - TEMPLATES_DISPLAYED);
+ }
+ selected = revert ?
+ (--selected < 0 ? 0 : selected) :
+ ++selected >= max ? max-1 : selected;
+ $creation.find('.cp-creation-template-element')
+ .removeClass('cp-creation-template-selected');
+ $($creation.find('.cp-creation-template-element').get(selected))
+ .addClass('cp-creation-template-selected');
+ };
+ });
// Display expiration form when checkbox checked
$creation.find('#cp-creation-expire').on('change', function () {
if ($(this).is(':checked')) {
$creation.find('.cp-creation-expire-picker:not(.active)').addClass('active');
+ $creation.find('.cp-creation-expire:not(.active)').addClass('active');
$creation.find('#cp-creation-expire-val').focus();
return;
}
$creation.find('.cp-creation-expire-picker').removeClass('active');
+ $creation.find('.cp-creation-expire').removeClass('active');
$creation.focus();
});
diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js
index 0a9a27f0d..d4adb1ee0 100644
--- a/www/common/cryptpad-common.js
+++ b/www/common/cryptpad-common.js
@@ -424,6 +424,7 @@ define([
// it allows us to add owners and expiration time if it is a new file
var parsed = Hash.parsePadUrl(href);
if(!parsed) { throw new Error("Cannot get template hash"); }
+ postMessage("INCREMENT_TEMPLATE_USE", href);
Crypt.get(parsed.hash, function (err, val) {
if (err) { throw new Error(err); }
var p = Hash.parsePadUrl(window.location.href);
diff --git a/www/common/loading.js b/www/common/loading.js
index a5f96b62a..c45dabdcd 100644
--- a/www/common/loading.js
+++ b/www/common/loading.js
@@ -1,3 +1,5 @@
+// dark #326599
+// light #4591c4
define([], function () {
var loadingStyle = (function(){/*
#cp-loading {
@@ -9,31 +11,74 @@ define([], function () {
bottom: 0px;
left: 0px;
right: 0px;
- background: #222;
+ background: linear-gradient(to right, #326599 0%, #326599 50%, #4591c4 50%, #4591c4 100%);
color: #fafafa;
- text-align: center;
font-size: 1.5em;
opacity: 1;
+ display: flex;
+ flex-flow: column;
+ justify-content: center;
+ align-items: center;
}
#cp-loading.cp-loading-hidden {
opacity: 0;
visibility: hidden;
}
+#cp-loading .cp-loading-logo {
+ height: 300px;
+ width: 300px;
+ margin-top: 50px;
+ flex: 0 1 auto;
+ min-height: 0;
+ text-align: center;
+}
+#cp-loading .cp-loading-logo img {
+ max-width: 100%;
+ max-height: 100%;
+}
#cp-loading .cp-loading-container {
- margin-top: 50vh;
- transform: translateY(-50%);
+ width: 700px;
+ max-width: 90vw;
+ height: 500px;
+ max-height: calc(100vh - 20px);
+ margin: 50px;
+ flex-shrink: 0;
+ display: flex;
+ flex-flow: column;
+ justify-content: center;
+ align-items: center;
+}
+@media screen and (max-height: 800px) {
+ #cp-loading .cp-loading-container {
+ height: auto;
+ }
+}
+@media screen and (max-width: 600px) {
+ #cp-loading .cp-loading-container {
+ height: auto;
+ }
}
#cp-loading .cp-loading-cryptofist {
margin-left: auto;
margin-right: auto;
- height: 300px;
+ //height: 300px;
+ max-width: 90vw;
+ max-height: 300px;
+ width: auto;
+ height: auto;
margin-bottom: 2em;
}
@media screen and (max-height: 450px) {
#cp-loading .cp-loading-cryptofist {
- display: none;
}
}
+#cp-loading-message {
+ background: #FFF;
+ padding: 20px;
+ width: 100%;
+ color: #000;
+ display: none;
+}
#cp-loading .cp-loading-spinner-container {
position: relative;
height: 100px;
@@ -75,8 +120,10 @@ define([], function () {
'',
+ '',
+ '
',
+ '
',
'',
- '
',
'
',
'',
'
',
diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js
index f3f1e1450..0125e6018 100644
--- a/www/common/outer/async-store.js
+++ b/www/common/outer/async-store.js
@@ -660,6 +660,15 @@ define([
});
cb(res);
};
+ Store.incrementTemplateUse = function (href) {
+ store.userObject.getPadAttribute(href, 'used', function (err, data) {
+ // This is a not critical function, abort in case of error to make sure we won't
+ // create any issue with the user object or the async store
+ if (err) { return; }
+ var used = typeof data === "number" ? ++data : 1;
+ store.userObject.setPadAttribute(href, 'used', used);
+ });
+ };
// Pads
Store.moveToTrash = function (data, cb) {
diff --git a/www/common/outer/store-rpc.js b/www/common/outer/store-rpc.js
index 1043f9dcf..1713d7a2a 100644
--- a/www/common/outer/store-rpc.js
+++ b/www/common/outer/store-rpc.js
@@ -126,6 +126,9 @@ define([
case 'GET_STRONGER_HASH': {
Store.getStrongerHash(data, cb); break;
}
+ case 'INCREMENT_TEMPLATE_USE': {
+ Store.incrementTemplateUse(data); break;
+ }
// Messaging
case 'INVITE_FROM_USERLIST': {
Store.inviteFromUserlist(data, cb); break;
diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js
index 11d20ce56..014914b50 100644
--- a/www/common/sframe-common-outer.js
+++ b/www/common/sframe-common-outer.js
@@ -431,6 +431,8 @@ define([
// File picker
var FP = {};
var initFilePicker = function (cfg) {
+ // cfg.hidden means pre-loading the filepicker while keeping it hidden.
+ // if cfg.hidden is true and the iframe already exists, do nothing
if (!FP.$iframe) {
var config = {};
config.onFilePicked = function (data) {
@@ -449,7 +451,7 @@ define([
};
FP.$iframe = $('