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.

354 lines
15 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-EventManager'>/**
  19. </span>* @class Ext.EventManager
  20. */
  21. Ext.apply(Ext.EventManager, function(){
  22. var resizeEvent,
  23. resizeTask,
  24. textEvent,
  25. textSize,
  26. D = Ext.lib.Dom,
  27. propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
  28. unload = Ext.EventManager._unload,
  29. curWidth = 0,
  30. curHeight = 0,
  31. // note 1: IE fires ONLY the keydown event on specialkey autorepeat
  32. // note 2: Safari &lt; 3.1, Gecko (Mac/Linux) &amp; Opera fire only the keypress event on specialkey autorepeat
  33. // (research done by @Jan Wolter at http://unixpapa.com/js/key.html)
  34. useKeydown = Ext.isWebKit ?
  35. Ext.num(navigator.userAgent.match(/AppleWebKit\/(\d+)/)[1]) &gt;= 525 :
  36. !((Ext.isGecko &amp;&amp; !Ext.isWindows) || Ext.isOpera);
  37. return {
  38. _unload: function(){
  39. Ext.EventManager.un(window, &quot;resize&quot;, this.fireWindowResize, this);
  40. unload.call(Ext.EventManager);
  41. },
  42. // private
  43. doResizeEvent: function(){
  44. var h = D.getViewHeight(),
  45. w = D.getViewWidth();
  46. //whacky problem in IE where the resize event will fire even though the w/h are the same.
  47. if(curHeight != h || curWidth != w){
  48. resizeEvent.fire(curWidth = w, curHeight = h);
  49. }
  50. },
  51. <span id='Ext-EventManager-method-onWindowResize'> /**
  52. </span> * Adds a listener to be notified when the browser window is resized and provides resize event buffering (100 milliseconds),
  53. * passes new viewport width and height to handlers.
  54. * @param {Function} fn The handler function the window resize event invokes.
  55. * @param {Object} scope The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the handler function executes. Defaults to the browser window.
  56. * @param {boolean} options Options object as passed to {@link Ext.Element#addListener}
  57. */
  58. onWindowResize : function(fn, scope, options){
  59. if(!resizeEvent){
  60. resizeEvent = new Ext.util.Event();
  61. resizeTask = new Ext.util.DelayedTask(this.doResizeEvent);
  62. Ext.EventManager.on(window, &quot;resize&quot;, this.fireWindowResize, this);
  63. }
  64. resizeEvent.addListener(fn, scope, options);
  65. },
  66. // exposed only to allow manual firing
  67. fireWindowResize : function(){
  68. if(resizeEvent){
  69. resizeTask.delay(100);
  70. }
  71. },
  72. <span id='Ext-EventManager-method-onTextResize'> /**
  73. </span> * Adds a listener to be notified when the user changes the active text size. Handler gets called with 2 params, the old size and the new size.
  74. * @param {Function} fn The function the event invokes.
  75. * @param {Object} scope The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the handler function executes. Defaults to the browser window.
  76. * @param {boolean} options Options object as passed to {@link Ext.Element#addListener}
  77. */
  78. onTextResize : function(fn, scope, options){
  79. if(!textEvent){
  80. textEvent = new Ext.util.Event();
  81. var textEl = new Ext.Element(document.createElement('div'));
  82. textEl.dom.className = 'x-text-resize';
  83. textEl.dom.innerHTML = 'X';
  84. textEl.appendTo(document.body);
  85. textSize = textEl.dom.offsetHeight;
  86. setInterval(function(){
  87. if(textEl.dom.offsetHeight != textSize){
  88. textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);
  89. }
  90. }, this.textResizeInterval);
  91. }
  92. textEvent.addListener(fn, scope, options);
  93. },
  94. <span id='Ext-EventManager-method-removeResizeListener'> /**
  95. </span> * Removes the passed window resize listener.
  96. * @param {Function} fn The method the event invokes
  97. * @param {Object} scope The scope of handler
  98. */
  99. removeResizeListener : function(fn, scope){
  100. if(resizeEvent){
  101. resizeEvent.removeListener(fn, scope);
  102. }
  103. },
  104. // private
  105. fireResize : function(){
  106. if(resizeEvent){
  107. resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
  108. }
  109. },
  110. <span id='Ext-EventManager-property-textResizeInterval'> /**
  111. </span> * The frequency, in milliseconds, to check for text resize events (defaults to 50)
  112. */
  113. textResizeInterval : 50,
  114. <span id='Ext-EventManager-property-ieDeferSrc'> /**
  115. </span> * Url used for onDocumentReady with using SSL (defaults to Ext.SSL_SECURE_URL)
  116. */
  117. ieDeferSrc : false,
  118. // protected, short accessor for useKeydown
  119. getKeyEvent : function(){
  120. return useKeydown ? 'keydown' : 'keypress';
  121. },
  122. // protected for use inside the framework
  123. // detects whether we should use keydown or keypress based on the browser.
  124. useKeydown: useKeydown
  125. };
  126. }());
  127. Ext.EventManager.on = Ext.EventManager.addListener;
  128. Ext.apply(Ext.EventObjectImpl.prototype, {
  129. <span id='Ext-EventManager-property-BACKSPACE'> /** Key constant @type Number */
  130. </span> BACKSPACE: 8,
  131. <span id='Ext-EventManager-property-TAB'> /** Key constant @type Number */
  132. </span> TAB: 9,
  133. <span id='Ext-EventManager-property-NUM_CENTER'> /** Key constant @type Number */
  134. </span> NUM_CENTER: 12,
  135. <span id='Ext-EventManager-property-ENTER'> /** Key constant @type Number */
  136. </span> ENTER: 13,
  137. <span id='Ext-EventManager-property-RETURN'> /** Key constant @type Number */
  138. </span> RETURN: 13,
  139. <span id='Ext-EventManager-property-SHIFT'> /** Key constant @type Number */
  140. </span> SHIFT: 16,
  141. <span id='Ext-EventManager-property-CTRL'> /** Key constant @type Number */
  142. </span> CTRL: 17,
  143. CONTROL : 17, // legacy
  144. <span id='Ext-EventManager-property-ALT'> /** Key constant @type Number */
  145. </span> ALT: 18,
  146. <span id='Ext-EventManager-property-PAUSE'> /** Key constant @type Number */
  147. </span> PAUSE: 19,
  148. <span id='Ext-EventManager-property-CAPS_LOCK'> /** Key constant @type Number */
  149. </span> CAPS_LOCK: 20,
  150. <span id='Ext-EventManager-property-ESC'> /** Key constant @type Number */
  151. </span> ESC: 27,
  152. <span id='Ext-EventManager-property-SPACE'> /** Key constant @type Number */
  153. </span> SPACE: 32,
  154. <span id='Ext-EventManager-property-PAGE_UP'> /** Key constant @type Number */
  155. </span> PAGE_UP: 33,
  156. PAGEUP : 33, // legacy
  157. <span id='Ext-EventManager-property-PAGE_DOWN'> /** Key constant @type Number */
  158. </span> PAGE_DOWN: 34,
  159. PAGEDOWN : 34, // legacy
  160. <span id='Ext-EventManager-property-END'> /** Key constant @type Number */
  161. </span> END: 35,
  162. <span id='Ext-EventManager-property-HOME'> /** Key constant @type Number */
  163. </span> HOME: 36,
  164. <span id='Ext-EventManager-property-LEFT'> /** Key constant @type Number */
  165. </span> LEFT: 37,
  166. <span id='Ext-EventManager-property-UP'> /** Key constant @type Number */
  167. </span> UP: 38,
  168. <span id='Ext-EventManager-property-RIGHT'> /** Key constant @type Number */
  169. </span> RIGHT: 39,
  170. <span id='Ext-EventManager-property-DOWN'> /** Key constant @type Number */
  171. </span> DOWN: 40,
  172. <span id='Ext-EventManager-property-PRINT_SCREEN'> /** Key constant @type Number */
  173. </span> PRINT_SCREEN: 44,
  174. <span id='Ext-EventManager-property-INSERT'> /** Key constant @type Number */
  175. </span> INSERT: 45,
  176. <span id='Ext-EventManager-property-DELETE'> /** Key constant @type Number */
  177. </span> DELETE: 46,
  178. <span id='Ext-EventManager-property-ZERO'> /** Key constant @type Number */
  179. </span> ZERO: 48,
  180. <span id='Ext-EventManager-property-ONE'> /** Key constant @type Number */
  181. </span> ONE: 49,
  182. <span id='Ext-EventManager-property-TWO'> /** Key constant @type Number */
  183. </span> TWO: 50,
  184. <span id='Ext-EventManager-property-THREE'> /** Key constant @type Number */
  185. </span> THREE: 51,
  186. <span id='Ext-EventManager-property-FOUR'> /** Key constant @type Number */
  187. </span> FOUR: 52,
  188. <span id='Ext-EventManager-property-FIVE'> /** Key constant @type Number */
  189. </span> FIVE: 53,
  190. <span id='Ext-EventManager-property-SIX'> /** Key constant @type Number */
  191. </span> SIX: 54,
  192. <span id='Ext-EventManager-property-SEVEN'> /** Key constant @type Number */
  193. </span> SEVEN: 55,
  194. <span id='Ext-EventManager-property-EIGHT'> /** Key constant @type Number */
  195. </span> EIGHT: 56,
  196. <span id='Ext-EventManager-property-NINE'> /** Key constant @type Number */
  197. </span> NINE: 57,
  198. <span id='Ext-EventManager-property-A'> /** Key constant @type Number */
  199. </span> A: 65,
  200. <span id='Ext-EventManager-property-B'> /** Key constant @type Number */
  201. </span> B: 66,
  202. <span id='Ext-EventManager-property-C'> /** Key constant @type Number */
  203. </span> C: 67,
  204. <span id='Ext-EventManager-property-D'> /** Key constant @type Number */
  205. </span> D: 68,
  206. <span id='Ext-EventManager-property-E'> /** Key constant @type Number */
  207. </span> E: 69,
  208. <span id='Ext-EventManager-property-F'> /** Key constant @type Number */
  209. </span> F: 70,
  210. <span id='Ext-EventManager-property-G'> /** Key constant @type Number */
  211. </span> G: 71,
  212. <span id='Ext-EventManager-property-H'> /** Key constant @type Number */
  213. </span> H: 72,
  214. <span id='Ext-EventManager-property-I'> /** Key constant @type Number */
  215. </span> I: 73,
  216. <span id='Ext-EventManager-property-J'> /** Key constant @type Number */
  217. </span> J: 74,
  218. <span id='Ext-EventManager-property-K'> /** Key constant @type Number */
  219. </span> K: 75,
  220. <span id='Ext-EventManager-property-L'> /** Key constant @type Number */
  221. </span> L: 76,
  222. <span id='Ext-EventManager-property-M'> /** Key constant @type Number */
  223. </span> M: 77,
  224. <span id='Ext-EventManager-property-N'> /** Key constant @type Number */
  225. </span> N: 78,
  226. <span id='Ext-EventManager-property-O'> /** Key constant @type Number */
  227. </span> O: 79,
  228. <span id='Ext-EventManager-property-P'> /** Key constant @type Number */
  229. </span> P: 80,
  230. <span id='Ext-EventManager-property-Q'> /** Key constant @type Number */
  231. </span> Q: 81,
  232. <span id='Ext-EventManager-property-R'> /** Key constant @type Number */
  233. </span> R: 82,
  234. <span id='Ext-EventManager-property-S'> /** Key constant @type Number */
  235. </span> S: 83,
  236. <span id='Ext-EventManager-property-T'> /** Key constant @type Number */
  237. </span> T: 84,
  238. <span id='Ext-EventManager-property-U'> /** Key constant @type Number */
  239. </span> U: 85,
  240. <span id='Ext-EventManager-property-V'> /** Key constant @type Number */
  241. </span> V: 86,
  242. <span id='Ext-EventManager-property-W'> /** Key constant @type Number */
  243. </span> W: 87,
  244. <span id='Ext-EventManager-property-X'> /** Key constant @type Number */
  245. </span> X: 88,
  246. <span id='Ext-EventManager-property-Y'> /** Key constant @type Number */
  247. </span> Y: 89,
  248. <span id='Ext-EventManager-property-Z'> /** Key constant @type Number */
  249. </span> Z: 90,
  250. <span id='Ext-EventManager-property-CONTEXT_MENU'> /** Key constant @type Number */
  251. </span> CONTEXT_MENU: 93,
  252. <span id='Ext-EventManager-property-NUM_ZERO'> /** Key constant @type Number */
  253. </span> NUM_ZERO: 96,
  254. <span id='Ext-EventManager-property-NUM_ONE'> /** Key constant @type Number */
  255. </span> NUM_ONE: 97,
  256. <span id='Ext-EventManager-property-NUM_TWO'> /** Key constant @type Number */
  257. </span> NUM_TWO: 98,
  258. <span id='Ext-EventManager-property-NUM_THREE'> /** Key constant @type Number */
  259. </span> NUM_THREE: 99,
  260. <span id='Ext-EventManager-property-NUM_FOUR'> /** Key constant @type Number */
  261. </span> NUM_FOUR: 100,
  262. <span id='Ext-EventManager-property-NUM_FIVE'> /** Key constant @type Number */
  263. </span> NUM_FIVE: 101,
  264. <span id='Ext-EventManager-property-NUM_SIX'> /** Key constant @type Number */
  265. </span> NUM_SIX: 102,
  266. <span id='Ext-EventManager-property-NUM_SEVEN'> /** Key constant @type Number */
  267. </span> NUM_SEVEN: 103,
  268. <span id='Ext-EventManager-property-NUM_EIGHT'> /** Key constant @type Number */
  269. </span> NUM_EIGHT: 104,
  270. <span id='Ext-EventManager-property-NUM_NINE'> /** Key constant @type Number */
  271. </span> NUM_NINE: 105,
  272. <span id='Ext-EventManager-property-NUM_MULTIPLY'> /** Key constant @type Number */
  273. </span> NUM_MULTIPLY: 106,
  274. <span id='Ext-EventManager-property-NUM_PLUS'> /** Key constant @type Number */
  275. </span> NUM_PLUS: 107,
  276. <span id='Ext-EventManager-property-NUM_MINUS'> /** Key constant @type Number */
  277. </span> NUM_MINUS: 109,
  278. <span id='Ext-EventManager-property-NUM_PERIOD'> /** Key constant @type Number */
  279. </span> NUM_PERIOD: 110,
  280. <span id='Ext-EventManager-property-NUM_DIVISION'> /** Key constant @type Number */
  281. </span> NUM_DIVISION: 111,
  282. <span id='Ext-EventManager-property-F1'> /** Key constant @type Number */
  283. </span> F1: 112,
  284. <span id='Ext-EventManager-property-F2'> /** Key constant @type Number */
  285. </span> F2: 113,
  286. <span id='Ext-EventManager-property-F3'> /** Key constant @type Number */
  287. </span> F3: 114,
  288. <span id='Ext-EventManager-property-F4'> /** Key constant @type Number */
  289. </span> F4: 115,
  290. <span id='Ext-EventManager-property-F5'> /** Key constant @type Number */
  291. </span> F5: 116,
  292. <span id='Ext-EventManager-property-F6'> /** Key constant @type Number */
  293. </span> F6: 117,
  294. <span id='Ext-EventManager-property-F7'> /** Key constant @type Number */
  295. </span> F7: 118,
  296. <span id='Ext-EventManager-property-F8'> /** Key constant @type Number */
  297. </span> F8: 119,
  298. <span id='Ext-EventManager-property-F9'> /** Key constant @type Number */
  299. </span> F9: 120,
  300. <span id='Ext-EventManager-property-F10'> /** Key constant @type Number */
  301. </span> F10: 121,
  302. <span id='Ext-EventManager-property-F11'> /** Key constant @type Number */
  303. </span> F11: 122,
  304. <span id='Ext-EventManager-property-F12'> /** Key constant @type Number */
  305. </span> F12: 123,
  306. <span id='Ext-EventManager-method-isNavKeyPress'> /** @private */
  307. </span> isNavKeyPress : function(){
  308. var me = this,
  309. k = this.normalizeKey(me.keyCode);
  310. return (k &gt;= 33 &amp;&amp; k &lt;= 40) || // Page Up/Down, End, Home, Left, Up, Right, Down
  311. k == me.RETURN ||
  312. k == me.TAB ||
  313. k == me.ESC;
  314. },
  315. isSpecialKey : function(){
  316. var k = this.normalizeKey(this.keyCode);
  317. return (this.type == 'keypress' &amp;&amp; this.ctrlKey) ||
  318. this.isNavKeyPress() ||
  319. (k == this.BACKSPACE) || // Backspace
  320. (k &gt;= 16 &amp;&amp; k &lt;= 20) || // Shift, Ctrl, Alt, Pause, Caps Lock
  321. (k &gt;= 44 &amp;&amp; k &lt;= 46); // Print Screen, Insert, Delete
  322. },
  323. getPoint : function(){
  324. return new Ext.lib.Point(this.xy[0], this.xy[1]);
  325. },
  326. <span id='Ext-EventManager-method-hasModifier'> /**
  327. </span> * Returns true if the control, meta, shift or alt key was pressed during this event.
  328. * @return {Boolean}
  329. */
  330. hasModifier : function(){
  331. return ((this.ctrlKey || this.altKey) || this.shiftKey);
  332. }
  333. });</pre>
  334. </body>
  335. </html>