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