|
|
1
|
+var assembly;
|
1
|
var classtype = {
|
2
|
var classtype = {
|
2
|
- "[object Array]": "array",
|
|
|
3
|
- "[object Boolean]": "boolean",
|
|
|
4
|
- "[object Date]": "date",
|
|
|
5
|
- "[object Function]": "function",
|
|
|
6
|
- "[object Number]": "number",
|
|
|
7
|
- "[object Object]": "object",
|
|
|
8
|
- "[object RegExp]": "regexp",
|
|
|
9
|
- "[object String]": "string"
|
3
|
+ '[object Array]': 'array',
|
|
|
4
|
+ '[object Boolean]': 'boolean',
|
|
|
5
|
+ '[object Date]': 'date',
|
|
|
6
|
+ '[object Function]': 'function',
|
|
|
7
|
+ '[object Number]': 'number',
|
|
|
8
|
+ '[object Object]': 'object',
|
|
|
9
|
+ '[object RegExp]': 'regexp',
|
|
|
10
|
+ '[object String]': 'string'
|
10
|
};
|
11
|
};
|
11
|
var me = {
|
12
|
var me = {
|
12
|
__Index: 0,
|
13
|
__Index: 0,
|
13
|
- list: new Array(),
|
14
|
+ list: [],
|
14
|
get: function(id) {
|
15
|
get: function(id) {
|
15
|
return id === undefined ? this.list : this.list[id];
|
16
|
return id === undefined ? this.list : this.list[id];
|
16
|
},
|
17
|
},
|
17
|
- fn: new Function(),
|
18
|
+ fn: function() { },
|
18
|
inherit: function(childClass, parentClass) {
|
19
|
inherit: function(childClass, parentClass) {
|
19
|
-
|
|
|
20
|
- var Constructor = new Function();
|
20
|
+ var Constructor = me.fn;
|
|
|
21
|
+
|
21
|
Constructor.prototype = parentClass.prototype;
|
22
|
Constructor.prototype = parentClass.prototype;
|
22
|
-
|
|
|
23
|
childClass.prototype = new Constructor();
|
23
|
childClass.prototype = new Constructor();
|
|
|
24
|
+
|
24
|
childClass.prototype.constructor = childClass;
|
25
|
childClass.prototype.constructor = childClass;
|
25
|
childClass.superclass = parentClass.prototype;
|
26
|
childClass.superclass = parentClass.prototype;
|
26
|
|
27
|
|
27
|
- if (childClass.prototype.constructor == Object.prototype.constructor) {
|
28
|
+ if (childClass.prototype.constructor === Object.prototype.constructor) {
|
28
|
childClass.prototype.constructor = parentClass;
|
29
|
childClass.prototype.constructor = parentClass;
|
29
|
}
|
30
|
}
|
30
|
},
|
31
|
},
|
31
|
extend: function(obj, newProperties) {
|
32
|
extend: function(obj, newProperties) {
|
32
|
var key;
|
33
|
var key;
|
33
|
-
|
|
|
34
|
- for (key in newProperties) {
|
|
|
35
|
|
34
|
|
|
|
35
|
+ for (key in newProperties) {
|
36
|
if (newProperties.hasOwnProperty(key)) {
|
36
|
if (newProperties.hasOwnProperty(key)) {
|
37
|
obj[key] = newProperties[key];
|
37
|
obj[key] = newProperties[key];
|
38
|
}
|
38
|
}
|
39
|
}
|
39
|
}
|
40
|
return obj;
|
40
|
return obj;
|
41
|
},
|
41
|
},
|
42
|
- copy: function(targetClass, obj, newProperties) {
|
|
|
43
|
-
|
42
|
+ copy: function(TargetClass, obj, newProperties) {
|
|
|
43
|
+ var value,o,key;
|
|
|
44
|
+
|
44
|
if (typeof obj !== 'object') {
|
45
|
if (typeof obj !== 'object') {
|
45
|
return obj;
|
46
|
return obj;
|
46
|
}
|
47
|
}
|
47
|
- var value = obj.valueOf();
|
|
|
48
|
-
|
|
|
49
|
- if (obj != value) {
|
48
|
+ value = obj.valueOf();
|
|
|
49
|
+ if (obj !== value) {
|
50
|
return new obj.constructor(value);
|
50
|
return new obj.constructor(value);
|
51
|
}
|
51
|
}
|
52
|
-
|
|
|
53
|
- var o;
|
|
|
54
|
-
|
|
|
55
|
if (obj instanceof obj.constructor && obj.constructor !== Object) {
|
52
|
if (obj instanceof obj.constructor && obj.constructor !== Object) {
|
56
|
- if (targetClass) {
|
|
|
57
|
- o = new targetClass();
|
53
|
+ if (TargetClass) {
|
|
|
54
|
+ o = new TargetClass();
|
58
|
} else {
|
55
|
} else {
|
59
|
o = me.clone(obj.constructor.prototype);
|
56
|
o = me.clone(obj.constructor.prototype);
|
60
|
}
|
57
|
}
|
61
|
|
58
|
|
62
|
- for (var key in obj) {
|
|
|
63
|
- if (targetClass || obj.hasOwnProperty(key)) {
|
59
|
+ for (key in obj) {
|
|
|
60
|
+ if (TargetClass || obj.hasOwnProperty(key)) {
|
64
|
o[key] = obj[key];
|
61
|
o[key] = obj[key];
|
65
|
}
|
62
|
}
|
66
|
}
|
63
|
}
|
67
|
} else {
|
64
|
} else {
|
68
|
o = {};
|
65
|
o = {};
|
69
|
- for (var key in obj) {
|
|
|
70
|
- o[key] = obj[key];
|
66
|
+ for (key in obj) {
|
|
|
67
|
+ if (o.hasOwnProperty(key)) {
|
|
|
68
|
+ o[key] = obj[key];
|
|
|
69
|
+ }
|
71
|
}
|
70
|
}
|
72
|
}
|
71
|
}
|
73
|
-
|
|
|
74
|
if (newProperties) {
|
72
|
if (newProperties) {
|
75
|
- for (var key in newProperties) {
|
|
|
76
|
- o[key] = newProperties[key];
|
73
|
+ for (key in newProperties) {
|
|
|
74
|
+ if (o.hasOwnProperty(key)) {
|
|
|
75
|
+ o[key] = newProperties[key];
|
|
|
76
|
+ }
|
77
|
}
|
77
|
}
|
78
|
}
|
78
|
}
|
79
|
|
79
|
|
|
@@ -86,62 +86,64 @@ var me = { |
|
@@ -86,62 +86,64 @@ var me = { |
86
|
__cloneFunc: function() {
|
86
|
__cloneFunc: function() {
|
87
|
},
|
87
|
},
|
88
|
delegate: function(func, scope) {
|
88
|
delegate: function(func, scope) {
|
|
|
89
|
+ var args;
|
|
|
90
|
+
|
89
|
scope = scope || window;
|
91
|
scope = scope || window;
|
90
|
-
|
92
|
+
|
91
|
if (arguments.length > 2) {
|
93
|
if (arguments.length > 2) {
|
92
|
- var args = Array.prototype.slice.call(arguments, 2);
|
94
|
+ args = Array.prototype.slice.call(arguments, 2);
|
|
|
95
|
+
|
93
|
return function() {
|
96
|
return function() {
|
94
|
return func.apply(scope, args);
|
97
|
return func.apply(scope, args);
|
95
|
- }
|
98
|
+ };
|
96
|
} else {
|
99
|
} else {
|
97
|
return function() {
|
100
|
return function() {
|
98
|
return func.call(scope);
|
101
|
return func.call(scope);
|
99
|
- }
|
102
|
+ };
|
100
|
}
|
103
|
}
|
101
|
},
|
104
|
},
|
102
|
dom: function($select, classCss) {
|
105
|
dom: function($select, classCss) {
|
103
|
var wrap = $select;
|
106
|
var wrap = $select;
|
104
|
var name, DOM = {
|
107
|
var name, DOM = {
|
105
|
- wrap: $(wrap)
|
108
|
+ wrap: wrap
|
106
|
},
|
109
|
},
|
107
|
- els = wrap[0].getElementsByTagName("*"),
|
110
|
+ els = wrap[0].getElementsByTagName('*'),
|
108
|
elsLen = els.length;
|
111
|
elsLen = els.length;
|
109
|
-
|
|
|
110
|
- for (var i = 0; i < elsLen; i++) {
|
112
|
+ var i;
|
|
|
113
|
+
|
|
|
114
|
+ for (i = 0; i < elsLen; i++) {
|
111
|
name = els[i].className;
|
115
|
name = els[i].className;
|
112
|
if (name.indexOf(classCss) > -1) {
|
116
|
if (name.indexOf(classCss) > -1) {
|
113
|
name = name.split(classCss)[1];
|
117
|
name = name.split(classCss)[1];
|
114
|
}
|
118
|
}
|
115
|
if (name) {
|
119
|
if (name) {
|
116
|
- DOM[name] = $(els[i], wrap)
|
120
|
+ DOM[name] = $(els[i], wrap);
|
117
|
}
|
121
|
}
|
118
|
}
|
122
|
}
|
119
|
- return DOM
|
123
|
+ return DOM;
|
120
|
},
|
124
|
},
|
|
|
125
|
+
|
121
|
//模板引擎
|
126
|
//模板引擎
|
122
|
template: function() {
|
127
|
template: function() {
|
123
|
- var args = arguments, result;
|
|
|
124
|
-
|
128
|
+ var result, key, reg,i;
|
|
|
129
|
+ var args = arguments;
|
|
|
130
|
+
|
125
|
if (args.length > 0) {
|
131
|
if (args.length > 0) {
|
126
|
-
|
|
|
127
|
if (me.isString(args[0])) {
|
132
|
if (me.isString(args[0])) {
|
128
|
result = args[0];
|
133
|
result = args[0];
|
129
|
-
|
|
|
130
|
- if (args.length == 2 && me.isObject(args[1])) {
|
|
|
131
|
-
|
|
|
132
|
- for (var key in args[1]) {
|
|
|
133
|
-
|
|
|
134
|
- if (args[1][key] != undefined) {
|
|
|
135
|
- var reg = new RegExp("({" + key + "})", "g");
|
134
|
+ if (args.length === 2 && me.isObject(args[1])) {
|
|
|
135
|
+ for (key in args[1]) {
|
|
|
136
|
+ if (args[1][key] !== undefined) {
|
|
|
137
|
+ reg = new RegExp('({' + key + '})', 'g');
|
|
|
138
|
+
|
136
|
result = result.replace(reg, args[1][key]);
|
139
|
result = result.replace(reg, args[1][key]);
|
137
|
}
|
140
|
}
|
138
|
}
|
141
|
}
|
139
|
} else {
|
142
|
} else {
|
140
|
-
|
|
|
141
|
- for (var i = 1; i < args.length; i++) {
|
|
|
142
|
-
|
|
|
143
|
- if (args[i] != undefined) {
|
|
|
144
|
- var reg = new RegExp("({[" + (i - 1) + "]})", "g");
|
143
|
+ for (i = 1; i < args.length; i++) {
|
|
|
144
|
+ if (args[i] !== undefined) {
|
|
|
145
|
+ reg = new RegExp('({[' + (i - 1) + ']})', 'g');
|
|
|
146
|
+
|
145
|
result = result.replace(reg, args[i]);
|
147
|
result = result.replace(reg, args[i]);
|
146
|
}
|
148
|
}
|
147
|
}
|
149
|
}
|
|
@@ -151,38 +153,35 @@ var me = { |
|
@@ -151,38 +153,35 @@ var me = { |
151
|
return result;
|
153
|
return result;
|
152
|
},
|
154
|
},
|
153
|
__type: function(obj) {
|
155
|
__type: function(obj) {
|
154
|
- return obj == null ? String(obj) : classtype[Object.prototype.toString.call(obj)] || "object";
|
156
|
+ return obj == null ? String(obj) : classtype[Object.prototype.toString.call(obj)] || 'object';
|
155
|
},
|
157
|
},
|
156
|
isObject: function(obj) {
|
158
|
isObject: function(obj) {
|
157
|
return this.isFunction(obj) || !!(obj && 'object' === typeof obj);
|
159
|
return this.isFunction(obj) || !!(obj && 'object' === typeof obj);
|
158
|
},
|
160
|
},
|
159
|
isFunction: function(obj) {
|
161
|
isFunction: function(obj) {
|
160
|
- return this.__type(obj) === "function";
|
162
|
+ return this.__type(obj) === 'function';
|
161
|
},
|
163
|
},
|
162
|
isArray: Array.isArray || function(obj) {
|
164
|
isArray: Array.isArray || function(obj) {
|
163
|
- return this.__type(obj) === "array";
|
165
|
+ return this.__type(obj) === 'array';
|
164
|
},
|
166
|
},
|
165
|
isNum: function(obj) {
|
167
|
isNum: function(obj) {
|
166
|
return !isNaN(parseFloat(obj)) && isFinite(obj);
|
168
|
return !isNaN(parseFloat(obj)) && isFinite(obj);
|
167
|
},
|
169
|
},
|
168
|
isString: function(obj) {
|
170
|
isString: function(obj) {
|
169
|
- return this.__type(obj) === "string";
|
171
|
+ return this.__type(obj) === 'string';
|
170
|
},
|
172
|
},
|
171
|
each: function(data, callback, args) {
|
173
|
each: function(data, callback, args) {
|
172
|
var i, len;
|
174
|
var i, len;
|
173
|
-
|
175
|
+
|
174
|
if (me.isArray(data)) {
|
176
|
if (me.isArray(data)) {
|
175
|
-
|
|
|
176
|
for (i = 0, len = data.length; i < len; i++) {
|
177
|
for (i = 0, len = data.length; i < len; i++) {
|
177
|
-
|
|
|
178
|
if (callback.call(data[i], i, data[i], args) === false) {
|
178
|
if (callback.call(data[i], i, data[i], args) === false) {
|
179
|
break;
|
179
|
break;
|
180
|
}
|
180
|
}
|
181
|
}
|
181
|
}
|
182
|
} else {
|
182
|
} else {
|
183
|
-
|
183
|
+
|
184
|
for (i in data) {
|
184
|
for (i in data) {
|
185
|
-
|
|
|
186
|
if (callback.call(data[i], i, data[i], args) === false) {
|
185
|
if (callback.call(data[i], i, data[i], args) === false) {
|
187
|
break;
|
186
|
break;
|
188
|
}
|
187
|
}
|
|
@@ -192,7 +191,7 @@ var me = { |
|
@@ -192,7 +191,7 @@ var me = { |
192
|
funManager: {
|
191
|
funManager: {
|
193
|
__loadList: {},
|
192
|
__loadList: {},
|
194
|
__loadFun: function(item, callback, win) {
|
193
|
__loadFun: function(item, callback, win) {
|
195
|
-
|
194
|
+
|
196
|
if (item.methord && me.isFunction(item.methord())) {
|
195
|
if (item.methord && me.isFunction(item.methord())) {
|
197
|
win = win || window;
|
196
|
win = win || window;
|
198
|
item.methord()(item, function() {
|
197
|
item.methord()(item, function() {
|
|
@@ -202,7 +201,7 @@ var me = { |
|
@@ -202,7 +201,7 @@ var me = { |
202
|
},
|
201
|
},
|
203
|
load: function(fns, statechange, win, __index) {
|
202
|
load: function(fns, statechange, win, __index) {
|
204
|
__index = __index || 0;
|
203
|
__index = __index || 0;
|
205
|
-
|
204
|
+
|
206
|
if (fns[__index]) {
|
205
|
if (fns[__index]) {
|
207
|
me.funManager.__loadFun(fns[__index], function() {
|
206
|
me.funManager.__loadFun(fns[__index], function() {
|
208
|
me.funManager.load(fns, statechange, win, __index + 1);
|
207
|
me.funManager.load(fns, statechange, win, __index + 1);
|
|
@@ -215,7 +214,10 @@ var me = { |
|
@@ -215,7 +214,10 @@ var me = { |
215
|
}
|
214
|
}
|
216
|
},
|
215
|
},
|
217
|
log: function(msg) {
|
216
|
log: function(msg) {
|
218
|
- var console = window.console || { log: function() { } };
|
217
|
+ var console = window.console || {
|
|
|
218
|
+ log: function() { }
|
|
|
219
|
+ };
|
|
|
220
|
+
|
219
|
console.log(msg);
|
221
|
console.log(msg);
|
220
|
},
|
222
|
},
|
221
|
Event: {
|
223
|
Event: {
|
|
@@ -223,16 +225,17 @@ var me = { |
|
@@ -223,16 +225,17 @@ var me = { |
223
|
var _eoe = e.originalEvent;
|
225
|
var _eoe = e.originalEvent;
|
224
|
var _de = _eoe.detail ? _eoe.detail * -1 : _eoe.wheelDelta / 40;
|
226
|
var _de = _eoe.detail ? _eoe.detail * -1 : _eoe.wheelDelta / 40;
|
225
|
var _direction = _de < 0 ? -1 : 1;
|
227
|
var _direction = _de < 0 ? -1 : 1;
|
|
|
228
|
+
|
226
|
return {
|
229
|
return {
|
227
|
direction: _direction,
|
230
|
direction: _direction,
|
228
|
unit: _de
|
231
|
unit: _de
|
229
|
- }
|
232
|
+ };
|
230
|
},
|
233
|
},
|
231
|
__: function(_e, el, event, handle) {
|
234
|
__: function(_e, el, event, handle) {
|
232
|
-
|
|
|
233
|
- for (var key in _e) {
|
|
|
234
|
-
|
|
|
235
|
- if (win[_e[key].validator]) {
|
235
|
+ var key;
|
|
|
236
|
+
|
|
|
237
|
+ for (key in _e) {
|
|
|
238
|
+ if (window[_e[key].validator]) {
|
236
|
el[_e[key].validator](_e[key].prefix + event, handle, false);
|
239
|
el[_e[key].validator](_e[key].prefix + event, handle, false);
|
237
|
break;
|
240
|
break;
|
238
|
}
|
241
|
}
|
|
@@ -240,40 +243,58 @@ var me = { |
|
@@ -240,40 +243,58 @@ var me = { |
240
|
},
|
243
|
},
|
241
|
add: function(el, event, handle) {
|
244
|
add: function(el, event, handle) {
|
242
|
var _e = [
|
245
|
var _e = [
|
243
|
- { validator: 'addEventListener', prefix: '' },
|
|
|
244
|
- { validator: 'attachEvent', prefix: 'on' }
|
|
|
245
|
- ];
|
246
|
+ {
|
|
|
247
|
+ validator: 'addEventListener',
|
|
|
248
|
+ prefix: ''
|
|
|
249
|
+ },
|
|
|
250
|
+ {
|
|
|
251
|
+ validator: 'attachEvent',
|
|
|
252
|
+ prefix: 'on'
|
|
|
253
|
+ }
|
|
|
254
|
+ ];
|
|
|
255
|
+
|
246
|
this.__(_e, el, event, handle);
|
256
|
this.__(_e, el, event, handle);
|
247
|
},
|
257
|
},
|
248
|
remove: function(el, event, handle) {
|
258
|
remove: function(el, event, handle) {
|
249
|
var _e = [
|
259
|
var _e = [
|
250
|
- { validator: 'removeEventListener', prefix: '' },
|
|
|
251
|
- { validator: 'detachEvent', prefix: 'on' }
|
|
|
252
|
- ];
|
260
|
+ {
|
|
|
261
|
+ validator: 'removeEventListener',
|
|
|
262
|
+ prefix: ''
|
|
|
263
|
+ },
|
|
|
264
|
+ {
|
|
|
265
|
+ validator: 'detachEvent',
|
|
|
266
|
+ prefix: 'on'
|
|
|
267
|
+ }
|
|
|
268
|
+ ];
|
|
|
269
|
+
|
253
|
this.__(_e, el, event, handle);
|
270
|
this.__(_e, el, event, handle);
|
254
|
}
|
271
|
}
|
255
|
},
|
272
|
},
|
256
|
getUid: function(_name) {
|
273
|
getUid: function(_name) {
|
257
|
- return me.template("me-{0}{1}-{2}", _name, new Date().getTime(), me.__Index++)
|
274
|
+ return me.template('me-{0}{1}-{2}', _name, new Date().getTime(), me.__Index++);
|
258
|
},
|
275
|
},
|
259
|
Browser: {
|
276
|
Browser: {
|
260
|
isTouch: function() {
|
277
|
isTouch: function() {
|
261
|
var msGesture = window.navigator && window.navigator.msPointerEnabled && window.MSGesture;
|
278
|
var msGesture = window.navigator && window.navigator.msPointerEnabled && window.MSGesture;
|
262
|
- return (("ontouchstart" in window) || msGesture || window.DocumentTouch && document instanceof DocumentTouch) ? true : false;
|
279
|
+
|
|
|
280
|
+ return (('ontouchstart' in window) || msGesture || window.DocumentTouch) ? true : false;
|
263
|
},
|
281
|
},
|
264
|
Prefix: function() {
|
282
|
Prefix: function() {
|
|
|
283
|
+ var i;
|
|
|
284
|
+
|
265
|
var props = ['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'];
|
285
|
var props = ['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'];
|
266
|
var obj = document.createElement('div');
|
286
|
var obj = document.createElement('div');
|
267
|
-
|
|
|
268
|
- for (var i in props) {
|
|
|
269
|
-
|
287
|
+
|
|
|
288
|
+ for (i in props) {
|
270
|
if (obj.style[props[i]] !== undefined) {
|
289
|
if (obj.style[props[i]] !== undefined) {
|
271
|
- return me.template("-{0}-", props[i].replace('Perspective', '').toLowerCase());
|
290
|
+ return me.template('-{0}-', props[i].replace('Perspective', '').toLowerCase());
|
272
|
}
|
291
|
}
|
273
|
}
|
292
|
}
|
274
|
},
|
293
|
},
|
275
|
parseURL: function(url) {
|
294
|
parseURL: function(url) {
|
276
|
var a = document.createElement('a');
|
295
|
var a = document.createElement('a');
|
|
|
296
|
+ var ret,seg,len,i,s;
|
|
|
297
|
+
|
277
|
a.href = url;
|
298
|
a.href = url;
|
278
|
return {
|
299
|
return {
|
279
|
source: url,
|
300
|
source: url,
|
|
@@ -282,43 +303,50 @@ var me = { |
|
@@ -282,43 +303,50 @@ var me = { |
282
|
port: a.port,
|
303
|
port: a.port,
|
283
|
query: a.search,
|
304
|
query: a.search,
|
284
|
params: (function() {
|
305
|
params: (function() {
|
285
|
- var ret = {},
|
|
|
286
|
- seg = a.search.replace(/^\?/, '').split('&'),
|
|
|
287
|
- len = seg.length, i = 0, s;
|
306
|
+ ret = {},
|
|
|
307
|
+ seg = a.search.replace(/^\?/, '').split('&'),
|
|
|
308
|
+ len = seg.length, i = 0, s;
|
|
|
309
|
+
|
288
|
for (; i < len; i++) {
|
310
|
for (; i < len; i++) {
|
289
|
- if (!seg[i]) { continue; }
|
311
|
+ if (!seg[i]) {
|
|
|
312
|
+ continue;
|
|
|
313
|
+ }
|
290
|
s = seg[i].split('=');
|
314
|
s = seg[i].split('=');
|
291
|
ret[s[0]] = s[1];
|
315
|
ret[s[0]] = s[1];
|
292
|
}
|
316
|
}
|
293
|
return ret;
|
317
|
return ret;
|
294
|
})(),
|
318
|
})(),
|
295
|
- file: (a.pathname.match(/\/([^\/?#]+)$/i) || [, ''])[1],
|
319
|
+ file: (a.pathname.match(/\/([^\/?#]+)$/i) || [null, ''])[1],
|
296
|
hash: a.hash.replace('#', ''),
|
320
|
hash: a.hash.replace('#', ''),
|
297
|
path: a.pathname.replace(/^([^\/])/, '/$1'),
|
321
|
path: a.pathname.replace(/^([^\/])/, '/$1'),
|
298
|
- relative: (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [, ''])[1],
|
322
|
+ relative: (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [null, ''])[1],
|
299
|
segments: a.pathname.replace(/^\//, '').split('/')
|
323
|
segments: a.pathname.replace(/^\//, '').split('/')
|
300
|
};
|
324
|
};
|
301
|
}
|
325
|
}
|
302
|
},
|
326
|
},
|
303
|
Array: {
|
327
|
Array: {
|
304
|
indexOf: function(array, val) {
|
328
|
indexOf: function(array, val) {
|
305
|
-
|
|
|
306
|
- for (var i = 0; i < array.length; i++) {
|
|
|
307
|
- if (this[i] == val) return i;
|
329
|
+ var i;
|
|
|
330
|
+
|
|
|
331
|
+ for (i = 0; i < array.length; i++) {
|
|
|
332
|
+ if (this[i] === val) {
|
|
|
333
|
+ return i;
|
|
|
334
|
+ }
|
308
|
}
|
335
|
}
|
309
|
return -1;
|
336
|
return -1;
|
310
|
},
|
337
|
},
|
311
|
remove: function(array, val) {
|
338
|
remove: function(array, val) {
|
312
|
var index = this.indexOf(array, val);
|
339
|
var index = this.indexOf(array, val);
|
313
|
-
|
340
|
+
|
314
|
if (index > -1) {
|
341
|
if (index > -1) {
|
315
|
array.splice(index, 1);
|
342
|
array.splice(index, 1);
|
316
|
}
|
343
|
}
|
317
|
return array;
|
344
|
return array;
|
318
|
}
|
345
|
}
|
319
|
}
|
346
|
}
|
320
|
-}
|
|
|
321
|
-var assembly = function(options) {
|
347
|
+};
|
|
|
348
|
+
|
|
|
349
|
+assembly = function(options) {
|
322
|
this.initialized = false;
|
350
|
this.initialized = false;
|
323
|
this.registerEvent = {
|
351
|
this.registerEvent = {
|
324
|
before: [],
|
352
|
before: [],
|
|
@@ -328,11 +356,13 @@ var assembly = function(options) { |
|
@@ -328,11 +356,13 @@ var assembly = function(options) { |
328
|
this.options = options;
|
356
|
this.options = options;
|
329
|
|
357
|
|
330
|
this.init(options);
|
358
|
this.init(options);
|
331
|
-}
|
359
|
+};
|
|
|
360
|
+
|
332
|
assembly.output = function() {
|
361
|
assembly.output = function() {
|
333
|
me.log(me.list);
|
362
|
me.log(me.list);
|
334
|
-}
|
363
|
+};
|
335
|
assembly.prototype.oninit = me.fn;
|
364
|
assembly.prototype.oninit = me.fn;
|
|
|
365
|
+
|
336
|
assembly.prototype.init = function(cfg) {
|
366
|
assembly.prototype.init = function(cfg) {
|
337
|
this.initialized = true;
|
367
|
this.initialized = true;
|
338
|
|
368
|
|
|
@@ -357,16 +387,13 @@ assembly.prototype.destory = function() { |
|
@@ -357,16 +387,13 @@ assembly.prototype.destory = function() { |
357
|
};
|
387
|
};
|
358
|
assembly.prototype.getUid = function() {
|
388
|
assembly.prototype.getUid = function() {
|
359
|
return this.__Uid;
|
389
|
return this.__Uid;
|
360
|
-}
|
390
|
+};
|
361
|
assembly.prototype.getOptions = function() {
|
391
|
assembly.prototype.getOptions = function() {
|
362
|
return this.options;
|
392
|
return this.options;
|
363
|
-}
|
393
|
+};
|
364
|
assembly.prototype.config = function() {
|
394
|
assembly.prototype.config = function() {
|
365
|
-
|
|
|
366
|
if (arguments.length > 0) {
|
395
|
if (arguments.length > 0) {
|
367
|
-
|
|
|
368
|
- if (typeof (arguments[0]) === "string") {
|
|
|
369
|
-
|
396
|
+ if (typeof (arguments[0]) === 'string') {
|
370
|
if (arguments.length > 1) {
|
397
|
if (arguments.length > 1) {
|
371
|
this.options[arguments[0]] = arguments[1];
|
398
|
this.options[arguments[0]] = arguments[1];
|
372
|
} else {
|
399
|
} else {
|
|
@@ -380,7 +407,7 @@ assembly.prototype.config = function() { |
|
@@ -380,7 +407,7 @@ assembly.prototype.config = function() { |
380
|
assembly.prototype.on = function(name, callback) {
|
407
|
assembly.prototype.on = function(name, callback) {
|
381
|
var __self = this;
|
408
|
var __self = this;
|
382
|
var _e = __self.registerEvent[name];
|
409
|
var _e = __self.registerEvent[name];
|
383
|
-
|
410
|
+
|
384
|
if (_e) {
|
411
|
if (_e) {
|
385
|
_e.push(callback);
|
412
|
_e.push(callback);
|
386
|
}
|
413
|
}
|
|
@@ -390,16 +417,18 @@ assembly.prototype.off = function(name, callback) { |
|
@@ -390,16 +417,18 @@ assembly.prototype.off = function(name, callback) { |
390
|
var __self = this;
|
417
|
var __self = this;
|
391
|
var _e = __self.registerEvent[name];
|
418
|
var _e = __self.registerEvent[name];
|
392
|
var e = [];
|
419
|
var e = [];
|
|
|
420
|
+
|
393
|
me.each(_e, function(name, _callback) {
|
421
|
me.each(_e, function(name, _callback) {
|
394
|
-
|
422
|
+
|
395
|
if (_callback === callback) {
|
423
|
if (_callback === callback) {
|
396
|
e.push(name);
|
424
|
e.push(name);
|
397
|
}
|
425
|
}
|
398
|
});
|
426
|
});
|
|
|
427
|
+
|
399
|
me.each(e.reverse(), function(name, _callback) {
|
428
|
me.each(e.reverse(), function(name, _callback) {
|
400
|
_e.splice(_callback, 1);
|
429
|
_e.splice(_callback, 1);
|
401
|
});
|
430
|
});
|
402
|
};
|
431
|
};
|
403
|
me.assembly = assembly;
|
432
|
me.assembly = assembly;
|
404
|
|
433
|
|
405
|
-module.exports =me; |
|
|
|
|
434
|
+module.exports = me; |