From 264f7dc6a166540717179d8ce18228de726ed803 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 30 Aug 2018 11:21:33 +0200 Subject: [PATCH] Move base64 migration prompt to corner and only when the pad is stored --- customize.dist/src/less2/include/corner.less | 4 ++ customize.dist/translations/messages.js | 1 + www/common/common-interface.js | 9 +++- www/common/common-ui-elements.js | 7 +-- www/pad/inner.js | 52 ++++++++++++-------- 5 files changed, 46 insertions(+), 27 deletions(-) diff --git a/customize.dist/src/less2/include/corner.less b/customize.dist/src/less2/include/corner.less index fb8113907..174c27eef 100644 --- a/customize.dist/src/less2/include/corner.less +++ b/customize.dist/src/less2/include/corner.less @@ -81,6 +81,10 @@ line-height: 200px; } } + &.cp-corner-big { + width: 400px; + height: 250px; + } .cp-corner-actions { min-height: 30px; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 1fd16f894..367411e27 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -222,6 +222,7 @@ define(function () { out.notifyRenamed = "{0} is now known as {1}"; out.notifyLeft = "{0} has left the collaborative session"; + out.ok = 'OK'; out.okButton = 'OK (enter)'; out.cancel = "Cancel"; diff --git a/www/common/common-interface.js b/www/common/common-interface.js index 4ec28b5f6..b33767f48 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -879,7 +879,9 @@ define([ UI.createRadio = Pages.createRadio; - UI.cornerPopup = function (text, actions, footer, startHidden) { + UI.cornerPopup = function (text, actions, footer, opts) { + opts = opts || {}; + var minimize = h('div.cp-corner-minimize.fa.fa-window-minimize'); var maximize = h('div.cp-corner-maximize.fa.fa-window-maximize'); var popup = h('div.cp-corner-container', [ @@ -902,9 +904,12 @@ define([ $(popup).removeClass('cp-minimized'); }); - if (startHidden) { + if (opts.hidden) { $(popup).addClass('cp-minimized'); } + if (opts.big) { + $(popup).addClass('cp-corner-big'); + } var hide = function () { $(popup).hide(); diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 0f8d31333..a47167e99 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -2335,13 +2335,10 @@ define([ var hide = h('button.cp-corner-cancel', Messages.autostore_hide); var store = h('button.cp-corner-primary', Messages.autostore_store); - var actions = h('div', [ - store, - hide, - ]); + var actions = h('div', [store, hide]); var initialHide = data && data.autoStore && data.autoStore === -1; - var modal = UI.cornerPopup(text, actions, footer, initialHide); + var modal = UI.cornerPopup(text, actions, footer, {hidden: initialHide}); $(modal.popup).find('.cp-corner-footer a').click(function (e) { e.preventDefault(); diff --git a/www/pad/inner.js b/www/pad/inner.js index 0c896d3ca..2356475d6 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -31,6 +31,7 @@ define([ '/common/common-hash.js', '/common/common-util.js', '/common/common-interface.js', + '/common/hyperscript.js', '/bower_components/chainpad/chainpad.dist.js', '/customize/application_config.js', '/common/test.js', @@ -54,6 +55,7 @@ define([ Hash, Util, UI, + h, ChainPad, AppConfig, Test @@ -588,27 +590,37 @@ define([ } }); - var b64images = $(inner).find('img[src^="data:image"]:not(.cke_reset)'); - if (b64images.length) { - UI.confirm(Messages.pad_base64, function (yes) { - if (!yes) { return; } - b64images.each(function (i, el) { - var src = $(el).attr('src'); - var blob = Util.dataURIToBlob(src); - var ext = '.' + (blob.type.split('/')[1] || 'png'); - var name = framework._.title.getTitle()+'_image' || 'Pad_image'; - blob.name = name + ext; - var ev = { - insertElement: function (newEl) { - var element = new window.CKEDITOR.dom.element(el); - newEl.replace(element); - setTimeout(framework.localChange); - } - }; - window.APP.FM.handleFile(blob, ev); + framework._.sfCommon.isPadStored(function (err, val) { + if (!val) { return; } + var b64images = $(inner).find('img[src^="data:image"]:not(.cke_reset)'); + if (b64images.length && framework._.sfCommon.isLoggedIn()) { + var no = h('button.cp-corner-cancel', Messages.cancel); + var yes = h('button.cp-corner-primary', Messages.ok); + var actions = h('div', [yes, no]); + var modal = UI.cornerPopup(Messages.pad_base64, actions, '', {big: true}); + $(no).click(function () { + modal.delete(); }); - }); - } + $(yes).click(function () { + modal.delete(); + b64images.each(function (i, el) { + var src = $(el).attr('src'); + var blob = Util.dataURIToBlob(src); + var ext = '.' + (blob.type.split('/')[1] || 'png'); + var name = (framework._.title.getTitle() || 'Pad')+'_image'; + blob.name = name + ext; + var ev = { + insertElement: function (newEl) { + var element = new window.CKEDITOR.dom.element(el); + newEl.replace(element); + setTimeout(framework.localChange); + } + }; + window.APP.FM.handleFile(blob, ev); + }); + }); + } + }); /*setTimeout(function () { $('iframe.cke_wysiwyg_frame').focus(); editor.focus();