From 93113f5175c1fbc0a75d758de03f9b953d229c1f Mon Sep 17 00:00:00 2001 From: Fredrik Karlsson Date: Tue, 20 Oct 2020 14:49:13 +0200 Subject: [PATCH] Added open to field-file dropdown menu --- modules/Cockpit/assets/components.js | 16 +++++++++++++++- modules/Cockpit/assets/components/field-file.tag | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/modules/Cockpit/assets/components.js b/modules/Cockpit/assets/components.js index 49e66b2c0..aa80ca13c 100755 --- a/modules/Cockpit/assets/components.js +++ b/modules/Cockpit/assets/components.js @@ -2263,7 +2263,7 @@ riot.tag2('field-date', '
 
', '', '', function(opts) { +riot.tag2('field-file', '
 
', '', '', function(opts) { var $this = this, $input; @@ -2336,6 +2336,20 @@ riot.tag2('field-file', '
0; + }.bind(this) + + this.open = function() { + var url = $this.refs.input.value.trim(); + if (url) { + if (!url.match(/^(https?:)?\/\/?/i)) { + url = SITE_URL + "/" + url; + } + var win = window.open(url, '_blank'); + win.focus(); + } + }.bind(this) }); riot.tag2('field-gallery', '
 

{App.i18n.get(\'Gallery is empty\')}

{App.i18n.get(\'Image Meta\')}

{field.info || \' \'}
', '', '', function(opts) { diff --git a/modules/Cockpit/assets/components/field-file.tag b/modules/Cockpit/assets/components/field-file.tag index e6080734b..f5949343e 100755 --- a/modules/Cockpit/assets/components/field-file.tag +++ b/modules/Cockpit/assets/components/field-file.tag @@ -18,6 +18,8 @@