Skip to content

Instantly share code, notes, and snippets.

@himedlooff
Created March 20, 2014 21:06
Show Gist options
  • Save himedlooff/9673813 to your computer and use it in GitHub Desktop.
Save himedlooff/9673813 to your computer and use it in GitHub Desktop.
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