简易js框架,基于js对象类操作.

支持css选择器,ui界面,表单验证。2d,3D的网页绘图(vml和纯js实现), 命名空间,js类集成,element扩展
全部代码点这里下载

对象目录
float zhuozhuo.version 版本(3.0起增加名称空间)
object zhuozhuo.namespace(namespace) 注册名称空间 并且返回此注册名称空间对象
class zhuozhuo.zclass(class…) 创建类或继承类,允许多继承(查看注解)
object zhuozhuo.getById(argv…) 根据一个或多个参数获取并包装对象(查看注解) 单参数返回zdom多参数返回array
object zhuozhuo.getBySelector(String selectors[, isAll]) 根据css规则包装输出ZDOM数组 如果isAll存在且为1或true则输出zdom数组,否则只输出一个对象
浏览器信息
string zhuozhuo.browser.version 浏览器内核版本(IE, Opera显示浏览器版本)
bool zhuozhuo.browser.kernel.isTrident 浏览器内核 IE
bool zhuozhuo.browser.kernel.isGecko 浏览器内核 Firefox,MozillaSuite/SeaMonkey,Mozilla,Thunderbird
bool zhuozhuo.browser.kernel.isPresto 浏览器内核 Opera
bool zhuozhuo.browser.kernel.isWebKit 浏览器内核 Safari
bool zhuozhuo.browser.kernel.isKHTML 浏览器内核 Konqueror
bool zhuozhuo.browser.features.isXPath 是否支持xpath
bool zhuozhuo.browser.features.isSelectorsAPI 是否支持css选择器

工具
string zhuozhuo.util.getClass(object) 返回对象类别字串
object zhuozhuo.util.extend(destination, source) source对象合并到destination上 相同的方法或涵数覆盖 返回 destination
object zhuozhuo.util.clone(object) 返回object的浅表复制
bool zhuozhuo.util.isArray(object) 判断object是否数组
bool zhuozhuo.util.isFunction(object) 判断object是否函数
bool zhuozhuo.util.isNumber(object) 判断object是否数字
bool zhuozhuo.util.isUndefined(object) 判断object是否未定义
bool zhuozhuo.util.isString(object) 判断object是否是字符串
array zhuozhuo.util.toArray(iteralbe) 把iteralbe转换为数组
void zhuozhuo.util.fnEmpty() 空function函数
bool zhuozhuo.util.fnTrue() 返回true的函数
string zhuozhuo.util.param(object) 序列化object
object zhuozhuo.util.trys(Function…) 执行多个function并返回最早的正确结果

String zhuozhuo.util.string.trim(value) 去除左右两边的空格
Integer zhuozhuo.util.string.wlength(value) 按英文长度返回字符串长度,一个汉字相当于两个英文字符
String zhuozhuo.util.string.wsubstr(value, wstart[, wlength]) 按英文长度从开始位置截取指定长度字符串 一个汉字相当于两个英文字符
String zhuozhuo.util.string.wsubstring(value, wstart, wend) 按英文长度截取指定范围的字符串

Array zhuozhuo.util.array.each(array, Function handler(Object object, Integer index))
迭代数组 并 相同的参数,面向所有的元素。返回调用方法的结果。第一参数数组值,第二个参数索引,返回执行结果数组
Array zhuozhuo.util.array.uniq(array) 返回不重复的数组
Integer zhuozhuo.util.array.indexOf(array Object object[, Integer startIndex]) 在数组中查找指定元素的位置,找不到返回 -1 可选参数 搜索的起始索引。空数组中 0(零)为有效值。

事件包装
new zhuozhuo.event.Event(event)
object .event 被包装事件对象(例:window.event)
bool .altKey 返回当事件被触发时,”ALT” 是否被按下。
bool .ctrlKey 返回当事件被触发时,”CTRL” 键是否被按下。
bool .shiftKey 返回当事件被触发时,”SHIFT” 键是否被按下。
int .keyCode 设置或获取与导致事件的按键关联的 Unicode 按键代码。
int .clientX 返回当事件被触发时,鼠标指针的水平坐标。
int .clientY 返回当事件被触发时,鼠标指针的垂直坐标。
int .screenX 返回当某个事件被触发时,鼠标指针的水平坐标。
int .screenY 返回当某个事件被触发时,鼠标指针的垂直坐标。
int .layerX 获取鼠标指针位置相对于触发事件的对象的 x 坐标。
int .layerY 获取鼠标指针位置相对于触发事件的对象的 y 坐标。
DOM .relatedTarget 返回与事件的目标节点相关的节点。(未包装)
int .detail 获取滚轮按钮滚动的距离和方向。
DOM .target 返回触发此事件的元素(事件的目标节点)。(未包装)
DOM .currentTarget 返回其事件监听器触发该事件的元素。(未包装)
string .type 返回当前 Event 对象表示的事件的名称。
ZDOM .getTarget() 返回触发事件对象(已包装 zhuozhuo.element.*)
Event .preventDefault() 取消事件的默认动作 返回当前事件包装
Event .stopPropagation() 停止事件冒泡 返回当前事件包装

事件监听
new zhuozhuo.event.Listener()
array .listeners 事件监听队列
void .addListener(eventName, handler) 添加事件(事件名,处理函数)
void .removeListener(eventName, handler) 添加事件(事件名,处理函数)
void .notifyEvent(eventName, eventObject) 通知事件(事件名,希望传递的事件参数对象)

