Skip to content

Commit

Permalink
[FIX] website_links: do not require flash to copy text to clipboard
Browse files Browse the repository at this point in the history
The "copy link" to clipboard button ancestrally used a flash (.swf) dependency
(ZeroClipboard) to work.
Since Odoo honours its history, it was still there.
However on Firefox you are asked to activate flash to make it work,
and on Chrome nothing happens.
We get rid of this shibboleth, using instead clipboard.js that is already used
elswhere for the same purpose.

closes odoo#27958
opw 1896509
  • Loading branch information
len-odoo authored and len-foss committed Oct 29, 2018
1 parent 1916fdc commit b4e310e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
8 changes: 3 additions & 5 deletions addons/website_links/static/src/js/website_links.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var Model = require('web.Model');

var qweb = core.qweb;
var _t = core._t;
var ZeroClipboard = window.ZeroClipboard;

var exports = {};

Expand Down Expand Up @@ -99,7 +98,8 @@ if(!$('.o_website_links_create_tracked_url').length) {
this.animating_copy = false;
},
start: function() {
new ZeroClipboard(this.$('.btn_shorten_url_clipboard'));
// DO NOT FORWARD PORT ABOVE V11
new Clipboard(this.$('.btn_shorten_url_clipboard')[0]);
},
toggle_copy_button: function() {
var self = this;
Expand Down Expand Up @@ -249,8 +249,6 @@ if(!$('.o_website_links_create_tracked_url').length) {

base.ready().done(function() {

ZeroClipboard.config({swfPath: location.origin + "/website_links/static/lib/zeroclipboard/ZeroClipboard.swf" });

// UTMS selects widgets
var campaign_select = new SelectBox('utm.campaign');
campaign_select.start($("#campaign-select"), _t('e.g. Promotion of June, Winter Newsletter, ..'));
Expand Down Expand Up @@ -282,7 +280,7 @@ if(!$('.o_website_links_create_tracked_url').length) {
});

// Clipboard Library
var client = new ZeroClipboard($("#btn_shorten_url"));
new Clipboard($("#btn_shorten_url")[0]);

$("#generated_tracked_link a").click(function() {
$("#generated_tracked_link a").text("Copied").removeClass("btn-primary").addClass("btn-success");
Expand Down
1 change: 0 additions & 1 deletion addons/website_links/views/website_links_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

<template id="assets_website_links" inherit_id="website.assets_frontend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/website_links/static/lib/zeroclipboard/ZeroClipboard.js"/>
<script type="text/javascript" src="/website_links/static/src/js/website_links.js"/>
<script type="text/javascript" src="/website_links/static/src/js/website_links_code_editor.js"/>
<script type="text/javascript" src="/website_links/static/src/js/website_links_charts.js"/>
Expand Down

0 comments on commit b4e310e

Please sign in to comment.