Sha256: 9dcd9149bca222cff2e007cb0cc1eb1fddf9797f2009d9e9be8d4446fa3606ff

Contents?: true

Size: 1.44 KB

Versions: 40

Compression:

Stored size: 1.44 KB

Contents

/**
 * Measure.js
 *
 * Released under LGPL License.
 * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
 *
 * License: http://www.tinymce.com/license
 * Contributing: http://www.tinymce.com/contributing
 */

define('tinymce/inlite/core/Measure', [
	'global!tinymce.DOM',
	'global!tinymce.geom.Rect',
	'tinymce/inlite/core/Convert'
], function (DOM, Rect, Convert) {
	var toAbsolute = function (rect) {
		var vp = DOM.getViewPort();

		return {
			x: rect.x + vp.x,
			y: rect.y + vp.y,
			w: rect.w,
			h: rect.h
		};
	};

	var measureElement = function (elm) {
		var clientRect = elm.getBoundingClientRect();

		return toAbsolute({
			x: clientRect.left,
			y: clientRect.top,
			w: Math.max(elm.clientWidth, elm.offsetWidth),
			h: Math.max(elm.clientHeight, elm.offsetHeight)
		});
	};

	var getElementRect = function (editor, elm) {
		return measureElement(elm);
	};

	var getPageAreaRect = function (editor) {
		return measureElement(editor.getElement().ownerDocument.body);
	};

	var getContentAreaRect = function (editor) {
		return measureElement(editor.getContentAreaContainer() || editor.getBody());
	};

	var getSelectionRect = function (editor) {
		var clientRect = editor.selection.getBoundingClientRect();
		return clientRect ? toAbsolute(Convert.fromClientRect(clientRect)) : null;
	};

	return {
		getElementRect: getElementRect,
		getPageAreaRect: getPageAreaRect,
		getContentAreaRect: getContentAreaRect,
		getSelectionRect: getSelectionRect
	};
});

Version data entries

40 entries across 40 versions & 2 rubygems

Version Path
wbase-0.3.20 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.19 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.18 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.17 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.16 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.15 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.14 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.13 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.12 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.11 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.10 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.9 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.8 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.7 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.6 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.5 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.4 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.3 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.2 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js
wbase-0.3.1 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js