X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/src/window/Window-legacy.js diff --git a/src/window/Window-legacy.js b/src/window/Window-legacy.js new file mode 100644 index 00000000..d82cef8b --- /dev/null +++ b/src/window/Window-legacy.js @@ -0,0 +1,57 @@ +/** + * @class Ext.Window + * @ignore + */ +Ext.Window.override({ + /** + * Anchors this window to another element and realigns it when the window is resized or scrolled. + * @param {Mixed} element The element to align to. + * @param {String} position The position to align to (see {@link Ext.core.Element#alignTo} for more details) + * @param {Array} offsets (optional) Offset the positioning by [x, y] + * @param {Boolean/Number} monitorScroll (optional) true to monitor body scroll and reposition. If this parameter + * is a number, it is used as the buffer delay (defaults to 50ms). + * @return {Ext.window.Window} this + */ + anchorTo: function(el, alignment, offsets, monitorScroll) { + this.clearAnchor(); + this.anchorTarget = { + el: el, + alignment: alignment, + offsets: offsets + }; + + Ext.EventManager.onWindowResize(this.doAnchor, this); + var tm = typeof monitorScroll; + if (tm != 'undefined') { + Ext.EventManager.on(window, 'scroll', this.doAnchor, this, + { + buffer: tm == 'number' ? monitorScroll: 50 + }); + } + return this.doAnchor(); + }, + + /** + * Performs the anchor, using the saved anchorTarget property. + * @return {Ext.window.Window} this + * @private + */ + doAnchor: function() { + var o = this.anchorTarget; + this.alignTo(o.el, o.alignment, o.offsets); + return this; + }, + + /** + * Removes any existing anchor from this window. See {@link #anchorTo}. + * @return {Ext.window.Window} this + */ + clearAnchor: function() { + if (this.anchorTarget) { + Ext.EventManager.removeResizeListener(this.doAnchor, this); + Ext.EventManager.un(window, 'scroll', this.doAnchor, this); + delete this.anchorTarget; + } + return this; + } +}); \ No newline at end of file