4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js">/*
19 * @class Ext.window.Window
23 * Anchors this window to another element and realigns it when the window is resized or scrolled.
24 * @param {String/HTMLElement/Ext.Element} element The element to align to.
25 * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details)
26 * @param {Number[]} offsets (optional) Offset the positioning by [x, y]
27 * @param {Boolean/Number} monitorScroll (optional) true to monitor body scroll and reposition. If this parameter
28 * is a number, it is used as the buffer delay (defaults to 50ms).
29 * @return {Ext.window.Window} this
31 anchorTo: function(el, alignment, offsets, monitorScroll) {
39 Ext.EventManager.onWindowResize(this.doAnchor, this);
40 var tm = typeof monitorScroll;
41 if (tm != 'undefined') {
42 Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
44 buffer: tm == 'number' ? monitorScroll: 50
47 return this.doAnchor();
51 * Performs the anchor, using the saved anchorTarget property.
52 * @return {Ext.window.Window} this
55 doAnchor: function() {
56 var o = this.anchorTarget;
57 this.alignTo(o.el, o.alignment, o.offsets);
62 * Removes any existing anchor from this window. See {@link #anchorTo}.
63 * @return {Ext.window.Window} this
65 clearAnchor: function() {
66 if (this.anchorTarget) {
67 Ext.EventManager.removeResizeListener(this.doAnchor, this);
68 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
69 delete this.anchorTarget;