template/build/bundle.js
/*
        Helper function to position and resize dropdown.
        Used in hover and click handler.
      */
Helper function to position and resize dropdown.
Used in hover and click handler.
Helper function to position and resize dropdown . Used in hover and click handler .
function placeDropdown(eventType) {
        if (eventType === 'focus') {
          isFocused = true;
        }
        updateOptions();
        activates.addClass('active');
        origin.addClass('active');
        if (curr_options.constrainWidth === true) {
          activates.css('width', origin.outerWidth());
        } else {
          activates.css('white-space', 'nowrap');
        }
        var windowHeight = window.innerHeight;
        var originHeight = origin.innerHeight();
        var offsetLeft = origin.offset().left;
        var offsetTop = origin.offset().top - $(window).scrollTop();
        var currAlignment = curr_options.alignment;
        var gutterSpacing = 0;
        var leftPosition = 0;
        var verticalOffset = 0;
        if (curr_options.belowOrigin === true) {
          verticalOffset = originHeight;
        }
        var scrollYOffset = 0;
        var scrollXOffset = 0;
        var wrapper = origin.parent();
        if (!wrapper.is('body')) {
          if (wrapper[0].scrollHeight > wrapper[0].clientHeight) {
            scrollYOffset = wrapper[0].scrollTop;
          }
          if (wrapper[0].scrollWidth > wrapper[0].clientWidth) {
            scrollXOffset = wrapper[0].scrollLeft;
          }
        }
        if (offsetLeft + activates.innerWidth() > $(window).width()) {
          currAlignment = 'right';
        } else if (offsetLeft - activates.innerWidth() + origin.innerWidth() < 0) {
          currAlignment = 'left';
        }
        if (offsetTop + activates.innerHeight() > windowHeight) {
          if (offsetTop + originHeight - activates.innerHeight() < 0) {
            var adjustedHeight = windowHeight - offsetTop - verticalOffset;
            activates.css('max-height', adjustedHeight);
          } else {
            if (!verticalOffset) {
              verticalOffset += originHeight;
            }
            verticalOffset -= activates.innerHeight();
          }
        }
        if (currAlignment === 'left') {
          gutterSpacing = curr_options.gutter;
          leftPosition = origin.position().left + gutterSpacing;
        } else if (currAlignment === 'right') {
          var offsetRight = origin.position().left + origin.outerWidth() - activates.outerWidth();
          gutterSpacing = -curr_options.gutter;
          leftPosition = offsetRight + gutterSpacing;
        }
        activates.css({
          position: 'absolute',
          top: origin.position().top + verticalOffset + scrollYOffset,
          left: leftPosition + scrollXOffset
        });
        activates.stop(true, true).css('opacity', 0).slideDown({
          queue: false,
          duration: curr_options.inDuration,
          easing: 'easeOutCubic',
          complete: function complete() {
            $(this).css('height', '');
          }
        }).animate({ opacity: 1 }, { queue: false, duration: curr_options.inDuration, easing: 'easeOutSine' });
        setTimeout(function () {
          $(document).bind('click.' + activates.attr('id'), function (e) {
            hideDropdown();
            $(document).unbind('click.' + activates.attr('id'));
          });
        }, 0);
      }
function placeDropdown ( eventType ) { if ( eventType === 'focus' ) { isFocused = true ; } updateOptions ( ) ; activates . addClass ( 'active' ) ; origin . addClass ( 'active' ) ; if ( curr_options . constrainWidth === true ) { activates . css ( 'width' , origin . outerWidth ( ) ) ; } else { activates . css ( 'white-space' , 'nowrap' ) ; } var windowHeight = window . innerHeight ; var originHeight = origin . innerHeight ( ) ; var offsetLeft = origin . offset ( ) . left ; var offsetTop = origin . offset ( ) . top - $ ( window ) . scrollTop ( ) ; var currAlignment = curr_options . alignment ; var gutterSpacing = 0 ; var leftPosition = 0 ; var verticalOffset = 0 ; if ( curr_options . belowOrigin === true ) { verticalOffset = originHeight ; } var scrollYOffset = 0 ; var scrollXOffset = 0 ; var wrapper = origin . parent ( ) ; if ( ! wrapper . is ( 'body' ) ) { if ( wrapper [ 0 ] . scrollHeight > wrapper [ 0 ] . clientHeight ) { scrollYOffset = wrapper [ 0 ] . scrollTop ; } if ( wrapper [ 0 ] . scrollWidth > wrapper [ 0 ] . clientWidth ) { scrollXOffset = wrapper [ 0 ] . scrollLeft ; } } if ( offsetLeft + activates . innerWidth ( ) > $ ( window ) . width ( ) ) { currAlignment = 'right' ; } else if ( offsetLeft - activates . innerWidth ( ) + origin . innerWidth ( ) < 0 ) { currAlignment = 'left' ; } if ( offsetTop + activates . innerHeight ( ) > windowHeight ) { if ( offsetTop + originHeight - activates . innerHeight ( ) < 0 ) { var adjustedHeight = windowHeight - offsetTop - verticalOffset ; activates . css ( 'max-height' , adjustedHeight ) ; } else { if ( ! verticalOffset ) { verticalOffset += originHeight ; } verticalOffset -= activates . innerHeight ( ) ; } } if ( currAlignment === 'left' ) { gutterSpacing = curr_options . gutter ; leftPosition = origin . position ( ) . left + gutterSpacing ; } else if ( currAlignment === 'right' ) { var offsetRight = origin . position ( ) . left + origin . outerWidth ( ) - activates . outerWidth ( ) ; gutterSpacing = - curr_options . gutter ; leftPosition = offsetRight + gutterSpacing ; } activates . css ( { position : 'absolute' , top : origin . position ( ) . top + verticalOffset + scrollYOffset , left : leftPosition + scrollXOffset } ) ; activates . stop ( true , true ) . css ( 'opacity' , 0 ) . slideDown ( { queue : false , duration : curr_options . inDuration , easing : 'easeOutCubic' , complete : function complete ( ) { $ ( this ) . css ( 'height' , '' ) ; } } ) . animate ( { opacity : 1 } , { queue : false , duration : curr_options . inDuration , easing : 'easeOutSine' } ) ; setTimeout ( function ( ) { $ ( document ) . bind ( 'click.' + activates . attr ( 'id' ) , function ( e ) { hideDropdown ( ) ; $ ( document ) . unbind ( 'click.' + activates . attr ( 'id' ) ) ; } ) ; } , 0 ) ; }
Helper function to position and resize dropdown.
Helper function to position and resize dropdown .
// Check for simultaneous focus and click events. // Check html data attributes // Set Dropdown state // Constrain width // Offscreen detection // Below Origin // Check for scrolling positioned container. // Dropdown goes past screen on right, force right alignment // Dropdown goes past screen on left, force left alignment // Vertical bottom offscreen detection // If going upwards still goes offscreen, just crop height of dropdown. // Flow upwards. // Handle edge alignment // Position dropdown // Show dropdown // Add click close handler to document