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.

197 lines
7.2 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.TimeField"></div>/**
  16. * @class Ext.form.TimeField
  17. * @extends Ext.form.ComboBox
  18. * Provides a time input field with a time dropdown and automatic time validation. Example usage:
  19. * <pre><code>
  20. new Ext.form.TimeField({
  21. minValue: '9:00 AM',
  22. maxValue: '6:00 PM',
  23. increment: 30
  24. });
  25. </code></pre>
  26. * @constructor
  27. * Create a new TimeField
  28. * @param {Object} config
  29. * @xtype timefield
  30. */
  31. Ext.form.TimeField = Ext.extend(Ext.form.ComboBox, {
  32. <div id="cfg-Ext.form.TimeField-minValue"></div>/**
  33. * @cfg {Date/String} minValue
  34. * The minimum allowed time. Can be either a Javascript date object with a valid time value or a string
  35. * time in a valid format -- see {@link #format} and {@link #altFormats} (defaults to undefined).
  36. */
  37. minValue : undefined,
  38. <div id="cfg-Ext.form.TimeField-maxValue"></div>/**
  39. * @cfg {Date/String} maxValue
  40. * The maximum allowed time. Can be either a Javascript date object with a valid time value or a string
  41. * time in a valid format -- see {@link #format} and {@link #altFormats} (defaults to undefined).
  42. */
  43. maxValue : undefined,
  44. <div id="cfg-Ext.form.TimeField-minText"></div>/**
  45. * @cfg {String} minText
  46. * The error text to display when the date in the cell is before minValue (defaults to
  47. * 'The time in this field must be equal to or after {0}').
  48. */
  49. minText : "The time in this field must be equal to or after {0}",
  50. <div id="cfg-Ext.form.TimeField-maxText"></div>/**
  51. * @cfg {String} maxText
  52. * The error text to display when the time is after maxValue (defaults to
  53. * 'The time in this field must be equal to or before {0}').
  54. */
  55. maxText : "The time in this field must be equal to or before {0}",
  56. <div id="cfg-Ext.form.TimeField-invalidText"></div>/**
  57. * @cfg {String} invalidText
  58. * The error text to display when the time in the field is invalid (defaults to
  59. * '{value} is not a valid time').
  60. */
  61. invalidText : "{0} is not a valid time",
  62. <div id="cfg-Ext.form.TimeField-format"></div>/**
  63. * @cfg {String} format
  64. * The default time format string which can be overriden for localization support. The format must be
  65. * valid according to {@link Date#parseDate} (defaults to 'g:i A', e.g., '3:15 PM'). For 24-hour time
  66. * format try 'H:i' instead.
  67. */
  68. format : "g:i A",
  69. <div id="cfg-Ext.form.TimeField-altFormats"></div>/**
  70. * @cfg {String} altFormats
  71. * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
  72. * format (defaults to 'g:ia|g:iA|g:i a|g:i A|h:i|g:i|H:i|ga|ha|gA|h a|g a|g A|gi|hi|gia|hia|g|H|gi a|hi a|giA|hiA|gi A|hi A').
  73. */
  74. altFormats : "g:ia|g:iA|g:i a|g:i A|h:i|g:i|H:i|ga|ha|gA|h a|g a|g A|gi|hi|gia|hia|g|H|gi a|hi a|giA|hiA|gi A|hi A",
  75. <div id="cfg-Ext.form.TimeField-increment"></div>/**
  76. * @cfg {Number} increment
  77. * The number of minutes between each time value in the list (defaults to 15).
  78. */
  79. increment: 15,
  80. // private override
  81. mode: 'local',
  82. // private override
  83. triggerAction: 'all',
  84. // private override
  85. typeAhead: false,
  86. // private - This is the date to use when generating time values in the absence of either minValue
  87. // or maxValue. Using the current date causes DST issues on DST boundary dates, so this is an
  88. // arbitrary "safe" date that can be any date aside from DST boundary dates.
  89. initDate: '1/1/2008',
  90. initDateFormat: 'j/n/Y',
  91. // private
  92. initComponent : function(){
  93. if(Ext.isDefined(this.minValue)){
  94. this.setMinValue(this.minValue, true);
  95. }
  96. if(Ext.isDefined(this.maxValue)){
  97. this.setMaxValue(this.maxValue, true);
  98. }
  99. if(!this.store){
  100. this.generateStore(true);
  101. }
  102. Ext.form.TimeField.superclass.initComponent.call(this);
  103. },
  104. <div id="method-Ext.form.TimeField-setMinValue"></div>/**
  105. * Replaces any existing {@link #minValue} with the new time and refreshes the store.
  106. * @param {Date/String} value The minimum time that can be selected
  107. */
  108. setMinValue: function(value, /* private */ initial){
  109. this.setLimit(value, true, initial);
  110. return this;
  111. },
  112. <div id="method-Ext.form.TimeField-setMaxValue"></div>/**
  113. * Replaces any existing {@link #maxValue} with the new time and refreshes the store.
  114. * @param {Date/String} value The maximum time that can be selected
  115. */
  116. setMaxValue: function(value, /* private */ initial){
  117. this.setLimit(value, false, initial);
  118. return this;
  119. },
  120. // private
  121. generateStore: function(initial){
  122. var min = this.minValue || new Date(this.initDate).clearTime(),
  123. max = this.maxValue || new Date(this.initDate).clearTime().add('mi', (24 * 60) - 1),
  124. times = [];
  125. while(min <= max){
  126. times.push(min.dateFormat(this.format));
  127. min = min.add('mi', this.increment);
  128. }
  129. this.bindStore(times, initial);
  130. },
  131. // private
  132. setLimit: function(value, isMin, initial){
  133. var d;
  134. if(Ext.isString(value)){
  135. d = this.parseDate(value);
  136. }else if(Ext.isDate(value)){
  137. d = value;
  138. }
  139. if(d){
  140. var val = new Date(this.initDate).clearTime();
  141. val.setHours(d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
  142. this[isMin ? 'minValue' : 'maxValue'] = val;
  143. if(!initial){
  144. this.generateStore();
  145. }
  146. }
  147. },
  148. // inherited docs
  149. getValue : function(){
  150. var v = Ext.form.TimeField.superclass.getValue.call(this);
  151. return this.formatDate(this.parseDate(v)) || '';
  152. },
  153. // inherited docs
  154. setValue : function(value){
  155. return Ext.form.TimeField.superclass.setValue.call(this, this.formatDate(this.parseDate(value)));
  156. },
  157. // private overrides
  158. validateValue : Ext.form.DateField.prototype.validateValue,
  159. formatDate : Ext.form.DateField.prototype.formatDate,
  160. parseDate: function(value) {
  161. if (!value || Ext.isDate(value)) {
  162. return value;
  163. }
  164. var id = this.initDate + ' ',
  165. idf = this.initDateFormat + ' ',
  166. v = Date.parseDate(id + value, idf + this.format), // *** handle DST. note: this.format is a TIME-only format
  167. af = this.altFormats;
  168. if (!v && af) {
  169. if (!this.altFormatsArray) {
  170. this.altFormatsArray = af.split("|");
  171. }
  172. for (var i = 0, afa = this.altFormatsArray, len = afa.length; i < len && !v; i++) {
  173. v = Date.parseDate(id + value, idf + afa[i]);
  174. }
  175. }
  176. return v;
  177. }
  178. });
  179. Ext.reg('timefield', Ext.form.TimeField);</pre>
  180. </body>
  181. </html>