| 
									
										
										
										
											2014-11-18 19:51:41 +03:00
										 |  |  | /********************************************************************** | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | **********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | define(function(require){ var module = {} | 
					
						
							|  |  |  | console.log('>>> objects') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //var DEBUG = DEBUG != null ? DEBUG : true
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var makeConstructor = | 
					
						
							|  |  |  | module.makeConstructor = | 
					
						
							|  |  |  | function makeConstructor(name, a, b){ | 
					
						
							|  |  |  | 	var proto = b == null ? a : b | 
					
						
							|  |  |  | 	var cls_proto = b == null ? b : a | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-18 20:20:35 +03:00
										 |  |  | 	var _constructor = function Constructor(){ | 
					
						
							| 
									
										
										
										
											2014-11-18 19:51:41 +03:00
										 |  |  | 		// in case this is called as a function (without new)...
 | 
					
						
							|  |  |  | 		if(this.constructor !== _constructor){ | 
					
						
							| 
									
										
										
										
											2014-11-18 20:20:35 +03:00
										 |  |  | 			// NOTE: the folowing does the job of the 'new' operator but
 | 
					
						
							|  |  |  | 			// 		with one advantage, we can now pass arbitrarry args 
 | 
					
						
							|  |  |  | 			// 		in...
 | 
					
						
							|  |  |  | 			// 		This is equivalent to:
 | 
					
						
							|  |  |  | 			//			return new _constructor(json)
 | 
					
						
							|  |  |  | 			var obj = {} | 
					
						
							|  |  |  | 			obj.__proto__ = _constructor.prototype | 
					
						
							|  |  |  | 			obj.constructor = _constructor | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			var obj = this | 
					
						
							| 
									
										
										
										
											2014-11-18 19:51:41 +03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// load initial state...
 | 
					
						
							| 
									
										
										
										
											2014-11-18 20:20:35 +03:00
										 |  |  | 		if(obj.__init__ != null){ | 
					
						
							|  |  |  | 			obj.__init__.apply(obj, arguments) | 
					
						
							| 
									
										
										
										
											2014-11-18 19:51:41 +03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-18 20:20:35 +03:00
										 |  |  | 		return obj | 
					
						
							| 
									
										
										
										
											2014-11-18 19:51:41 +03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-18 20:20:35 +03:00
										 |  |  | 	// this is here to make Chrome output more user friendly...
 | 
					
						
							| 
									
										
										
										
											2014-11-24 17:37:50 +03:00
										 |  |  | 	// skip for IE...
 | 
					
						
							|  |  |  | 	if(_constructor.name == 'Constructor'  | 
					
						
							|  |  |  | 			// skip for chrome app...
 | 
					
						
							|  |  |  | 			&& !(window.chrome && chrome.runtime && chrome.runtime.id)){ | 
					
						
							| 
									
										
										
										
											2014-11-18 20:20:35 +03:00
										 |  |  | 		eval('_constructor = '+ _constructor | 
					
						
							|  |  |  | 				.toString() | 
					
						
							|  |  |  | 				.replace(/Constructor/g, name)) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-11-18 19:51:41 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	_constructor.__proto__ = cls_proto | 
					
						
							|  |  |  | 	_constructor.prototype = proto | 
					
						
							|  |  |  | 	_constructor.prototype.constructor = _constructor | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return _constructor | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /********************************************************************** | 
					
						
							|  |  |  | * vim:set ts=4 sw=4 :                                                */ | 
					
						
							|  |  |  | return module }) |