]>
git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blob - sources/core/dom/window.js
2 * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
7 * @fileOverview Defines the {@link CKEDITOR.dom.document} class, which
8 * represents a DOM document.
12 * Represents a DOM window.
14 * var document = new CKEDITOR.dom.window( window );
17 * @extends CKEDITOR.dom.domObject
18 * @constructor Creates a window class instance.
19 * @param {Object} domWindow A native DOM window.
21 CKEDITOR
.dom
.window = function( domWindow
) {
22 CKEDITOR
.dom
.domObject
.call( this, domWindow
);
25 CKEDITOR
.dom
.window
.prototype = new CKEDITOR
.dom
.domObject();
27 CKEDITOR
.tools
.extend( CKEDITOR
.dom
.window
.prototype, {
29 * Moves the selection focus to this window.
31 * var win = new CKEDITOR.dom.window( window );
39 * Gets the width and height of this window's viewable area.
41 * var win = new CKEDITOR.dom.window( window );
42 * var size = win.getViewPaneSize();
43 * alert( size.width );
44 * alert( size.height );
46 * @returns {Object} An object with the `width` and `height`
47 * properties containing the size.
49 getViewPaneSize: function() {
50 var doc
= this.$.document
,
51 stdMode
= doc
.compatMode
== 'CSS1Compat';
53 width: ( stdMode
? doc
.documentElement
.clientWidth : doc
.body
.clientWidth
) || 0,
54 height: ( stdMode
? doc
.documentElement
.clientHeight : doc
.body
.clientHeight
) || 0
59 * Gets the current position of the window's scroll.
61 * var win = new CKEDITOR.dom.window( window );
62 * var pos = win.getScrollPosition();
66 * @returns {Object} An object with the `x` and `y` properties
67 * containing the scroll position.
69 getScrollPosition: function() {
72 if ( 'pageXOffset' in $ ) {
74 x: $.pageXOffset
|| 0,
80 x: doc
.documentElement
.scrollLeft
|| doc
.body
.scrollLeft
|| 0,
81 y: doc
.documentElement
.scrollTop
|| doc
.body
.scrollTop
|| 0
87 * Gets the frame element containing this window context.
89 * @returns {CKEDITOR.dom.element} The frame element or `null` if not in a frame context.
91 getFrame: function() {
92 var iframe
= this.$.frameElement
;
93 return iframe
? new CKEDITOR
.dom
.element
.get( iframe
) : null;