Merge duplicated code between framework and whiteboard
This commit is contained in:
parent
7ca45eac72
commit
18a4d2a72c
@ -2639,7 +2639,6 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// XXX add txid
|
|
||||||
UIElements.initFilePicker = function (common, cfg) {
|
UIElements.initFilePicker = function (common, cfg) {
|
||||||
var onSelect = cfg.onSelect || $.noop;
|
var onSelect = cfg.onSelect || $.noop;
|
||||||
var sframeChan = common.getSframeChannel();
|
var sframeChan = common.getSframeChannel();
|
||||||
|
|||||||
@ -525,18 +525,23 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
$embedButton = common.createButton('mediatag', true).click(function () {
|
$embedButton = common.createButton('mediatag', true).click(function () {
|
||||||
common.openFilePicker({
|
var cfg = {
|
||||||
types: ['file'],
|
types: ['file'],
|
||||||
where: ['root']
|
where: ['root']
|
||||||
});
|
};
|
||||||
|
if ($embedButton.data('filter')) {
|
||||||
|
cfg.filter = $embedButton.data('filter');
|
||||||
|
}
|
||||||
|
common.openFilePicker(cfg);
|
||||||
}).appendTo(toolbar.$rightside).hide();
|
}).appendTo(toolbar.$rightside).hide();
|
||||||
};
|
};
|
||||||
var setMediaTagEmbedder = function (mte) {
|
var setMediaTagEmbedder = function (mte, filter) {
|
||||||
if (!common.isLoggedIn()) { return; }
|
if (!common.isLoggedIn()) { return; }
|
||||||
if (!mte || readOnly) {
|
if (!mte || readOnly) {
|
||||||
$embedButton.hide();
|
$embedButton.hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (filter) { $embedButton.data('filter', filter); }
|
||||||
$embedButton.show();
|
$embedButton.show();
|
||||||
mediaTagEmbedder = mte;
|
mediaTagEmbedder = mte;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -399,34 +399,18 @@ define([
|
|||||||
}).appendTo($rightside);
|
}).appendTo($rightside);
|
||||||
|
|
||||||
if (framework._.sfCommon.isLoggedIn()) {
|
if (framework._.sfCommon.isLoggedIn()) {
|
||||||
var fileDialogCfg = {
|
framework.setMediaTagEmbedder(function ($mt) {
|
||||||
onSelect: function (data) {
|
framework._.sfCommon.displayMediatagImage($mt, function (err, $image) {
|
||||||
if (data.type === 'file') {
|
// Convert src from blob URL to base64 data URL
|
||||||
var mt = '<media-tag src="' + data.src + '" data-crypto-key="cryptpad:' + data.key + '"></media-tag>';
|
Util.blobURLToImage($image.attr('src'), function (imgSrc) {
|
||||||
framework._.sfCommon.displayMediatagImage($(mt), function (err, $image) {
|
var img = new Image();
|
||||||
// Convert src from blob URL to base64 data URL
|
img.onload = function () { addImageToCanvas(img); };
|
||||||
// XXX base64 is heavy...
|
img.src = imgSrc;
|
||||||
Util.blobURLToImage($image.attr('src'), function (imgSrc) {
|
});
|
||||||
var img = new Image();
|
});
|
||||||
img.onload = function () { addImageToCanvas(img); };
|
}, {
|
||||||
img.src = imgSrc;
|
fileType: ['image/']
|
||||||
});
|
});
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
framework._.sfCommon.initFilePicker(fileDialogCfg);
|
|
||||||
framework._.sfCommon.createButton('mediatag', true).click(function () {
|
|
||||||
var pickerCfg = {
|
|
||||||
types: ['file'],
|
|
||||||
where: ['root'],
|
|
||||||
filter: {
|
|
||||||
fileType: ['image/']
|
|
||||||
}
|
|
||||||
};
|
|
||||||
framework._.sfCommon.openFilePicker(pickerCfg);
|
|
||||||
}).appendTo($rightside);
|
|
||||||
|
|
||||||
// Export to drive as PNG
|
// Export to drive as PNG
|
||||||
framework._.sfCommon.createButton('savetodrive', true, {}).click(function () {
|
framework._.sfCommon.createButton('savetodrive', true, {}).click(function () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user