Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var $dif = $('.js-details-container');
$dif.each(function(index){
$thisDif = $(this);
$buttons = $thisDif.find('.meta .actions .button-group');
$review = $('<a href="#" class="button minibutton diff-review">Mark as reviewed<code></code></a>');
$collapse = $('<a href="#" class="button minibutton diff-collapse">Collapse<code></code></a>');
$buttons.append($review);
$buttons.append($collapse);
$review = $thisDif.find('.diff-review');
$collapse = $thisDif.find('.diff-collapse');
$collapse.on('click', function(e){
var $this = $(this);
e.preventDefault();
if ($this.text() == 'Collapse') {
$this.html('Expand<code></code>');
} else {
$this.html('Collapse<code></code>');
}
getDiffFromButton($this).toggle();
});
$review.on('click', function(e){
var $this = $(this);
e.preventDefault();
if ($this.text().indexOf('Reviewed') != -1) {
getContainerFromButton($this).fadeTo('fast', 1);
$this.html('Mark as reviewed<code></code>');
} else {
getContainerFromButton($this).fadeTo('fast', .2);
$this.html('Reviewed<code></code>');
}
});
function getDiffFromButton($button) {
return $button.parents('.js-details-container').find('.data, .image');
}
function getContainerFromButton($button) {
return $button.parents('.js-details-container');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.