web/static/res/js/incresize.js
changeset 42 01415303372e
parent 36 6cd5bc3dc7a2
child 78 8c3f0b94d056
--- a/web/static/res/js/incresize.js	Tue Dec 11 13:13:44 2012 +0100
+++ b/web/static/res/js/incresize.js	Tue Dec 11 17:39:04 2012 +0100
@@ -22,7 +22,9 @@
 		if (bottomId != null) {
 			this.bottom = $('#' + bottomId);
 		}
-		this.footer =  $('#' + footerId);
+		if (footerId != null) {
+			this.footer =  $('#' + footerId);
+		}
 		this.minTopBottomHeight = minTopBottomHeight;
 		this.ratio = ratio;
 		this.preMiddleSizeFunc = preMiddleSizeFunc;
@@ -39,10 +41,13 @@
 		var self = incResize;
 
 		// Compute maximun middle element height
-		var heightForTopMiddleBotom = $(self.content).height() - $(self.footer).height() - 70;
+		var heightForTopMiddleBotom = $(self.content).height() - 70;
+		if (self.footer !== undefined) {
+			heightForTopMiddleBotom -= $(self.footer).height()			
+		}
 		var maxMiddleHeight = heightForTopMiddleBotom - self.minTopBottomHeight * 2;
 
-		// Get the middle element parent width nad test if it is not to big (to let place for top and bottom without adding scroll bars)
+		// Get the middle element parent width and test if it is not to big (to let place for top and bottom without adding scroll bars)
 		var middleRatio = 1 / self.ratio;
 		var newMiddleWidth = $(self.middleContainer).width();
 		var newMiddleHeight = newMiddleWidth * middleRatio;
@@ -80,7 +85,7 @@
 		// Change top and bottom heights
 		if (this.top != undefined && this.bottom != undefined) {
 			// Get the full height and compute heigth for top and bottom
-			var remainingHeight = $(self.content).height() - $(self.footer).height() - newMiddleHeight - 70;
+			var remainingHeight = heightForTopMiddleBotom - newMiddleHeight;
 			var newOtherHeight = remainingHeight / 2.0;
 			if (newOtherHeight < self.minTopBottomHeight) {
 				newOtherHeight = self.minTopBottomHeight;
@@ -88,7 +93,7 @@
 			$(self.top).css({"height" : +newOtherHeight+'px', "lineHeight" : +newOtherHeight+'px'});
 			$(self.bottom).css({"height" : +newOtherHeight+'px', "lineHeight" : +newOtherHeight+'px'});					
 		}
-	}
+	};
 }
 
 var incResize = new IncResize();