Skip to content

Commit

Permalink
Remove confusing copy button
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Mar 8, 2018
1 parent ab6a9f3 commit 1b25e37
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 61 deletions.
25 changes: 3 additions & 22 deletions memegen/static/javascript/index.js
Expand Up @@ -19,13 +19,12 @@ function generateMeme() {
var data = {"top": top, "bottom": bottom, "redirect": false, "masked" : masked};

$.post(url, data, function(data){
$("#meme-image img").attr('src', data.href + '?watermark=none');
$("#meme-image").attr('href', data.href);
$("#meme-image").attr('src', data.href + '?watermark=none');
});
}

function getShareLink() {
return $("#meme-image").attr('href') + "?watermark=none&share=true";
return $("#meme-image").attr('src') + "&share=true";
}

/*** Events ***/
Expand All @@ -51,26 +50,8 @@ $('#meme-form').on('submit', function(event) {

});

var clipboard = new Clipboard('#btn-copy', {
text: function(trigger) {
return getShareLink();
}
});
clipboard.on('success', function(event) {
$(event.trigger).attr('title', 'Link Copied').tooltip('fixTitle').tooltip('show');
});
clipboard.on('error', function(event) {
console.log(event);
});

$('#btn-share').on('click', function(event) {
var url = getShareLink();
var win = window.open(url, '_blank');
if (win) {
win.focus();
} else {
window.location.href = url;
}
window.location.href = getShareLink();
});

/*** Loading ***/
Expand Down
37 changes: 9 additions & 28 deletions memegen/templates/custom.html
Expand Up @@ -45,13 +45,12 @@

<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" class="btn btn-primary" id="btn-generate" value="Generate Image" />
<button type="submit" class="btn btn-primary" id="btn-generate">
<span class="glyphicon glyphicon-picture"></span>
&nbsp;
Generate
</button>
<div class="pull-right">
<button type="button" class="btn btn-primary" id="btn-copy" data-toggle="tooltip" title="Copy link">
<span class="glyphicon glyphicon-copy"></span>
&nbsp;
Copy Link
</button>
<button type="button" class="btn btn-primary" id="btn-share" data-toggle="tooltip" title="View sharing options">
<span class="glyphicon glyphicon-share"></span>
&nbsp;
Expand All @@ -74,7 +73,6 @@

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.16/clipboard.min.js"></script>

<script>
function getShareLink() {
Expand All @@ -94,6 +92,10 @@
$("#meme-image").attr('href', imageUrl);
});

$('#btn-share').on('click', function(event) {
window.location.href = getShareLink();
});

// Generate with defaults
$('#meme-line-1').val("your text");
$('#meme-line-2').val("goes here");
Expand All @@ -106,26 +108,5 @@
$('#meme-line-2').val("");
$('#meme-background').val("");

var clipboard = new Clipboard('#btn-copy', {
text: function(trigger) {
return getShareLink();
}
});
clipboard.on('success', function(event) {
$(event.trigger).attr('title', 'Link Copied').tooltip('fixTitle').tooltip('show');
});
clipboard.on('error', function(event) {
console.log(event);
});

$('#btn-share').on('click', function(event) {
var url = getShareLink();
var win = window.open(url, '_blank');
if (win) {
win.focus();
} else {
window.location.href = url;
}
});
</script>
{% endblock %}
2 changes: 1 addition & 1 deletion memegen/templates/examples.html
Expand Up @@ -7,7 +7,7 @@
<div class="row">
{% for img in sample_images %}
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 col-xl-2">
<a href="{{img.url}}">
<a href="{{ img.url }}&share=true">
<img class="meme-img" src="{{ img.url }}" />
</a>
</div>
Expand Down
14 changes: 4 additions & 10 deletions memegen/templates/index.html
Expand Up @@ -45,14 +45,11 @@
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">
Generate Image
<span class="glyphicon glyphicon-picture"></span>
&nbsp;
Generate
</button>
<div class="pull-right">
<button type="button" class="btn btn-primary" id="btn-copy" data-toggle="tooltip" title="Copy link">
<span class="glyphicon glyphicon-copy"></span>
&nbsp;
Copy Link
</button>
<button type="button" class="btn btn-primary" id="btn-share" data-toggle="tooltip" title="View sharing options">
<span class="glyphicon glyphicon-share"></span>
&nbsp;
Expand All @@ -65,9 +62,7 @@
</div>

<div class="meme-holder col-md-6">
<a id="meme-image" href="">
<img width='400' src="" />
</a>
<img width='400' src="" id="meme-image"/>
</div>
</div>
</div>
Expand All @@ -88,7 +83,6 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2-rc.1/js/select2.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.16/clipboard.min.js"></script>

<script src="static/javascript/index.js"></script>

Expand Down

0 comments on commit 1b25e37

Please sign in to comment.