diff src/implab/components/_ActivatableMixin.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/_ActivatableMixin.js	Fri Jun 02 19:28:20 2017 +0300
+++ b/src/implab/components/_ActivatableMixin.js	Tue Jun 06 19:45:32 2017 +0300
@@ -1,40 +1,38 @@
-define([ "dojo/_base/declare", "../guard", "./StateMachine", "../log/_LogMixin", ],
-
-function(declare, guard, StateMachine, _LogMixin) {
+define(["dojo/_base/declare", "../guard", "./StateMachine", "../log/_LogMixin", ], function (declare, guard, StateMachine, _LogMixin) {
 
 	var states = {
-		inactive : {
-			activate : "activating"
+		inactive: {
+			activate: "activating"
 		},
-		activating : {
-			success : "active",
-			failed : "inactive"
+		activating: {
+			success: "active",
+			failed: "inactive"
 		},
-		active : {
-			deactivate : "deactivating"
+		active: {
+			deactivate: "deactivating"
 		},
-		deactivating : {
-			success : "inactive",
-			failed : "active"
+		deactivating: {
+			success: "inactive",
+			failed: "active"
 		}
 	};
 
-	return declare([ _LogMixin ], {
-		_controller : null,
+	return declare([_LogMixin], {
+		_controller: null,
 
-		_active : null,
+		_active: null,
 
-		constructor : function() {
+		constructor: function () {
 			this._active = new StateMachine({
-				states : states,
-				initial : "inactive"
+				states: states,
+				initial: "inactive"
 			});
 		},
 
 		/**
 		 * @returns {Object} контроллер для активации текущей компоненты
 		 */
-		getController : function() {
+		getController: function () {
 			return this._controller;
 		},
 
@@ -42,18 +40,18 @@
 		 * @param {Object}
 		 *            v Контроллер для активации текущей компоненты
 		 */
-		setController : function(v) {
+		setController: function (v) {
 			this._controller = v;
 		},
 
 		/**
 		 * @returns {Boolean} текущая компонента активна
 		 */
-		isActive : function() {
+		isActive: function () {
 			return this._active.current == "active";
 		},
 
-		assertActive : function() {
+		assertActive: function () {
 			if (!this.isActive())
 				throw new Error("The object must be active to perform the operation");
 		},
@@ -68,20 +66,20 @@
 		 *            контроллера.
 		 * @return{Boolean} успешно/неуспешно
 		 */
-		activate : function(direct) {
+		activate: function (direct) {
 			var me = this;
 			if (!direct && this._controller)
-				return me._controller.activate(me).then(function() {
+				return me._controller.activate(me).then(function () {
 					me.onActivated();
 				});
 
 			me._active.move("activate");
-			return guard(me, "onActivating").then(function() {
+			return guard(me, "onActivating").then(function () {
 				me.log("Activated");
 				me._active.move("success");
 				if (!me._controller)
 					me.onActivated();
-			}, function(err) {
+			}, function (err) {
 				console.error(err);
 				me.error("Activation failed: {0}", err);
 				me._active.move("failed");
@@ -98,20 +96,20 @@
 		 *                 участия контроллера.
 		 * 
 		 */
-		deactivate : function(direct) {
+		deactivate: function (direct) {
 			var me = this;
 			if (!direct && me._controller)
-				return me._controller.deactivate(me).then(function() {
+				return me._controller.deactivate(me).then(function () {
 					me.onDeactivated();
 				});
 
 			me._active.move("deactivate");
-			return guard(me, "onDeactivating").then(function() {
+			return guard(me, "onDeactivating").then(function () {
 				me.log("Deactivated");
 				me._active.move("success");
 				if (!me._controller)
 					me.onDeactivated();
-			}, function(err) {
+			}, function (err) {
 				console.error(err);
 				me.error("Deactivation failed: {0}", err);
 				me.move("failed");
@@ -120,9 +118,9 @@
 
 		},
 
-		toogleActive : function() {
+		toogleActive: function () {
 			var me = this;
-			return (me.isActive() ? me.deactivate() : me.activate()).then(function() {
+			return (me.isActive() ? me.deactivate() : me.activate()).then(function () {
 				return me.isActive();
 			});
 		},
@@ -132,28 +130,24 @@
 		 * 
 		 * @returns{Boolean|undefined} если false - активация будет отменена
 		 */
-		onActivating : function() {
-		},
+		onActivating: function () {},
 
 		/**
 		 * Событие вызывается перед деактивацией текущей компоненты
 		 * 
 		 * @returns {Boolean|undefined} если false - деактивация будет отменена
 		 */
-		onDeactivating : function() {
-		},
+		onDeactivating: function () {},
 
 		/**
 		 * Событие вызывается после активации текущей компоненты
 		 */
-		onActivated : function() {
-		},
+		onActivated: function () {},
 
 		/**
 		 * Событие вызывается после деактивации текущей компоненты
 		 */
-		onDeactivated : function() {
-		}
+		onDeactivated: function () {}
 
 	});
 });
\ No newline at end of file