节点包装
array zhuozhuo.element.zdomcache 包装对象缓存 此对象用于重复包装同一节点
void zhuozhuo.element.syncCache() 同步对象缓存 触发空对象finalize() 释放事件
ZDOM zhuozhuo.element.extend(HTMLElement) 包装节点 返回已包装element对象
ZDOM zhuozhuo.element.createTable(rows, cells) 创建表格
ZDOM zhuozhuo.element.createElement(tagName) 创建标签
object zhuozhuo.element.view.getDimensions() 获取尺寸 {Integer pageWidth,Integer pageHeight,Integer screenWidth,Integer screenHeight}
object zhuozhuo.element.view.getScrollOffsets() 获取滚动条偏移位置 {Integer top,Integer left}

css规则元素包装
array zhuozhuo.element.getElementsBySelector(selectors, ZDOM) 使用css3选择符号

new zhuozhuo.element.window(DOM) extneds zhuozhuo.event.Listener window节点包装类
DOM .element 被包装节点
array .eventsmaps 包装事件影射 {key,callback}
ZDOM .addEvent(eventName, handler) 添加事件 返回当前包装实例
ZDOM .removeEvent(eventName, handler) 删除事件 返回当前包装实例
ZDOM .startCapture() 开始捕获鼠标 返回当前包装实例
ZDOM .stopCapture() 停止捕获鼠标 返回当前包装实例

zhuozhuo.element.document extends zhuozhuo.element.window 通用文档节点包装类
new zhuozhuo.element.document(DOM)
object .getBySelector(selectors[, isAll]) 使用当前对象调用 zhuozhuo.getBySelector
bool .hasClassName(className) 判断是否存在指定样式类名
ZDOM .addClassName(className) 添加指定名称样式定义 返回当前包装实例
ZDOM .removeClassName(className) 删除指定名称样式定义 返回当前包装实例
bool .hasAttribute(attributeName) 判断是否存在指定属性
ZDOM .setAttribute(name, value) 设置指定名称属性 返回当前包装实例
ZDOM .setAttribute(attributes) 设置指定名称属性 {n0:v0,n1:v1….} 返回当前包装实例
object .getAttribute(attributeName) 获取属性值
ZDOM .setStyle(name, value) 设置样式 返回当前包装实例
ZDOM .setStyle(styles) 设置样式 {n0:v0,n1:v1….} 返回当前包装实例
string .getStyle(styleName) 获取样式
ZDOM .setAlphaImage(imgurl) 设置背景图 返回当前包装实例
string .getAlphaImage() 获取背景图
ZDOM .setOpacity(opacity) 设置透明度 0 – 1 返回当前包装实例
float .getOpacity() 获取透明度
ZDOM .setText(value) 设置节点text内容 返回当前包装实例
string .getText() 获取节点text内容
ZDOM .setHTML(value) 设置节点html内容 返回当前包装实例
string .getHTML() 获取节点html内容
ZDOM .show(value) 显示节点 value 默认为 “block” 返回当前包装实例
ZDOM .hide() 隐藏节点 返回当前包装实例
ZDOM .toggle(value) 显示或隐藏节点 返回当前包装实例
object .getOffsets() 获取放置偏移坐标 {left, top}
object .getDimensions() 获取尺寸{width, height}
ZDOM .remove() 删除自己 返回当前包装实例 触发一次同步缓村操作
ZDOM .append(ZDOM) 附加结点返回被附加节点 返回新节点
string .append(string html) 附加文本内容代码
ZDOM .insert(sWhere, ZDOM) 插入节点sWhere=beforeBegin|afterBegin|beforeEnd|afterEnd返回新插入的节点
ZDOM .animate(Object styles, int frames, int delay, int factor, fn callback(ZDOM node, int frames))
自定义动画 (value:目的样式属性,frames:帧数,delay:每帧时间,factor:渐变因子(为”average”或非数字时 等于平均变化,否则每次按照此设置除法递减),callback:回调参数)
callback 调用有两个参数node和frames node=被执节点,frames=当前倒数帧数 frames到1 到数 为1表示最后一帧 0表示结束
ZDOM .animate(Object styles, int frames, int delay, fn callback) 自定义动画
ZDOM .animate(Object styles, int frames, fn callback) 自定义动画
ZDOM .animate(Object styles, fn callback) 自定义动画
ZDOM .animate(Object styles) 自定义动画
……………………………………………………………………..
new zhuozhuo.element.tag.FORM extends zhuozhuo.element.document
new zhuozhuo.element.tag.INPUT extends zhuozhuo.element.document 表单元素包装
string .getValue() 获取值
ZDOM .setValue(string value) 设置值 返回当前包装
……………………………………………………………………..
new zhuozhuo.element.tag.TEXTAREA extends zhuozhuo.element.tag.INPUT 多行文本输入包装
……………………………………………………………………..
new zhuozhuo.element.tag.SELECR extends zhuozhuo.element.tag.INPUT 选择筐输入包装


ajax对象
zhuozhuo.ajax.Response
构造:
new zhuozhuo.ajax.Response(XMLHTTP XmlHttp) 包装构建一个新的 AjaxResponse 对象。
属性:
XMLHTTP xmlHttp 被封装Xmlhttp对象
String text 以文本形式获取返回内容
XmlDocument xml 以xml形式获取返回内容
String length 获取返回长度
String type 获取内容类型
Integer status 状态码
方法:
String getAllHeaders() 获取所有返回头

String getHeader(String header) 获取指定名称返回头

