Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   Объединение фалов в один, для последующей минимизации. (https://javascript.ru/forum/misc/48512-obedinenie-falov-v-odin-dlya-posleduyushhejj-minimizacii.html)

Isfet 07.07.2014 07:54

Объединение фалов в один, для последующей минимизации.
 
Здравствуйте.

В index.php я подключаю js файлы, в определенном порядке, чтобы в последующие файлы "видели" переменные из предыдущих, каким образом можно сделать так, чтобы последовательность подключения файлов не имела значение? Вычитал тутhttp://habrahabr.ru/post/130276/
что нужно обернуть все классы в анонимные функции, но не могу понять как это сделать.

вот код одного класса
function Preloader(config){

	var _this = this;
	this._leftDragLimit;
	this._timeout;
	this._rotateBgContainer;
	
	this._initialize = function(config) {
	
        Kinetic.Group.call(this, config);
		
		var brRect = new Kinetic.Rect({
			fill:'#000000',
			opacity:0,
			width:Controller.STAGE_WIDTH,
			height:Controller.STAGE_HEIGHT
		});
		
		_this.add(brRect);
		
		var posX = Controller.STAGE_WIDTH * 0.5;
		var posY = Controller.STAGE_HEIGHT * 0.5;
		
		
		var imageObj = new Image();
		
			imageObj.onload = function() {
			
				var bg = new Kinetic.Image({
					x:posX-24,
					y:posY-24,
					image: imageObj,
					width: 48,
					height: 48 
				});

				_this.add(bg);

			};
		imageObj.src = 'http://localhost/imgs/preloader_bg.png';
		
		
		
		
		var imageObj2 = new Image();
		
			imageObj2.onload = function() {
			
				var rotateBg = new Kinetic.Image({
					x:-18,
					y:-18,
					image: imageObj2,
					width: 36,
					height: 36 
				});
				
				_this._rotateBgContainer = new Kinetic.Group({
					x:posX,
					y:posY
				});
				_this.add(_this._rotateBgContainer);
				_this._rotateBgContainer.add(rotateBg);
			};
		imageObj2.src = 'http://localhost/imgs/preloader_rotate_bg.png';
		
		
		
		
		
	};
	this.start = function() {
		
		_this._timeout = setInterval(preloaderRotation, 40);

	}
	this.stop = function() {	
		clearInterval(_this._timeout);	
		
	}
	preloaderRotation = function() {
	
		_this._rotateBgContainer.setRotation(_this._rotateBgContainer.getRotation() + 10);
		controller.redraw();
	}
	this._initialize(config);
	
}
Kinetic.Util.extend(Preloader, Kinetic.Group);


как видно класс, принимает параметр, как обернуть его в анонимную функцию с параметром?


Часовой пояс GMT +3, время: 13:05.