From 2a8151cd4eed448f367c463e6a42a69a905fee9a Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Fri, 11 Dec 2015 12:31:56 +0000 Subject: [PATCH] SSDM-2941 : Layout Improvements - Finalize Split View Layout SVN: 35289 --- .../html/js/controllers/MainController.js | 7 ++- .../views/SampleForm/SampleFormController.js | 8 ++++ .../js/views/SampleForm/SampleFormView.js | 44 +++++++++++++------ 3 files changed, 43 insertions(+), 16 deletions(-) diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js index 39aa4f3acc6..c72b0a3d1e6 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js @@ -171,9 +171,12 @@ function MainController(profile) { return; } // - // Reset overflow + // Finalize view, used to undo mayor modifications to how layout and events are handled // - $("body").css("overflow", "auto"); + if( this.currentView && + this.currentView.finalize) { + this.currentView.finalize(); + } // // // diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js index baebb9c97c6..e76fbd2df08 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js @@ -20,6 +20,7 @@ function SampleFormController(mainController, mode, sample) { this._sampleFormView = new SampleFormView(this, this._sampleFormModel); // this._storageControllers = []; this._plateController = null; + this._windowHandlers = []; this.init = function($container) { // Loading datasets @@ -40,6 +41,13 @@ function SampleFormController(mainController, mode, sample) { } + this.finalize = function() { + for(var whIdx = 0; whIdx < this._windowHandlers.length; whIdx++) { + $(window).off("resize", this._windowHandlers[whIdx]); + } + $("body").css("overflow", "auto"); + } + this.isDirty = function() { return this._sampleFormModel.isFormDirty; } diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js index cda448cc5d7..7a7177eb636 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js @@ -17,7 +17,6 @@ function SampleFormView(sampleFormController, sampleFormModel) { this._sampleFormController = sampleFormController; this._sampleFormModel = sampleFormModel; - this._$rightPanel = null; this.repaint = function($container) { // @@ -35,17 +34,29 @@ function SampleFormView(sampleFormController, sampleFormModel) { 'onsubmit' : 'mainController.currentView.createUpdateCopySample();' }); - this._$rightPanel = $("<span>", { "class" : "row col-md-4 form-panel-two", "style" : "margin-left:20px; margin-top:20px;"}); + var $rightPanel = $("<span>", { "class" : "row col-md-4 form-panel-two", "style" : "margin-left:20px; margin-top:20px;"}); - var windowWidth = $(window).width(); - var windowHeight = $(window).height(); - var panelCss = {'min-height' : windowHeight + 'px', 'max-height' : windowHeight + 'px' }; - - if(windowWidth > 768) { //On non tablet devices - $("body").css("overflow", "hidden"); - this._$rightPanel.css(panelCss); - $formColumn.css(panelCss); + // + var windowScrollManager = function($form, $rightPanel) { + return function() { + if($(window).width() > 1024) { //Min Desktop resolution + var scrollablePanelCss = {'min-height' : $(window).height() + 'px', 'max-height' : $(window).height() + 'px' }; + $("body").css("overflow", "hidden"); + $formColumn.css(scrollablePanelCss); + $rightPanel.css(scrollablePanelCss); + } else { + var normalPanelCss = {'min-height' : 'initial', 'max-height' : 'initial' }; + $("body").css("overflow", "auto"); + $formColumn.css(normalPanelCss); + $rightPanel.css(normalPanelCss); + } + } } + windowScrollManager = windowScrollManager($form, $rightPanel); + $(window).resize(windowScrollManager); + this._sampleFormController._windowHandlers.push(windowScrollManager); + $(window).resize(); + // $form.append($formColumn); @@ -191,8 +202,13 @@ function SampleFormView(sampleFormController, sampleFormModel) { Util.showImage($("#preview-image").attr("src")); }); - this._$rightPanel.append($("<legend>").append("Preview")); - this._$rightPanel.append($previewImage); + if($(window).width() > 1024) { //Min Desktop resolution + $rightPanel.append($previewImage); + } else { + $formColumn.append($previewImage); + } + + } // @@ -333,12 +349,12 @@ function SampleFormView(sampleFormController, sampleFormModel) { // var $dataSetViewerContainer = $("<div>", { 'id' : 'dataSetViewerContainer', 'style' : 'margin-top:10px;'}); - this._$rightPanel.append($dataSetViewerContainer); + $rightPanel.append($dataSetViewerContainer); // // INIT // - $container.append($form).append(this._$rightPanel); + $container.append($form).append($rightPanel); // // Extra content // -- GitLab