Last active
May 27, 2016 11:37
-
-
Save cmattoon/9d676748eec91dc31c5b to your computer and use it in GitHub Desktop.
Inject fullscreen button into GitLab diffs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name GitLab Fullscreen Diffs | |
// @version 0.1 | |
// @description Adds a 'fullscreen' button to GitLab diffs. | |
// @match http://* | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js | |
// @grant none | |
// ==/UserScript== | |
/** | |
* Be sure to change the @match param above to suit your needs. | |
* This script requires the Tampermonkey extension for Chrome. You can download it here: | |
* | |
* https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=en | |
*/ | |
function make_button() { | |
return $('<button/>').text('Fullscreen').addClass('btn btn-small btn-fullscreen').css('background-color', '#fff200'); | |
} | |
function toggle_fullscreen(div) { | |
if (div.data('fullscreen')) { | |
style = { | |
'width': '95%', | |
'margin-bottom': '2em', | |
'left': '2.5%', | |
'position': 'absolute', | |
'box-shadow': '1em 1em 1em #ccc', | |
'z-index': 9999 | |
}; | |
div.data('fullscreen', 0); | |
} else { | |
style = { | |
'width': '100%', | |
'margin-bottom': '1em', | |
'left': 'initial', | |
'position': 'initial', | |
'box-shadow': 'none' | |
}; | |
div.data('fullscreen', 1); | |
} | |
div.css(style); | |
} | |
$(function() { | |
$('.diff-file').each(function() { | |
$(this).find('.diff-header').prepend(make_button()); | |
}); | |
$('.btn-fullscreen').on('click', function() { | |
var diff = $(this).parents('.diff-file'); | |
toggle_fullscreen(diff); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment