← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17983: Dashboard, redrawing full width items on window resize

 

------------------------------------------------------------
revno: 17983
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-01-14 13:12:11 +0100
message:
  Dashboard, redrawing full width items on window resize
modified:
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js	2015-01-14 11:45:05 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js	2015-01-14 12:12:11 +0000
@@ -42,6 +42,8 @@
 	$( "#interpretationArea" ).autogrow();
 
 	$( document ).click( dhis2.db.hideSearch );
+	
+	$( window ).resize( dhis2.db.drawFullWidthItems );
 
 	$( "#searchField" ).focus( function() {
 		$( "#searchDiv" ).css( "border-color", "#999" );
@@ -413,17 +415,15 @@
 dhis2.db.resizeItem = function( id )
 {
 	$.getJSON( "../api/dashboardItems/" + id, function( item ) {
-		
-		var newShape = dhis2.db.shapeFullWidth;			
-		
+				
 		if ( dhis2.db.shapeFullWidth == item.shape ) {
-			newShape = dhis2.db.shapeNormal;
+			var newShape = dhis2.db.shapeNormal;
 			$( "#" + id ).css( "width", dhis2.db.widthNormal + "px" );
 			Ext.get( "plugin-" + id ).viewport.setWidth( dhis2.db.widthNormal );
 		}
 		else {
-			newShape = dhis2.db.shapeFullWidth,
-			fullWidth = dhis2.db.getFullWidth();
+			var newShape = dhis2.db.shapeFullWidth,
+				fullWidth = dhis2.db.getFullWidth();
 			$( "#" + id ).css( "width", fullWidth + "px" );
 			Ext.get( "plugin-" + id ).viewport.setWidth( fullWidth );
 		}
@@ -435,6 +435,24 @@
 	} );
 }
 
+dhis2.db.drawFullWidthItems = function()
+{
+	if ( undefined !== dhis2.db.current() ) {
+		var url = "../api/dashboards/" + dhis2.db.current() + "?fields=dashboardItems[id,shape]";
+		
+		$.getJSON( url, function( dashboard ) {
+			$.each( dashboard.dashboardItems, function( i, item ) {
+				if ( dhis2.db.shapeFullWidth == item.shape ) {
+					var fullWidth = dhis2.db.getFullWidth();
+					$( "#" + item.id ).css( "width", fullWidth + "px" );
+					Ext.get( "plugin-" + item.id ).viewport.setWidth( fullWidth );
+				}
+			} );
+		} );
+	}
+}
+
+
 dhis2.db.renderDashboard = function( id )
 {
     var contentHeight = 304,
@@ -454,7 +472,7 @@
 
     $( "#dashboard-" + dhis2.db.current() ).addClass( "currentDashboard" );
 
-    $.getJSON( "../api/dashboards/" + id + "/?fields=:all,dashboardItems[:all]&" + dhis2.util.cacheBust(), function( data )
+    $.getJSON( "../api/dashboards/" + id + "?fields=:all,dashboardItems[:all]&" + dhis2.util.cacheBust(), function( data )
     {
 		$d = $( "#contentList" ).empty();