From 0962d7fb27968d910dfb99c432c64e8dd1aa1358 Mon Sep 17 00:00:00 2001 From: nathangray Date: Wed, 22 Jun 2016 09:56:16 -0600 Subject: [PATCH] Better/more hiding of calendar redrawing when changing views --- calendar/js/app.js | 44 +++++++++++++++++++++++------- calendar/js/et2_widget_timegrid.js | 6 ++++ 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/calendar/js/app.js b/calendar/js/app.js index 91bb5b4af3..1c2385220a 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -2023,6 +2023,16 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( */ if(grid) { + // Show loading div to hide redrawing + egw.loading_prompt( + this.appname,true,egw.lang('please wait...'), + typeof framework !== 'undefined' ? framework.applications.calendar.tab.contentDiv : false, + egwIsMobile()?'horizental':'spinner' + ); + + var loading = false; + + var value = []; state.state.first = view.start_date(state.state).toJSON(); // We'll modify this one, so it needs to be a new object @@ -2096,11 +2106,11 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( owner: state.state.owner[i] }); } - this._need_data(day_value,state.state); + loading = this._need_data(day_value,state.state); } else { - this._need_data(value,state.state); + loading = this._need_data(value,state.state); } var row_index = 0; @@ -2226,7 +2236,7 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( } } var value = [{start_date: state.state.first, end_date: state.state.last}]; - this._need_data(value,state.state); + loading = this._need_data(value,state.state); } // Include first & last dates in state, mostly for server side processing if(state.state.first && state.state.first.toJSON) state.state.first = state.state.first.toJSON(); @@ -2270,13 +2280,6 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( },this,et2_calendar_timegrid); } - // Trigger resize to get correct sizes, as they may have sized while - // hidden - for(var i = 0; i < view.etemplates.length; i++) - { - view.etemplates[i].resize(); - } - // List view (nextmatch) has slightly different fields if(state.state.view === 'listview') { @@ -2415,6 +2418,23 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( } egw.set_preference('calendar','saved_states', save); + // Trigger resize to get correct sizes, as they may have sized while + // hidden + for(var i = 0; i < view.etemplates.length; i++) + { + view.etemplates[i].resize(); + } + + // If we need to fetch data from the server, it will hide the loader + // when done but if everything is in the cache, hide from here. + if(!loading) + { + window.setTimeout(jQuery.proxy(function() { + + egw.loading_prompt(this.appname,false); + },this),500); + } + return; } // old calendar state handling on server-side (incl. switching to and from listview) @@ -2651,6 +2671,8 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( * * @param {Object} value * @param {Object} state + * + * @return {boolean} Data was requested */ _need_data: function(value, state) { @@ -2728,6 +2750,8 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( this.sidebox_et2 ? null : this.et2.getInstanceManager() ); } + + return need_data; }, /** diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js index 3000713a68..54634f63fa 100644 --- a/calendar/js/et2_widget_timegrid.js +++ b/calendar/js/et2_widget_timegrid.js @@ -767,6 +767,10 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. * We use a timeout to avoid doing it multiple times if redrawing or resizing. */ resizeTimes: function() { + + // Hide resizing from user + this.loader.show(); + // Wait a bit to see if anything else changes, then re-draw the times if(this.resize_timer) { @@ -824,6 +828,8 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. child.resize(); },this, et2_IResizeable); } + + this.loader.hide(); }, /**