OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
_backup
/
tinymce
/
tinymce
/
src
/
core
/
main
/
ts
/
dom
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/20/2020 05:44:43 AM
rwxr-xr-x
📄
Dimensions.ts
1.28 KB
02/20/2020 05:42:59 AM
rw-r--r--
📄
DomSerializer.ts
4.65 KB
02/20/2020 05:42:59 AM
rw-r--r--
📄
DomSerializerFilters.ts
6.91 KB
02/20/2020 05:43:00 AM
rw-r--r--
📄
DomSerializerPreProcess.ts
1.81 KB
02/20/2020 05:43:00 AM
rw-r--r--
📄
ElementType.ts
2.39 KB
02/20/2020 05:43:01 AM
rw-r--r--
📄
Empty.ts
2.18 KB
02/20/2020 05:43:02 AM
rw-r--r--
📄
MousePosition.ts
2.37 KB
02/20/2020 05:43:03 AM
rw-r--r--
📄
NodePath.ts
970 bytes
02/20/2020 05:43:03 AM
rw-r--r--
📄
NodeType.ts
3.37 KB
02/20/2020 05:43:04 AM
rw-r--r--
📄
PaddingBr.ts
1.7 KB
02/20/2020 05:43:04 AM
rw-r--r--
📄
Parents.ts
1020 bytes
02/20/2020 05:43:05 AM
rw-r--r--
📄
Position.ts
2.9 KB
02/20/2020 05:43:05 AM
rw-r--r--
📄
RangePoint.ts
639 bytes
02/20/2020 05:43:06 AM
rw-r--r--
📄
ScrollIntoView.ts
3.27 KB
02/20/2020 05:43:07 AM
rw-r--r--
📄
StyleSheetLoader.ts
6.49 KB
02/20/2020 05:43:08 AM
rw-r--r--
📄
TrimHtml.ts
1.62 KB
02/20/2020 05:43:08 AM
rw-r--r--
📄
TrimNode.ts
2.58 KB
02/20/2020 05:43:09 AM
rw-r--r--
Editing: Position.ts
Close
/** * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ */ import { Arr } from '@ephox/katamari'; import { PlatformDetection } from '@ephox/sand'; import { Element, Node, Css, Traverse } from '@ephox/sugar'; const browser = PlatformDetection.detect().browser; const firstElement = function (nodes) { return Arr.find(nodes, Node.isElement); }; // Firefox has a bug where caption height is not included correctly in offset calculations of tables // this tries to compensate for that by detecting if that offsets are incorrect and then remove the height const getTableCaptionDeltaY = function (elm) { if (browser.isFirefox() && Node.name(elm) === 'table') { return firstElement(Traverse.children(elm)).filter(function (elm) { return Node.name(elm) === 'caption'; }).bind(function (caption) { return firstElement(Traverse.nextSiblings(caption)).map(function (body) { const bodyTop = body.dom().offsetTop; const captionTop = caption.dom().offsetTop; const captionHeight = caption.dom().offsetHeight; return bodyTop <= captionTop ? -captionHeight : 0; }); }).getOr(0); } else { return 0; } }; const getPos = function (body, elm, rootElm) { let x = 0, y = 0, offsetParent; const doc = body.ownerDocument; let pos; rootElm = rootElm ? rootElm : body; if (elm) { // Use getBoundingClientRect if it exists since it's faster than looping offset nodes // Fallback to offsetParent calculations if the body isn't static better since it stops at the body root if (rootElm === body && elm.getBoundingClientRect && Css.get(Element.fromDom(body), 'position') === 'static') { pos = elm.getBoundingClientRect(); // Add scroll offsets from documentElement or body since IE with the wrong box model will use d.body and so do WebKit // Also remove the body/documentelement clientTop/clientLeft on IE 6, 7 since they offset the position x = pos.left + (doc.documentElement.scrollLeft || body.scrollLeft) - doc.documentElement.clientLeft; y = pos.top + (doc.documentElement.scrollTop || body.scrollTop) - doc.documentElement.clientTop; return { x, y }; } offsetParent = elm; while (offsetParent && offsetParent !== rootElm && offsetParent.nodeType) { x += offsetParent.offsetLeft || 0; y += offsetParent.offsetTop || 0; offsetParent = offsetParent.offsetParent; } offsetParent = elm.parentNode; while (offsetParent && offsetParent !== rootElm && offsetParent.nodeType) { x -= offsetParent.scrollLeft || 0; y -= offsetParent.scrollTop || 0; offsetParent = offsetParent.parentNode; } y += getTableCaptionDeltaY(Element.fromDom(elm)); } return { x, y }; }; export default { getPos };