src/pyams_thesaurus/zmi/resources/js/pyams_thesaurus.js
changeset 114 e7e4b4146a91
parent 102 882b5db98946
child 118 935341eda021
--- a/src/pyams_thesaurus/zmi/resources/js/pyams_thesaurus.js	Fri Feb 01 18:37:43 2019 +0100
+++ b/src/pyams_thesaurus/zmi/resources/js/pyams_thesaurus.js	Fri Mar 22 15:23:35 2019 +0100
@@ -184,6 +184,34 @@
 
 
 		/**
+		 * Thesaurus term tree widget
+		 */
+		widget: {
+
+			/**
+			 * Initialize terms lists by adding class to lists headers containing selected terms
+			 */
+			initTree: function(element) {
+				$('input:checked', element).parents('.widget-body:first')
+										   .siblings('header')
+										   .addClass('active');
+			},
+
+			/**
+			 * Update header status after term (de)selection
+			 */
+			updateSelection: function(event) {
+				var widget = $(this).parents('.widget-body:first');
+				var header = widget.siblings('header');
+				header.removeClass('active');
+				if ($('input:checked', widget).exists()) {
+					header.addClass('active');
+				}
+			}
+		},
+
+
+		/**
 		 * Search terms in tree
 		 */
 		search: function() {