From b5de896ef69408355153fec218ba347009522a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Sat, 19 Jan 2013 17:48:04 +0100 Subject: [PATCH] #16 - When displaying an image add a download button --- zerobin/static/js/behavior.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/zerobin/static/js/behavior.js b/zerobin/static/js/behavior.js index a004954..e23fb6b 100644 --- a/zerobin/static/js/behavior.js +++ b/zerobin/static/js/behavior.js @@ -501,7 +501,6 @@ $('.btn-primary').live("click", function(e){ 'Error'); } } - }); /** @@ -557,11 +556,22 @@ if (content && key) { $('#paste-content').text(content); if(content.indexOf('data:image') == 0) { + // Display Image $('#paste-content').hide(); var img = $(''); $(img).attr('src', content); $(img).css('max-width', '742px'); $('#paste-content').after(img); + + // Display Download button + $('.btn-clone').hide(); + + var button = $('').attr('href', content); + $(button).attr('download', '0bin_'+document.location.pathname.split('/').pop()); + $(button).addClass('btn'); + $(button).html(' Download'); + $('.btn-clone').after(button); + } bar.set('Code coloration...', '95%');