From b1166c088d6d191c064b5369c160bf58346bf88f Mon Sep 17 00:00:00 2001 From: ileyd Date: Wed, 29 Jun 2016 07:13:05 +1000 Subject: Implemented clipboard support --- static/js/app.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'static') diff --git a/static/js/app.js b/static/js/app.js index e9e755a..dbf8176 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -81,6 +81,26 @@ document.addEventListener('DOMContentLoaded', function () { link.textContent = response.files[0].url.replace(/.*?:\/\//g, ''); link.href = response.files[0].url; url.appendChild(link); + var copy = document.createElement('button'); + copy.className = 'upload-clipboard-btn'; + var glyph = document.createElement('span'); + glyph.className = 'glyphicon glyphicon-copy'; + copy.appendChild(glyph); + url.appendChild(copy); + copy.addEventListener("click", function(event) { + /*why create element? text needs to be on screen to be selected + and thus copied. only text we have on screen is the link without + the http[s]:// part. so this creates an element with the full link + for a moment and then deletes. */ + var element = document.createElement('a'); + element.textContent = response.files[0].url; + link.appendChild(element); + var range = document.createRange(); + range.selectNode(element); + window.getSelection().addRange(range); + document.execCommand("copy"); + link.removeChild(element); + }); } else { bar.innerHTML = 'Error: ' + response.description; } @@ -172,4 +192,6 @@ document.addEventListener('DOMContentLoaded', function () { uploadButton.addEventListener('click', selectFiles.bind(this, uploadInput)); uploadButton.addEventListener('drop', handleDragDrop.bind(this, state, uploadButton), false); document.getElementById('upload-form').classList.add('js'); + + }); -- cgit v1.2.3 From 9c084fc6a22352fd9be0488a77d24ad72f8797cd Mon Sep 17 00:00:00 2001 From: ileyd Date: Wed, 29 Jun 2016 07:48:37 +1000 Subject: Added copy icon --- static/img/glyphicons-512-copy.png | Bin 0 -> 1356 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 static/img/glyphicons-512-copy.png (limited to 'static') diff --git a/static/img/glyphicons-512-copy.png b/static/img/glyphicons-512-copy.png new file mode 100644 index 0000000..4e293dc Binary files /dev/null and b/static/img/glyphicons-512-copy.png differ -- cgit v1.2.3 From 0a546f1082755fdd39c984542c2e4e63874d30fd Mon Sep 17 00:00:00 2001 From: ileyd Date: Wed, 29 Jun 2016 07:56:16 +1000 Subject: Changed glyph to png format --- static/js/app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'static') diff --git a/static/js/app.js b/static/js/app.js index dbf8176..44c8453 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -83,8 +83,9 @@ document.addEventListener('DOMContentLoaded', function () { url.appendChild(link); var copy = document.createElement('button'); copy.className = 'upload-clipboard-btn'; - var glyph = document.createElement('span'); - glyph.className = 'glyphicon glyphicon-copy'; + var glyph = document.createElement('img'); + glyph.src = 'img/glyphicons-512-copy.png'; + glyph.style = 'height:16px'; copy.appendChild(glyph); url.appendChild(copy); copy.addEventListener("click", function(event) { -- cgit v1.2.3 From 45b5dcc6f46c184863548a103e3a1d19de68b927 Mon Sep 17 00:00:00 2001 From: Austin Date: Tue, 28 Jun 2016 20:43:50 -0500 Subject: Switch copy button styling code to CSS file --- static/css/pomf.css | 3 +++ static/js/app.js | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'static') diff --git a/static/css/pomf.css b/static/css/pomf.css index 9bc5852..ae4e75e 100644 --- a/static/css/pomf.css +++ b/static/css/pomf.css @@ -231,6 +231,9 @@ nav > ul > li:last-child:after { .error#upload-filelist { color: #891A18; } +button.upload-clipboard-btn { + height: 16px; +} .error#upload-filelist .progress-percent { color: #B94A48; } diff --git a/static/js/app.js b/static/js/app.js index 44c8453..27a9353 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -85,7 +85,6 @@ document.addEventListener('DOMContentLoaded', function () { copy.className = 'upload-clipboard-btn'; var glyph = document.createElement('img'); glyph.src = 'img/glyphicons-512-copy.png'; - glyph.style = 'height:16px'; copy.appendChild(glyph); url.appendChild(copy); copy.addEventListener("click", function(event) { -- cgit v1.2.3