$(document).ready(function() { $('.toggle-button').mouseover(function(event) { $(this).css('cursor', 'pointer'); }); $('.brick-group').each(function() { var h = $(this).children('ul:first').outerHeight(); $(this).children('ul').css('height', h); $(this).children('ul:odd').addClass('alternate'); }); $('.toggle-button').click(function(event) { var index = $('.toggle-button').index(this); var img = '.toggle-button img:eq(' + index + ')'; $(this).parent().nextAll('ul').toggle(); if ($(img).attr('src') == '/Content/images/app/icon_minus.png') { $(img).attr('src', '/Content/images/app/icon_plus.png') .attr('alt', 'Expand') .attr('title', 'Expand'); } else { $(img).attr('src', '/Content/images/app/icon_minus.png') .attr('alt', 'Collapse') .attr('title', 'Collapse'); } }); $('.brick-link').click(function(event) { $(this).nextAll('.brick-options').toggle(); var img = $(this).nextAll('img'); if ($(img).attr('src') == '/Content/images/arrow_collapsed.png') { $(img).attr('src', '/Content/images/arrow_expanded.png'); } else { $(img).attr('src', '/Content/images/arrow_collapsed.png'); } resetListHeigts($(this).parents('ul')); event.preventDefault(); }); $('.gs1-info > img') .mouseover(function(event) { var brickDef = $(this).parent().next('.brick-definition'); var deptGrp = $('#department-group'); var top = event.pageY + 20; var left = deptGrp.position().left + ((deptGrp.outerWidth() - brickDef.outerWidth()) / 2); if ((brickDef.outerHeight() + top) > (deptGrp.outerHeight() + deptGrp.position().top)) { top = event.pageY - brickDef.outerHeight() - 20; } brickDef.css('display', 'block') .css('top', top + 'px') .css('left', left + 'px'); }) .mouseout(function(event) { $(this).parent().next('.brick-definition') .css('display', 'none'); }); }); function resetListHeigts(ul) { $(ul).parent().children('ul').css('height', 'auto'); var maxHeight = 0; $(ul).parent().children('ul').each(function() { var h = $(this).outerHeight(); if (h > maxHeight) maxHeight = h; }); $(ul).parent().children('ul').each(function() { $(this).css('height', maxHeight); }); }