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