Ticket #64: ZOO-api.patch
File ZOO-api.patch, 2.1 KB (added by rldhont, 13 years ago) |
---|
adding ZOO.class object |
-
.js
old new 333 333 }; 334 334 335 335 /** 336 * Class: ZOO.Class 337 * Object for creating CLASS 338 */ 339 ZOO.Class = function() { 340 var len = arguments.length; 341 var P = arguments[0]; 342 var F = arguments[len-1]; 343 var C = typeof F.initialize == "function" ? 344 F.initialize : 345 function(){ P.prototype.initialize.apply(this, arguments); }; 346 347 if (len > 1) { 348 var newArgs = [C, P].concat( 349 Array.prototype.slice.call(arguments).slice(1, len-1), F); 350 ZOO.inherit.apply(null, newArgs); 351 } else { 352 C.prototype = F; 353 } 354 return C; 355 }; 356 /** 357 * Function: create 358 * Function for creating CLASS 359 */ 360 ZOO.Class.create = function() { 361 return function() { 362 if (arguments && arguments[0] != ZOO.Class.isPrototype) { 363 this.initialize.apply(this, arguments); 364 } 365 }; 366 }; 367 /** 368 * Function: inherit 369 * Function for inheriting CLASS 370 */ 371 ZOO.Class.inherit = function (P) { 372 var C = function() { 373 P.call(this); 374 }; 375 var newArgs = [C].concat(Array.prototype.slice.call(arguments)); 376 ZOO.inherit.apply(null, newArgs); 377 return C.prototype; 378 }; 379 /** 380 * Function: inherit 381 * Function for inheriting CLASS 382 */ 383 ZOO.inherit = function(C, P) { 384 var F = function() {}; 385 F.prototype = P.prototype; 386 C.prototype = new F; 387 var i, l, o; 388 for(i=2, l=arguments.length; i<l; i++) { 389 o = arguments[i]; 390 if(typeof o === "function") { 391 o = o.prototype; 392 } 393 ZOO.Util.extend(C.prototype, o); 394 } 395 }; 396 /** 397 * Class: ZOO.Util 398 * Object for utilities 399 */ 400 ZOO.Util = ZOO.Util || {}; 401 /** 402 * Function: extend 403 * Function for extending object 404 */ 405 ZOO.Util.extend = function(destination, source) { 406 destination = destination || {}; 407 if (source) { 408 for (var property in source) { 409 var value = source[property]; 410 if (value !== undefined) { 411 destination[property] = value; 412 } 413 } 414 } 415 return destination; 416 }; 417 418 /** 336 419 * Class: ZOO.Request 337 420 * Contains convenience methods for working with ZOORequest which 338 421 * replace XMLHttpRequest. Because of we are not in a browser