类 zhuozhuo.ajax.Request extends zhuozhuo.event.Listener 继承自事件监听
构造:
new zhuozhuo.ajax.Request() 构建一个新的 Ajax 对象。
属性:
XMLHTTP xmlHttp 此ajax类被包装xmlhttp对象
string encoding = “UTF-8” 编码
string url 请求url
string method 请求方法 get 或 post
bool async 是否异步
string user 帐号
string password 密码
object requestHeaders 请求头集合
方法:
void open(String url, String method = “POST”, Boolean async = true, String user = null, String password = null)
创建一个新的http请求,并指定此请求的方法、URL以及验证信息
void setHeader(String header, String value) 设置请求头 (POST打开会自动设置必须header)
void setHeaders(Object headers) 设置请求头
void send(Object varBody = {}) 发送 带数据的请求
void onreadystatechange() 异步触发
void abort() 取消当前请求
事件:
事件名 参数
request Integer readyState 读取状态 状态 0-4 0 (未初始化) 1 (初始化) 2 (发送数据) 3 (数据传送中) 4 (完成);
success Ajax.Response response 请求成功 请自行包装xmlhttp
failure Ajax.Response response 请求失败 请自行包装xmlhttp
GET请求
zhuozhuo.ajax.Request zhuozhuo.ajax.get({
String url:””, 请求url
Object data:null, 请求数据
boolean async:true, 同步异步
String user:null, 用户名
String password:null, 密码
Function request:ZHUOZHUO.FALSE(int readyState), 请求中
Function success:ZHUOZHUO.FALSE(Ajax.Response response), 成功
Function failure:ZHUOZHUO.FALSE(Ajax.Response response)}); 失败
POST请求
zhuozhuo.ajax.Request zhuozhuo.ajax.post({参数同Ajax.get});


注解:
class zhuozhuo.zclass([superclass,…]currentclass)
创建javascript类,允许多重继承,并且增加构造和完成函数
例:
var newClass = zhuozhuo.zclass(超类1..,超类N,{ 类方法名:函数体});
var newClass1= zhuozhuo.zclass({ 类方法名:函数体});
构造函数
initialize()
调用父构造函数
类名.superclass.initialize.apply(this, arguments)
完成函数
finalize()
调用父完成函数
类名.superclass.finalize.apply(this)
调用父其他函数
类名.superclass.方法名.apply(this, arguments)
类名.superclass.方法名.call(this[, arg0[, arg1]…])
其他说明
多个父类时,按输入类名顺序,后面的方法覆盖前面类的同名方法

object getById(argv1 [, …[, argvN]])
根据一个或多个参数获取并包装对象,
参数类型可以为 HTMLElment,string,或 zhuozhuo.element.*, zhuozhuo.element.tag.*的实例
如类型正确,返回包装后的元素实例.多个实例集合为数组

DOM,ZDOM 类型
DOM:未包装DHTMLElement对象
ZDOM:已包装的DHTMLElement实例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
/* 
 * zhuozhuo.org javascript library core code
 * Shi,Zhuolin
 * http://www.zhuozhuo.org
 * shizhuolin@hotmail.com
 * 2011-03-01
 */
