Skip to content

Instantly share code, notes, and snippets.

@shabda
Forked from dheerosaur/default.js
Created December 12, 2011 09:07
Show Gist options
  • Save shabda/1466082 to your computer and use it in GitHub Desktop.
Save shabda/1466082 to your computer and use it in GitHub Desktop.
Hiding stuff, go directly to "My active tickets" in unfuddle
// Reusable extension for jQuery so that we can hide jQuery objects
// and hide them. We will show an arrow at the top-right corner which
// will toggle the display of these.
// Examples:
//
// For github.com.js:
// $("#header").toggleStuff();
//
// Some random site:
// $("#report_attachment").parent().next().toggleStuff()
$.fn.toggleStuff = ->
$this = $(this)
anchorCss =
position: 'fixed'
top: '30px'
right: '10px'
'z-index': '999'
'font-size': '30px'
'font-weight': 'bold'
'text-decoration': 'none'
anchor = $("<a>").text('▼').css(anchorCss).addClass("dotjsToggler").prependTo("body")
upUp = ->
$this slideUp
anchor.text '▲'
downDown = ->
$this slideDown
anchor.text '▼'
anchor.toggle(upUp, downDown).click();
jQuery(function (){
var hash = document.location.hash;
function setHash(s) {
hash = document.location.hash = s;
}
if (hash.search('/projects/1') === -1) {
// hash may vary
setHash('#/projects/1');
}
if (hash === '#/projects/1') {
// hash may vary
setHash('#/projects/1/ticket_reports/10');
}
// Unfuddle fetches content through Ajax. You may want to
// increase the timeout if your connection is slower.
setTimeout(function () {
$("#header").toggleStuff();
}, 1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment