From 4ae61cee221a0c164ec384134cc121f70321f1ab Mon Sep 17 00:00:00 2001 From: Romain Estievenart Date: Wed, 26 Jul 2023 10:54:55 +0000 Subject: [PATCH] [IMP] web *: remove unused jquery.scrollTo library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit *: project, mrp_subcontracting This commit is a code cleanup, we remove an unused lib from the codebase The last usage of jquery.scrollTo was dropped in saas-16.4 after the refactoring of livechat, see here [1]. Note that we have our own ´scrollTo´ utility. References : https://github.com/flesler/jquery.scrollTo [1] https://github.com/odoo/odoo/commit/20c1772d351e14e5233a636313dc79c2fe5b9115#diff-8925fb7187d27cf7abc3fbb149a22cdcfa83eaa435a667b5beb042c4fd0fe3fdL220 closes odoo/odoo#132035 Signed-off-by: Adrien Dieudonné (adr) --- addons/mrp_subcontracting/__manifest__.py | 1 - addons/project/__manifest__.py | 1 - addons/web/__manifest__.py | 1 - .../lib/jquery.scrollTo/jquery.scrollTo.js | 187 ------------------ debian/copyright | 4 - 5 files changed, 194 deletions(-) delete mode 100644 addons/web/static/lib/jquery.scrollTo/jquery.scrollTo.js diff --git a/addons/mrp_subcontracting/__manifest__.py b/addons/mrp_subcontracting/__manifest__.py index f396baf8ff0..08a71ad97f0 100644 --- a/addons/mrp_subcontracting/__manifest__.py +++ b/addons/mrp_subcontracting/__manifest__.py @@ -74,7 +74,6 @@ 'web/static/src/env.js', - 'web/static/lib/jquery.scrollTo/jquery.scrollTo.js', 'web/static/lib/jquery.ba-bbq/jquery.ba-bbq.js', 'web/static/src/legacy/scss/fields.scss', diff --git a/addons/project/__manifest__.py b/addons/project/__manifest__.py index 81eca7903c0..98bbea01898 100644 --- a/addons/project/__manifest__.py +++ b/addons/project/__manifest__.py @@ -127,7 +127,6 @@ 'web/static/src/env.js', - 'web/static/lib/jquery.scrollTo/jquery.scrollTo.js', 'web/static/lib/jquery.ba-bbq/jquery.ba-bbq.js', 'web/static/src/legacy/scss/fields.scss', diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py index 64d13d21d04..0ba328554f3 100644 --- a/addons/web/__manifest__.py +++ b/addons/web/__manifest__.py @@ -179,7 +179,6 @@ This module provides the core of the Odoo Web Client. 'web/static/src/env.js', - 'web/static/lib/jquery.scrollTo/jquery.scrollTo.js', 'web/static/lib/jquery.ba-bbq/jquery.ba-bbq.js', 'web/static/src/scss/ace.scss', diff --git a/addons/web/static/lib/jquery.scrollTo/jquery.scrollTo.js b/addons/web/static/lib/jquery.scrollTo/jquery.scrollTo.js deleted file mode 100644 index c2f41399d65..00000000000 --- a/addons/web/static/lib/jquery.scrollTo/jquery.scrollTo.js +++ /dev/null @@ -1,187 +0,0 @@ -/*! - * jQuery.scrollTo - * Copyright (c) 2007-2014 Ariel Flesler - afleslergmailcom | http://flesler.blogspot.com - * Licensed under MIT - * http://flesler.blogspot.com/2007/10/jqueryscrollto.html - * @projectDescription Easy element scrolling using jQuery. - * @author Ariel Flesler - * @version 1.4.14 - */ -;(function (define) { - 'use strict'; - - define(['jquery'], function ($) { - - var $scrollTo = $.scrollTo = function( target, duration, settings ) { - return $(window).scrollTo( target, duration, settings ); - }; - - $scrollTo.defaults = { - axis:'xy', - duration: 0, - limit:true - }; - - // Returns the element that needs to be animated to scroll the window. - // Kept for backwards compatibility (specially for localScroll & serialScroll) - $scrollTo.window = function( scope ) { - return $(window)._scrollable(); - }; - - // Hack, hack, hack :) - // Returns the real elements to scroll (supports window/iframes, documents and regular nodes) - $.fn._scrollable = function() { - return this.map(function() { - var elem = this, - isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) != -1; - - if (!isWin) - return elem; - - var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem; - - return /webkit/i.test(navigator.userAgent) || doc.compatMode == 'BackCompat' ? - doc.body : - doc.documentElement; - }); - }; - - $.fn.scrollTo = function( target, duration, settings ) { - if (typeof duration == 'object') { - settings = duration; - duration = 0; - } - if (typeof settings == 'function') - settings = { onAfter:settings }; - - if (target == 'max') - target = 9e9; - - settings = $.extend( {}, $scrollTo.defaults, settings ); - // Speed is still recognized for backwards compatibility - duration = duration || settings.duration; - // Make sure the settings are given right - settings.queue = settings.queue && settings.axis.length > 1; - - if (settings.queue) - // Let's keep the overall duration - duration /= 2; - settings.offset = both( settings.offset ); - settings.over = both( settings.over ); - - return this._scrollable().each(function() { - // Null target yields nothing, just like jQuery does - if (target == null) return; - - var elem = this, - $elem = $(elem), - targ = target, toff, attr = {}, - win = $elem.is('html,body'); - - switch (typeof targ) { - // A number will pass the regex - case 'number': - case 'string': - if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) { - targ = both( targ ); - // We are done - break; - } - // Relative/Absolute selector, no break! - targ = win ? $(targ) : $(targ, this); - if (!targ.length) return; - case 'object': - // DOMElement / jQuery - if (targ.is || targ.style) - // Get the real position of the target - toff = (targ = $(targ)).offset(); - } - - var offset = $.isFunction(settings.offset) && settings.offset(elem, targ) || settings.offset; - - $.each( settings.axis.split(''), function( i, axis ) { - var Pos = axis == 'x' ? 'Left' : 'Top', - pos = Pos.toLowerCase(), - key = 'scroll' + Pos, - old = elem[key], - max = $scrollTo.max(elem, axis); - - if (toff) {// jQuery / DOMElement - attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] ); - - // If it's a dom element, reduce the margin - if (settings.margin) { - attr[key] -= parseInt(targ.css('margin'+Pos)) || 0; - attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0; - } - - attr[key] += offset[pos] || 0; - - if(settings.over[pos]) - // Scroll to a fraction of its width/height - attr[key] += targ[axis=='x'?'width':'height']() * settings.over[pos]; - } else { - var val = targ[pos]; - // Handle percentage values - attr[key] = val.slice && val.slice(-1) == '%' ? - parseFloat(val) / 100 * max - : val; - } - - // Number or 'number' - if (settings.limit && /^\d+$/.test(attr[key])) - // Check the limits - attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max ); - - // Queueing axes - if (!i && settings.queue) { - // Don't waste time animating, if there's no need. - if (old != attr[key]) - // Intermediate animation - animate( settings.onAfterFirst ); - // Don't animate this axis again in the next iteration. - delete attr[key]; - } - }); - - animate( settings.onAfter ); - - function animate( callback ) { - $elem.animate( attr, duration, settings.easing, callback && function() { - callback.call(this, targ, settings); - }); - } - }).end(); - }; - - // Max scrolling position, works on quirks mode - // It only fails (not too badly) on IE, quirks mode. - $scrollTo.max = function( elem, axis ) { - var Dim = axis == 'x' ? 'Width' : 'Height', - scroll = 'scroll'+Dim; - - if (!$(elem).is('html,body')) - return elem[scroll] - $(elem)[Dim.toLowerCase()](); - - var size = 'client' + Dim, - html = elem.ownerDocument.documentElement, - body = elem.ownerDocument.body; - - return Math.max( html[scroll], body[scroll] ) - Math.min( html[size] , body[size] ); - }; - - function both( val ) { - return $.isFunction(val) || $.isPlainObject(val) ? val : { top:val, left:val }; - } - - // AMD requirement - return $scrollTo; - }) -}(typeof define === 'function' && define.amd ? define : function (deps, factory) { - if (typeof module !== 'undefined' && module.exports) { - // Node - module.exports = factory(require('jquery')); - } else { - factory(jQuery); - } -})); diff --git a/debian/copyright b/debian/copyright index 630086f5f1e..30decec4bd6 100644 --- a/debian/copyright +++ b/debian/copyright @@ -265,10 +265,6 @@ Files: addons/web/static/lib/jquery.mjs.nestedSortable/* Copyright: 2010-2016 Manuele J Sarfatti and contributors License: MIT -Files: addons/web/static/lib/jquery.scrollTo/* -Copyright: 2007-2014 Ariel Flesler -License: MIT - Files: addons/web/static/lib/jquery.ui/* Copyright: jQuery Foundation and other contributors License: MIT