Move base64 migration prompt to corner and only when the pad is stored

pull/1/head
yflory 7 years ago
parent 7b06626581
commit 264f7dc6a1

@ -81,6 +81,10 @@
line-height: 200px; line-height: 200px;
} }
} }
&.cp-corner-big {
width: 400px;
height: 250px;
}
.cp-corner-actions { .cp-corner-actions {
min-height: 30px; min-height: 30px;

@ -222,6 +222,7 @@ define(function () {
out.notifyRenamed = "{0} is now known as {1}"; out.notifyRenamed = "{0} is now known as {1}";
out.notifyLeft = "{0} has left the collaborative session"; out.notifyLeft = "{0} has left the collaborative session";
out.ok = 'OK';
out.okButton = 'OK (enter)'; out.okButton = 'OK (enter)';
out.cancel = "Cancel"; out.cancel = "Cancel";

@ -879,7 +879,9 @@ define([
UI.createRadio = Pages.createRadio; 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 minimize = h('div.cp-corner-minimize.fa.fa-window-minimize');
var maximize = h('div.cp-corner-maximize.fa.fa-window-maximize'); var maximize = h('div.cp-corner-maximize.fa.fa-window-maximize');
var popup = h('div.cp-corner-container', [ var popup = h('div.cp-corner-container', [
@ -902,9 +904,12 @@ define([
$(popup).removeClass('cp-minimized'); $(popup).removeClass('cp-minimized');
}); });
if (startHidden) { if (opts.hidden) {
$(popup).addClass('cp-minimized'); $(popup).addClass('cp-minimized');
} }
if (opts.big) {
$(popup).addClass('cp-corner-big');
}
var hide = function () { var hide = function () {
$(popup).hide(); $(popup).hide();

@ -2335,13 +2335,10 @@ define([
var hide = h('button.cp-corner-cancel', Messages.autostore_hide); var hide = h('button.cp-corner-cancel', Messages.autostore_hide);
var store = h('button.cp-corner-primary', Messages.autostore_store); var store = h('button.cp-corner-primary', Messages.autostore_store);
var actions = h('div', [ var actions = h('div', [store, hide]);
store,
hide,
]);
var initialHide = data && data.autoStore && data.autoStore === -1; 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) { $(modal.popup).find('.cp-corner-footer a').click(function (e) {
e.preventDefault(); e.preventDefault();

@ -31,6 +31,7 @@ define([
'/common/common-hash.js', '/common/common-hash.js',
'/common/common-util.js', '/common/common-util.js',
'/common/common-interface.js', '/common/common-interface.js',
'/common/hyperscript.js',
'/bower_components/chainpad/chainpad.dist.js', '/bower_components/chainpad/chainpad.dist.js',
'/customize/application_config.js', '/customize/application_config.js',
'/common/test.js', '/common/test.js',
@ -54,6 +55,7 @@ define([
Hash, Hash,
Util, Util,
UI, UI,
h,
ChainPad, ChainPad,
AppConfig, AppConfig,
Test Test
@ -588,27 +590,37 @@ define([
} }
}); });
var b64images = $(inner).find('img[src^="data:image"]:not(.cke_reset)'); framework._.sfCommon.isPadStored(function (err, val) {
if (b64images.length) { if (!val) { return; }
UI.confirm(Messages.pad_base64, function (yes) { var b64images = $(inner).find('img[src^="data:image"]:not(.cke_reset)');
if (!yes) { return; } if (b64images.length && framework._.sfCommon.isLoggedIn()) {
b64images.each(function (i, el) { var no = h('button.cp-corner-cancel', Messages.cancel);
var src = $(el).attr('src'); var yes = h('button.cp-corner-primary', Messages.ok);
var blob = Util.dataURIToBlob(src); var actions = h('div', [yes, no]);
var ext = '.' + (blob.type.split('/')[1] || 'png'); var modal = UI.cornerPopup(Messages.pad_base64, actions, '', {big: true});
var name = framework._.title.getTitle()+'_image' || 'Pad_image'; $(no).click(function () {
blob.name = name + ext; modal.delete();
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);
}); });
}); $(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 () { /*setTimeout(function () {
$('iframe.cke_wysiwyg_frame').focus(); $('iframe.cke_wysiwyg_frame').focus();
editor.focus(); editor.focus();

Loading…
Cancel
Save