diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 9908dcae6..d73b91692 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -2639,7 +2639,6 @@ define([ }); }; - // XXX add txid UIElements.initFilePicker = function (common, cfg) { var onSelect = cfg.onSelect || $.noop; var sframeChan = common.getSframeChannel(); diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js index a90877ff1..ff3de520d 100644 --- a/www/common/sframe-app-framework.js +++ b/www/common/sframe-app-framework.js @@ -525,18 +525,23 @@ define([ } }); $embedButton = common.createButton('mediatag', true).click(function () { - common.openFilePicker({ + var cfg = { types: ['file'], where: ['root'] - }); + }; + if ($embedButton.data('filter')) { + cfg.filter = $embedButton.data('filter'); + } + common.openFilePicker(cfg); }).appendTo(toolbar.$rightside).hide(); }; - var setMediaTagEmbedder = function (mte) { + var setMediaTagEmbedder = function (mte, filter) { if (!common.isLoggedIn()) { return; } if (!mte || readOnly) { $embedButton.hide(); return; } + if (filter) { $embedButton.data('filter', filter); } $embedButton.show(); mediaTagEmbedder = mte; }; diff --git a/www/whiteboard/inner.js b/www/whiteboard/inner.js index 80ab8408f..5dd436909 100644 --- a/www/whiteboard/inner.js +++ b/www/whiteboard/inner.js @@ -399,34 +399,18 @@ define([ }).appendTo($rightside); if (framework._.sfCommon.isLoggedIn()) { - var fileDialogCfg = { - onSelect: function (data) { - if (data.type === 'file') { - var mt = ''; - framework._.sfCommon.displayMediatagImage($(mt), function (err, $image) { - // Convert src from blob URL to base64 data URL - // XXX base64 is heavy... - Util.blobURLToImage($image.attr('src'), function (imgSrc) { - var img = new Image(); - img.onload = function () { addImageToCanvas(img); }; - img.src = imgSrc; - }); - }); - 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); + framework.setMediaTagEmbedder(function ($mt) { + framework._.sfCommon.displayMediatagImage($mt, function (err, $image) { + // Convert src from blob URL to base64 data URL + Util.blobURLToImage($image.attr('src'), function (imgSrc) { + var img = new Image(); + img.onload = function () { addImageToCanvas(img); }; + img.src = imgSrc; + }); + }); + }, { + fileType: ['image/'] + }); // Export to drive as PNG framework._.sfCommon.createButton('savetodrive', true, {}).click(function () {