From 1943c83f699d675b108839ed988f969b4ed177ec Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 11 Sep 2017 16:24:43 +0200 Subject: [PATCH 1/4] clean up api for Cryptpad.confirm --- www/common/common-interface.js | 6 +++--- www/register/main.js | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/www/common/common-interface.js b/www/common/common-interface.js index 654c140e8..bd36edb07 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -285,7 +285,7 @@ define([ }); }; - UI.confirm = function (msg, cb, opt, force, styleCB) { + UI.confirm = function (msg, cb, opt, force) { cb = cb || function () {}; opt = opt || {}; @@ -328,8 +328,8 @@ define([ document.body.appendChild(frame); setTimeout(function () { UI.notify(); - if (typeof(styleCB) === 'function') { - styleCB($ok.closest('.dialog')); + if (typeof(opt.done) === 'function') { + opt.done($ok.closest('.dialog')); } }); }; diff --git a/www/register/main.js b/www/register/main.js index 86d0d9b14..d302a0634 100644 --- a/www/register/main.js +++ b/www/register/main.js @@ -217,9 +217,10 @@ define([ cancelClass: 'safe', okClass: 'danger', reverseOrder: true, - }, true, function ($dialog) { - $dialog.find('> div').addClass('half'); - }); + done: function ($dialog) { + $dialog.find('> div').addClass('half'); + }, + }, true); }, 150); }); From 306fec2d0e61cea9a5d591a3fd2f740e5446566d Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 11 Sep 2017 16:25:58 +0200 Subject: [PATCH 2/4] improve messages for template picker confirm --- customize.dist/translations/messages.js | 4 +++- www/common/sframe-common-interface.js | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 5415ae147..6a6becf5b 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -131,7 +131,9 @@ define(function () { out.saveTemplatePrompt = "Choose a title for the template"; out.templateSaved = "Template saved!"; out.selectTemplate = "Select a template or press escape"; - out.useTemplate = "You have available templates for that type of pad. Do you want to use one?"; + out.useTemplate = "Start with a template?"; //Would you like to "You have available templates for this type of pad. Do you want to use one?"; + out.useTemplateOK = 'Pick a template (Enter)'; + out.useTemplateCancel = 'Start fresh (Esc)'; out.previewButtonTitle = "Display or hide the Markdown preview mode"; diff --git a/www/common/sframe-common-interface.js b/www/common/sframe-common-interface.js index 7ca161528..0b63bb586 100644 --- a/www/common/sframe-common-interface.js +++ b/www/common/sframe-common-interface.js @@ -490,7 +490,10 @@ define([ sframeChan.query("Q_TEMPLATE_EXIST", type, function (err, data) { if (data) { - Cryptpad.confirm(Messages.useTemplate, onConfirm); + Cryptpad.confirm(Messages.useTemplate, onConfirm, { + ok: Messages.useTemplateOK, + cancel: Messages.useTemplateCancel, + }); } }); }; From 58c38dd77b9c1e3fe55ed62443c72758f31e3131 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 11 Sep 2017 16:34:00 +0200 Subject: [PATCH 3/4] focus on the current window when you pop an alert --- www/common/common-interface.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/common/common-interface.js b/www/common/common-interface.js index bd36edb07..b93e57de3 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -237,6 +237,7 @@ define([ setTimeout(function () { $ok.focus(); UI.notify(); + if (!document.hasFocus()) { window.focus(); } }); }; @@ -282,6 +283,7 @@ define([ setTimeout(function () { input.select().focus(); UI.notify(); + if (!document.hasFocus()) { window.focus(); } }); }; @@ -331,6 +333,7 @@ define([ if (typeof(opt.done) === 'function') { opt.done($ok.closest('.dialog')); } + if (!document.hasFocus()) { window.focus(); } }); }; From 79094aa4bb83a721dc5fd265870bd9fdedb3f97e Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 11 Sep 2017 16:36:24 +0200 Subject: [PATCH 4/4] Fix closing the title input when the title is not modified --- www/common/sframe-common-title.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/sframe-common-title.js b/www/common/sframe-common-title.js index 61a5fb46e..3df144b0e 100644 --- a/www/common/sframe-common-title.js +++ b/www/common/sframe-common-title.js @@ -34,7 +34,7 @@ define(['jquery'], function ($) { exp.updateTitle = function (newTitle, cb) { cb = cb || $.noop; - if (newTitle === exp.title) { return; } + if (newTitle === exp.title) { return void cb(); } metadataMgr.updateTitle(newTitle); titleUpdated = cb; };