code: function (t) {
          var o_p = this.offsetParent(),
              o = o_p.offset(),
              p = t.offset();
  
          p.top -= o.top;
          p.left -= o.left;
  
          //set some flags on the p object to pass along
          p.missRight = false;
          p.missTop = false;
          p.missLeft = false;
          p.leftRightFlag = false;
  
          //lets see if the panel will be off the screen
          //get the actual width of the page and store it
          var actualBodyWidth;
          if (document.getElementsByClassName('row')[0]) {
            actualBodyWidth = document.getElementsByClassName('row')[0].clientWidth;
          } else {
            actualBodyWidth = window.outerWidth;
          }
  
          var actualMarginWidth = (window.outerWidth - actualBodyWidth) / 2;
          var actualBoundary = actualBodyWidth;
  
          if (!this.hasClass('mega')) {
            //miss top
            if (t.offset().top <= this.outerHeight()) {
              p.missTop = true;
              actualBoundary = window.outerWidth - actualMarginWidth;
              p.leftRightFlag = true;
            }
  
            //miss right
            if (t.offset().left + this.outerWidth() > t.offset().left + actualMarginWidth && t.offset().left - actualMarginWidth > this.outerWidth()) {
              p.missRight = true;
              p.missLeft = false;
            }
  
            //miss left
            if (t.offset().left - this.outerWidth() <= 0) {
              p.missLeft = true;
              p.missRight = false;
            }
          }
  
          return p;
        }
docs: Calculate target offset