(function(scope){
    var zz = scope.zhuozhuo = scope.zhuozhuo || {};
    //library version
    zz.version = 3.0;
    //register namespace
    zz.namespace = function(ns){
        if (!ns || !ns.length) return null;
        var levels = ns.split('.'), nsobj = scope;
        for (var i = 0; i < levels.length; i++) {
            nsobj[levels[i]] = nsobj[levels[i]] || {};
            nsobj = nsobj[levels[i]];
        }
        return nsobj;
    }
    //create javascript class
    zz.zclass = function(){
        var zclass, baseclass, method, superclass = (function(){}).prototype;
        zclass = function(){
            this.initialize.apply(this, arguments);
        }
        superclass.initialize = zclass.prototype.initialize = function(){};
        superclass.finalize = zclass.prototype.finalize = function(){
            for(var key in this) this[key] = null;
        }
        for(var i = 0, length = arguments.length; i < length; i++){
            if(zz.util.isFunction(arguments[i])){
                baseclass = function(){};
                baseclass.prototype = arguments[i].prototype;
                baseclass = new baseclass;
                for(method in baseclass) superclass[method] = baseclass[method];
            }else {
                baseclass = arguments[i];
            }
            for(method in baseclass)
                if(!/^(toString|valueOf)$/.test(method))
                    if(zz.util.isFunction(baseclass[method])) zclass.prototype[method] = baseclass[method];
            if(baseclass.toString!== Object.prototype.toString) zclass.prototype.toString= baseclass.toString;
            if(baseclass.valueOf !== Object.prototype.valueOf) zclass.prototype.valueOf = baseclass.valueOf;
        }
        zclass.superclass = superclass;
        return zclass;
    }
    //zhuozhuo.getById
    zz.getById = function(){
        if (arguments.length > 1) {
            for (var i = 0, elements = [], length = arguments.length; i < length; i++) elements.push(zz.getById(arguments[i]));
            return elements;
        }
        return zz.element.extend(zz.util.isString(arguments[0]) ? document.getElementById(arguments[0]) : arguments[0]);
    }
    //zhuozhuo.getBySelector
    zz.getBySelector = function(selectors, isAll){
        return zz.getById(document).getBySelector(selectors, isAll);
    }
})(this);
//browser information
(function(scope){
    var agent = navigator.userAgent;
    scope.zhuozhuo.browser = {
        version : (/MSIE\s(\d+(\.\d+)*)/.exec(agent) || /rv:(\d+(\.\d+)*)/.exec(agent) || /AppleWebKit\/(\d+(\.\d+)*)/.exec(agent) || /Opera.(\d+(\.\d+)*)?/.exec(agent) || /Presto\/(\d+(\.\d+)*)/.exec(agent) || /KHTML\/(\d+(\.\d+)*)/.exec(agent) || /Konqueror\/(\d+(\.\d+)*)/.exec(agent) || /[;\(]\s*(\w?\d+(\.\d+)*)\s*\)?/.exec(agent) || [,null])[1],
        kernel : {
            isTrident : agent.indexOf("MSIE") > -1,
            isGecko   : agent.indexOf("Gecko/") > -1,
            isPresto  : agent.indexOf("Presto/") > -1 || agent.indexOf("Opera/") > -1,
            isWebKit  : agent.indexOf("AppleWebKit/") > -1,
            isKHTML   : agent.indexOf("KHTML/") > -1 || agent.indexOf("Konqueror/") > -1
        },
        features : {
            isXPath        : !!document.evaluate,
            isSelectorsAPI : !!document.querySelector
        }
    }
})(this);
//zhuozhuo.util.*
(function(scope){
    var zz = scope.zhuozhuo;
    zz.util = {
        getClass : function(object){
            return Object.prototype.toString.call(object).match(/^\[object\s(.*)\]$/)[1];
        },
        extend : function(destination, source){
            for(var property in source) destination[property] = source[property];
            return destination;
        },
        clone : function(object){
            return zz.util.extend({}, object);
        },
        isArray : function(object){
            return zz.util.getClass(object) === "Array";
        },
        isUndefined : function(object){
            return typeof object === "undefined";
        },
        isFunction : function(object){
            return typeof object === "function";
        },
        isString : function(object){
            return typeof object === "string";
        },
        isNumber : function(object){
            return typeof object === "number";
        },
        toArray : function(iterable){
            if (!iterable) return [];
            if ("toArray" in iterable) return iterable.toArray();
            var length = iterable.length || 0, results = new Array(length);
            while (length--) results[length] = iterable[length];
            return results;
        },
        fnEmpty : function(){},
        fnTrue : function(){
            return true;
        },
        param : function(object){
            var array = [];
            for(var key in object) array.push(encodeURIComponent(key) + '=' + encodeURIComponent(object[key]));
            return array.join('&');
        },
        trys : function(){
            var result;
            for (var i = 0, length = arguments.length; i < length; i++) try {
                result = arguments[i]();
                break;
            }
            catch (e) {}
            return result;
        }
    }
    zz.util.string = {
        trim : function(value){
            return value.replace(/(^\s+)|(\s+$)/g, '');
        },
        wlength : function(value){
            return value.replace(/[^\x00-\xff]/g, "rr").length;
        },
        wsubstr : function(value, wstart, wlength){
            wlength = isNaN(wlength) ? Number.MAX_VALUE : wlength;
            return wlength == 0 ? "" : zz.util.string.wsubstring(value, wstart, wstart + wlength - 1);
        },
        wsubstring : function(value, wstart, wend){
            var ws = Math.min(wstart, wend), we = Math.max(wstart, wend);
            var i = 0, length = value.length, retult = "";
            for(; i < length; i++){
                var wl = value.substring(0, i).wlength();
                if(wl > we) break;
                if(wl >= ws) retult += value.substr(i, 1);
            }
            return retult;
        }
    }
    zz.util.array = {
        each : function(arr, handler){
            var retus = [];
            for (var i = 0, length = arr.length; i < length; i++) retus.push(handler(arr[i], i));
            return retus;
        },
        uniq : function(arr){
            var array = [];
            for(var i = 0, length = arr.length; i < length; i++)
                if(zz.util.array.indexOf(array, arr[i]) == -1) array.push(arr[i]);
            return array;
        },
        indexOf : function(arr, object, startIndex){
            startIndex = startIndex || 0;
            var length = arr.length;
            if(startIndex < 0) startIndex = 0;
            if(startIndex > length) startIndex = length;
            for(; startIndex < length; startIndex++)
                if(arr[startIndex] === object) return startIndex;
            return -1;
        }
    }
})(this);
//zhuozhuo.event.*
(function(scope){
    var zz = scope.zhuozhuo;
    var util = zz.util;
    zz.event = {
        Event : zz.zclass({
            initialize : function(event){
                this.event   = event;
                this.altKey  = event.altKey;
                this.clientX = event.clientX;
                this.clientY = event.clientY;
                this.ctrlKey = event.ctrlKey;
                this.keyCode = event.keyCode;
                this.screenX = event.screenX;
                this.screenY = event.screenY;
                this.layerX  = event.offsetX || event.layerX;
                this.layerY  = event.offsetY || event.layerY;
                this.shiftKey= event.shiftKey;
                this.detail  = event.detail ? event.detail > 0 ? 1 : -1 : event.wheelDelta > 0 ? -1 : 1;
                this.target  = event.srcElement || event.target;
                this.type    = event.type;
                this.relatedTarget= event.fromElement || event.relatedTarget;
                this.currentTarget= event.toElement || event.currentTarget;
            },
            stopPropagation : function(){
                var event = this.event;
                event.stopPropagation ? event.stopPropagation() : event.cancelBubble = true;
                return this;
            },
            preventDefault : function(){
                var event = this.event;
                event.preventDefault ? event.preventDefault() : event.returnValue = false;
                return this;
            },
            getTarget : function(){
                var node = this.target, type = this.type;
                var currentTarget = this.currentTarget;
                if ((currentTarget && currentTarget.tagName) && (type === "load" || type === "error" || (type === "click" && currentTarget.tagName.toLowerCase() === "input" && currentTarget.type === "radio"))) node = currentTarget;
                if(node.nodeType === 3) node = node.parentNode;
                return zz.element.extend(node);
            }
        }),
        Listener : zz.zclass({
            initialize : function(){
                this.listeners = [];
            },
            addListener : function(eventName, handler){
                if(!util.isFunction(handler)) return;
                for(var i = 0, length = this.listeners.length; i < length; i++)
                    if(this.listeners[i].eventName === eventName && this.listeners[i].handler === handler)
                        return;
                this.listeners.push({
                    eventName : eventName,
                    handler : handler
                });
            },
            removeListener : function(eventName, handler){
                if(!util.isFunction(handler)) return;
                for(var i = 0, length = this.listeners.length; i < length; i++)
                    if(this.listeners[i].eventName === eventName && this.listeners[i].handler === handler)
                    {
                        this.listeners[i] = this.listeners[i].eventName = this.listeners[i].handler = null;
                        this.listeners.splice(i, 1);
                        return;
                    }
            },
            notifyEvent : function(eName, eobj){
                for(var i = 0, length = this.listeners.length; i < length; i++)
                    if(this.listeners[i].eventName === eName)
                        this.listeners[i].handler(eobj);
            },
            finalize : function(){
                for(var i = 0, length = this.listeners.length; i < length; i++)
                    this.listeners[i].eventName = this.listeners[i].handler = null;
                zz.event.Listener.superclass.finalize.apply(this)
            }
        })
    }
})(this);
//window and document and other element
(function(scope){
    var zz = scope.zhuozhuo;
    var util = zz.util;
    zz.namespace("zhuozhuo.element.tag");
    zz.element.zdomcache = [];
    zz.element.syncCache = function(){
        var newcache = [];
        for(var i = 0, length = zz.element.zdomcache.length; i < length; i++){
            if(!checkin(zz.element.zdomcache[i].element)){
                zz.element.zdomcache[i].finalize();
                zz.element.zdomcache[i] = null;
            }else newcache.push(zz.element.zdomcache[i]);
        }
        zz.element.zdomcache = newcache;
        function checkin(ele){
            while(ele){
                if(ele === window.document.body) return true
                if(ele === window.document) return true;
                if(ele === window) return true;
                ele = ele.parentNode;
            }
            return false;
        }
    };
    zz.element.extend = function(element){
        if(!element || util.isFunction(element) || !!element.element || !!element.initialize) return element;
        var byClass;
        if(element === window) byClass = zz.element.window;
        else{
            if(element === document) byClass = zz.element.document;
            else{
                if(element.nodeType != 1) return element;
                byClass = zz.element.tag[element.tagName.toUpperCase()] || zz.element.document;
            }
        }
        for(var i=0, length = zz.element.zdomcache.length; i < length ; i++)
            if(zz.element.zdomcache[i].element === element) return zz.element.zdomcache[i];
        var zdom = new byClass(element);
        zz.element.zdomcache.push(zdom);
        return zdom;
    }
    zz.element.createTable = function(rows, cells){
        var table = document.createElement("table");
        for(var i = 0; i < rows; i++){
            table.insertRow(i);
            for(var j = 0; j < cells; j++) table.rows[i].insertCell(j);
        }
        return zz.element.extend(table);
    }
    zz.element.createElement= function(tagName){
        return zz.element.extend(document.createElement(tagName));
    }
    zz.element.view = {
        getDimensions : function(){
            var scrW, scrH, win = window, doc = document;
            if(win.innerHeight && win.scrollMaxY) {
                scrW = win.innerWidth + win.scrollMaxX;
                scrH = win.innerHeight + win.scrollMaxY;
            } else if(!doc.body && doc.documentElement && doc.documentElement.scrollWidth){
                scrW = doc.documentElement.scrollWidth;
                scrH = doc.documentElement.scrollHeight;
            } else if(doc.body){
                scrW = doc.body.scrollWidth;
                scrH = doc.body.scrollHeight;
            }
            var winW, winH;
            if(win.innerHeight) {
                winW = win.innerWidth;
                winH = win.innerHeight;
            } else if (doc.documentElement && doc.documentElement.clientHeight){
                winW = doc.documentElement.clientWidth;
                winH = doc.documentElement.clientHeight;
            } else if (doc.body) {
                winW = doc.body.clientWidth;
                winH = doc.body.clientHeight;
            }
            var pageW = scrW < winW ? winW : scrW;
            var pageH = scrH < winH ? winH : scrH;
            return {
                pageWidth   : pageW,
                pageHeight  : pageH,
                screenWidth : winW,
                screenHeight: winH
            };
        },
        getScrollOffsets : function(){
            var top = 0, left = 0, win = window, doc = document;
            if(win.pageYOffset){
                top  = win.pageYOffset;
                left = win.pageXOffset;
            }else if(doc.compatMode && doc.compatMode != "BackCompat"){
                top  = doc.documentElement.scrollTop;
                left = doc.documentElement.scrollLeft;
            }else if(doc.body){
                top  = doc.body.scrollTop;
                left = doc.body.scrollLeft;
            }
            return {
                top  : top,
                left : left
            };
        }
    }
    zz.element.getElementsBySelector = function(selectors, zdom){
        var element = zdom.element;
        var _re0 = "(?=([^\"\']*[\"\'][^\"']*[\"'])*(?![^\"']*[\"']))";
        var _re1 = "(?=([^\\[]*\\[[^\\]]*\\])*(?![^\\]]*\\]))";
        var elements = zz.browser.features.isSelectorsAPI ? util.toArray(element.querySelectorAll(selectors)) : zz.browser.features.isXPath ? _querySelectorAllByXPath(selectors, element) : _querySelectorAllByJavaScript(selectors, element);
        for(var i = 0, length = elements.length; i < length; i++) elements[i] = zz.element.extend(elements[i]);
        function _querySelectorAllByXPath(selectors, element){
            var xpath = selectors.trim();
            xpath = xpath.replace(new RegExp("^\\s*|\\s*,\\s*" + _re1, 'g'), function(e){
                return (e.indexOf(',') > -1 ? '|' : '') + ".//*";
            });
            xpath = xpath.replace(new RegExp("\\s*~\\s*" + _re1, 'g'), "/following-sibling::*");
            xpath = xpath.replace(new RegExp("\\s*\\+\\s*" + _re1, 'g'), "/following-sibling::*[1]");
            xpath = xpath.replace(new RegExp("\\s*>\\s*" + _re1, 'g'), "/*");
            xpath = xpath.replace(new RegExp("\\s+" + _re1, 'g'), "//*");
            xpath = xpath.replace(new RegExp("\\*(\\w)" + _re1, 'g'), "$1");
            xpath = xpath.replace(new RegExp("\\[\\s*(\\w+)\\s*]" + _re0, 'g'), "[@$1]");
            xpath = xpath.replace(new RegExp("\\.(\\w+)" + _re0, 'g'), "[class~='$1']");
            xpath = xpath.replace(new RegExp("#(\\w+)" + _re0, 'g'), "[id='$1']");
            xpath = xpath.replace(new RegExp("\\[\\s*(\\w+)\\s*\\^=\\s*'?([^']*)'?\\s*]" + _re0, 'g'), "[starts-with(@$1,'$2')]");
            xpath = xpath.replace(new RegExp("\\[\\s*(\\w+)\\s*\\$=\\s*'?([^']*)'?\\s*]" + _re0, 'g'), "[substring(@$1,(string-length(@$1) - string-length('$2') + 1))='$2']");
            xpath = xpath.replace(new RegExp("\\[\\s*(\\w+)\\s*\\*=\\s*'?([^']*)'?\\s*]" + _re0, 'g'), "[contains(@$1,'$2')]");
            xpath = xpath.replace(new RegExp("\\[\\s*(\\w+)\\s*\\|=\\s*'?([^']*)'?\\s*]" + _re0, 'g'), "[contains(concat('-',@$1,'-'),'-$2-')]");
            xpath = xpath.replace(new RegExp("\\[\\s*(\\w+)\\s*~=\\s*'?([^']*)'?\\s*]" + _re0, 'g'), "[contains(concat(' ',@$1,' '),' $2 ')]");
            xpath = xpath.replace(new RegExp("\\[\\s*(\\w+)\\s*=\\s*'?([^']*)'?\\s*]" + _re0, 'g'), "[@$1='$2']");
            var query = doc.evaluate(xpath, element, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null), results = [];
            for(var i = 0, length = query.snapshotLength; i < length; i++) results.push(query.snapshotItem(i));
            return results;
        }
        function _querySelectorAllByJavaScript(selectors, element){
            var expression = util.string.trim(selectors);
            expression = expression.replace(new RegExp("(^|\\s|,|>|\\+|~)(#|\\.|\\[)" + _re0, 'g'), "$1*$2");
            expression = expression.replace(new RegExp("\\s{2,}" + _re0, 'g'), ' ');
            expression = expression.replace(new RegExp("\\s*(>|\\+|~|,)\\s*" + _re0, 'g'), '$1');
            expression = expression.replace(new RegExp("#(\\w+)" + _re0, 'g'), "[id='$1']");
            expression = expression.replace(new RegExp("\\.(\\w+)" + _re0, 'g'), "[class~='$1']");
            var ElementArray = [], elements, child, selector;
            util.array.each(util.string.trim(expression).split(new RegExp(',' + _re1, 'g')), function(strSelector){
                if(strSelector == '') return false;
                elements = [element];
                strSelector = strSelector.replace(new RegExp("(\\s|>|\\+|~)(\\w|\\*)" + _re1, 'g'), "\n$1$2").split('\n');
                for (var i = 0, length = strSelector.length; i < length; i++){
                    child = strSelector[i].substr(0, 1);
                    selector= strSelector[i].substr(1);
                    switch(child){
                        case ' ' :
                            elements = __concatMatcher(selector, elements);
                            break;
                        case '>' :
                            elements = __childSelectors(selector, elements);
                            break;
                        case '+' :
                            elements = __nextSiblings(selector, elements);
                            break;
                        case '~' :
                            elements = __nextSiblingAll(selector, elements);
                            break;
                        default :
                            elements = __concatMatcher(strSelector[i], elements);
                    }
                }
                ElementArray = ElementArray.concat(elements);
                return false;
            });
            function __getTagAttrs(selector){
                var TAASL   = selector.replace(new RegExp("(\\[|])" + _re0, 'g'), '\n').split('\n');
                var tagName = TAASL[0], attrs=[];
                TAASL.shift();
                util.array.each(TAASL, function(v){
                    v = util.string.trim(v);
                    if(v != '' ) attrs.push('['+v+']');
                });
                attrs = attrs.join('');
                return {
                    tagName : tagName,
                    attrs   : attrs
                };
            }
            function __getAttr(element, attributeName){
                if(attributeName == "class" && zz.browser.kernel.isTrident) return element.className;
                if(attributeName == "style" && zz.browser.kernel.isTrident) return element.style.cssText;
                return element.getAttribute(attributeName);
            }
            function __checkAttr(element, attrs){
                var TAASL = attrs.replace(new RegExp("\\[|]" + _re0, 'g'), '\n').split('\n'), value, returs = true;
                if(element.nodeType != 1) return false;
                for(var i = 0, length = TAASL.length; i < length; i++){
                    attrs = util.string.trim(TAASL[i]);
                    if(attrs == '') continue;
                    attrs = attrs.replace(new RegExp("([~\\|\\^\\$\\*]?=)" + _re0, 'g'), "\n$1\n").split('\n');
                    attrs[0] = util.string.trim(attrs[0]);
                    value = __getAttr(element, attrs[0]);
                    if(attrs.length == 1){
                        if(!/^(class|style)$/.test(attrs[0]) && (value === null || element[attrs[0]] === undefined)) returs = false;
                    }else{
                        attrs[2] = attrs[2].replace(/(^\s*')|('\s*$)/g, '');
                        switch(attrs[1]){
                            case "|=" :
                                if(!new RegExp("(^|-)" + attrs[2] + "(-|$)", 'g').test(value)) returs = false;
                                break;
                            case "~=" :
                                if(!new RegExp("(^|\\s)" + attrs[2] + "(\\s|$)", 'g').test(value)) returs = false;
                                break;
                            case "*=" :
                                if(!new RegExp(attrs[2], 'g').test(value)) returs = false;
                                break;
                            case "$=" :
                                if(!new RegExp(attrs[2] + '$', 'g').test(value)) returs = false;
                                break;
                            case "^=" :
                                if(!new RegExp('^' + attrs[2], 'g').test(value)) returs = false;
                                break;
                            default :
                                if(!new RegExp('^' + attrs[2] + '$', 'g').test(value)) returs = false;
                        }
                    }
                }
                return returs;
            }
            function __reTagAndAttr(tagAndAttrSelector, element){
                var v = __getTagAttrs(tagAndAttrSelector), returs = [];
                var elements = element.getElementsByTagName(v.tagName);
                for(var i = 0, length = elements.length; i < length; i++)
                    if(__checkAttr(elements[i], v.attrs)) returs.push(elements[i]);
                return returs;
            }
            function __concatMatcher(selector, elements){
                var returs = [];
                for(var i = 0, length = elements.length; i < length; i++) returs = returs.concat(__reTagAndAttr(selector, elements[i]));
                return returs;
            }
            function __childSelectors(selector, elements){
                var v = __getTagAttrs(selector), tmpelements = [], childnodes;
                for(var i = 0, length = elements.length; i < length; i++){
                    childnodes  = elements[i].childNodes;
                    for(var j = 0, len = childnodes.length; j < len; j++)
                        if(childnodes[j].nodeType == 1 && __checkAttr(childnodes[j], v.attrs) && (childnodes[j].tagName.toLowerCase() == v.tagName || v.tagName == '*'))
                            tmpelements.push(childnodes[j]);
                }
                return tmpelements;
            }
            function __nextSiblings(selector, elements){
                var v = __getTagAttrs(selector), tmpelements = [], next;
                for(var i = 0, length = elements.length; i < length; i++){
                    next = elements[i].nextSibling;
                    if(next && next.nodeType == 1 && checkattr(next, v.attrs) && (next.tagName.toLowerCase() == v.tagName || v.tagName == '*')) tmpelements.push(next);
                }
                return tmpelements;
            }
            function __nextSiblingAll(selector, elements){
                var v = __getTagAttrs(selector), tmpelements = [], next;
                for(var i = 0, length = elements.length; i < length; i++){
                    next = elements[i];
                    while(next){
                        if(next && next.nodeType == 1 && checkattr(next, v.attrs) && (next.tagName.toLowerCase() == v.tagName || v.tagName == '*')) tmpelements.push(next);
                        next  = next.nextSibling;
                    }
                }
                return tmpelements;
            }
            return util.array.uniq(ElementArray);
        }
        return elements;
    }
    zz.element.window = zz.zclass(zz.event.Listener, {
        initialize : function(element){
            zz.element.window.superclass.initialize.apply(this, arguments)
            this.element = element;
            this.eventsmaps = [];
        },
        addEvent : function(eventName, callback){
            var handler = function(event){
                callback(new zz.event.Event(event));
            }
            this.eventsmaps.push({
                key    : callback,
                handler: handler
            });
            this.addListener(eventName, handler);
            var element = this.element;
            if(eventName.toLowerCase() == "mousewheel" && zz.browser.kernel.isGecko) eventName = "DOMMouseScroll";
            element.attachEvent ? element.attachEvent("on" + eventName, handler) : element.addEventListener(eventName, handler, false);
            return this;
        },
        removeEvent : function(eventName, callback){
            for(var i = 0, length = this.eventsmaps.length; i < length; i++){
                if(this.eventsmaps[i].key === callback){
                    var element = this.element;
                    var handler = this.eventsmaps[i].handler;
                    this.removeListener(eventName, handler);
                    if(eventName.toLowerCase() == "mousewheel" && zz.browser.kernel.isGecko) eventName = "DOMMouseScroll";
                    element.detachEvent ? element.detachEvent("on" + eventName, handler) : element.removeEventListener(eventName, handler, false);
                    this.eventsmaps[i] = this.eventsmaps[i].key = this.eventsmaps[i].handler = null;
                    this.eventsmaps.splice(i, 1);
                    return this;
                }
            }
            return this;
        },
        startCapture : function(){
            var element = this.element;
            element.setCapture ? element.setCapture() : window.captureEvents ? (zz.browser.kernel.isGecko && parseFloat(zz.browser.version) >= 1.9) ? util.fnEmpty() : window.captureEvents(Event.MOUSEMOVE) : util.fnEmpty();
            return this;
        },
        stopCapture : function(){
            var element = this.element;
            element.releaseCapture ? element.releaseCapture() : window.releaseEvents ? (zz.browser.kernel.isGecko && parseFloat(zz.browser.version) >= 1.9) ? util.fnEmpty() : window.releaseEvents(Event.MOUSEMOVE) : util.fnEmpty();
            return this;
        },
        finalize : function(){
            for(i = 0, length = this.listeners.length; i < length; i++)
                this.removeEvent(this.listeners[i].eventName, this.listeners[i].handler);
            for(var i = 0, length = this.eventsmaps.length; i < length; i++)
                this.eventsmaps[i] = this.eventsmaps[i].key = this.eventsmaps[i].handler = null;
            zz.element.window.superclass.finalize.apply(this);
        }
    });
    zz.element.document = zz.zclass(zz.element.window,{
        getBySelector : function(selectors, isAll){
            var result = zz.element.getElementsBySelector(selectors, this);
            return isAll ? result : result.length == 0 ? null : result[0];
        },
        hasClassName : function(className){
            var value = this.element.className;
            return (value.length > 0 && (value == className || new RegExp("(^|\\s)" + className + "(\\s|$)").test(value)));
        },
        addClassName : function(className){
            var element = this.element;
            if(!this.hasClassName(className)) element.className += (element.className ? ' ' : '') + className;
            return this;
        },
        removeClassName : function(className){
            var element = this.element;
            element.className = util.string.trim(element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' '));
            return this;
        },
        hasAttribute : function(attributeName) {
            if(this.hasAttribute) return this.hasAttribute(attributeName);
            return this.getAttribute(attributeName) != null;
        },
        setAttribute : function(property, value){
            if(arguments.length == 1) for(var name in property) this.setAttribute(name, property[name]);
            else{
                var element = this.element;
                if(property == "style" && zz.browser.kernel.isTrident) element.style.cssText = value;
                else element.setAttribute(property, value);
            }
            return this;
        },
        getAttribute : function(attributeName){
            var element = this.element;
            if(attributeName == "class" && ZHUOZHUO.BrowserKernel.Trident) return element.className;
            if(attributeName == "style" && ZHUOZHUO.BrowserKernel.Trident) return element.style.cssText;
            return element.getAttribute(attributeName);
        },
        setStyle : function(property, value){
            if(arguments.length == 1) for(var style in property) this.setStyle(style, property[style]);
            else{
                if(zz.browser.kernel.isTrident && parseFloat(zz.browser.version) < 8.0 && property == "zIndex" && value == "auto") value = "";
                property == "alphaImage" ? this.setAlphaImage(value) : property == "opacity" ? this.setOpacity(value) : this.element.style[property == "styleFloat" ? document.defaultView ? "cssFloat" : property : property] = value;
            }
            return this;
        },
        getStyle : function(styleName){
            var element = this.element;
            if(styleName == "opacity") return this.getOpacity();
            if(styleName == "alphaImage") return this.getAlphaImage();
            styleName = styleName == "styleFloat" ? document.defaultView ? "cssFloat" : styleName : styleName;
            styleName = styleName == "${opacity}" ? "opacity" : styleName;
            var value = element.currentStyle ? element.currentStyle[styleName] : document.defaultView.getComputedStyle(element, null) ? document.defaultView.getComputedStyle(element, null)[styleName] : element.style[styleName];
            if(/^(width|height)$/.test(styleName) && (isNaN(parseFloat(value)) || value.indexOf('%') > -1)){
                var values = styleName == "width" ? ["Left", "Right"] : ["Top", "Bottom"];
                var padding = 0, border = 0;
                value = (styleName == "width") ? element.offsetWidth : element.offsetHeight;
                for(var i = 0, length = values.length; i < length; i++){
                    padding += parseFloat(this.getStyle("padding" + values[i])) || 0;
                    border += parseFloat(this.getStyle("border" + values[i] + "Width")) || 0;
                }
                value = value - padding - border + "px";
            }
            return value ? value : null;
        },
        setAlphaImage : function(url){
            var element = this.element;
            if(element.filters){
                var filterName = "DXImageTransform.Microsoft.AlphaImageLoader";
                var AlphaImageLoader = element.filters[filterName];
                if(AlphaImageLoader){
                    AlphaImageLoader.src = url;
                    AlphaImageLoader.sizingMethod = "crop";
                    AlphaImageLoader.Enabled = !!url;
                }else if(url) element.style.filter = "progid:" + filterName + "(sizingMethod=\"crop\", src=\"" + url + "\")";
            }else{
                if(url){
                    element.style.backgroundImage = "url(\"" + url + "\")";
                    element.style.backgroundRepeat= "no-repeat";
                }else element.style.backgroundImage = "none";
            }
            return this;
        },
        getAlphaImage : function(){
            if(this.element.filters){
                var AlphaImageLoader = this.element.filters["DXImageTransform.Microsoft.AlphaImageLoader"];
                return (AlphaImageLoader && AlphaImageLoader.Enabled) ? AlphaImageLoader.src : null;
            }else return this.getStyle("backgroundImage").replace(/^\s*url\s*\(\s*["']?\s*([^"'\)]+)\s*['"]?\s*\)\s*$/i,"$1") || null;
        },
        setOpacity : function(opacity){
            var element = this.element;
            if(element.filters){
                var filterName = "DXImageTransform.Microsoft.Alpha";
                var Alpha = element.filters[filterName];
                opacity = opacity * 100;
                if(Alpha){
                    Alpha.Enabled = opacity !== 100;
                    Alpha.Opacity = opacity;
                }else if(opacity !== 100) element.style.filter = "progid:" + filterName + "(opacity = " + opacity + ")";
            }else{
                element.style.opacity     = opacity;
                element.style.MozOpacity  = opacity;
                element.style.KhtmlOpacity= opacity;
            }
            return this;
        },
        getOpacity : function(){
            var opacity = NaN;
            if(this.element.filters){
                var Alpha = this.element.filters["DXImageTransform.Microsoft.Alpha"];
                opacity = (Alpha && Alpha.Enabled) ? Alpha.Opacity / 100 : NaN;
            }
            if(isNaN(opacity)) opacity = parseFloat(this.getStyle("${opacity}"));
            if(isNaN(opacity)) opacity = parseFloat(this.getStyle("MozOpacity"));
            if(isNaN(opacity)) opacity = parseFloat(this.getStyle("KhtmlOpacity"));