amalgame/commit

mapping.fetchDetail() calls builder.onWindowResize() after evidences are loaded to get long lists to reasonable size

authorJacco van Ossenbruggen
Sun Jul 20 20:43:50 2014 +0200
committerJacco van Ossenbruggen
Sun Jul 20 20:43:50 2014 +0200
commitaff10f3f34765e756c6cd6f9ef7ebdaf9cef9e5a
tree47e4b2f5f28ef5bdfd10dd8bde0a2e0ce4d44e72
parenta708021a68e0983830a184904e656d9ca5c80549
Diff style: patch stat
diff --git a/web/js/builder.js b/web/js/builder.js
index 1b4c6ff..8280780 100644
--- a/web/js/builder.js
+++ b/web/js/builder.js
@@ -47,12 +47,12 @@ YUI.add('builder', function(Y) {
 			this.readonly = (this.get('readonly') != "false"); // string/boolean
 
 			// initalize the different modules
-			this._initLayout();
 			this._initGraph();
 			this._initControls();
 			this._initInfo();
 			this._initMapping();
 			this._initVocabulary();
+			this._initLayout();
 
 			// handlers for the controls
 			if (!this.readonly) {
@@ -92,37 +92,48 @@ YUI.add('builder', function(Y) {
 			this.mapping.set("selected", selected);
 			this.vocabulary.set("selected", selected);
 		},
-		_initLayout : function() {
-			var oSelf = this,
-				controls = Y.one("#controls"),
-				bottom = Y.one("#bottom"),
-				graph = Y.one("#graph");
-			
-			function windowResize() {
+
+		onWindowResize : function() {
+			Y.log('onWindowResize');
+			var oSelf = this;
+			function _onWindowResize() {
+				var controls = Y.one("#controls");
+				var bottom = Y.one("#bottom");
+				var graph = Y.one("#graph");
 				var graphWrapper = graph.get("parentNode"),
+					evidences = Y.one(".evidences"),
 					contentHeight = oSelf._contentHeight(),
 					graphHeight = contentHeight - (bottom.get("offsetHeight")+10);
+					evHeight = 0.97 * contentHeight - 360;
 
 				graph.setStyle("height", graphHeight);
 				graphWrapper.setStyle("height", graphHeight);
 				graph.setStyle("width", "100%");
 				graphWrapper.setStyle("width", "100%");
 				controls.setStyle("height", contentHeight);
+				if (evidences) {
+					Y.log(evHeight);
+					evidences.setStyle("max-height", evHeight);
+				} else {
+					Y.log(evidences);
+				}
 			}
+			Y.detach("windowresize", _onWindowResize);
+			Y.on("windowresize", _onWindowResize);
+			_onWindowResize();
+	    	},
 			
+		_initLayout : function() {
 			// graph node is resizable in height
 			var resize = new Y.Resize({
-		        node: '#graph',
+		        	node: '#graph',
 				handles: 'b',
 				wrap: true
-		    });
+		    	});
 			resize.after("resize", this._onGraphResize, this);
 			resize.after("end", this._onGraphResize, this);
-			
-			//			
-			Y.on("windowresize", windowResize);
-			windowResize();
 
+			this.onWindowResize();
 		},
 
 		_initGraph : function() {
@@ -155,6 +166,7 @@ YUI.add('builder', function(Y) {
 
 		_initMapping : function() {
 			this.mapping = new Y.Mapping({
+				builder: this,
 				paths: this.get("paths"),
 				alignment: this.get("alignment"),
 				selected: this.get("selected")
diff --git a/web/js/mapping.js b/web/js/mapping.js
index ff233fa..1234110 100644
--- a/web/js/mapping.js
+++ b/web/js/mapping.js
@@ -15,12 +15,9 @@ YUI.add('mapping', function(Y) {
 	}
 	Mapping.NAME = "mapping";
 	Mapping.ATTRS = {
-		alignment : {
-			value: null
-		},
- 		selected : {
-			value: null
-		},
+		alignment : { value: null },
+ 		selected : { value: null },
+ 		builder : { value: null },
 		paths:{
 			value:{
 				mapping:"/amalgame/data/mapping",
@@ -84,9 +81,11 @@ YUI.add('mapping', function(Y) {
 
 		_initDetail : function() {
 			this.detailOverlay = new Y.Overlay({
-				srcNode:NODE_DETAIL,
+				id: "detail_overlay",
+			        srcNode:NODE_DETAIL,
 				visible:false,
-				width:"80%",
+				width: '85%',
+				height:'95%',
 				align:{points:[Y.WidgetPositionAlign.TC, Y.WidgetPositionAlign.TC]}
 			}).render();
 			NODE_DETAIL.removeClass("hidden");
@@ -177,18 +176,11 @@ YUI.add('mapping', function(Y) {
 		},
 
 		_fetchDetail : function() {
+			var builder = this.get('builder');
 			var overlay = this.detailOverlay,
 				node = this._selectedRow,
 				server = this.get("paths").cinfo;
 
-			// position the overlay below the currently selected row
-			//overlay.set("width", node.get("offsetWidth"));
-			//overlay.set("align", {
-			//node:node,
-			//points:[Y.WidgetPositionAlign.TR, Y.WidgetPositionAlign.BR]
-			//});
-
-			// call the server
 			var data = {
 				alignment:this.get("alignment"),
 				mapping:this.get("selected").uri,
@@ -202,20 +194,11 @@ YUI.add('mapping', function(Y) {
 				on:{success:function(e,o) {
 						NODE_CONCEPTS.setContent(o.responseText);
 						overlay.set("visible", true);
+						builder.onWindowResize();
 					}
 				}
 			});
 		}
-
-
-/*
-						target.all(".moretoggle").on("click", function(e) {
-							p = e.currentTarget.get("parentNode");
-							p.all(".moretoggle").toggleClass("hidden");
-							p.one(".morelist").toggleClass("hidden");
-						})
-*/
-
 	});
 
 	Y.Mapping = Mapping;