From 1ca3b3df3421961caec3b747a364071c80f5c7da Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 17:14:58 +0700 Subject: initial commit --- backend_theme_v14/static/src/js/sidebar.js | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 backend_theme_v14/static/src/js/sidebar.js (limited to 'backend_theme_v14/static/src/js/sidebar.js') diff --git a/backend_theme_v14/static/src/js/sidebar.js b/backend_theme_v14/static/src/js/sidebar.js new file mode 100644 index 0000000..3bc7a22 --- /dev/null +++ b/backend_theme_v14/static/src/js/sidebar.js @@ -0,0 +1,33 @@ +/* Copyright 2016, 2019 Openworx. + * License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */ + +// Check if debug mode is active and then add debug into URL when clicking on the App sidebar +odoo.define('backend_theme_v14.Sidebar', function(require) { + "use strict"; + var core = require('web.core'); + var session = require('web.session'); + var Widget = require('web.Widget'); + $(function() { + (function($) { + $.addDebug = function(url) { + url = url.replace(/(.{4})/, "$1?debug"); + return url; + } + $.addDebugWithAssets = function(url) { + url = url.replace(/(.{4})/, "$1?debug=assets"); + return url; + } + $.delDebug = function(url) { + var str = url.match(/web(\S*)#/); + url = url.replace("str/g", ""); + return url; + } + }) (jQuery); + $("#sidebar a").each(function() { + var url = $(this).attr('href'); + if (session.debug == 1) $(this).attr('href', $.addDebug(url)); + if (session.debug == 'assets') $(this).attr('href', $.addDebugWithAssets(url)); + if (session.debug == false) $(this).attr('href', $.delDebug(url)); + }); + }); +}); -- cgit v1.2.3