getOffset() now falls back to old slower version for CSS layouts which cannot figure out bounding box widths. This fixes the photo and attachment upload buttons for some themes such as vier.
This commit is contained in:
parent
6a2a54c9be
commit
06246bb0f2
|
@ -57,6 +57,22 @@
|
|||
timeout = setTimeout(fn, 100);
|
||||
});
|
||||
}
|
||||
|
||||
// Get offset adding all offsets, slow fall-back method
|
||||
var getOffsetSlow = function(el){
|
||||
var top = 0, left = 0;
|
||||
do {
|
||||
top += el.offsetTop || 0;
|
||||
left += el.offsetLeft || 0;
|
||||
el = el.offsetParent;
|
||||
} while (el);
|
||||
|
||||
return {
|
||||
left: left,
|
||||
top: top
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// Needs more testing, will be rewriten for next version
|
||||
// getOffset function copied from jQuery lib (http://jquery.com/)
|
||||
|
@ -78,6 +94,11 @@
|
|||
var bound = body.getBoundingClientRect();
|
||||
zoom = (bound.right - bound.left) / body.clientWidth;
|
||||
}
|
||||
|
||||
// some CSS layouts gives 0 width and/or bounding boxes
|
||||
// in this case we fall back to the slow method
|
||||
if (zoom == 0 || body.clientWidth == 0)
|
||||
return getOffsetSlow(el);
|
||||
|
||||
if (zoom > 1) {
|
||||
clientTop = 0;
|
||||
|
@ -92,20 +113,7 @@
|
|||
};
|
||||
};
|
||||
} else {
|
||||
// Get offset adding all offsets
|
||||
var getOffset = function(el){
|
||||
var top = 0, left = 0;
|
||||
do {
|
||||
top += el.offsetTop || 0;
|
||||
left += el.offsetLeft || 0;
|
||||
el = el.offsetParent;
|
||||
} while (el);
|
||||
|
||||
return {
|
||||
left: left,
|
||||
top: top
|
||||
};
|
||||
};
|
||||
var getOffset = getOffsetSlow;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user