3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">Ext.ux.Spotlight = function(config){
\r
9 Ext.apply(this, config);
\r
11 Ext.ux.Spotlight.prototype = {
\r
20 createElements : function(){
\r
21 var bd = Ext.getBody();
\r
23 this.right = bd.createChild({cls:'x-spotlight'});
\r
24 this.left = bd.createChild({cls:'x-spotlight'});
\r
25 this.top = bd.createChild({cls:'x-spotlight'});
\r
26 this.bottom = bd.createChild({cls:'x-spotlight'});
\r
28 this.all = new Ext.CompositeElement([this.right, this.left, this.top, this.bottom]);
\r
31 show : function(el, callback, scope){
\r
33 this.show.defer(50, this, [el, callback, scope]);
\r
36 this.el = Ext.get(el);
\r
38 this.createElements();
\r
41 this.all.setDisplayed('');
\r
42 this.applyBounds(true, false);
\r
44 Ext.EventManager.onWindowResize(this.syncSize, this);
\r
45 this.applyBounds(false, this.animate, false, callback, scope);
\r
47 this.applyBounds(false, false, false, callback, scope); // all these booleans look hideous
\r
51 hide : function(callback, scope){
\r
53 this.hide.defer(50, this, [callback, scope]);
\r
56 Ext.EventManager.removeResizeListener(this.syncSize, this);
\r
57 this.applyBounds(true, this.animate, true, callback, scope);
\r
60 doHide : function(){
\r
61 this.active = false;
\r
62 this.all.setDisplayed(false);
\r
65 syncSize : function(){
\r
66 this.applyBounds(false, false);
\r
69 applyBounds : function(basePts, anim, doHide, callback, scope){
\r
71 var rg = this.el.getRegion();
\r
73 var dw = Ext.lib.Dom.getViewWidth(true);
\r
74 var dh = Ext.lib.Dom.getViewHeight(true);
\r
76 var c = 0, cb = false;
\r
79 callback: function(){
\r
82 this.animated = false;
\r
86 Ext.callback(callback, scope, [this]);
\r
90 duration: this.duration,
\r
93 this.animated = true;
\r
96 this.right.setBounds(
\r
98 basePts ? dh : rg.top,
\r
100 basePts ? 0 : (dh - rg.top),
\r
103 this.left.setBounds(
\r
107 basePts ? 0 : rg.bottom,
\r
110 this.top.setBounds(
\r
111 basePts ? dw : rg.left,
\r
113 basePts ? 0 : dw - rg.left,
\r
117 this.bottom.setBounds(
\r
120 basePts ? 0 : rg.right,
\r
129 Ext.callback(callback, scope, [this]);
\r
134 destroy : function(){
\r
147 Ext.Spotlight = Ext.ux.Spotlight;</pre>
\r