Sha256: 7767d2df983a675861f3b63a4d4cb9839d04258bef87bf00a0bae7704744cb2a

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

// wrapped by build app
define("dojox/lang/oo/rearrange", ["dijit","dojo","dojox"], function(dijit,dojo,dojox){
dojo.provide("dojox.lang.oo.rearrange");

(function(){
	var extraNames = dojo._extraNames, extraLen = extraNames.length,
		opts = Object.prototype.toString, empty = {};

	dojox.lang.oo.rearrange = function(bag, map){
		// summary:
		//		Process properties in place by removing and renaming them.
		// description:
		//		Properties of an object are to be renamed or removed specified
		//		by "map" argument. Only own properties of "map" are processed.
		// example:
		//	|	oo.rearrange(bag, {
		//	|		abc: "def",	// rename "abc" attribute to "def"
		//	|		ghi: null	// remove/hide "ghi" attribute
		//	|	});
		// bag: Object
		//		the object to be processed
		// map: Object
		//		the dictionary for renaming (false value indicates removal of the named property)
		// returns: Object
		//		the original object

	var name, newName, prop, i, t;

		for(name in map){
			newName = map[name];
			if(!newName || opts.call(newName) == "[object String]"){
				prop = bag[name];
				if(!(name in empty) || empty[name] !== prop){
					if(!(delete bag[name])){
						// can't delete => hide it
						bag[name] = undefined;
					}
					if(newName){
						bag[newName] = prop;
					}
				}
			}
		}
		if(extraLen){
			for(i = 0; i < extraLen; ++i){
				name = extraNames[i];
				// repeating the body above
				newName = map[name];
				if(!newName || opts.call(newName) == "[object String]"){
					prop = bag[name];
					if(!(name in empty) || empty[name] !== prop){
						if(!(delete bag[name])){
							// can't delete => hide it
							bag[name] = undefined;
						}
						if(newName){
							bag[newName] = prop;
						}
					}
				}
			}
		}

		return bag;	// Object
	};
})();

});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dojox-rails-0.11.0 vendor/assets/javascripts/lang/oo/rearrange.js.uncompressed.js