Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI tweaks #15

Merged
merged 2 commits into from
Nov 19, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 39 additions & 18 deletions assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,72 @@ $(document).ready(function() {
null
]
});

// Syntax highlight all files up front - deactivated
// $('.source_table pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});

// Syntax highlight source files on first toggle of the file view popup
$("a.src_link").click(function() {
// Get the source file element that corresponds to the clicked element
var source_table = $($(this).attr('href'));

// If not highlighted yet, do it!
if (!source_table.hasClass('highlighted')) {
source_table.find('pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});
source_table.addClass('highlighted');
};
});


var prev_anchor;
var curr_anchor;

// Set-up of popup for source file views
$("a.src_link").fancybox({
'hideOnContentClick': true,
'centerOnScroll': true,
'width': '90%',
'padding': 0,
'transitionIn': 'elastic'
$("a.src_link").colorbox({
transition: "none",
inline: true,
opacity: 1,
width: "95%",
height: "95%",
onLoad: function() {
if (prev_anchor) {
prev_anchor = jQuery.url.attr('anchor');
}
curr_anchor = this.href.split('#')[1];
window.location.hash = curr_anchor;
},
onCleanup: function() {
if (prev_anchor) {
$('a[href="#'+prev_anchor+'"]').click();
curr_anchor = prev_anchor;
} else {
$('.group_tabs a:first').click();
prev_anchor = curr_anchor;
curr_anchor = "#_AllFiles";
}
window.location.hash = curr_anchor;
}
});

// Hide src files and file list container after load
$('.source_files').hide();
$('.file_list_container').hide();

// Add tabs based upon existing file_list_containers
$('.file_list_container h2').each(function(){
var container_id = $(this).parent().attr('id');
var group_name = $(this).find('.group_name').first().html();
var covered_percent = $(this).find('.covered_percent').first().html();

$('.group_tabs').append('<li><a href="#' + container_id + '">' + group_name + ' ('+ covered_percent +')</a></li>');
});

$('.group_tabs a').each( function() {
$(this).addClass($(this).attr('href').replace('#', ''));
});

// Make sure tabs don't get ugly focus borders when active
$('.group_tabs a').live('focus', function() { $(this).blur(); });

var favicon_path = $('link[rel="shortcut icon"]').attr('href');
$('.group_tabs a').live('click', function(){
if (!$(this).parent().hasClass('active')) {
Expand All @@ -71,21 +92,21 @@ $(document).ready(function() {
$('.file_list_container').hide();
$(".file_list_container" + $(this).attr('href')).show();
window.location.href = window.location.href.split('#')[0] + $(this).attr('href').replace('#', '#_');

// Force favicon reload - otherwise the location change containing anchor would drop the favicon...
// Works only on firefox, but still... - Anyone know a better solution to force favicon on local file?
$('link[rel="shortcut icon"]').remove();
$('head').append('<link rel="shortcut icon" type="image/png" href="'+ favicon_path +'" />');
};
return false;
});

if (jQuery.url.attr('anchor')) {
$('.group_tabs a.'+jQuery.url.attr('anchor').replace('_', '')).click();
} else {
$('.group_tabs a:first').click();
};

$("abbr.timeago").timeago();
$('#loading').fadeOut();
$('#wrapper').show();
Expand Down
Loading