You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
4.3 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. Ext.ux.Spotlight = function(config){
  16. Ext.apply(this, config);
  17. }
  18. Ext.ux.Spotlight.prototype = {
  19. active : false,
  20. animate : true,
  21. duration: .25,
  22. easing:'easeNone',
  23. // private
  24. animated : false,
  25. createElements : function(){
  26. var bd = Ext.getBody();
  27. this.right = bd.createChild({cls:'x-spotlight'});
  28. this.left = bd.createChild({cls:'x-spotlight'});
  29. this.top = bd.createChild({cls:'x-spotlight'});
  30. this.bottom = bd.createChild({cls:'x-spotlight'});
  31. this.all = new Ext.CompositeElement([this.right, this.left, this.top, this.bottom]);
  32. },
  33. show : function(el, callback, scope){
  34. if(this.animated){
  35. this.show.defer(50, this, [el, callback, scope]);
  36. return;
  37. }
  38. this.el = Ext.get(el);
  39. if(!this.right){
  40. this.createElements();
  41. }
  42. if(!this.active){
  43. this.all.setDisplayed('');
  44. this.applyBounds(true, false);
  45. this.active = true;
  46. Ext.EventManager.onWindowResize(this.syncSize, this);
  47. this.applyBounds(false, this.animate, false, callback, scope);
  48. }else{
  49. this.applyBounds(false, false, false, callback, scope); // all these booleans look hideous
  50. }
  51. },
  52. hide : function(callback, scope){
  53. if(this.animated){
  54. this.hide.defer(50, this, [callback, scope]);
  55. return;
  56. }
  57. Ext.EventManager.removeResizeListener(this.syncSize, this);
  58. this.applyBounds(true, this.animate, true, callback, scope);
  59. },
  60. doHide : function(){
  61. this.active = false;
  62. this.all.setDisplayed(false);
  63. },
  64. syncSize : function(){
  65. this.applyBounds(false, false);
  66. },
  67. applyBounds : function(basePts, anim, doHide, callback, scope){
  68. var rg = this.el.getRegion();
  69. var dw = Ext.lib.Dom.getViewWidth(true);
  70. var dh = Ext.lib.Dom.getViewHeight(true);
  71. var c = 0, cb = false;
  72. if(anim){
  73. cb = {
  74. callback: function(){
  75. c++;
  76. if(c == 4){
  77. this.animated = false;
  78. if(doHide){
  79. this.doHide();
  80. }
  81. Ext.callback(callback, scope, [this]);
  82. }
  83. },
  84. scope: this,
  85. duration: this.duration,
  86. easing: this.easing
  87. };
  88. this.animated = true;
  89. }
  90. this.right.setBounds(
  91. rg.right,
  92. basePts ? dh : rg.top,
  93. dw - rg.right,
  94. basePts ? 0 : (dh - rg.top),
  95. cb);
  96. this.left.setBounds(
  97. 0,
  98. 0,
  99. rg.left,
  100. basePts ? 0 : rg.bottom,
  101. cb);
  102. this.top.setBounds(
  103. basePts ? dw : rg.left,
  104. 0,
  105. basePts ? 0 : dw - rg.left,
  106. rg.top,
  107. cb);
  108. this.bottom.setBounds(
  109. 0,
  110. rg.bottom,
  111. basePts ? 0 : rg.right,
  112. dh - rg.bottom,
  113. cb);
  114. if(!anim){
  115. if(doHide){
  116. this.doHide();
  117. }
  118. if(callback){
  119. Ext.callback(callback, scope, [this]);
  120. }
  121. }
  122. },
  123. destroy : function(){
  124. this.doHide();
  125. Ext.destroy(
  126. this.right,
  127. this.left,
  128. this.top,
  129. this.bottom);
  130. delete this.el;
  131. delete this.all;
  132. }
  133. };
  134. //backwards compat
  135. Ext.Spotlight = Ext.ux.Spotlight;