← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21070: PT noext.

 

------------------------------------------------------------
revno: 21070
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-11-16 17:26:50 +0100
message:
  PT noext.
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app2.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-apps/src/main/webapp/dhis-web-pivot/scripts/app2.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app2.js	2015-11-14 23:41:41 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app2.js	2015-11-16 16:26:50 +0000
@@ -6,6 +6,11 @@
         var UiManager = function() {
             var t = this;
 
+            // uninitialized
+            t.viewport;
+            t.menuRegion;
+
+            // support
             t.getScrollbarSize = function(force) {
                 var size,
                     body = document.body,
@@ -28,12 +33,23 @@
             };
         };
 
+        UiManager.addViewport = function(viewport) {
+            this.viewport = viewport;
+        };
+
+        UiManager.addMenuRegion = function(viewport) {
+            this.viewport = viewport;
+        };
+
         N.UiManager = new UiManager();
     })();
 
-    // UiMenuRegion
+    // UiViewport
     (function() {
-        var UiMenuAccordion = function(config) {
+
+        // UiMenuRegion
+
+        var UiMenuAccordion = function(cmp, config) {
             var t = this;
 
             config = N.isObject(config) ? config : {};
@@ -42,10 +58,7 @@
             var tabHeight = config.tabHeight || 28;
 
             // constructor
-            $.extend(this, Ext.create('Ext.panel.Panel', {
-                bodyStyle: 'border-style:none; padding:1px; padding-bottom:0; overflow-y:scroll;',
-                items: new N.UiMenuAccordionBody()
-            }));
+            $.extend(this, cmp);
         };
 
         //UiMenuAccordion.prototype.thisSetHeight = function(mx) {
@@ -63,10 +76,9 @@
                 //accordion.setHeight((height > mx ? mx : height) - 2);
                 //accordionBody.setHeight((height > mx ? mx : height) - 2);
             //}
-    })();
-
-    // UiMenuRegion
-    (function() {
+
+        // UiMenuRegion
+
         var UiMenuRegion = function(config) {
             var t = this;
 
@@ -86,6 +98,113 @@
                 items: new N.UiMenuAccordion()
             }));
         };
+
+        // UiViewport
+
+        var UiViewport = function(config) {
+            var t = this;
+
+            config = N.isObject(config) ? config : {};
+
+            // local
+            var menuRegion = new UiMenuRegion();
+
+            // constructor
+            $.extend(this, Ext.create('Ext.container.Viewport', {
+                layout: 'border',
+                //period: period,
+                //treePanel: treePanel,
+                //setGui: setGui,
+                //westRegion: westRegion,
+                //centerRegion: centerRegion,
+                items: [
+                    menuRegion,
+                    Ext.create('Ext.panel.Panel', {
+                        region: 'center'
+                    })
+                ],
+                listeners: {
+                    //render: function() {
+                        //ns.app.viewport = this;
+
+                        //ns.app.layoutWindow = LayoutWindow();
+                        //ns.app.layoutWindow.hide();
+
+                        //ns.app.optionsWindow = OptionsWindow();
+                        //ns.app.optionsWindow.hide();
+                    //},
+                    afterrender: function() {
+
+                        // resize event handler
+                        westRegion.on('resize', function() {
+                            var panel = accordion.getExpandedPanel();
+
+                            if (panel) {
+                                panel.onExpand();
+                            }
+                        });
+
+                        // left gui
+                        var viewportHeight = westRegion.getHeight(),
+                            numberOfTabs = ns.core.init.dimensions.length + 3,
+                            tabHeight = 28,
+                            minPeriodHeight = 380;
+
+                        if (viewportHeight > numberOfTabs * tabHeight + minPeriodHeight) {
+                            if (!Ext.isIE) {
+                                accordion.setAutoScroll(false);
+                                westRegion.setWidth(ns.core.conf.layout.west_width);
+                                accordion.doLayout();
+                            }
+                        }
+                        else {
+                            westRegion.hasScrollbar = true;
+                        }
+
+                        // expand first panel
+                        accordion.getFirstPanel().expand();
+
+                        // look for url params
+                        var id = ns.core.web.url.getParam('id'),
+                            session = ns.core.web.url.getParam('s'),
+                            layout;
+
+                        if (id) {
+                            ns.core.web.pivot.loadTable(id);
+                        }
+                        else if (Ext.isString(session) && NS.isSessionStorage && Ext.isObject(JSON.parse(sessionStorage.getItem('dhis2'))) && session in JSON.parse(sessionStorage.getItem('dhis2'))) {
+                            layout = ns.core.api.layout.Layout(JSON.parse(sessionStorage.getItem('dhis2'))[session]);
+
+                            if (layout) {
+                                ns.core.web.pivot.getData(layout, true);
+                            }
+                        }
+
+                        // remove params from url
+                        if (id || session) {
+                            history.pushState(null, null, '.')
+                        }
+
+                        var initEl = document.getElementById('init');
+                        initEl.parentNode.removeChild(initEl);
+
+                        Ext.getBody().setStyle('background', '#fff');
+                        Ext.getBody().setStyle('opacity', 0);
+
+                        // fade in
+                        Ext.defer( function() {
+                            Ext.getBody().fadeIn({
+                                duration: 600
+                            });
+                        }, 300 );
+                    }
+                }
+            });
+
+            N.UiManager.setMenuRegion(menuRegion);
+
+            N.UiViewport = new UiViewport();
+        };
     })();
 
     // initialize