Commit 1ef133e2 authored by Frank Bergmann's avatar Frank Bergmann

- GanttEditor:

  - Continued refactoring code
  - Moved ResizeController to sencha-core, because
    it is a reusable part
  - Fixed issue with GanttBarPanel surface.size
parent af29de4d
/*
* ResizeController.js
*
* Copyright (c) 2011 - 2014 ]project-open[ Business Solutions, S.L.
* This file may be used under the terms of the GNU General Public
* License version 3.0 or alternatively unter the terms of the ]po[
* FL or CL license as specified in www.project-open.com/en/license.
*/
/**
* ResizeController
*
* This controller is responsible for editor geometry and resizing:
* <ul>
* <li>The boundaries of the outer window
* <li>The separator between the treePanel and the ganttPanel
* </ul>
*/
Ext.define('PO.controller.ResizeController', {
extend: 'Ext.app.Controller',
debug: false,
'ganttPanelContainer': null, // Defined during initialization
'ganttTreePanel': null, // Defined during initialization
'ganttBarPanel': null, // Defined during initialization
refs: [
{ ref: 'ganttTreePanel', selector: '#ganttTreePanel' }
],
init: function() {
var me = this;
if (me.debug) { if (me.debug) console.log('PO.controller.gantt_editor.GanttResizeController: init'); }
var sideBarTab = Ext.get('sideBarTab'); // ]po[ side-bar collapses the left-hand menu
sideBarTab.on('click', me.onSideBarResize, me); // Handle collapsable side menu
Ext.EventManager.onWindowResize(me.onWindowResize, me); // Deal with resizing the main window
me.ganttPanelContainer.on('resize', me.onGanttPanelContainerResize, me); // Deal with resizing the outer boundaries
return this;
},
/**
* Adapt the size of the ganttPanelContainer (the outer Gantt panel)
* to the available drawing area.
* Takes the size of the browser and subtracts the sideBar at the
* left and the size of the menu on top.
*/
onResize: function (sideBarWidth) {
var me = this;
if (me.debug) console.log('PO.controller.gantt_editor.GanttResizeController.onResize: Starting');
var sideBar = Ext.get('sidebar'); // ]po[ left side bar component
if (undefined === sideBarWidth) {
sideBarWidth = sideBar.getSize().width;
}
var screenSize = Ext.getBody().getViewSize(); // Total browser size
var width = screenSize.width - sideBarWidth - 100; // What's left after ]po[ side borders
var height = screenSize.height - 280; // What's left after ]po[ menu bar on top
me.ganttPanelContainer.setSize(width, height);
if (me.debug) console.log('PO.controller.gantt_editor.GanttResizeController.onResize: Finished');
},
/**
* Clicked on the ]po[ "side menu" bar for showing/hiding the left-menu
*/
onSideBarResize: function () {
var me = this;
if (me.debug) console.log('PO.controller.gantt_editor.GanttResizeController.onSidebarResize: Starting');
var sideBar = Ext.get('sidebar'); // ]po[ left side bar component
var sideBarWidth = sideBar.getSize().width;
// We get the event _before_ the sideBar has changed it's size.
// So we actually need to the the oposite of the sidebar size:
if (sideBarWidth > 100) {
sideBarWidth = 2; // Determines size when Sidebar collapsed
} else {
sideBarWidth = 245; // Determines size when Sidebar visible
}
me.onResize(sideBarWidth); // Perform actual resize
if (me.debug) console.log('PO.controller.gantt_editor.GanttResizeController.onSidebarResize: Finished');
},
/**
* The user changed the size of the browser window
*/
onWindowResize: function () {
var me = this;
if (me.debug) console.log('PO.controller.gantt_editor.GanttResizeController.onWindowResize: Starting');
if (!me.fullScreenP) {
var sideBar = Ext.get('sidebar');// ]po[ left side bar component
var sideBarWidth = sideBar.getSize().width;
if (sideBarWidth > 100) {
sideBarWidth = 340;// Determines size when Sidebar visible
} else {
sideBarWidth = 85;// Determines size when Sidebar collapsed
}
me.onResize(sideBarWidth);
} else {
me.onSwitchToFullScreen();
}
if (me.debug) console.log('PO.controller.gantt_editor.GanttResizeController.onWindowResize: Finished');
},
/**
* Manually changed the size of the ganttPanelContainer
*/
onGanttPanelContainerResize: function () {
var me = this;
if (me.debug) console.log('PO.controller.gantt_editor.GanttResizeController.onGanttPanelContainerResize: Starting');
me.ganttBarPanel.redraw(); // Perform actual resize
if (me.debug) console.log('PO.controller.gantt_editor.GanttResizeController.onGanttPanelContainerResize: Finished');
},
onSwitchToFullScreen: function () {
var me = this;
me.fullScreenP = true;
if (me.debug) console.log('PO.controller.gantt_editor.GanttResizeController.onSwitchToFullScreen: Starting');
me.ganttPanelContainer.setSize(Ext.getBody().getViewSize().width, Ext.getBody().getViewSize().height);
me.ganttBarPanel.setSize(Ext.getBody().getViewSize().width, Ext.getBody().getViewSize().height);
me.ganttBarPanel.redraw();
if (me.debug) console.log('PO.controller.gantt_editor.GanttResizeController.onSwitchToFullScreen: Finished');
},
onSwitchBackFromFullScreen: function () {
var me = this;
me.fullScreenP = false;
if (me.debug) console.log('PO.controller.gantt_editor.GanttResizeController.onSwitchBackFromFullScreen: Starting');
var sideBar = Ext.get('sidebar'); // ]po[ left side bar component
var sideBarWidth = sideBar.getSize().width;
if (undefined === sideBarWidth) {
sideBarWidth = Ext.get('sidebar').getSize().width;
}
var screenSize = Ext.getBody().getViewSize();
var width = screenSize.width - sideBarWidth - 100;
var height = screenSize.height - 280;
me.ganttPanelContainer.setSize(width, height);
if (me.debug) console.log('PO.controller.gantt_editor.GanttResizeController.onSwitchBackFromFullScreen: Finished');
}
});
// /sencha-core/www/controller/StoreLoadCoordinator.js
//
// Copyright (C) 2013 ]project-open[
//
// All rights reserved. Please see
// http://www.project-open.com/license/ for details.
//
/*
* StoreLoadCoordinator.js
*
* Copyright (c) 2011 - 2014 ]project-open[ Business Solutions, S.L.
* This file may be used under the terms of the GNU General Public
* License version 3.0 or alternatively unter the terms of the ]po[
* FL or CL license as specified in www.project-open.com/en/license.
*/
/**
* This coodinator is initiated with:
* stores: A list of stores that need to be loaded and
* listeners: {
......@@ -19,7 +20,6 @@
* Ext.Loader has finished loading classes and before
* the start of the actual application.
*/
Ext.define('PO.controller.StoreLoadCoordinator', {
/**
......
......@@ -47,9 +47,6 @@ Ext.define('PO.view.gantt.AbstractGanttPanel', {
dndBaseSprite: null, // DnD sprite being draged
dndShadowSprite: null, // DnD shadow generated for BaseSprite
dndConfig: null,
// Size of the Gantt diagram
ganttSurfaceWidth: 1500,
ganttBarHeight: 12,
monthThreeChar: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment