(function($) { $(document).ready(function() { $(window).bind('scroll', function() { $('#nav').fixedNav({ $window: $(this) }); }); $('a.external').bind('click', function(e) { e.preventDefault(); try { mpmetrics.track($(this).data('event')); } catch(e) { } window.location = $(this).attr('href'); }); $('body').delegate('nav a[href*="#"]:not(.button)', 'click', function(e) { e.preventDefault(); $(this).goToSection(); }); $('a.switch').bind('click', function(e) { e.preventDefault(); $(this).toggleSwitch(); }).each(function() { if ( $(this).siblings('input').val() == 'false' ) { $(this).find('span.switchButton') .css({ 'left': 0 }); $(this).find('.switchOn') .css({ 'width': 0, 'left': -40 }); } }); $('#tableBlock').getCommits(); $('#buildTable').bind('click', function(e) { e.preventDefault(); try { mpmetrics.track('Build-Table-Demo', { 'footer': $('#hasFooter').val(), 'cloneHeadToFoot': $('#cloneHeadToFoot').val(), 'fixedColumn': $('#fixedColumn').val() }); } catch(e) { } $('#tableBlock').fixedHeaderTable('destroy') .empty() .getCommits(); }); }); $.fn.extend({ toggleSwitch: function( ) { var $self = $(this), self = this, $button = $self.find('span.switchButton'), inputId = $self.data('for'), $input = $('#'+inputId), left = 30; if ( $button.position().left == 30 ) { left = 0; $input.val('false'); $('#demoOptions').text(''); $self.find('.switchOn') .animate({ 'width': '0' }, 300, function(){ $(this).css({ 'left': -40 }); }); } else { $input.val('true'); $self.find('.switchOn') .css({ 'left': 0 }) .animate({ 'width': '40', 'left': 0 }, 300); } $('#'+inputId+'Demo').text($input.val()); $button.animate({ left: left }, 200); }, fixedNav: function( options ) { var $self = $(this), self = this, $window = options.$window, offset = $self.outerHeight() - $self.find('a').outerHeight() - 26, $fixedWrapper = $('#fixedNav'); if ( $window.scrollTop() >= offset && !$('#fixedNav').length ) { $fixedWrapper = $('
').prependTo('body'); $fixedWrapper.append($self.clone()) .find('nav') .removeAttr('id'); setTimeout(function() {$fixedWrapper.find('nav').addClass('fixed');}, 0); } else if ( $fixedWrapper.length && $window.scrollTop() <= offset ) { $fixedWrapper.remove(); } return self; }, goToSection: function( options ) { var $self = $(this), self = this, hash = $self.attr('href'), scrollDistance = 0; hash = hash.replace('#',''); try { mpmetrics.track(hash); // track event } catch(e) { } if ( hash.toLowerCase() != 'home' ) { scrollDistance = $('#'+hash).offset().top - ( $('#nav li a').outerHeight(true) + 26 ); } $('html,body').animate({ 'scrollTop': scrollDistance }, 700); }, buildTable: function( options ) { var $self = $(this), self = this, $footer = $('#hasFooter'), $clone = $('#cloneHeadToFoot'), $fixedColumn = $('#fixedColumn'), hasFooter = ( $footer.val() == 'true' ) ? true : false, hasClone = ( $clone.val() == 'true' ) ? true : false, hasFixedColumn = ( $fixedColumn.val() == 'true' ) ? true : false, aMessages = options.data.commits, colSpan = 4, $thead, $tbody, $tfoot, $currentRow, commitDate, authoredDate, aCommitMessage, commitMessage; if ( hasFixedColumn == true ) { colSpan = 5; } if ( hasFooter && !hasClone ) { $self.append('"; commitMessage += aCommitMessage[theMessage]; commitMessage += "
"; } } $currentRow = $('