Save button in the pad creation screen

pull/1/head
yflory 7 years ago
parent a4a6385e86
commit 753b7550ca

@ -75,7 +75,7 @@
} }
} }
.cp-creation-create { .cp-creation-create, .cp-creation-settings {
button { button {
.tools_unselectable(); .tools_unselectable();
padding: 15px; padding: 15px;
@ -84,6 +84,7 @@
margin: 3px 10px; margin: 3px 10px;
border: none; border: none;
cursor: pointer; cursor: pointer;
outline: none;
&:hover { &:hover {
background: darken(@colortheme_loading-bg, 5%); background: darken(@colortheme_loading-bg, 5%);
} }
@ -159,6 +160,9 @@
color: lighten(#0275d8, 10%); color: lighten(#0275d8, 10%);
} }
} }
&> span.fa {
margin-left: 15px;
}
} }
.cp-creation-deleted { .cp-creation-deleted {
background: #111; background: #111;

@ -857,6 +857,7 @@ define(function () {
out.creation_createFromTemplate = "Depuis un modèle"; out.creation_createFromTemplate = "Depuis un modèle";
out.creation_createFromScratch = "Nouveau pad vide"; out.creation_createFromScratch = "Nouveau pad vide";
out.creation_settings = "Préférences des nouveaux pads"; out.creation_settings = "Préférences des nouveaux pads";
out.creation_saveSettings = "Sauver les préférences";
// Properties about creation data // Properties about creation data
out.creation_owners = "Propriétaires"; out.creation_owners = "Propriétaires";
out.creation_ownedByOther = "Possédé par un autre utilisateur"; out.creation_ownedByOther = "Possédé par un autre utilisateur";

@ -895,6 +895,7 @@ define(function () {
out.creation_createFromTemplate = "From template"; out.creation_createFromTemplate = "From template";
out.creation_createFromScratch = "From scratch"; out.creation_createFromScratch = "From scratch";
out.creation_settings = "New Pad settings"; out.creation_settings = "New Pad settings";
out.creation_saveSettings = "Save settings";
// Properties about creation data // Properties about creation data
out.creation_owners = "Owners"; out.creation_owners = "Owners";
out.creation_ownedByOther = "Owned by another user"; out.creation_ownedByOther = "Owned by another user";

@ -1839,8 +1839,7 @@ define([
UIElements.setExpirationValue(cfg.expire, $creation); UIElements.setExpirationValue(cfg.expire, $creation);
// Create the pad // Create the pad
var create = function (template) { var getFormValues = function (template) {
$creationContainer.remove();
// Type of pad // Type of pad
var ownedVal = parseInt($('input[name="cp-creation-owned"]:checked').val()); var ownedVal = parseInt($('input[name="cp-creation-owned"]:checked').val());
// Life time // Life time
@ -1856,11 +1855,16 @@ define([
expireVal = ($('#cp-creation-expire-val').val() || 0) * unit; expireVal = ($('#cp-creation-expire-val').val() || 0) * unit;
} }
common.createPad({ return {
owned: ownedVal, owned: ownedVal,
expire: expireVal, expire: expireVal,
template: template template: template
}, function () { };
};
var create = function (template) {
$creationContainer.remove();
common.createPad(getFormValues(template), function () {
cb(); cb();
}); });
}; };
@ -1905,10 +1909,39 @@ define([
// Settings button // Settings button
var origin = common.getMetadataMgr().getPrivateData().origin; var origin = common.getMetadataMgr().getPrivateData().origin;
$(h('div.cp-creation-settings', h('a', { var $ok = $('<span>', {'class': 'fa fa-check', title: Messages.saved}).hide();
href: origin + '/settings/#creation', var $spinner = $('<span>', {'class': 'fa fa-spinner fa-pulse'}).hide();
target: '_blank' var okTo;
}, Messages.creation_settings))).appendTo($creation); var $saveButton = $('<button>').text(Messages.creation_saveSettings).click(function () {
if (okTo) { clearTimeout(okTo); }
$ok.hide();
$spinner.show();
var val = getFormValues();
NThen(function (waitFor) {
common.setAttribute(['general', 'creation', 'owned'], val.owned, waitFor(function (e) {
if (e) { return void console.error(e); }
}));
common.setAttribute(['general', 'creation', 'expire'], val.expire, waitFor(function (e) {
if (e) { return void console.error(e); }
}));
}).nThen(function () {
$spinner.hide();
$ok.show();
okTo = setTimeout(function () {
$ok.hide();
}, 5000);
});
});
$(h('div.cp-creation-settings', [
$saveButton[0],
h('br'),
h('a', {
href: origin + '/settings/#creation',
target: '_blank'
}, Messages.creation_settings),
$ok[0],
$spinner[0]
])).appendTo($creation);
}; };
UIElements.onServerError = function (common, err, toolbar, cb) { UIElements.onServerError = function (common, err, toolbar, cb) {

Loading…
Cancel
Save