Skip to content

Commit

Permalink
General cleanup of code base.
Browse files Browse the repository at this point in the history
  • Loading branch information
baphled committed Jun 9, 2010
1 parent 9da4af0 commit 20f2673
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions public/javascripts/scrollingHoverable.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,33 @@ $.fn.scrollingHoverable = function(options) {

$(this).live('mouseover', function() {
var sidebarPostfix = $('div#sidebar > ul').attr('id').split('_');
var $sidebar = $('div#sidebar > ul');
var $sidebarList = $('div#sidebar > ul');
var hoverItem = 'li#' + $(this).attr('id') + '_' + sidebarPostfix[1];
var height = $('div#lists').outerHeight() - $('div#footer').outerHeight();

var headerHeight = $(hoverItem).find('h3').outerHeight(),
footerHeight = $('div#footer').outerHeight(),
listHeight = $('div#lists').outerHeight();

var height = (listHeight - footerHeight) + headerHeight;
var setHoverPosition = function() {
var y = $(window).scrollTop();

if (y >= $('div#sidebar').offset().top) {
$sidebar.css('width', $('.hover').width())
$sidebar.addClass('fixed');
$sidebarList.css('width', $('.hover').width())
$sidebarList.addClass('fixed');
} else {
$(hoverItem).find('ul').css('');
$sidebar.removeClass('fixed');
// $(hoverItem).find('ul').css('');
$sidebarList.removeClass('fixed');
}
}

$sidebar.addClass('ui-widget ui-widget-content ui-corner-all');
$sidebarList.addClass('ui-widget ui-widget-content ui-corner-all');
setHoverPosition();

if (!$(hoverItem).is(':visible')) {
$('div#sidebar').find('li.side_hover').hide();
$sidebar.find(hoverItem).toggle();
$(hoverItem).autoScroller({speed: 500, height: height});
$sidebarList.find(hoverItem).toggle();
$(hoverItem).autoScroller({speed: 200, height: height, stopOnHover: opts.stopOnHover});

$(window).scroll(setHoverPosition);
}
Expand All @@ -44,7 +48,8 @@ $.fn.scrollingHoverable = function(options) {
// default options
$.fn.scrollingHoverable.defaults = {
scrollSpeed:500,
height:500
height:500,
stopOnHover: false
};

})(jQuery);

0 comments on commit 20f2673

Please sign in to comment.