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  
    333333};
    334334
    335335/**
     336 * Class: ZOO.Class
     337 * Object for creating CLASS
     338 */
     339ZOO.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 */
     360ZOO.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 */
     371ZOO.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 */
     383ZOO.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 */
     400ZOO.Util = ZOO.Util || {};
     401/**
     402 * Function: extend
     403 * Function for extending object
     404 */
     405ZOO.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/**
    336419 * Class: ZOO.Request
    337420 * Contains convenience methods for working with ZOORequest which
    338421 *     replace XMLHttpRequest. Because of we are not in a browser

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png