amalgame/commit

IMPROVED: activate/disable controls in UI

authorJacco van Ossenbruggen
Mon Sep 8 23:28:38 2014 +0200
committerJacco van Ossenbruggen
Mon Sep 8 23:28:38 2014 +0200
commitdc2837a54dc243d3bbc0c8c63819c5d3f81d8d89
treecb8711b6073415f443d2f69f24c442695bf65120
parent80a5468887475e603c93e47c8cf22e60d7f459a1
Diff style: patch stat
diff --git a/components/amalgame/controls.pl b/components/amalgame/controls.pl
index 16b5ea7..3d45f33 100644
--- a/components/amalgame/controls.pl
+++ b/components/amalgame/controls.pl
@@ -237,7 +237,7 @@ module_input_type(M, vocab) :-
 module_input_type(M, vocab) :-
 	rdfs_subclass_of(M, amalgame:'VocabPartitioner'),
 	!.
-module_input_type(_, '').
+module_input_type(_, 'always_active').
 
 %%	module_special_type(+ModuleURI, -Type).
 %
diff --git a/web/js/controls.js b/web/js/controls.js
index a78ea85..ca75b40 100644
--- a/web/js/controls.js
+++ b/web/js/controls.js
@@ -6,6 +6,7 @@ YUI.add('controls', function(Y) {
 
 	var NODE_CONTROLS = Y.all(".control"),
 		NODE_INPUT_CONTROLS = Y.all("#select .control"),
+		NODE_CONTROLS_ACTIVE = Y.all(".control.always_active"),
 		NODE_CONCEPT_INPUTS = Y.all('.vocab input.concept'),
 		NODE_INPUT = Y.one("#input"),
 		NODE_SOURCE = Y.one("#source"),
@@ -163,18 +164,21 @@ YUI.add('controls', function(Y) {
 			this._setMappingSelecter();
 			var secSelecter = Y.one(".secinput_selecter");
 
-			// Re-enable all controls by default:
-			NODE_CONTROLS.each(function(node) { node.removeClass("disabled") });
+			// Disable controls incompatible with the active type
+			NODE_CONTROLS.each(function(node) {
+				if( !type || !node.hasClass(type) ) 
+					node.addClass("disabled"); 
+				else
+					node.removeClass("disabled"); 
+			});
+
+			NODE_CONTROLS_ACTIVE.removeClass("disabled");
 
 			// Disable controls requiring secondairy mappings if there are non:
 			if (!secSelecter || !secSelecter.getContent()) {
 				Y.all(".secinput").addClass("disabled");
 			}
 
-			// Disable controls incompatible with the active type
-			NODE_INPUT_CONTROLS.each(function(node) {
-				if(!type || !node.hasClass(type)) node.addClass("disabled");
-			});
 
 			// enable input select when a vocabulary is selected
 			NODE_INPUT_BTN.setAttribute("disabled", true);