From 98b1ba46c68c964d981ee0a0cfca77d88bc546b7 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 31 Dec 2017 21:48:47 +0000 Subject: [PATCH] Add button to copy to clipboard --- layouts/_default/single.html | 1 + package.json | 1 + static/src/js/index.js | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 50ddb9b..c7c3958 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -9,6 +9,7 @@ + diff --git a/package.json b/package.json index a891234..1175367 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ }, "dependencies": { "bootstrap": "4.0.0-beta.2", + "clipboard": "1.7.1", "font-awesome": "4.7.0", "jquery": "3.2.1", "lg-thumbnail": "1.1.0", diff --git a/static/src/js/index.js b/static/src/js/index.js index c6ea6ef..b20dc9c 100644 --- a/static/src/js/index.js +++ b/static/src/js/index.js @@ -3,10 +3,12 @@ require('./jquery-global'); require('bootstrap'); + require('lightgallery/dist/js/lightgallery'); require('lg-thumbnail/dist/lg-thumbnail'); require('plyr').setup(); +var Clipboard = require('clipboard'); $('.image').each(function () { // setup div-image hybrids @@ -49,3 +51,14 @@ $('.navbar-brand').on('click', function (event) { } event.preventDefault(); }); + +var clipboard = new Clipboard('a'); +clipboard.on('success', function (e) { + var ele = $(e.trigger); + ele.find('i').attr('class', 'fa fa-check'); + ele.attr('title', 'Copied!'); +}); + +$('[data-clipboard-text]').on('click', function (event) { + event.preventDefault(); +});