diff src/implab/components/ActivationController.js @ 3:00779cb63b12

formatting
author cin
date Tue, 06 Jun 2017 19:45:32 +0300
parents 7d7059d2a810
children
line wrap: on
line diff
--- a/src/implab/components/ActivationController.js	Fri Jun 02 19:28:20 2017 +0300
+++ b/src/implab/components/ActivationController.js	Tue Jun 06 19:45:32 2017 +0300
@@ -1,55 +1,53 @@
-define([ "dojo/_base/declare", "../guard", "../safe", "../log/_LogMixin" ],
-
-function(declare, guard, safe, _LogMixin) {
+define(["dojo/_base/declare", "../guard", "../safe", "../log/_LogMixin"], function (declare, guard, safe, _LogMixin) {
 	"use strict";
-	return declare([ _LogMixin ], {
+	return declare([_LogMixin], {
 
-		_current : null,
+		_current: null,
 
-		_pending : false,
+		_pending: false,
 
-		getCurrent : function() {
+		getCurrent: function () {
 			return this._current;
 		},
 
-		_start : function() {
+		_start: function () {
 			if (this._pending)
 				throw new Error("The activation/decativation is already pending");
 			this._pending = true;
 		},
 
-		_await : function(d) {
+		_await: function (d) {
 			var me = this;
-			return d.then(function(x) {
+			return d.then(function (x) {
 				me._pending = false;
 				return x;
-			}, function(e) {
+			}, function (e) {
 				me._pending = false;
 				throw e;
 			});
 		},
 
-		activate : function(component) {
+		activate: function (component) {
 			safe.argumentNotNull(component, "component");
 			var me = this;
 			if (component.getController() !== this)
 				throw new Error("The specified component doesn't belong to this controller");
 
-			return me._await(guard(me, "_start").then(function() {
+			return me._await(guard(me, "_start").then(function () {
 				me._activate(component);
 			}));
 		},
 
-		_activate : function(component) {
+		_activate: function (component) {
 			var me = this;
 			if (me._current === component)
 				return guard(false);
 
 			// before activation hook
-			return guard(me, "onActivating", [ component ]).then(function() {
+			return guard(me, "onActivating", [component]).then(function () {
 				// deactivate curent
 				if (me._current)
-					return me._current.deactivate(true).then(function() {
+					return me._current.deactivate(true).then(function () {
 						try {
 							me._current.onDeactivated();
 						} catch (err) {
@@ -65,9 +63,9 @@
 						me._current = null;
 
 					});
-			}).then(function() {
+			}).then(function () {
 				return component.activate(true);
-			}).then(function() {
+			}).then(function () {
 				me._current = component;
 				try {
 					me.onActivated(component);
@@ -86,21 +84,21 @@
 		 * @returns true - компонента была деактивирована, либо нет активной
 		 *          компоненты. false - запрос на деактивацию - отклонен.
 		 */
-		deactivate : function() {
+		deactivate: function () {
 			var me = this;
-			return me._await(guard(me,"_start").then(function() {
+			return me._await(guard(me, "_start").then(function () {
 				return me._deactivate();
 			}));
 		},
 
-		_deactivate : function() {
+		_deactivate: function () {
 			var me = this;
 			if (!me._current)
 				return guard(false);
 
-			return guard(me, "onDeactivating").then(function() {
+			return guard(me, "onDeactivating").then(function () {
 				return me._current.deactivate(true);
-			}).then(function() {
+			}).then(function () {
 				// HACK raise deactivated event
 				try {
 					me.onDeactivated(me._current);
@@ -111,16 +109,12 @@
 			});
 		},
 
-		onActivating : function(component) {
-		},
+		onActivating: function (component) {},
 
-		onDeactivating : function(component) {
-		},
+		onDeactivating: function (component) {},
 
-		onDeactivated : function(component, next) {
-		},
+		onDeactivated: function (component, next) {},
 
-		onActivated : function(component) {
-		}
+		onActivated: function (component) {}
 	});
 });
\ No newline at end of file