From 6b3d1612a8e95e3da7272e9c129bad4e02e6472a Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 2 Dec 2015 02:24:23 +0100 Subject: [PATCH] Reduced dom operations at loading time. --- .../_application_controller.coffee | 2 +- .../app/controllers/navigation.coffee | 1 + .../app/controllers/taskbar_widget.coffee | 23 ++++++----- .../app/controllers/ticket_zoom.coffee | 2 +- .../app/lib/app_post/interface_handle.coffee | 3 ++ .../app/lib/app_post/task_manager.coffee | 40 +++++++------------ .../app/views/task_widget_tasks.jst.eco | 16 ++++---- 7 files changed, 41 insertions(+), 46 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller.coffee b/app/assets/javascripts/app/controllers/_application_controller.coffee index 34c765d8a..5008e5378 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.coffee @@ -544,7 +544,7 @@ class App.Controller extends Spine.Controller metaTaskUpdate: -> App.Delay.set( -> App.Event.trigger 'task:render' - 450 + App.TaskManager.renderDelay() 'meta-task-update' ) diff --git a/app/assets/javascripts/app/controllers/navigation.coffee b/app/assets/javascripts/app/controllers/navigation.coffee index dadba0be7..27184e1ff 100644 --- a/app/assets/javascripts/app/controllers/navigation.coffee +++ b/app/assets/javascripts/app/controllers/navigation.coffee @@ -382,6 +382,7 @@ class App.Navigation extends App.ControllerWidgetPermanent update: (url) => @$('.is-active').removeClass('is-active') + return if !url || url is '#' @$("[href=\"#{url}\"]").addClass('is-active') recentViewNavbarItemsRebuild: => diff --git a/app/assets/javascripts/app/controllers/taskbar_widget.coffee b/app/assets/javascripts/app/controllers/taskbar_widget.coffee index e8ac0b281..1d92c362d 100644 --- a/app/assets/javascripts/app/controllers/taskbar_widget.coffee +++ b/app/assets/javascripts/app/controllers/taskbar_widget.coffee @@ -26,30 +26,31 @@ class App.TaskbarWidget extends App.Controller for task in tasks # collect meta data of task for task bar item - data = - url: '#' - id: false + meta = + url: '#' + id: false iconClass: 'loading' - title: App.i18n.translateInline('Loading...') - head: App.i18n.translateInline('Loading...') + title: App.i18n.translateInline('Loading...') + head: App.i18n.translateInline('Loading...') + active: false worker = App.TaskManager.worker(task.key) if worker - meta = worker.meta() + data = worker.meta() # apply meta data of controller - if meta - for key, value of meta - data[key] = value + if data + for key, value of data + meta[key] = value # collect new task bar items item = {} item.task = task - item.data = data + item.meta = meta taskItems.push item # set title if task.active - @title data.title + @title meta.title @html App.view('task_widget_tasks')( taskItems: taskItems diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.coffee index a5829b281..961e66824 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.coffee @@ -365,7 +365,7 @@ class App.TicketZoom extends App.Controller formMeta: @formMeta ) - # render init page + # render init content if elLocal @html elLocal diff --git a/app/assets/javascripts/app/lib/app_post/interface_handle.coffee b/app/assets/javascripts/app/lib/app_post/interface_handle.coffee index 9e32b4201..bf19ee6f7 100644 --- a/app/assets/javascripts/app/lib/app_post/interface_handle.coffee +++ b/app/assets/javascripts/app/lib/app_post/interface_handle.coffee @@ -21,6 +21,9 @@ class App.Run extends App.Controller # create web socket connection App.WebSocket.connect() + # init tasks + App.TaskManager.init() + # start frontend time update @frontendTimeUpdate() diff --git a/app/assets/javascripts/app/lib/app_post/task_manager.coffee b/app/assets/javascripts/app/lib/app_post/task_manager.coffee index 5b024923a..5e80dfec6 100644 --- a/app/assets/javascripts/app/lib/app_post/task_manager.coffee +++ b/app/assets/javascripts/app/lib/app_post/task_manager.coffee @@ -5,65 +5,44 @@ class App.TaskManager _instance ?= new _taskManagerSingleton( params ) @all: -> - if _instance == undefined - _instance ?= new _taskManagerSingleton _instance.all() @execute: ( params ) -> - if _instance == undefined - _instance ?= new _taskManagerSingleton _instance.execute( params ) @get: ( key ) -> - if _instance == undefined - _instance ?= new _taskManagerSingleton _instance.get( key ) @update: ( key, params ) -> - if _instance == undefined - _instance ?= new _taskManagerSingleton _instance.update( key, params ) @remove: (key, rerender = true) -> - if _instance == undefined - _instance ?= new _taskManagerSingleton _instance.remove(key, rerender) @notify: ( key ) -> - if _instance == undefined - _instance ?= new _taskManagerSingleton _instance.notify( key ) @mute: ( key ) -> - if _instance == undefined - _instance ?= new _taskManagerSingleton _instance.mute( key ) @reorder: ( order ) -> - if _instance == undefined - _instance ?= new _taskManagerSingleton _instance.reorder( order ) @reset: -> - if _instance == undefined - _instance ?= new _taskManagerSingleton _instance.reset() @worker: ( key ) -> - if _instance == undefined - _instance ?= new _taskManagerSingleton _instance.worker( key ) @nextTaskUrl: -> - if _instance == undefined - _instance ?= new _taskManagerSingleton _instance.nextTaskUrl() @TaskbarId: -> - if _instance == undefined - _instance ?= new _taskManagerSingleton _instance.TaskbarId() + @renderDelay: -> + _instance.renderDelay() + class _taskManagerSingleton extends App.Controller @include App.LogInclude @@ -98,6 +77,7 @@ class _taskManagerSingleton extends App.Controller @allTasks = [] @tasksToUpdate = {} @activeTaskHistory = [] + @renderDelayTime = 600 all: -> @@ -511,9 +491,19 @@ class _taskManagerSingleton extends App.Controller persistent: false init: true ) - task_count * 600 + task_count * 450 undefined 'task' ) + # set new renderDelayTime + App.Delay.set( + => + @renderDelayTime = 20 + task_count * 450 + ) + App.Event.trigger 'taskbar:ready' + + renderDelay: => + @renderDelayTime diff --git a/app/assets/javascripts/app/views/task_widget_tasks.jst.eco b/app/assets/javascripts/app/views/task_widget_tasks.jst.eco index 050af9961..07e9c897c 100644 --- a/app/assets/javascripts/app/views/task_widget_tasks.jst.eco +++ b/app/assets/javascripts/app/views/task_widget_tasks.jst.eco @@ -1,18 +1,18 @@ <% for item in @taskItems: %> - -