demo/ui-bootstrap-tpls.0.11.2.js
function (hostEl, targetEl, positionStr, appendToBody) {

        var positionStrParts = positionStr.split('-');
        var pos0 = positionStrParts[0], pos1 = positionStrParts[1] || 'center';

        var hostElPos,
          targetElWidth,
          targetElHeight,
          targetElPos;

        hostElPos = appendToBody ? this.offset(hostEl) : this.position(hostEl);

        targetElWidth = targetEl.prop('offsetWidth');
        targetElHeight = targetEl.prop('offsetHeight');

        var shiftWidth = {
          center: function () {
            return hostElPos.left + hostElPos.width / 2 - targetElWidth / 2;
          },
          left: function () {
            return hostElPos.left;
          },
          right: function () {
            return hostElPos.left + hostElPos.width;
          }
        };

        var shiftHeight = {
          center: function () {
            return hostElPos.top + hostElPos.height / 2 - targetElHeight / 2;
          },
          top: function () {
            return hostElPos.top;
          },
          bottom: function () {
            return hostElPos.top + hostElPos.height;
          }
        };

        switch (pos0) {
          case 'right':
            targetElPos = {
              top: shiftHeight[pos1](),
              left: shiftWidth[pos0]()
            };
            break;
          case 'left':
            targetElPos = {
              top: shiftHeight[pos1](),
              left: hostElPos.left - targetElWidth
            };
            break;
          case 'bottom':
            targetElPos = {
              top: shiftHeight[pos0](),
              left: shiftWidth[pos1]()
            };
            break;
          default:
            targetElPos = {
              top: hostElPos.top - targetElHeight,
              left: shiftWidth[pos1]()
            };
            break;
        }

        return targetElPos;
      }
function (hostEl, targetEl, positionStr, appendToBody) {

        var positionStrParts = positionStr.split('-');
        var pos0 = positionStrParts[0], pos1 = positionStrParts[1] || 'center';

        var hostElPos,
          targetElWidth,
          targetElHeight,
          targetElPos;

        hostElPos = appendToBody ? this.offset(hostEl) : this.position(hostEl);

        targetElWidth = targetEl.prop('offsetWidth');
        targetElHeight = targetEl.prop('offsetHeight');

        var shiftWidth = {
          center: function () {
            return hostElPos.left + hostElPos.width / 2 - targetElWidth / 2;
          },
          left: function () {
            return hostElPos.left;
          },
          right: function () {
            return hostElPos.left + hostElPos.width;
          }
        };

        var shiftHeight = {
          center: function () {
            return hostElPos.top + hostElPos.height / 2 - targetElHeight / 2;
          },
          top: function () {
            return hostElPos.top;
          },
          bottom: function () {
            return hostElPos.top + hostElPos.height;
          }
        };

        switch (pos0) {
          case 'right':
            targetElPos = {
              top: shiftHeight[pos1](),
              left: shiftWidth[pos0]()
            };
            break;
          case 'left':
            targetElPos = {
              top: shiftHeight[pos1](),
              left: hostElPos.left - targetElWidth
            };
            break;
          case 'bottom':
            targetElPos = {
              top: shiftHeight[pos0](),
              left: shiftWidth[pos1]()
            };
            break;
          default:
            targetElPos = {
              top: hostElPos.top - targetElHeight,
              left: shiftWidth[pos1]()
            };
            break;
        }

        return targetElPos;
      }
function ( hostEl , targetEl , positionStr , appendToBody ) { var positionStrParts = positionStr . split ( '-' ) ; var pos0 = positionStrParts [ 0 ] , pos1 = positionStrParts [ 1 ] || 'center' ; var hostElPos , targetElWidth , targetElHeight , targetElPos ; hostElPos = appendToBody ? this . offset ( hostEl ) : this . position ( hostEl ) ; targetElWidth = targetEl . prop ( 'offsetWidth' ) ; targetElHeight = targetEl . prop ( 'offsetHeight' ) ; var shiftWidth = { center : function ( ) { return hostElPos . left + hostElPos . width / 2 - targetElWidth / 2 ; } , left : function ( ) { return hostElPos . left ; } , right : function ( ) { return hostElPos . left + hostElPos . width ; } } ; var shiftHeight = { center : function ( ) { return hostElPos . top + hostElPos . height / 2 - targetElHeight / 2 ; } , top : function ( ) { return hostElPos . top ; } , bottom : function ( ) { return hostElPos . top + hostElPos . height ; } } ; switch ( pos0 ) { case 'right' : targetElPos = { top : shiftHeight [ pos1 ] ( ) , left : shiftWidth [ pos0 ] ( ) } ; break ; case 'left' : targetElPos = { top : shiftHeight [ pos1 ] ( ) , left : hostElPos . left - targetElWidth } ; break ; case 'bottom' : targetElPos = { top : shiftHeight [ pos0 ] ( ) , left : shiftWidth [ pos1 ] ( ) } ; break ; default : targetElPos = { top : hostElPos . top - targetElHeight , left : shiftWidth [ pos1 ] ( ) } ; break ; } return targetElPos ; }
Provides coordinates for the targetEl in relation to hostEl
Provides coordinates for the targetEl in relation to hostEl