if (typeof Sitefinity == "undefined") { var Sitefinity = {}; } /** * Returns the namespace specified and creates it if it doesn't exist *
* Sitefinity.namespace("property.package");
* Sitefinity.namespace("Sitefinity.property.package");
*
* Either of the above would create Sitefinity.property, then
* Sitefinity.property.package
*
* Be careful when naming packages. Reserved words may work in some browsers
* and not others. For instance, the following will fail in Safari:
*
* Sitefinity.namespace("really.long.nested.namespace");
*
* This fails because "long" is a future reserved word in ECMAScript
*
* @method namespace
* @static
* @param {String*} arguments 1-n namespaces to create
* @return {Object} A reference to the last namespace object created
*/
Sitefinity.namespace = function() {
var a=arguments, o=null, i, j, d;
for (i=0; i
* var A = function() {};
* A.prototype.foo = 'foo';
* var a = new A();
* a.foo = 'foo';
* alert(a.hasOwnProperty('foo')); // true
* alert(Sitefinity.lang.hasOwnProperty(a, 'foo')); // false when using fallback
*
* @method hasOwnProperty
* @param {any} obj The object being testing
* @return Boolean
*/
hasOwnProperty: function(obj, prop) {
if (Object.prototype.hasOwnProperty) {
return obj.hasOwnProperty(prop);
}
return !Sitefinity.lang.isUndefined(obj[prop]) &&
obj.constructor.prototype[prop] !== obj[prop];
},
/**
* Utility to set up the prototype, constructor and superclass properties to
* support an inheritance strategy that can chain constructors and methods.
*
* @method extend
* @static
* @param {Function} subc the object to modify
* @param {Function} superc the object to inherit
* @param {Object} overrides additional properties/methods to add to the
* subclass prototype. These will override the
* matching items obtained from the superclass
* if present.
*/
extend: function(subc, superc, overrides) {
var F = function() {};
F.prototype=superc.prototype;
subc.prototype=new F();
subc.prototype.constructor=subc;
subc.superclass=superc.prototype;
if (superc.prototype.constructor == Object.prototype.constructor) {
superc.prototype.constructor=superc;
}
if (overrides) {
for (var i in overrides) {
subc.prototype[i]=overrides[i];
}
}
},
/**
* Applies all prototype properties in the supplier to the receiver if the
* receiver does not have these properties yet. Optionally, one or more
* methods/properties can be specified (as additional parameters). This
* option will overwrite the property if receiver has it already.
*
* @method augment
* @static
* @param {Function} r the object to receive the augmentation
* @param {Function} s the object that supplies the properties to augment
* @param {String*} arguments zero or more properties methods to augment the
* receiver with. If none specified, everything
* in the supplier will be used unless it would
* overwrite an existing property in the receiver
*/
augment: function(r, s) {
var rp=r.prototype, sp=s.prototype, a=arguments, i, p;
if (a[2]) {
for (i=2; i