2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html 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 * @augments CKEDITOR.dom.domObject
15 * @param {Object} domWindow A native DOM window.
17 * var document = new CKEDITOR.dom.window( window );
19 CKEDITOR.dom.window = function( domWindow )
21 CKEDITOR.dom.domObject.call( this, domWindow );
24 CKEDITOR.dom.window.prototype = new CKEDITOR.dom.domObject();
26 CKEDITOR.tools.extend( CKEDITOR.dom.window.prototype,
27 /** @lends CKEDITOR.dom.window.prototype */
30 * Moves the selection focus to this window.
33 * var win = new CKEDITOR.dom.window( window );
38 // Webkit is sometimes failed to focus iframe, blur it first(#3835).
39 if ( CKEDITOR.env.webkit && this.$.parent )
40 this.$.parent.focus();
45 * Gets the width and height of this window's viewable area.
47 * @returns {Object} An object with the "width" and "height"
48 * properties containing the size.
50 * var win = new CKEDITOR.dom.window( window );
51 * var size = <b>win.getViewPaneSize()</b>;
52 * alert( size.width );
53 * alert( size.height );
55 getViewPaneSize : function()
57 var doc = this.$.document,
58 stdMode = doc.compatMode == 'CSS1Compat';
60 width : ( stdMode ? doc.documentElement.clientWidth : doc.body.clientWidth ) || 0,
61 height : ( stdMode ? doc.documentElement.clientHeight : doc.body.clientHeight ) || 0
66 * Gets the current position of the window's scroll.
68 * @returns {Object} An object with the "x" and "y" properties
69 * containing the scroll position.
71 * var win = new CKEDITOR.dom.window( window );
72 * var pos = <b>win.getScrollPosition()</b>;
76 getScrollPosition : function()
80 if ( 'pageXOffset' in $ )
83 x : $.pageXOffset || 0,
84 y : $.pageYOffset || 0
91 x : doc.documentElement.scrollLeft || doc.body.scrollLeft || 0,
92 y : doc.documentElement.scrollTop || doc.body.scrollTop || 0