define([ 'jquery', '/api/config', '/common/common-util.js', '/common/common-hash.js', '/common/common-language.js', '/common/common-interface.js', '/common/common-constants.js', '/common/common-feedback.js', '/common/hyperscript.js', '/common/media-tag.js', '/common/clipboard.js', '/customize/messages.js', '/customize/application_config.js', '/bower_components/nthen/index.js', 'css!/common/tippy.css', ], function ($, Config, Util, Hash, Language, UI, Constants, Feedback, h, MediaTag, Clipboard, Messages, AppConfig, NThen) { var UIElements = {}; // Configure MediaTags to use our local viewer if (MediaTag && MediaTag.PdfPlugin) { MediaTag.PdfPlugin.viewer = '/common/pdfjs/web/viewer.html'; } UIElements.updateTags = function (common, href) { var sframeChan = common.getSframeChannel(); sframeChan.query('Q_TAGS_GET', href || null, function (err, res) { if (err || res.error) { if (res.error === 'NO_ENTRY') { UI.alert(Messages.tags_noentry); } return void console.error(err || res.error); } UI.dialog.tagPrompt(res.data, function (tags) { if (!Array.isArray(tags)) { return; } sframeChan.event('EV_TAGS_SET', { tags: tags, href: href, }); }); }); }; var importContent = function (type, f, cfg) { return function () { var $files = $('', {type:"file"}); if (cfg && cfg.accept) { $files.attr('accept', cfg.accept); } $files.click(); $files.on('change', function (e) { var file = e.target.files[0]; var reader = new FileReader(); reader.onload = function (e) { f(e.target.result, file); }; reader.readAsText(file, type); }); }; }; var getPropertiesData = function (common, cb) { var data = {}; NThen(function (waitFor) { common.getPadAttribute('href', waitFor(function (err, val) { var base = common.getMetadataMgr().getPrivateData().origin; var parsed = Hash.parsePadUrl(val); if (parsed.hashData.mode === "view") { data.roHref = base + val; return; } // We're not in a read-only pad data.href = base + val; // Get Read-only href if (parsed.hashData.type !== "pad") { return; } var i = data.href.indexOf('#') + 1; var hBase = data.href.slice(0, i); var hrefsecret = Hash.getSecrets(parsed.type, parsed.hash); if (!hrefsecret.keys) { return; } var viewHash = Hash.getViewHashFromKeys(hrefsecret.channel, hrefsecret.keys); data.roHref = hBase + viewHash; })); common.getPadAttribute('atime', waitFor(function (err, val) { data.atime = val; })); common.getPadAttribute('ctime', waitFor(function (err, val) { data.ctime = val; })); common.getPadAttribute('tags', waitFor(function (err, val) { data.tags = val; })); common.getPadAttribute('owners', waitFor(function (err, val) { data.owners = val; })); common.getPadAttribute('expire', waitFor(function (err, val) { data.expire = val; })); }).nThen(function () { cb(void 0, data); }); }; var getRightsProperties = function (common, data, cb) { var $d = $('
'); if (!data) { return void cb(void 0, $d); } $('