OSDN Git Service

ebfcea0ea00c1b4c0572746f8c5962db7e7619cd
[pettanr/clientJs.git] / 0.6.x / js / core / 02_XType.js
1 /*\r
2  * http://pettanr.sourceforge.jp/test/type.html\r
3  * \r
4  * need xua\r
5  */\r
6 \r
7 X.Type = {\r
8         isObject : function(v) {\r
9                 return v !== null && typeof v === 'object';\r
10         },\r
11         \r
12         isFunction : function(v) {\r
13                 return typeof v === 'function';\r
14         },\r
15         isArray :\r
16                 X.UA.IE && ( X.UA.IE < 5 || X.UA.MacIE ) ? (function(v){ return v && typeof v.length === 'number';}) :\r
17                 window['Array'] ? (new Function('v', 'return v instanceof Array;')) :\r
18                 (function(v){ return Object.prototype.toString.call(v) === '[object Array]';}),\r
19                 \r
20         isBoolean : function(v) {\r
21                 return typeof v === 'boolean';\r
22         },\r
23         isString : function(v) {\r
24                 return typeof v === 'string';\r
25         },\r
26         isNumber : function(v) {\r
27                 return typeof v === 'number';\r
28         },\r
29         isFinite : function(v){\r
30                 return X.Type.isNumber(v) && isFinite(v);\r
31         },\r
32         isHTMLElement :\r
33                 // ie4 or MacIE5.23\r
34                 X.UA.IE && ( X.UA.IE < 5 || X.UA.MacIE ) ? (function(v){ return v && v.tagName && v.all;}) :\r
35                 window['HTMLElement'] ? (new Function('v', 'return v instanceof HTMLElement')) :\r
36                 (function(v){ return v && v.nodeType === 1 && v.appendChild;}),\r
37         /*\r
38         isElementCollection : function(v) {\r
39                 return (Object.prototype.toString.call(v) === "[object HTMLCollection]");\r
40         },\r
41         */\r
42         isNull : function(v) {\r
43                 return v === null;\r
44         },\r
45         isUndefined : function(v) {\r
46                 return typeof v === 'undefined';\r
47         }\r
48 };\r
49 \r
50 console.log( 'X.Core.Type' );\r