summaryrefslogtreecommitdiff
path: root/addons/website_links/static/src/js/website_links_menu.js
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/website_links/static/src/js/website_links_menu.js
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/website_links/static/src/js/website_links_menu.js')
-rw-r--r--addons/website_links/static/src/js/website_links_menu.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/addons/website_links/static/src/js/website_links_menu.js b/addons/website_links/static/src/js/website_links_menu.js
new file mode 100644
index 00000000..6f673223
--- /dev/null
+++ b/addons/website_links/static/src/js/website_links_menu.js
@@ -0,0 +1,26 @@
+/**
+ * The purpose of this script is to copy the current URL of the website
+ * into the URL form of the URL shortener (module website_links)
+ * when the user clicks the link "Share this page" on top of the page.
+ */
+
+odoo.define('website_links.website_links_menu', function (require) {
+'use strict';
+
+var publicWidget = require('web.public.widget');
+var websiteNavbarData = require('website.navbar');
+
+var WebsiteLinksMenu = publicWidget.Widget.extend({
+
+ /**
+ * @override
+ */
+ start: function () {
+ this.$el.attr('href', '/r?u=' + encodeURIComponent(window.location.href));
+ return this._super.apply(this, arguments);
+ },
+});
+
+websiteNavbarData.websiteNavbarRegistry.add(WebsiteLinksMenu, '#o_website_links_share_page');
+
+});