3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
7 Ext.ux.Spotlight = function(config){
8 Ext.apply(this, config);
10 Ext.ux.Spotlight.prototype = {
19 createElements : function(){
20 var bd = Ext.getBody();
22 this.right = bd.createChild({cls:'x-spotlight'});
23 this.left = bd.createChild({cls:'x-spotlight'});
24 this.top = bd.createChild({cls:'x-spotlight'});
25 this.bottom = bd.createChild({cls:'x-spotlight'});
27 this.all = new Ext.CompositeElement([this.right, this.left, this.top, this.bottom]);
30 show : function(el, callback, scope){
32 this.show.defer(50, this, [el, callback, scope]);
35 this.el = Ext.get(el);
37 this.createElements();
40 this.all.setDisplayed('');
41 this.applyBounds(true, false);
43 Ext.EventManager.onWindowResize(this.syncSize, this);
44 this.applyBounds(false, this.animate, false, callback, scope);
46 this.applyBounds(false, false, false, callback, scope); // all these booleans look hideous
50 hide : function(callback, scope){
52 this.hide.defer(50, this, [callback, scope]);
55 Ext.EventManager.removeResizeListener(this.syncSize, this);
56 this.applyBounds(true, this.animate, true, callback, scope);
61 this.all.setDisplayed(false);
64 syncSize : function(){
65 this.applyBounds(false, false);
68 applyBounds : function(basePts, anim, doHide, callback, scope){
70 var rg = this.el.getRegion();
72 var dw = Ext.lib.Dom.getViewWidth(true);
73 var dh = Ext.lib.Dom.getViewHeight(true);
75 var c = 0, cb = false;
81 this.animated = false;
85 Ext.callback(callback, scope, [this]);
89 duration: this.duration,
97 basePts ? dh : rg.top,
99 basePts ? 0 : (dh - rg.top),
106 basePts ? 0 : rg.bottom,
110 basePts ? dw : rg.left,
112 basePts ? 0 : dw - rg.left,
116 this.bottom.setBounds(
119 basePts ? 0 : rg.right,
128 Ext.callback(callback, scope, [this]);
133 destroy : function(){
146 Ext.Spotlight = Ext.ux.Spotlight;