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.

700 lines
28 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'>/**
  19. </span> * @class Ext
  20. */
  21. Ext.ns(&quot;Ext.grid&quot;, &quot;Ext.list&quot;, &quot;Ext.dd&quot;, &quot;Ext.tree&quot;, &quot;Ext.form&quot;, &quot;Ext.menu&quot;,
  22. &quot;Ext.state&quot;, &quot;Ext.layout.boxOverflow&quot;, &quot;Ext.app&quot;, &quot;Ext.ux&quot;, &quot;Ext.chart&quot;, &quot;Ext.direct&quot;, &quot;Ext.slider&quot;);
  23. <span id='Ext-property-ux'> /**
  24. </span> * Namespace alloted for extensions to the framework.
  25. * @property ux
  26. * @type Object
  27. */
  28. Ext.apply(Ext, function(){
  29. var E = Ext,
  30. idSeed = 0,
  31. scrollWidth = null;
  32. return {
  33. <span id='Ext-property-emptyFn'> /**
  34. </span> * A reusable empty function
  35. * @property
  36. * @type Function
  37. */
  38. emptyFn : function(){},
  39. <span id='Ext-property-BLANK_IMAGE_URL'> /**
  40. </span> * URL to a 1x1 transparent gif image used by Ext to create inline icons with CSS background images.
  41. * In older versions of IE, this defaults to &quot;http://extjs.com/s.gif&quot; and you should change this to a URL on your server.
  42. * For other browsers it uses an inline data URL.
  43. * @type String
  44. */
  45. BLANK_IMAGE_URL : Ext.isIE6 || Ext.isIE7 || Ext.isAir ?
  46. 'http:/' + '/www.extjs.com/s.gif' :
  47. 'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==',
  48. extendX : function(supr, fn){
  49. return Ext.extend(supr, fn(supr.prototype));
  50. },
  51. <span id='Ext-method-getDoc'> /**
  52. </span> * Returns the current HTML document object as an {@link Ext.Element}.
  53. * @return Ext.Element The document
  54. */
  55. getDoc : function(){
  56. return Ext.get(document);
  57. },
  58. <span id='Ext-method-num'> /**
  59. </span> * Utility method for validating that a value is numeric, returning the specified default value if it is not.
  60. * @param {Mixed} value Should be a number, but any type will be handled appropriately
  61. * @param {Number} defaultValue The value to return if the original value is non-numeric
  62. * @return {Number} Value, if numeric, else defaultValue
  63. */
  64. num : function(v, defaultValue){
  65. v = Number(Ext.isEmpty(v) || Ext.isArray(v) || typeof v == 'boolean' || (typeof v == 'string' &amp;&amp; v.trim().length == 0) ? NaN : v);
  66. return isNaN(v) ? defaultValue : v;
  67. },
  68. <span id='Ext-method-value'> /**
  69. </span> * &lt;p&gt;Utility method for returning a default value if the passed value is empty.&lt;/p&gt;
  70. * &lt;p&gt;The value is deemed to be empty if it is&lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  71. * &lt;li&gt;null&lt;/li&gt;
  72. * &lt;li&gt;undefined&lt;/li&gt;
  73. * &lt;li&gt;an empty array&lt;/li&gt;
  74. * &lt;li&gt;a zero length string (Unless the &lt;tt&gt;allowBlank&lt;/tt&gt; parameter is &lt;tt&gt;true&lt;/tt&gt;)&lt;/li&gt;
  75. * &lt;/ul&gt;&lt;/div&gt;
  76. * @param {Mixed} value The value to test
  77. * @param {Mixed} defaultValue The value to return if the original value is empty
  78. * @param {Boolean} allowBlank (optional) true to allow zero length strings to qualify as non-empty (defaults to false)
  79. * @return {Mixed} value, if non-empty, else defaultValue
  80. */
  81. value : function(v, defaultValue, allowBlank){
  82. return Ext.isEmpty(v, allowBlank) ? defaultValue : v;
  83. },
  84. <span id='Ext-method-escapeRe'> /**
  85. </span> * Escapes the passed string for use in a regular expression
  86. * @param {String} str
  87. * @return {String}
  88. */
  89. escapeRe : function(s) {
  90. return s.replace(/([-.*+?^${}()|[\]\/\\])/g, &quot;\\$1&quot;);
  91. },
  92. sequence : function(o, name, fn, scope){
  93. o[name] = o[name].createSequence(fn, scope);
  94. },
  95. <span id='Ext-method-addBehaviors'> /**
  96. </span> * Applies event listeners to elements by selectors when the document is ready.
  97. * The event name is specified with an &lt;tt&gt;&amp;#64;&lt;/tt&gt; suffix.
  98. * &lt;pre&gt;&lt;code&gt;
  99. Ext.addBehaviors({
  100. // add a listener for click on all anchors in element with id foo
  101. '#foo a&amp;#64;click' : function(e, t){
  102. // do something
  103. },
  104. // add the same listener to multiple selectors (separated by comma BEFORE the &amp;#64;)
  105. '#foo a, #bar span.some-class&amp;#64;mouseover' : function(){
  106. // do something
  107. }
  108. });
  109. * &lt;/code&gt;&lt;/pre&gt;
  110. * @param {Object} obj The list of behaviors to apply
  111. */
  112. addBehaviors : function(o){
  113. if(!Ext.isReady){
  114. Ext.onReady(function(){
  115. Ext.addBehaviors(o);
  116. });
  117. } else {
  118. var cache = {}, // simple cache for applying multiple behaviors to same selector does query multiple times
  119. parts,
  120. b,
  121. s;
  122. for (b in o) {
  123. if ((parts = b.split('@'))[1]) { // for Object prototype breakers
  124. s = parts[0];
  125. if(!cache[s]){
  126. cache[s] = Ext.select(s);
  127. }
  128. cache[s].on(parts[1], o[b]);
  129. }
  130. }
  131. cache = null;
  132. }
  133. },
  134. <span id='Ext-method-getScrollBarWidth'> /**
  135. </span> * Utility method for getting the width of the browser scrollbar. This can differ depending on
  136. * operating system settings, such as the theme or font size.
  137. * @param {Boolean} force (optional) true to force a recalculation of the value.
  138. * @return {Number} The width of the scrollbar.
  139. */
  140. getScrollBarWidth: function(force){
  141. if(!Ext.isReady){
  142. return 0;
  143. }
  144. if(force === true || scrollWidth === null){
  145. // Append our div, do our calculation and then remove it
  146. var div = Ext.getBody().createChild('&lt;div class=&quot;x-hide-offsets&quot; style=&quot;width:100px;height:50px;overflow:hidden;&quot;&gt;&lt;div style=&quot;height:200px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;'),
  147. child = div.child('div', true);
  148. var w1 = child.offsetWidth;
  149. div.setStyle('overflow', (Ext.isWebKit || Ext.isGecko) ? 'auto' : 'scroll');
  150. var w2 = child.offsetWidth;
  151. div.remove();
  152. // Need to add 2 to ensure we leave enough space
  153. scrollWidth = w1 - w2 + 2;
  154. }
  155. return scrollWidth;
  156. },
  157. // deprecated
  158. combine : function(){
  159. var as = arguments, l = as.length, r = [];
  160. for(var i = 0; i &lt; l; i++){
  161. var a = as[i];
  162. if(Ext.isArray(a)){
  163. r = r.concat(a);
  164. }else if(a.length !== undefined &amp;&amp; !a.substr){
  165. r = r.concat(Array.prototype.slice.call(a, 0));
  166. }else{
  167. r.push(a);
  168. }
  169. }
  170. return r;
  171. },
  172. <span id='Ext-method-copyTo'> /**
  173. </span> * Copies a set of named properties fom the source object to the destination object.
  174. * &lt;p&gt;example:&lt;pre&gt;&lt;code&gt;
  175. ImageComponent = Ext.extend(Ext.BoxComponent, {
  176. initComponent: function() {
  177. this.autoEl = { tag: 'img' };
  178. MyComponent.superclass.initComponent.apply(this, arguments);
  179. this.initialBox = Ext.copyTo({}, this.initialConfig, 'x,y,width,height');
  180. }
  181. });
  182. * &lt;/code&gt;&lt;/pre&gt;
  183. * @param {Object} dest The destination object.
  184. * @param {Object} source The source object.
  185. * @param {Array/String} names Either an Array of property names, or a comma-delimited list
  186. * of property names to copy.
  187. * @return {Object} The modified object.
  188. */
  189. copyTo : function(dest, source, names){
  190. if(typeof names == 'string'){
  191. names = names.split(/[,;\s]/);
  192. }
  193. Ext.each(names, function(name){
  194. if(source.hasOwnProperty(name)){
  195. dest[name] = source[name];
  196. }
  197. }, this);
  198. return dest;
  199. },
  200. <span id='Ext-method-destroy'> /**
  201. </span> * Attempts to destroy any objects passed to it by removing all event listeners, removing them from the
  202. * DOM (if applicable) and calling their destroy functions (if available). This method is primarily
  203. * intended for arguments of type {@link Ext.Element} and {@link Ext.Component}, but any subclass of
  204. * {@link Ext.util.Observable} can be passed in. Any number of elements and/or components can be
  205. * passed into this function in a single call as separate arguments.
  206. * @param {Mixed...} args An {@link Ext.Element}, {@link Ext.Component}, or an Array of either of these to destroy
  207. */
  208. destroy : function(){
  209. Ext.each(arguments, function(arg){
  210. if(arg){
  211. if(Ext.isArray(arg)){
  212. this.destroy.apply(this, arg);
  213. }else if(typeof arg.destroy == 'function'){
  214. arg.destroy();
  215. }else if(arg.dom){
  216. arg.remove();
  217. }
  218. }
  219. }, this);
  220. },
  221. <span id='Ext-method-destroyMembers'> /**
  222. </span> * Attempts to destroy and then remove a set of named properties of the passed object.
  223. * @param {Object} o The object (most likely a Component) who's properties you wish to destroy.
  224. * @param {Mixed} arg1 The name of the property to destroy and remove from the object.
  225. * @param {Mixed} etc... More property names to destroy and remove.
  226. */
  227. destroyMembers : function(o, arg1, arg2, etc){
  228. for(var i = 1, a = arguments, len = a.length; i &lt; len; i++) {
  229. Ext.destroy(o[a[i]]);
  230. delete o[a[i]];
  231. }
  232. },
  233. <span id='Ext-method-clean'> /**
  234. </span> * Creates a copy of the passed Array with falsy values removed.
  235. * @param {Array/NodeList} arr The Array from which to remove falsy values.
  236. * @return {Array} The new, compressed Array.
  237. */
  238. clean : function(arr){
  239. var ret = [];
  240. Ext.each(arr, function(v){
  241. if(!!v){
  242. ret.push(v);
  243. }
  244. });
  245. return ret;
  246. },
  247. <span id='Ext-method-unique'> /**
  248. </span> * Creates a copy of the passed Array, filtered to contain only unique values.
  249. * @param {Array} arr The Array to filter
  250. * @return {Array} The new Array containing unique values.
  251. */
  252. unique : function(arr){
  253. var ret = [],
  254. collect = {};
  255. Ext.each(arr, function(v) {
  256. if(!collect[v]){
  257. ret.push(v);
  258. }
  259. collect[v] = true;
  260. });
  261. return ret;
  262. },
  263. <span id='Ext-method-flatten'> /**
  264. </span> * Recursively flattens into 1-d Array. Injects Arrays inline.
  265. * @param {Array} arr The array to flatten
  266. * @return {Array} The new, flattened array.
  267. */
  268. flatten : function(arr){
  269. var worker = [];
  270. function rFlatten(a) {
  271. Ext.each(a, function(v) {
  272. if(Ext.isArray(v)){
  273. rFlatten(v);
  274. }else{
  275. worker.push(v);
  276. }
  277. });
  278. return worker;
  279. }
  280. return rFlatten(arr);
  281. },
  282. <span id='Ext-method-min'> /**
  283. </span> * Returns the minimum value in the Array.
  284. * @param {Array|NodeList} arr The Array from which to select the minimum value.
  285. * @param {Function} comp (optional) a function to perform the comparision which determines minimization.
  286. * If omitted the &quot;&lt;&quot; operator will be used. Note: gt = 1; eq = 0; lt = -1
  287. * @return {Object} The minimum value in the Array.
  288. */
  289. min : function(arr, comp){
  290. var ret = arr[0];
  291. comp = comp || function(a,b){ return a &lt; b ? -1 : 1; };
  292. Ext.each(arr, function(v) {
  293. ret = comp(ret, v) == -1 ? ret : v;
  294. });
  295. return ret;
  296. },
  297. <span id='Ext-method-max'> /**
  298. </span> * Returns the maximum value in the Array
  299. * @param {Array|NodeList} arr The Array from which to select the maximum value.
  300. * @param {Function} comp (optional) a function to perform the comparision which determines maximization.
  301. * If omitted the &quot;&gt;&quot; operator will be used. Note: gt = 1; eq = 0; lt = -1
  302. * @return {Object} The maximum value in the Array.
  303. */
  304. max : function(arr, comp){
  305. var ret = arr[0];
  306. comp = comp || function(a,b){ return a &gt; b ? 1 : -1; };
  307. Ext.each(arr, function(v) {
  308. ret = comp(ret, v) == 1 ? ret : v;
  309. });
  310. return ret;
  311. },
  312. <span id='Ext-method-mean'> /**
  313. </span> * Calculates the mean of the Array
  314. * @param {Array} arr The Array to calculate the mean value of.
  315. * @return {Number} The mean.
  316. */
  317. mean : function(arr){
  318. return arr.length &gt; 0 ? Ext.sum(arr) / arr.length : undefined;
  319. },
  320. <span id='Ext-method-sum'> /**
  321. </span> * Calculates the sum of the Array
  322. * @param {Array} arr The Array to calculate the sum value of.
  323. * @return {Number} The sum.
  324. */
  325. sum : function(arr){
  326. var ret = 0;
  327. Ext.each(arr, function(v) {
  328. ret += v;
  329. });
  330. return ret;
  331. },
  332. <span id='Ext-method-partition'> /**
  333. </span> * Partitions the set into two sets: a true set and a false set.
  334. * Example:
  335. * Example2:
  336. * &lt;pre&gt;&lt;code&gt;
  337. // Example 1:
  338. Ext.partition([true, false, true, true, false]); // [[true, true, true], [false, false]]
  339. // Example 2:
  340. Ext.partition(
  341. Ext.query(&quot;p&quot;),
  342. function(val){
  343. return val.className == &quot;class1&quot;
  344. }
  345. );
  346. // true are those paragraph elements with a className of &quot;class1&quot;,
  347. // false set are those that do not have that className.
  348. * &lt;/code&gt;&lt;/pre&gt;
  349. * @param {Array|NodeList} arr The array to partition
  350. * @param {Function} truth (optional) a function to determine truth. If this is omitted the element
  351. * itself must be able to be evaluated for its truthfulness.
  352. * @return {Array} [true&lt;Array&gt;,false&lt;Array&gt;]
  353. */
  354. partition : function(arr, truth){
  355. var ret = [[],[]];
  356. Ext.each(arr, function(v, i, a) {
  357. ret[ (truth &amp;&amp; truth(v, i, a)) || (!truth &amp;&amp; v) ? 0 : 1].push(v);
  358. });
  359. return ret;
  360. },
  361. <span id='Ext-method-invoke'> /**
  362. </span> * Invokes a method on each item in an Array.
  363. * &lt;pre&gt;&lt;code&gt;
  364. // Example:
  365. Ext.invoke(Ext.query(&quot;p&quot;), &quot;getAttribute&quot;, &quot;id&quot;);
  366. // [el1.getAttribute(&quot;id&quot;), el2.getAttribute(&quot;id&quot;), ..., elN.getAttribute(&quot;id&quot;)]
  367. * &lt;/code&gt;&lt;/pre&gt;
  368. * @param {Array|NodeList} arr The Array of items to invoke the method on.
  369. * @param {String} methodName The method name to invoke.
  370. * @param {...*} args Arguments to send into the method invocation.
  371. * @return {Array} The results of invoking the method on each item in the array.
  372. */
  373. invoke : function(arr, methodName){
  374. var ret = [],
  375. args = Array.prototype.slice.call(arguments, 2);
  376. Ext.each(arr, function(v,i) {
  377. if (v &amp;&amp; typeof v[methodName] == 'function') {
  378. ret.push(v[methodName].apply(v, args));
  379. } else {
  380. ret.push(undefined);
  381. }
  382. });
  383. return ret;
  384. },
  385. <span id='Ext-method-pluck'> /**
  386. </span> * Plucks the value of a property from each item in the Array
  387. * &lt;pre&gt;&lt;code&gt;
  388. // Example:
  389. Ext.pluck(Ext.query(&quot;p&quot;), &quot;className&quot;); // [el1.className, el2.className, ..., elN.className]
  390. * &lt;/code&gt;&lt;/pre&gt;
  391. * @param {Array|NodeList} arr The Array of items to pluck the value from.
  392. * @param {String} prop The property name to pluck from each element.
  393. * @return {Array} The value from each item in the Array.
  394. */
  395. pluck : function(arr, prop){
  396. var ret = [];
  397. Ext.each(arr, function(v) {
  398. ret.push( v[prop] );
  399. });
  400. return ret;
  401. },
  402. <span id='Ext-method-zip'> /**
  403. </span> * &lt;p&gt;Zips N sets together.&lt;/p&gt;
  404. * &lt;pre&gt;&lt;code&gt;
  405. // Example 1:
  406. Ext.zip([1,2,3],[4,5,6]); // [[1,4],[2,5],[3,6]]
  407. // Example 2:
  408. Ext.zip(
  409. [ &quot;+&quot;, &quot;-&quot;, &quot;+&quot;],
  410. [ 12, 10, 22],
  411. [ 43, 15, 96],
  412. function(a, b, c){
  413. return &quot;$&quot; + a + &quot;&quot; + b + &quot;.&quot; + c
  414. }
  415. ); // [&quot;$+12.43&quot;, &quot;$-10.15&quot;, &quot;$+22.96&quot;]
  416. * &lt;/code&gt;&lt;/pre&gt;
  417. * @param {Arrays|NodeLists} arr This argument may be repeated. Array(s) to contribute values.
  418. * @param {Function} zipper (optional) The last item in the argument list. This will drive how the items are zipped together.
  419. * @return {Array} The zipped set.
  420. */
  421. zip : function(){
  422. var parts = Ext.partition(arguments, function( val ){ return typeof val != 'function'; }),
  423. arrs = parts[0],
  424. fn = parts[1][0],
  425. len = Ext.max(Ext.pluck(arrs, &quot;length&quot;)),
  426. ret = [];
  427. for (var i = 0; i &lt; len; i++) {
  428. ret[i] = [];
  429. if(fn){
  430. ret[i] = fn.apply(fn, Ext.pluck(arrs, i));
  431. }else{
  432. for (var j = 0, aLen = arrs.length; j &lt; aLen; j++){
  433. ret[i].push( arrs[j][i] );
  434. }
  435. }
  436. }
  437. return ret;
  438. },
  439. <span id='Ext-method-getCmp'> /**
  440. </span> * This is shorthand reference to {@link Ext.ComponentMgr#get}.
  441. * Looks up an existing {@link Ext.Component Component} by {@link Ext.Component#id id}
  442. * @param {String} id The component {@link Ext.Component#id id}
  443. * @return Ext.Component The Component, &lt;tt&gt;undefined&lt;/tt&gt; if not found, or &lt;tt&gt;null&lt;/tt&gt; if a
  444. * Class was found.
  445. */
  446. getCmp : function(id){
  447. return Ext.ComponentMgr.get(id);
  448. },
  449. <span id='Ext-property-useShims'> /**
  450. </span> * By default, Ext intelligently decides whether floating elements should be shimmed. If you are using flash,
  451. * you may want to set this to true.
  452. * @type Boolean
  453. */
  454. useShims: E.isIE6 || (E.isMac &amp;&amp; E.isGecko2),
  455. // inpired by a similar function in mootools library
  456. <span id='Ext-method-type'> /**
  457. </span> * Returns the type of object that is passed in. If the object passed in is null or undefined it
  458. * return false otherwise it returns one of the following values:&lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  459. * &lt;li&gt;&lt;b&gt;string&lt;/b&gt;: If the object passed is a string&lt;/li&gt;
  460. * &lt;li&gt;&lt;b&gt;number&lt;/b&gt;: If the object passed is a number&lt;/li&gt;
  461. * &lt;li&gt;&lt;b&gt;boolean&lt;/b&gt;: If the object passed is a boolean value&lt;/li&gt;
  462. * &lt;li&gt;&lt;b&gt;date&lt;/b&gt;: If the object passed is a Date object&lt;/li&gt;
  463. * &lt;li&gt;&lt;b&gt;function&lt;/b&gt;: If the object passed is a function reference&lt;/li&gt;
  464. * &lt;li&gt;&lt;b&gt;object&lt;/b&gt;: If the object passed is an object&lt;/li&gt;
  465. * &lt;li&gt;&lt;b&gt;array&lt;/b&gt;: If the object passed is an array&lt;/li&gt;
  466. * &lt;li&gt;&lt;b&gt;regexp&lt;/b&gt;: If the object passed is a regular expression&lt;/li&gt;
  467. * &lt;li&gt;&lt;b&gt;element&lt;/b&gt;: If the object passed is a DOM Element&lt;/li&gt;
  468. * &lt;li&gt;&lt;b&gt;nodelist&lt;/b&gt;: If the object passed is a DOM NodeList&lt;/li&gt;
  469. * &lt;li&gt;&lt;b&gt;textnode&lt;/b&gt;: If the object passed is a DOM text node and contains something other than whitespace&lt;/li&gt;
  470. * &lt;li&gt;&lt;b&gt;whitespace&lt;/b&gt;: If the object passed is a DOM text node and contains only whitespace&lt;/li&gt;
  471. * &lt;/ul&gt;&lt;/div&gt;
  472. * @param {Mixed} object
  473. * @return {String}
  474. */
  475. type : function(o){
  476. if(o === undefined || o === null){
  477. return false;
  478. }
  479. if(o.htmlElement){
  480. return 'element';
  481. }
  482. var t = typeof o;
  483. if(t == 'object' &amp;&amp; o.nodeName) {
  484. switch(o.nodeType) {
  485. case 1: return 'element';
  486. case 3: return (/\S/).test(o.nodeValue) ? 'textnode' : 'whitespace';
  487. }
  488. }
  489. if(t == 'object' || t == 'function') {
  490. switch(o.constructor) {
  491. case Array: return 'array';
  492. case RegExp: return 'regexp';
  493. case Date: return 'date';
  494. }
  495. if(typeof o.length == 'number' &amp;&amp; typeof o.item == 'function') {
  496. return 'nodelist';
  497. }
  498. }
  499. return t;
  500. },
  501. intercept : function(o, name, fn, scope){
  502. o[name] = o[name].createInterceptor(fn, scope);
  503. },
  504. // internal
  505. callback : function(cb, scope, args, delay){
  506. if(typeof cb == 'function'){
  507. if(delay){
  508. cb.defer(delay, scope, args || []);
  509. }else{
  510. cb.apply(scope, args || []);
  511. }
  512. }
  513. }
  514. };
  515. }());
  516. <span id='Function'>/**
  517. </span> * @class Function
  518. * These functions are available on every Function object (any JavaScript function).
  519. */
  520. Ext.apply(Function.prototype, {
  521. <span id='Function-method-createSequence'> /**
  522. </span> * Create a combined function call sequence of the original function + the passed function.
  523. * The resulting function returns the results of the original function.
  524. * The passed fcn is called with the parameters of the original function. Example usage:
  525. * &lt;pre&gt;&lt;code&gt;
  526. var sayHi = function(name){
  527. alert('Hi, ' + name);
  528. }
  529. sayHi('Fred'); // alerts &quot;Hi, Fred&quot;
  530. var sayGoodbye = sayHi.createSequence(function(name){
  531. alert('Bye, ' + name);
  532. });
  533. sayGoodbye('Fred'); // both alerts show
  534. &lt;/code&gt;&lt;/pre&gt;
  535. * @param {Function} fcn The function to sequence
  536. * @param {Object} scope (optional) The scope (&lt;code&gt;&lt;b&gt;this&lt;/b&gt;&lt;/code&gt; reference) in which the passed function is executed.
  537. * &lt;b&gt;If omitted, defaults to the scope in which the original function is called or the browser window.&lt;/b&gt;
  538. * @return {Function} The new function
  539. */
  540. createSequence : function(fcn, scope){
  541. var method = this;
  542. return (typeof fcn != 'function') ?
  543. this :
  544. function(){
  545. var retval = method.apply(this || window, arguments);
  546. fcn.apply(scope || this || window, arguments);
  547. return retval;
  548. };
  549. }
  550. });
  551. <span id='String'>/**
  552. </span> * @class String
  553. * These functions are available as static methods on the JavaScript String object.
  554. */
  555. Ext.applyIf(String, {
  556. <span id='String-static-method-escape'> /**
  557. </span> * Escapes the passed string for ' and \
  558. * @param {String} string The string to escape
  559. * @return {String} The escaped string
  560. * @static
  561. */
  562. escape : function(string) {
  563. return string.replace(/('|\\)/g, &quot;\\$1&quot;);
  564. },
  565. <span id='String-static-method-leftPad'> /**
  566. </span> * Pads the left side of a string with a specified character. This is especially useful
  567. * for normalizing number and date strings. Example usage:
  568. * &lt;pre&gt;&lt;code&gt;
  569. var s = String.leftPad('123', 5, '0');
  570. // s now contains the string: '00123'
  571. * &lt;/code&gt;&lt;/pre&gt;
  572. * @param {String} string The original string
  573. * @param {Number} size The total length of the output string
  574. * @param {String} char (optional) The character with which to pad the original string (defaults to empty string &quot; &quot;)
  575. * @return {String} The padded string
  576. * @static
  577. */
  578. leftPad : function (val, size, ch) {
  579. var result = String(val);
  580. if(!ch) {
  581. ch = &quot; &quot;;
  582. }
  583. while (result.length &lt; size) {
  584. result = ch + result;
  585. }
  586. return result;
  587. }
  588. });
  589. <span id='String-method-toggle'>/**
  590. </span> * Utility function that allows you to easily switch a string between two alternating values. The passed value
  591. * is compared to the current string, and if they are equal, the other value that was passed in is returned. If
  592. * they are already different, the first value passed in is returned. Note that this method returns the new value
  593. * but does not change the current string.
  594. * &lt;pre&gt;&lt;code&gt;
  595. // alternate sort directions
  596. sort = sort.toggle('ASC', 'DESC');
  597. // instead of conditional logic:
  598. sort = (sort == 'ASC' ? 'DESC' : 'ASC');
  599. &lt;/code&gt;&lt;/pre&gt;
  600. * @param {String} value The value to compare to the current string
  601. * @param {String} other The new value to use if the string already equals the first value passed in
  602. * @return {String} The new value
  603. */
  604. String.prototype.toggle = function(value, other){
  605. return this == value ? other : value;
  606. };
  607. <span id='String-method-trim'>/**
  608. </span> * Trims whitespace from either end of a string, leaving spaces within the string intact. Example:
  609. * &lt;pre&gt;&lt;code&gt;
  610. var s = ' foo bar ';
  611. alert('-' + s + '-'); //alerts &quot;- foo bar -&quot;
  612. alert('-' + s.trim() + '-'); //alerts &quot;-foo bar-&quot;
  613. &lt;/code&gt;&lt;/pre&gt;
  614. * @return {String} The trimmed string
  615. */
  616. String.prototype.trim = function(){
  617. var re = /^\s+|\s+$/g;
  618. return function(){ return this.replace(re, &quot;&quot;); };
  619. }();
  620. // here to prevent dependency on Date.js
  621. <span id='Date-method-getElapsed'>/**
  622. </span> Returns the number of milliseconds between this date and date
  623. @param {Date} date (optional) Defaults to now
  624. @return {Number} The diff in milliseconds
  625. @member Date getElapsed
  626. */
  627. Date.prototype.getElapsed = function(date) {
  628. return Math.abs((date || new Date()).getTime()-this.getTime());
  629. };
  630. <span id='Number'>/**
  631. </span> * @class Number
  632. */
  633. Ext.applyIf(Number.prototype, {
  634. <span id='Number-method-constrain'> /**
  635. </span> * Checks whether or not the current number is within a desired range. If the number is already within the
  636. * range it is returned, otherwise the min or max value is returned depending on which side of the range is
  637. * exceeded. Note that this method returns the constrained value but does not change the current number.
  638. * @param {Number} min The minimum number in the range
  639. * @param {Number} max The maximum number in the range
  640. * @return {Number} The constrained value if outside the range, otherwise the current value
  641. */
  642. constrain : function(min, max){
  643. return Math.min(Math.max(this, min), max);
  644. }
  645. });
  646. </pre>
  647. </body>
  648. </html>