From fedecc1f27d3f325093a7ba3268d0c30f73d1fec Mon Sep 17 00:00:00 2001 From: Pierre Paridans Date: Thu, 31 Aug 2023 12:55:23 +0200 Subject: [PATCH] [IMP] web,*: remove unused legacy download.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit task-3439226 closes odoo/odoo#133768 Signed-off-by: Adrien Dieudonné (adr) --- addons/mrp_subcontracting/__manifest__.py | 1 - addons/point_of_sale/__manifest__.py | 1 - addons/project/__manifest__.py | 1 - addons/web/__manifest__.py | 2 - .../web/static/src/legacy/js/libs/download.js | 152 ------------------ addons/web_editor/__manifest__.py | 1 - addons/website_slides/__manifest__.py | 1 - debian/copyright | 4 - 8 files changed, 163 deletions(-) delete mode 100644 addons/web/static/src/legacy/js/libs/download.js diff --git a/addons/mrp_subcontracting/__manifest__.py b/addons/mrp_subcontracting/__manifest__.py index 979ebcb28be..bce3ddf5d14 100644 --- a/addons/mrp_subcontracting/__manifest__.py +++ b/addons/mrp_subcontracting/__manifest__.py @@ -99,7 +99,6 @@ 'web/static/lib/jSignature/jSignatureCustom.js', 'web/static/src/legacy/js/libs/autocomplete.js', 'web/static/src/legacy/js/libs/bootstrap.js', - 'web/static/src/legacy/js/libs/download.js', 'web/static/src/legacy/js/libs/jquery.js', 'web/static/src/legacy/js/libs/moment.js', 'web/static/src/legacy/js/libs/jSignatureCustom.js', diff --git a/addons/point_of_sale/__manifest__.py b/addons/point_of_sale/__manifest__.py index 8b887787d96..ecf5455253e 100644 --- a/addons/point_of_sale/__manifest__.py +++ b/addons/point_of_sale/__manifest__.py @@ -184,7 +184,6 @@ 'web/static/src/webclient/webclient.js', 'web/static/src/views/view_dialogs/form_view_dialog.js', 'web/static/src/views/view_dialogs/select_create_dialog.js', - 'web/static/src/legacy/js/libs/download.js', # BEGIN copy of web.tests_assets. We don't 'include' it because other modules add their # own test helpers in this module that depend on files that they add in assets_backend 'web/static/lib/qunit/qunit-2.9.1.css', diff --git a/addons/project/__manifest__.py b/addons/project/__manifest__.py index 06937778649..9d1265950c0 100644 --- a/addons/project/__manifest__.py +++ b/addons/project/__manifest__.py @@ -150,7 +150,6 @@ 'web/static/lib/jSignature/jSignatureCustom.js', 'web/static/src/legacy/js/libs/autocomplete.js', 'web/static/src/legacy/js/libs/bootstrap.js', - 'web/static/src/legacy/js/libs/download.js', 'web/static/src/legacy/js/libs/jquery.js', 'web/static/src/legacy/js/libs/moment.js', 'web/static/src/legacy/js/libs/jSignatureCustom.js', diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py index 6dc3d3188da..11f1a401e70 100644 --- a/addons/web/__manifest__.py +++ b/addons/web/__manifest__.py @@ -99,7 +99,6 @@ This module provides the core of the Odoo Web Client. 'web/static/lib/jSignature/jSignatureCustom.js', 'web/static/src/legacy/js/libs/autocomplete.js', 'web/static/src/legacy/js/libs/bootstrap.js', - 'web/static/src/legacy/js/libs/download.js', 'web/static/src/legacy/js/libs/jquery.js', 'web/static/src/legacy/js/libs/moment.js', 'web/static/src/legacy/js/libs/jSignatureCustom.js', @@ -245,7 +244,6 @@ This module provides the core of the Odoo Web Client. 'web/static/lib/jSignature/jSignatureCustom.js', 'web/static/src/legacy/js/libs/autocomplete.js', 'web/static/src/legacy/js/libs/bootstrap.js', - 'web/static/src/legacy/js/libs/download.js', 'web/static/src/legacy/js/libs/jquery.js', 'web/static/src/legacy/js/libs/moment.js', 'web/static/src/legacy/js/libs/jSignatureCustom.js', diff --git a/addons/web/static/src/legacy/js/libs/download.js b/addons/web/static/src/legacy/js/libs/download.js deleted file mode 100644 index 0f64022eaa5..00000000000 --- a/addons/web/static/src/legacy/js/libs/download.js +++ /dev/null @@ -1,152 +0,0 @@ -/** @odoo-module **/ -/* -MIT License - -Copyright (c) 2016 dandavis - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - */ - -/** - * download.js v4.2, by dandavis; 2008-2018. [MIT] see http://danml.com/download.html for tests/usage - * - * @param {Blob | File | String} data - * @param {String} [filename] - * @param {String} [mimetype] - */ -export default function download(data, filename, mimetype) { - var self = window, // this script is only for browsers anyway... - defaultMime = "application/octet-stream", // this default mime also triggers iframe downloads - mimeType = mimetype || defaultMime, payload = data, - url = !filename && !mimetype && payload, - anchor = document.createElement("a"), - toString = function (a) {return String(a);}, - myBlob = (self.Blob || self.MozBlob || self.WebKitBlob || toString), - fileName = filename || "download", blob, reader; - myBlob = myBlob.call ? myBlob.bind(self) : Blob; - - if (String(this) === "true") { //reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback - payload = [payload, mimeType]; - mimeType = payload[0]; - payload = payload[1]; - } - - if (url && url.length < 2048) { // if no filename and no mime, assume a url was passed as the only argument - fileName = url.split("/").pop().split("?")[0]; - anchor.href = url; // assign href prop to temp anchor - if (anchor.href.indexOf(url) !== -1) { // if the browser determines that it's a potentially valid url path: - var ajax = new XMLHttpRequest(); - ajax.open("GET", url, true); - ajax.responseType = 'blob'; - ajax.onload = function (e) { - download(e.target.response, fileName, defaultMime); - }; - setTimeout(function () { ajax.send();}, 0); // allows setting custom ajax headers using the return: - return ajax; - } - } - - //go ahead and download dataURLs right away - if (/^data:[\w+\-]+\/[\w+\-]+[,;]/.test(payload)) { - - if (payload.length > (1024 * 1024 * 1.999) && myBlob !== toString) { - payload = dataUrlToBlob(payload); - mimeType = payload.type || defaultMime; - } else { - return navigator.msSaveBlob ? // IE10 can't do a[download], only Blobs: - navigator.msSaveBlob(dataUrlToBlob(payload), fileName) : saver(payload); // everyone else can save dataURLs un-processed - } - - } - - blob = payload instanceof myBlob ? payload : new myBlob([payload], {type: mimeType}); - - - function dataUrlToBlob(strUrl) { - var parts = strUrl.split(/[:;,]/), type = parts[1], - decoder = parts[2] === "base64" ? atob : decodeURIComponent, - binData = decoder(parts.pop()), mx = binData.length, - i = 0, uiArr = new Uint8Array(mx); - - for (i; i < mx; ++i) uiArr[i] = binData.charCodeAt(i); - - return new myBlob([uiArr], {type: type}); - } - - function saver(url, winMode) { - if ('download' in anchor) { //html5 A[download] - anchor.href = url; - anchor.setAttribute("download", fileName); - anchor.className = "download-js-link"; - anchor.innerHTML = "downloading..."; - anchor.style.display = "none"; - document.body.appendChild(anchor); - setTimeout(function () { - anchor.click(); - document.body.removeChild(anchor); - if (winMode === true) {setTimeout(function () { self.URL.revokeObjectURL(anchor.href);}, 250);} - }, 66); - return true; - } - - // handle non-a[download] safari as best we can: - if (/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)) { - url = url.replace(/^data:([\w\/\-+]+)/, defaultMime); - if (!window.open(url)) { // popup blocked, offer direct download: - if (confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")) { location.href = url; } - } - return true; - } - - //do iframe dataURL download (old ch+FF): - var f = document.createElement("iframe"); - document.body.appendChild(f); - - if (!winMode) { // force a mime that will download: - url = "data:" + url.replace(/^data:([\w\/\-+]+)/, defaultMime); - } - f.src = url; - setTimeout(function () { document.body.removeChild(f); }, 333); - } - - if (navigator.msSaveBlob) { // IE10+ : (has Blob, but not a[download] or URL) - return navigator.msSaveBlob(blob, fileName); - } - - if (self.URL) { // simple fast and modern way using Blob and URL: - saver(self.URL.createObjectURL(blob), true); - } else { - // handle non-Blob()+non-URL browsers: - if (typeof blob === "string" || blob.constructor === toString) { - try { - return saver("data:" + mimeType + ";base64," + self.btoa(blob)); - } catch (y) { - return saver("data:" + mimeType + "," + encodeURIComponent(blob)); - } - } - - // Blob but not URL support: - reader = new FileReader(); - reader.onload = function () { - saver(this.result); - }; - reader.readAsDataURL(blob); - } - return true; -}; diff --git a/addons/web_editor/__manifest__.py b/addons/web_editor/__manifest__.py index c5bbd40ede1..6578fd77758 100644 --- a/addons/web_editor/__manifest__.py +++ b/addons/web_editor/__manifest__.py @@ -89,7 +89,6 @@ Odoo Web Editor widget. 'web/static/lib/jSignature/jSignatureCustom.js', 'web/static/src/legacy/js/libs/autocomplete.js', 'web/static/src/legacy/js/libs/bootstrap.js', - 'web/static/src/legacy/js/libs/download.js', 'web/static/src/legacy/js/libs/jquery.js', 'web/static/src/legacy/js/libs/moment.js', 'web/static/src/legacy/js/libs/jSignatureCustom.js', diff --git a/addons/website_slides/__manifest__.py b/addons/website_slides/__manifest__.py index 3732f754ca2..a62929e86d2 100644 --- a/addons/website_slides/__manifest__.py +++ b/addons/website_slides/__manifest__.py @@ -191,7 +191,6 @@ Featuring 'web/static/lib/jSignature/jSignatureCustom.js', 'web/static/src/legacy/js/libs/autocomplete.js', 'web/static/src/legacy/js/libs/bootstrap.js', - 'web/static/src/legacy/js/libs/download.js', 'web/static/src/legacy/js/libs/jquery.js', 'web/static/src/legacy/js/libs/moment.js', 'website/static/src/libs/zoomodoo/zoomodoo.js', diff --git a/debian/copyright b/debian/copyright index 7dab9fed94f..54acba5be86 100644 --- a/debian/copyright +++ b/debian/copyright @@ -362,10 +362,6 @@ Files: addons/web/static/src/js/core/mixins.js Copyright: 2010-2012 Jeremy Ashkenas License: MIT -Files: addons/web/static/src/js/libs/download.js -Copyright: 2016 dandavis -License: MIT - Files: addons/website/static/src/libs/zoomodoo/zoomodoo.js Copyright: 2013 Matt Hinchliffe License: MIT