source: trunk/admin/inc/ckeditor/_source/core/dom/window.js@ 239

Last change on this file since 239 was 239, checked in by luc, 9 years ago

Admin: correzione visulaizzazione immissione dati spoglio per Chrome e Safari - Aggiornamento dell'editor da FCKeditor a CKeditor , accessibili anche a Chrome e Safari.

  • Property svn:executable set to *
File size: 2.5 KB
Line 
1/*
2Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3For licensing, see LICENSE.html or http://ckeditor.com/license
4*/
5
6/**
7 * @fileOverview Defines the {@link CKEDITOR.dom.document} class, which
8 * represents a DOM document.
9 */
10
11/**
12 * Represents a DOM window.
13 * @constructor
14 * @augments CKEDITOR.dom.domObject
15 * @param {Object} domWindow A native DOM window.
16 * @example
17 * var document = new CKEDITOR.dom.window( window );
18 */
19CKEDITOR.dom.window = function( domWindow )
20{
21 CKEDITOR.dom.domObject.call( this, domWindow );
22};
23
24CKEDITOR.dom.window.prototype = new CKEDITOR.dom.domObject();
25
26CKEDITOR.tools.extend( CKEDITOR.dom.window.prototype,
27 /** @lends CKEDITOR.dom.window.prototype */
28 {
29 /**
30 * Moves the selection focus to this window.
31 * @function
32 * @example
33 * var win = new CKEDITOR.dom.window( window );
34 * <b>win.focus()</b>;
35 */
36 focus : function()
37 {
38 // Webkit is sometimes failed to focus iframe, blur it first(#3835).
39 if ( CKEDITOR.env.webkit && this.$.parent )
40 this.$.parent.focus();
41 this.$.focus();
42 },
43
44 /**
45 * Gets the width and height of this window's viewable area.
46 * @function
47 * @returns {Object} An object with the "width" and "height"
48 * properties containing the size.
49 * @example
50 * var win = new CKEDITOR.dom.window( window );
51 * var size = <b>win.getViewPaneSize()</b>;
52 * alert( size.width );
53 * alert( size.height );
54 */
55 getViewPaneSize : function()
56 {
57 var doc = this.$.document,
58 stdMode = doc.compatMode == 'CSS1Compat';
59 return {
60 width : ( stdMode ? doc.documentElement.clientWidth : doc.body.clientWidth ) || 0,
61 height : ( stdMode ? doc.documentElement.clientHeight : doc.body.clientHeight ) || 0
62 };
63 },
64
65 /**
66 * Gets the current position of the window's scroll.
67 * @function
68 * @returns {Object} An object with the "x" and "y" properties
69 * containing the scroll position.
70 * @example
71 * var win = new CKEDITOR.dom.window( window );
72 * var pos = <b>win.getScrollPosition()</b>;
73 * alert( pos.x );
74 * alert( pos.y );
75 */
76 getScrollPosition : function()
77 {
78 var $ = this.$;
79
80 if ( 'pageXOffset' in $ )
81 {
82 return {
83 x : $.pageXOffset || 0,
84 y : $.pageYOffset || 0
85 };
86 }
87 else
88 {
89 var doc = $.document;
90 return {
91 x : doc.documentElement.scrollLeft || doc.body.scrollLeft || 0,
92 y : doc.documentElement.scrollTop || doc.body.scrollTop || 0
93 };
94 }
95 }
96 });
Note: See TracBrowser for help on using the repository browser.