Skip to content

Commit

Permalink
Fixed copy citation button success message. Closes #408 and Related to
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenwalker committed Jun 19, 2018
1 parent 3399b1a commit 9908c37
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/js/views/MetadataView.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ define(['jquery',
this.insertDataSource();
// is this the latest version? (includes DOI link when needed)
this.showLatestVersion();


// If we're displaying the metrics well then display copy citation and edit button
// inside the well
Expand All @@ -231,13 +231,13 @@ define(['jquery',
else {
// Copy Citation button
this.insertControls();

// Edit button and the publish button
this.insertOwnerControls();
}




//Show loading icon in metadata section
this.$(this.metadataContainer).html(this.loadingTemplate({ msg: "Retrieving metadata ..." }));
Expand Down Expand Up @@ -955,8 +955,22 @@ define(['jquery',
_.each(copyBtns, function(btn){
//Create a copy citation button
var clipboard = new Clipboard(btn);

clipboard.on("success", function(e){
$(e.trigger).siblings(".copy-success").show().delay(1000).fadeOut();

var originalWidth = $(e.trigger).width();

$(e.trigger).html( $(document.createElement("span")).addClass("icon icon-ok success") )
.append(" Copied")
.addClass("success")
.css("width", originalWidth + "px");

setTimeout(function() {
$(e.trigger).html("<i class='icon icon-copy icon-on-left'></i> Copy Citation")
.removeClass("success")
.css("width", "auto");
}, 500)

});

clipboard.on("error", function(e){
Expand Down Expand Up @@ -1026,24 +1040,24 @@ define(['jquery',

metrics.append(buttonToolbar);
}


if(MetacatUI.appModel.get("displayDatasetControls")) {
var controlsToolbar = $(document.createElement("div")).addClass("edit-toolbar btn-toolbar");
var copyCitationToolbar = this.$(this.controlsContainer);

//Insert controls
this.insertControls();
controlsToolbar.append(copyCitationToolbar)

if(MetacatUI.appModel.get("displayDatasetEditButton")) {
var editToolbar = this.$(this.ownerControlsContainer);

// Insert Owner Controls
this.insertOwnerControls();
controlsToolbar.append(editToolbar)
}

metrics.append(controlsToolbar);
}

Expand Down

0 comments on commit 9908c37

Please sign in to comment.