From 65ccfe39ef017f4db1c9ac1f6169eb6b3b0e54c6 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 9 Jan 2018 12:02:56 +0100 Subject: [PATCH] Add a 'properties' button in pads to display pad data --- .../src/less2/include/alertify.less | 5 + customize.dist/translations/messages.fr.js | 3 + customize.dist/translations/messages.js | 3 + www/common/common-ui-elements.js | 128 +++++++++++++++++- www/common/sframe-app-framework.js | 3 + www/drive/inner.js | 82 ++--------- 6 files changed, 150 insertions(+), 74 deletions(-) diff --git a/customize.dist/src/less2/include/alertify.less b/customize.dist/src/less2/include/alertify.less index a75a0bb07..d3bf95360 100644 --- a/customize.dist/src/less2/include/alertify.less +++ b/customize.dist/src/less2/include/alertify.less @@ -125,6 +125,8 @@ width: 100%; } } + display: flex; + flex-flow: column; } width: 100%; @@ -132,6 +134,8 @@ position: relative; top: 50%; transform: translateY(-50%); + max-height: 100%; + display: flex; > * { width: 100%; @@ -148,6 +152,7 @@ padding: @alertify_padding-base; margin-bottom: @alertify_padding-base; margin: 0; + overflow: auto; } input:not(.form-control), textarea { diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index c254c69ee..ad1059b6c 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -144,6 +144,9 @@ define(function () { out.backgroundButtonTitle = 'Changer la couleur de fond de la présentation'; out.colorButtonTitle = 'Changer la couleur du texte en mode présentation'; + out.propertiesButton = "Propriétés"; + out.propertiesButtonTitle = 'Voir les propriétés de ce pad'; + out.printText = "Imprimer"; out.printButton = "Imprimer (Entrée)"; out.printButtonTitle = "Imprimer votre présentation ou l'enregistrer au format PDF"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 5cee6cb97..08d206ca4 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -147,6 +147,9 @@ define(function () { out.backgroundButtonTitle = 'Change the background color in the presentation'; out.colorButtonTitle = 'Change the text color in presentation mode'; + out.propertiesButton = "Properties"; + out.propertiesButtonTitle = 'Get pad properties'; + out.printText = "Print"; out.printButton = "Print (enter)"; out.printButtonTitle = "Print your slides or export them as a PDF file"; diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 992f98352..3cd975a65 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -9,9 +9,12 @@ define([ '/common/hyperscript.js', '/common/media-tag.js', '/customize/messages.js', + '/customize/application_config.js', + '/bower_components/nthen/index.js', 'css!/common/tippy.css', -], function ($, Config, Util, Hash, Language, UI, Feedback, h, MediaTag, Messages) { +], function ($, Config, Util, Hash, Language, UI, Feedback, h, MediaTag, Messages, AppConfig, + NThen) { var UIElements = {}; // Configure MediaTags to use our local viewer @@ -54,6 +57,112 @@ define([ }; }; + 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; + })); + }).nThen(function () { + cb(void 0, data); + }); + }; + UIElements.getProperties = function (common, data, cb) { + var $d = $('
'); + $('').text(Messages.fc_prop).appendTo($d); + + if (!data || !data.href) { return void cb(void 0, $d); } + + $('
').appendTo($d); + if (data.href) { + $('