Skip to content

Commit

Permalink
Avoid some redundant calls of $(this)
Browse files Browse the repository at this point in the history
  • Loading branch information
okonomiyaki3000 committed Jan 17, 2018
1 parent ddbe7a0 commit fdd2ac3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions administrator/templates/isis/js/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,16 @@ jQuery(function($)
{

// Set max-height (and width if scroll) for dropdown menu, depending of window height
var $dropdownMenu = $(this).children('ul'),
var $self = $(this),
$dropdownMenu = $self.children('ul'),
windowHeight = $w.height(),
linkHeight = $(this).outerHeight(true),
linkHeight = $self.outerHeight(true),
statusHeight = $('#status').outerHeight(true),
menuHeight = $dropdownMenu.height(),
menuOuterHeight = $dropdownMenu.outerHeight(true),
scrollMenuWidth = $dropdownMenu.width() + 15,
maxHeight = windowHeight - (linkHeight + statusHeight + (menuOuterHeight - menuHeight) + 20),
linkPaddingLeft = $(this).children('a').css('padding-left');
linkPaddingLeft = $self.children('a').css('padding-left');

if (maxHeight < menuHeight)
{
Expand All @@ -106,9 +107,9 @@ jQuery(function($)
$dropdownMenu.css('max-height', maxHeight);

// Get the submenu position
linkWidth = $(this).outerWidth(true);
linkWidth = $self.outerWidth(true);
menuWidth = $dropdownMenu.width();
offsetLeft = Math.round($(this).offset().left) - parseInt(linkPaddingLeft);
offsetLeft = Math.round($self.offset().left) - parseInt(linkPaddingLeft);

emptyMenu.empty().hide();

Expand All @@ -120,7 +121,7 @@ jQuery(function($)
dropdown = $self.next('ul'),
submenuWidth = dropdown.outerWidth(),
offsetTop = $self.offset().top,
linkPaddingTop = parseInt(dropdown.css('padding-top')) + parseInt($(this).css('padding-top')),
linkPaddingTop = parseInt(dropdown.css('padding-top')) + parseInt($self.css('padding-top')),
scroll = $w.scrollTop() + linkPaddingTop;

// Set the submenu position
Expand Down

0 comments on commit fdd2ac3

Please sign in to comment.