Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions dist/mentio.js
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,7 @@ angular.module('mentio')
selectionEl.css({
top: coordinates.top + 'px',
left: coordinates.left + 'px',
position: 'absolute',
zIndex: 10000,
position: coordinates.fixed ? 'fixed' : 'absolute',
display: 'block'
});

Expand Down Expand Up @@ -1113,12 +1112,32 @@ angular.module('mentio')
return coordinates;
}

// borrowed from jQuery getStyles code
// https://github.com/jquery/jquery/blob/master/src/css/var/getStyles.js
function getStyles (elem) {
// Support: IE <=11 only, Firefox <=30 (#15098, #14150)
// IE throws on elements created in popups
// FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
var view = elem.ownerDocument.defaultView;

if ( !view || !view.opener ) {
view = window;
}

return view.getComputedStyle( elem );
}

function localToGlobalCoordinates(ctx, element, coordinates) {
var obj = element;
var iframe = ctx ? ctx.iframe : null;
while(obj) {
coordinates.left += obj.offsetLeft + obj.clientLeft;
coordinates.top += obj.offsetTop + obj.clientTop;

if (getStyles(obj).position == 'fixed') {
coordinates.fixed = true;
}

obj = obj.offsetParent;
if (!obj && iframe) {
obj = iframe;
Expand Down
Loading