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.

188 lines
6.7 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.form.Checkbox"></div>/**
  16. * @class Ext.form.Checkbox
  17. * @extends Ext.form.Field
  18. * Single checkbox field. Can be used as a direct replacement for traditional checkbox fields.
  19. * @constructor
  20. * Creates a new Checkbox
  21. * @param {Object} config Configuration options
  22. * @xtype checkbox
  23. */
  24. Ext.form.Checkbox = Ext.extend(Ext.form.Field, {
  25. <div id="cfg-Ext.form.Checkbox-focusClass"></div>/**
  26. * @cfg {String} focusClass The CSS class to use when the checkbox receives focus (defaults to undefined)
  27. */
  28. focusClass : undefined,
  29. <div id="cfg-Ext.form.Checkbox-fieldClass"></div>/**
  30. * @cfg {String} fieldClass The default CSS class for the checkbox (defaults to 'x-form-field')
  31. */
  32. fieldClass : 'x-form-field',
  33. <div id="cfg-Ext.form.Checkbox-checked"></div>/**
  34. * @cfg {Boolean} checked <tt>true</tt> if the checkbox should render initially checked (defaults to <tt>false</tt>)
  35. */
  36. checked : false,
  37. <div id="cfg-Ext.form.Checkbox-boxLabel"></div>/**
  38. * @cfg {String} boxLabel The text that appears beside the checkbox
  39. */
  40. boxLabel: '&#160;',
  41. <div id="cfg-Ext.form.Checkbox-autoCreate"></div>/**
  42. * @cfg {String/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to
  43. * {tag: 'input', type: 'checkbox', autocomplete: 'off'})
  44. */
  45. defaultAutoCreate : { tag: 'input', type: 'checkbox', autocomplete: 'off'},
  46. <div id="cfg-Ext.form.Checkbox-inputValue"></div>/**
  47. * @cfg {String} inputValue The value that should go into the generated input element's value attribute
  48. */
  49. <div id="cfg-Ext.form.Checkbox-handler"></div>/**
  50. * @cfg {Function} handler A function called when the {@link #checked} value changes (can be used instead of
  51. * handling the check event). The handler is passed the following parameters:
  52. * <div class="mdetail-params"><ul>
  53. * <li><b>checkbox</b> : Ext.form.Checkbox<div class="sub-desc">The Checkbox being toggled.</div></li>
  54. * <li><b>checked</b> : Boolean<div class="sub-desc">The new checked state of the checkbox.</div></li>
  55. * </ul></div>
  56. */
  57. <div id="cfg-Ext.form.Checkbox-scope"></div>/**
  58. * @cfg {Object} scope An object to use as the scope ('this' reference) of the {@link #handler} function
  59. * (defaults to this Checkbox).
  60. */
  61. // private
  62. actionMode : 'wrap',
  63. // private
  64. initComponent : function(){
  65. Ext.form.Checkbox.superclass.initComponent.call(this);
  66. this.addEvents(
  67. <div id="event-Ext.form.Checkbox-check"></div>/**
  68. * @event check
  69. * Fires when the checkbox is checked or unchecked.
  70. * @param {Ext.form.Checkbox} this This checkbox
  71. * @param {Boolean} checked The new checked value
  72. */
  73. 'check'
  74. );
  75. },
  76. // private
  77. onResize : function(){
  78. Ext.form.Checkbox.superclass.onResize.apply(this, arguments);
  79. if(!this.boxLabel && !this.fieldLabel){
  80. this.el.alignTo(this.wrap, 'c-c');
  81. }
  82. },
  83. // private
  84. initEvents : function(){
  85. Ext.form.Checkbox.superclass.initEvents.call(this);
  86. this.mon(this.el, {
  87. scope: this,
  88. click: this.onClick,
  89. change: this.onClick
  90. });
  91. },
  92. <div id="method-Ext.form.Checkbox-markInvalid"></div>/**
  93. * @hide
  94. * Overridden and disabled. The editor element does not support standard valid/invalid marking.
  95. * @method
  96. */
  97. markInvalid : Ext.emptyFn,
  98. <div id="method-Ext.form.Checkbox-clearInvalid"></div>/**
  99. * @hide
  100. * Overridden and disabled. The editor element does not support standard valid/invalid marking.
  101. * @method
  102. */
  103. clearInvalid : Ext.emptyFn,
  104. // private
  105. onRender : function(ct, position){
  106. Ext.form.Checkbox.superclass.onRender.call(this, ct, position);
  107. if(this.inputValue !== undefined){
  108. this.el.dom.value = this.inputValue;
  109. }
  110. this.wrap = this.el.wrap({cls: 'x-form-check-wrap'});
  111. if(this.boxLabel){
  112. this.wrap.createChild({tag: 'label', htmlFor: this.el.id, cls: 'x-form-cb-label', html: this.boxLabel});
  113. }
  114. if(this.checked){
  115. this.setValue(true);
  116. }else{
  117. this.checked = this.el.dom.checked;
  118. }
  119. // Need to repaint for IE, otherwise positioning is broken
  120. if (Ext.isIE && !Ext.isStrict) {
  121. this.wrap.repaint();
  122. }
  123. this.resizeEl = this.positionEl = this.wrap;
  124. },
  125. // private
  126. onDestroy : function(){
  127. Ext.destroy(this.wrap);
  128. Ext.form.Checkbox.superclass.onDestroy.call(this);
  129. },
  130. // private
  131. initValue : function() {
  132. this.originalValue = this.getValue();
  133. },
  134. <div id="method-Ext.form.Checkbox-getValue"></div>/**
  135. * Returns the checked state of the checkbox.
  136. * @return {Boolean} True if checked, else false
  137. */
  138. getValue : function(){
  139. if(this.rendered){
  140. return this.el.dom.checked;
  141. }
  142. return this.checked;
  143. },
  144. // private
  145. onClick : function(){
  146. if(this.el.dom.checked != this.checked){
  147. this.setValue(this.el.dom.checked);
  148. }
  149. },
  150. <div id="method-Ext.form.Checkbox-setValue"></div>/**
  151. * Sets the checked state of the checkbox, fires the 'check' event, and calls a
  152. * <code>{@link #handler}</code> (if configured).
  153. * @param {Boolean/String} checked The following values will check the checkbox:
  154. * <code>true, 'true', '1', or 'on'</code>. Any other value will uncheck the checkbox.
  155. * @return {Ext.form.Field} this
  156. */
  157. setValue : function(v){
  158. var checked = this.checked,
  159. inputVal = this.inputValue;
  160. this.checked = (v === true || v === 'true' || v == '1' || (inputVal ? v == inputVal : String(v).toLowerCase() == 'on'));
  161. if(this.rendered){
  162. this.el.dom.checked = this.checked;
  163. this.el.dom.defaultChecked = this.checked;
  164. }
  165. if(checked != this.checked){
  166. this.fireEvent('check', this, this.checked);
  167. if(this.handler){
  168. this.handler.call(this.scope || this, this, this.checked);
  169. }
  170. }
  171. return this;
  172. }
  173. });
  174. Ext.reg('checkbox', Ext.form.Checkbox);
  175. </pre>
  176. </body>
  177. </html>