diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-11-30 11:15:06 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-11-30 11:16:26 -0500 |
commit | 6acc5f9128db1c2c0d0c468f6123d0dccf153156 (patch) | |
tree | aaa082a4963662df17f6654dd1c12d9d25004877 /application/palemoon/components/newtab/dragDataHelper.js | |
parent | 71737d61f75651efc5b9eaf5313a11dc3469bb1d (diff) | |
download | UXP-6acc5f9128db1c2c0d0c468f6123d0dccf153156.tar UXP-6acc5f9128db1c2c0d0c468f6123d0dccf153156.tar.gz UXP-6acc5f9128db1c2c0d0c468f6123d0dccf153156.tar.lz UXP-6acc5f9128db1c2c0d0c468f6123d0dccf153156.tar.xz UXP-6acc5f9128db1c2c0d0c468f6123d0dccf153156.zip |
Issue #889 - Clean up the Pale Moon tree - Part 1b: Move newtab to components
Diffstat (limited to 'application/palemoon/components/newtab/dragDataHelper.js')
-rw-r--r-- | application/palemoon/components/newtab/dragDataHelper.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/application/palemoon/components/newtab/dragDataHelper.js b/application/palemoon/components/newtab/dragDataHelper.js new file mode 100644 index 000000000..675ff2671 --- /dev/null +++ b/application/palemoon/components/newtab/dragDataHelper.js @@ -0,0 +1,22 @@ +#ifdef 0 +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ +#endif + +var gDragDataHelper = { + get mimeType() { + return "text/x-moz-url"; + }, + + getLinkFromDragEvent: function DragDataHelper_getLinkFromDragEvent(aEvent) { + let dt = aEvent.dataTransfer; + if (!dt || !dt.types.includes(this.mimeType)) { + return null; + } + + let data = dt.getData(this.mimeType) || ""; + let [url, title] = data.split(/[\r\n]+/); + return {url: url, title: title}; + } +}; |