Fixed: Copy to clipboard not working with calendar feed (#3495)

* Replace flash clipboard implementation with document.execute("copy")

Fixes #3486

* Replace flash clipboard implementation with document.execCommand("copy")

Resolves Radarr/Radarr#3486
This commit is contained in:
Michael Poutre 2019-05-02 03:38:00 -07:00 committed by Leonardo Galli
parent c79578e99f
commit da012eb6b5
7 changed files with 91 additions and 58 deletions

3
.gitignore vendored
View File

@ -177,3 +177,6 @@ packages.config.md5sum
**/.idea/**/*.iml **/.idea/**/*.iml
**/.idea/**/contentModel.xml **/.idea/**/contentModel.xml
**/.idea/**/modules.xml **/.idea/**/modules.xml
# ignore node_modules symlink
node_modules
node_modules.nosync

102
package-lock.json generated
View File

@ -318,6 +318,7 @@
"version": "2.10.1", "version": "2.10.1",
"resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz",
"integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=",
"optional": true,
"requires": { "requires": {
"hoek": "2.x.x" "hoek": "2.x.x"
} }
@ -495,6 +496,7 @@
"version": "1.0.5", "version": "1.0.5",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz",
"integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=",
"optional": true,
"requires": { "requires": {
"delayed-stream": "~1.0.0" "delayed-stream": "~1.0.0"
} }
@ -638,7 +640,8 @@
"delayed-stream": { "delayed-stream": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
"optional": true
}, },
"depd": { "depd": {
"version": "0.4.5", "version": "0.4.5",
@ -875,7 +878,8 @@
"extsprintf": { "extsprintf": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
"integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=",
"optional": true
}, },
"fancy-log": { "fancy-log": {
"version": "1.3.0", "version": "1.3.0",
@ -1061,7 +1065,8 @@
}, },
"ansi-regex": { "ansi-regex": {
"version": "2.1.1", "version": "2.1.1",
"bundled": true "bundled": true,
"optional": true
}, },
"aproba": { "aproba": {
"version": "1.1.1", "version": "1.1.1",
@ -1104,7 +1109,8 @@
}, },
"balanced-match": { "balanced-match": {
"version": "0.4.2", "version": "0.4.2",
"bundled": true "bundled": true,
"optional": true
}, },
"bcrypt-pbkdf": { "bcrypt-pbkdf": {
"version": "1.0.1", "version": "1.0.1",
@ -1117,6 +1123,7 @@
"block-stream": { "block-stream": {
"version": "0.0.9", "version": "0.0.9",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"inherits": "~2.0.0" "inherits": "~2.0.0"
} }
@ -1124,6 +1131,7 @@
"boom": { "boom": {
"version": "2.10.1", "version": "2.10.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"hoek": "2.x.x" "hoek": "2.x.x"
} }
@ -1131,6 +1139,7 @@
"brace-expansion": { "brace-expansion": {
"version": "1.1.7", "version": "1.1.7",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^0.4.1", "balanced-match": "^0.4.1",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -1138,7 +1147,8 @@
}, },
"buffer-shims": { "buffer-shims": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true "bundled": true,
"optional": true
}, },
"caseless": { "caseless": {
"version": "0.12.0", "version": "0.12.0",
@ -1152,30 +1162,36 @@
}, },
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true "bundled": true,
"optional": true
}, },
"combined-stream": { "combined-stream": {
"version": "1.0.5", "version": "1.0.5",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"delayed-stream": "~1.0.0" "delayed-stream": "~1.0.0"
} }
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true "bundled": true,
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true "bundled": true,
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true "bundled": true,
"optional": true
}, },
"cryptiles": { "cryptiles": {
"version": "2.0.5", "version": "2.0.5",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"boom": "2.x.x" "boom": "2.x.x"
} }
@ -1210,7 +1226,8 @@
}, },
"delayed-stream": { "delayed-stream": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true "bundled": true,
"optional": true
}, },
"delegates": { "delegates": {
"version": "1.0.0", "version": "1.0.0",
@ -1237,7 +1254,8 @@
}, },
"extsprintf": { "extsprintf": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true "bundled": true,
"optional": true
}, },
"forever-agent": { "forever-agent": {
"version": "0.6.1", "version": "0.6.1",
@ -1256,11 +1274,13 @@
}, },
"fs.realpath": { "fs.realpath": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true "bundled": true,
"optional": true
}, },
"fstream": { "fstream": {
"version": "1.0.11", "version": "1.0.11",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"graceful-fs": "^4.1.2", "graceful-fs": "^4.1.2",
"inherits": "~2.0.0", "inherits": "~2.0.0",
@ -1311,6 +1331,7 @@
"glob": { "glob": {
"version": "7.1.2", "version": "7.1.2",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"fs.realpath": "^1.0.0", "fs.realpath": "^1.0.0",
"inflight": "^1.0.4", "inflight": "^1.0.4",
@ -1322,7 +1343,8 @@
}, },
"graceful-fs": { "graceful-fs": {
"version": "4.1.11", "version": "4.1.11",
"bundled": true "bundled": true,
"optional": true
}, },
"har-schema": { "har-schema": {
"version": "1.0.5", "version": "1.0.5",
@ -1346,6 +1368,7 @@
"hawk": { "hawk": {
"version": "3.1.3", "version": "3.1.3",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"boom": "2.x.x", "boom": "2.x.x",
"cryptiles": "2.x.x", "cryptiles": "2.x.x",
@ -1355,7 +1378,8 @@
}, },
"hoek": { "hoek": {
"version": "2.16.3", "version": "2.16.3",
"bundled": true "bundled": true,
"optional": true
}, },
"http-signature": { "http-signature": {
"version": "1.1.1", "version": "1.1.1",
@ -1370,6 +1394,7 @@
"inflight": { "inflight": {
"version": "1.0.6", "version": "1.0.6",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"once": "^1.3.0", "once": "^1.3.0",
"wrappy": "1" "wrappy": "1"
@ -1377,7 +1402,8 @@
}, },
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true "bundled": true,
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.4", "version": "1.3.4",
@ -1387,6 +1413,7 @@
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -1398,7 +1425,8 @@
}, },
"isarray": { "isarray": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true "bundled": true,
"optional": true
}, },
"isstream": { "isstream": {
"version": "0.1.2", "version": "0.1.2",
@ -1461,11 +1489,13 @@
}, },
"mime-db": { "mime-db": {
"version": "1.27.0", "version": "1.27.0",
"bundled": true "bundled": true,
"optional": true
}, },
"mime-types": { "mime-types": {
"version": "2.1.15", "version": "2.1.15",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"mime-db": "~1.27.0" "mime-db": "~1.27.0"
} }
@ -1473,17 +1503,20 @@
"minimatch": { "minimatch": {
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
}, },
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true "bundled": true,
"optional": true
}, },
"mkdirp": { "mkdirp": {
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -1533,7 +1566,8 @@
}, },
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true "bundled": true,
"optional": true
}, },
"oauth-sign": { "oauth-sign": {
"version": "0.8.2", "version": "0.8.2",
@ -1548,6 +1582,7 @@
"once": { "once": {
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -1573,7 +1608,8 @@
}, },
"path-is-absolute": { "path-is-absolute": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true "bundled": true,
"optional": true
}, },
"performance-now": { "performance-now": {
"version": "0.2.0", "version": "0.2.0",
@ -1582,7 +1618,8 @@
}, },
"process-nextick-args": { "process-nextick-args": {
"version": "1.0.7", "version": "1.0.7",
"bundled": true "bundled": true,
"optional": true
}, },
"punycode": { "punycode": {
"version": "1.4.1", "version": "1.4.1",
@ -1615,6 +1652,7 @@
"readable-stream": { "readable-stream": {
"version": "2.2.9", "version": "2.2.9",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"buffer-shims": "~1.0.0", "buffer-shims": "~1.0.0",
"core-util-is": "~1.0.0", "core-util-is": "~1.0.0",
@ -1657,13 +1695,15 @@
"rimraf": { "rimraf": {
"version": "2.6.1", "version": "2.6.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"glob": "^7.0.5" "glob": "^7.0.5"
} }
}, },
"safe-buffer": { "safe-buffer": {
"version": "5.0.1", "version": "5.0.1",
"bundled": true "bundled": true,
"optional": true
}, },
"semver": { "semver": {
"version": "5.3.0", "version": "5.3.0",
@ -1683,6 +1723,7 @@
"sntp": { "sntp": {
"version": "1.0.9", "version": "1.0.9",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"hoek": "2.x.x" "hoek": "2.x.x"
} }
@ -1713,6 +1754,7 @@
"string-width": { "string-width": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -1722,6 +1764,7 @@
"string_decoder": { "string_decoder": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.0.1" "safe-buffer": "^5.0.1"
} }
@ -1734,6 +1777,7 @@
"strip-ansi": { "strip-ansi": {
"version": "3.0.1", "version": "3.0.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
@ -1746,6 +1790,7 @@
"tar": { "tar": {
"version": "2.2.1", "version": "2.2.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"block-stream": "*", "block-stream": "*",
"fstream": "^1.0.2", "fstream": "^1.0.2",
@ -1795,7 +1840,8 @@
}, },
"util-deprecate": { "util-deprecate": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true "bundled": true,
"optional": true
}, },
"uuid": { "uuid": {
"version": "3.0.1", "version": "3.0.1",
@ -1820,7 +1866,8 @@
}, },
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true "bundled": true,
"optional": true
} }
} }
}, },
@ -2760,7 +2807,8 @@
"hoek": { "hoek": {
"version": "2.16.3", "version": "2.16.3",
"resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz",
"integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=" "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=",
"optional": true
}, },
"homedir-polyfill": { "homedir-polyfill": {
"version": "1.0.1", "version": "1.0.1",
@ -3522,12 +3570,14 @@
"mime-db": { "mime-db": {
"version": "1.29.0", "version": "1.29.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.29.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.29.0.tgz",
"integrity": "sha1-SNJtI1WJZRcErFkWygYAGRQmaHg=" "integrity": "sha1-SNJtI1WJZRcErFkWygYAGRQmaHg=",
"optional": true
}, },
"mime-types": { "mime-types": {
"version": "2.1.16", "version": "2.1.16",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.16.tgz", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.16.tgz",
"integrity": "sha1-K4WKUuXs1RbbiXrCvodIeDBpjiM=", "integrity": "sha1-K4WKUuXs1RbbiXrCvodIeDBpjiM=",
"optional": true,
"requires": { "requires": {
"mime-db": "~1.29.0" "mime-db": "~1.29.0"
} }

View File

@ -1,6 +1,5 @@
var Marionette = require('marionette'); var Marionette = require('marionette');
var StatusModel = require('../System/StatusModel'); var StatusModel = require('../System/StatusModel');
require('../Mixins/CopyToClipboard');
require('../Mixins/TagInput'); require('../Mixins/TagInput');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
@ -18,16 +17,21 @@ module.exports = Marionette.Layout.extend({
events : { events : {
'click .x-includeUnmonitored' : '_updateUrl', 'click .x-includeUnmonitored' : '_updateUrl',
'click .x-premiersOnly' : '_updateUrl', 'click .x-premiersOnly' : '_updateUrl',
'click .x-ical-copy' : '_copyIcalToClipboard',
'itemAdded .x-tags' : '_updateUrl', 'itemAdded .x-tags' : '_updateUrl',
'itemRemoved .x-tags' : '_updateUrl' 'itemRemoved .x-tags' : '_updateUrl'
}, },
onShow : function() { onShow : function() {
this._updateUrl(); this._updateUrl();
this.ui.icalCopy.copyToClipboard(this.ui.icalUrl);
this.ui.tags.tagInput({ allowNew: false }); this.ui.tags.tagInput({ allowNew: false });
}, },
_copyIcalToClipboard: function () {
this.ui.icalUrl.select();
document.execCommand("copy");
},
_updateUrl : function() { _updateUrl : function() {
var icalUrl = window.location.host + StatusModel.get('urlBase') + '/feed/calendar/Radarr.ics?'; var icalUrl = window.location.host + StatusModel.get('urlBase') + '/feed/calendar/Radarr.ics?';

View File

@ -1,22 +0,0 @@
var $ = require('jquery');
var StatusModel = require('../System/StatusModel');
var ZeroClipboard = require('zero.clipboard');
var Messenger = require('../Shared/Messenger');
$.fn.copyToClipboard = function(input) {
ZeroClipboard.config({
swfPath : StatusModel.get('urlBase') + '/Content/zero.clipboard.swf'
});
var client = new ZeroClipboard(this);
client.on('ready', function(e) {
client.on('copy', function(e) {
e.clipboardData.setData("text/plain", input.val());
});
client.on('aftercopy', function() {
Messenger.show({ message : 'Copied text to clipboard' });
});
});
};

View File

@ -4,8 +4,6 @@ var CommandController = require('../../Commands/CommandController');
var AsModelBoundView = require('../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../Mixins/AsValidatedView'); var AsValidatedView = require('../../Mixins/AsValidatedView');
require('../../Mixins/CopyToClipboard');
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/General/GeneralViewTemplate', template : 'Settings/General/GeneralViewTemplate',
@ -14,6 +12,7 @@ var view = Marionette.ItemView.extend({
'change .x-proxy' : '_setProxyOptionsVisibility', 'change .x-proxy' : '_setProxyOptionsVisibility',
'change .x-ssl' : '_setSslOptionsVisibility', 'change .x-ssl' : '_setSslOptionsVisibility',
'click .x-reset-api-key' : '_resetApiKey', 'click .x-reset-api-key' : '_resetApiKey',
'click .x-copy-api-key' : '_copyApiKeyToClipboard',
'change .x-update-mechanism' : '_setScriptGroupVisibility' 'change .x-update-mechanism' : '_setScriptGroupVisibility'
}, },
@ -57,11 +56,12 @@ var view = Marionette.ItemView.extend({
command : { command : {
name : 'resetApiKey' name : 'resetApiKey'
} }
}); });
}, },
onShow : function() { _copyApiKeyToClipboard : function() {
this.ui.copyApiKey.copyToClipboard(this.ui.apiKeyInput); this.ui.apiKeyInput.select();
document.execCommand("copy");
}, },
_setAuthOptionsVisibility : function() { _setAuthOptionsVisibility : function() {

View File

@ -29,7 +29,6 @@ require.config({
'messenger' : 'JsLibraries/messenger', 'messenger' : 'JsLibraries/messenger',
'jquery' : 'JsLibraries/jquery', 'jquery' : 'JsLibraries/jquery',
'typeahead' : 'JsLibraries/typeahead', 'typeahead' : 'JsLibraries/typeahead',
'zero.clipboard' : 'JsLibraries/zero.clipboard',
'libs' : 'JsLibraries/' 'libs' : 'JsLibraries/'
}, },

View File

@ -11,7 +11,6 @@ require('jquery.knob');
require('jquery.easypiechart'); require('jquery.easypiechart');
require('jquery.dotdotdot'); require('jquery.dotdotdot');
require('typeahead'); require('typeahead');
require('zero.clipboard');
/*Bootstrap*/ /*Bootstrap*/
require('bootstrap'); require('bootstrap');