Web Interface For Lite Argus Control modules
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.

177 lines
5.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. <div id="cls-Ext.KeyNav"></div>/**
  16. * @class Ext.KeyNav
  17. * <p>Provides a convenient wrapper for normalized keyboard navigation. KeyNav allows you to bind
  18. * navigation keys to function calls that will get called when the keys are pressed, providing an easy
  19. * way to implement custom navigation schemes for any UI component.</p>
  20. * <p>The following are all of the possible keys that can be implemented: enter, left, right, up, down, tab, esc,
  21. * pageUp, pageDown, del, home, end. Usage:</p>
  22. <pre><code>
  23. var nav = new Ext.KeyNav("my-element", {
  24. "left" : function(e){
  25. this.moveLeft(e.ctrlKey);
  26. },
  27. "right" : function(e){
  28. this.moveRight(e.ctrlKey);
  29. },
  30. "enter" : function(e){
  31. this.save();
  32. },
  33. scope : this
  34. });
  35. </code></pre>
  36. * @constructor
  37. * @param {Mixed} el The element to bind to
  38. * @param {Object} config The config
  39. */
  40. Ext.KeyNav = function(el, config){
  41. this.el = Ext.get(el);
  42. Ext.apply(this, config);
  43. if(!this.disabled){
  44. this.disabled = true;
  45. this.enable();
  46. }
  47. };
  48. Ext.KeyNav.prototype = {
  49. <div id="cfg-Ext.KeyNav-disabled"></div>/**
  50. * @cfg {Boolean} disabled
  51. * True to disable this KeyNav instance (defaults to false)
  52. */
  53. disabled : false,
  54. <div id="cfg-Ext.KeyNav-defaultEventAction"></div>/**
  55. * @cfg {String} defaultEventAction
  56. * The method to call on the {@link Ext.EventObject} after this KeyNav intercepts a key. Valid values are
  57. * {@link Ext.EventObject#stopEvent}, {@link Ext.EventObject#preventDefault} and
  58. * {@link Ext.EventObject#stopPropagation} (defaults to 'stopEvent')
  59. */
  60. defaultEventAction: "stopEvent",
  61. <div id="cfg-Ext.KeyNav-forceKeyDown"></div>/**
  62. * @cfg {Boolean} forceKeyDown
  63. * Handle the keydown event instead of keypress (defaults to false). KeyNav automatically does this for IE since
  64. * IE does not propagate special keys on keypress, but setting this to true will force other browsers to also
  65. * handle keydown instead of keypress.
  66. */
  67. forceKeyDown : false,
  68. // private
  69. relay : function(e){
  70. var k = e.getKey(),
  71. h = this.keyToHandler[k];
  72. if(h && this[h]){
  73. if(this.doRelay(e, this[h], h) !== true){
  74. e[this.defaultEventAction]();
  75. }
  76. }
  77. },
  78. // private
  79. doRelay : function(e, h, hname){
  80. return h.call(this.scope || this, e, hname);
  81. },
  82. // possible handlers
  83. enter : false,
  84. left : false,
  85. right : false,
  86. up : false,
  87. down : false,
  88. tab : false,
  89. esc : false,
  90. pageUp : false,
  91. pageDown : false,
  92. del : false,
  93. home : false,
  94. end : false,
  95. // quick lookup hash
  96. keyToHandler : {
  97. 37 : "left",
  98. 39 : "right",
  99. 38 : "up",
  100. 40 : "down",
  101. 33 : "pageUp",
  102. 34 : "pageDown",
  103. 46 : "del",
  104. 36 : "home",
  105. 35 : "end",
  106. 13 : "enter",
  107. 27 : "esc",
  108. 9 : "tab"
  109. },
  110. stopKeyUp: function(e) {
  111. var k = e.getKey();
  112. if (k >= 37 && k <= 40) {
  113. // *** bugfix - safari 2.x fires 2 keyup events on cursor keys
  114. // *** (note: this bugfix sacrifices the "keyup" event originating from keyNav elements in Safari 2)
  115. e.stopEvent();
  116. }
  117. },
  118. <div id="method-Ext.KeyNav-destroy"></div>/**
  119. * Destroy this KeyNav (this is the same as calling disable).
  120. */
  121. destroy: function(){
  122. this.disable();
  123. },
  124. <div id="method-Ext.KeyNav-enable"></div>/**
  125. * Enable this KeyNav
  126. */
  127. enable: function() {
  128. if (this.disabled) {
  129. if (Ext.isSafari2) {
  130. // call stopKeyUp() on "keyup" event
  131. this.el.on('keyup', this.stopKeyUp, this);
  132. }
  133. this.el.on(this.isKeydown()? 'keydown' : 'keypress', this.relay, this);
  134. this.disabled = false;
  135. }
  136. },
  137. <div id="method-Ext.KeyNav-disable"></div>/**
  138. * Disable this KeyNav
  139. */
  140. disable: function() {
  141. if (!this.disabled) {
  142. if (Ext.isSafari2) {
  143. // remove "keyup" event handler
  144. this.el.un('keyup', this.stopKeyUp, this);
  145. }
  146. this.el.un(this.isKeydown()? 'keydown' : 'keypress', this.relay, this);
  147. this.disabled = true;
  148. }
  149. },
  150. <div id="method-Ext.KeyNav-setDisabled"></div>/**
  151. * Convenience function for setting disabled/enabled by boolean.
  152. * @param {Boolean} disabled
  153. */
  154. setDisabled : function(disabled){
  155. this[disabled ? "disable" : "enable"]();
  156. },
  157. // private
  158. isKeydown: function(){
  159. return this.forceKeyDown || Ext.EventManager.useKeydown;
  160. }
  161. };
  162. </pre>
  163. </body>
  164. </html>