From 73cebf8e4aa28a518ead0f73741c37724d9c957e Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 20 Feb 2013 08:49:46 +0100 Subject: [PATCH] Moved to module layer, to start not hard coded widgets, to start registured widgets. --- .../app/controllers/chat_widget.js.coffee | 1 + .../app/controllers/navigation.js.coffee | 4 ++-- .../app/controllers/notify.js.coffee | 3 +-- .../lib/app_post/interface_handle.js.coffee | 22 ++++++++----------- app/views/init/index.html.erb | 7 +----- 5 files changed, 14 insertions(+), 23 deletions(-) diff --git a/app/assets/javascripts/app/controllers/chat_widget.js.coffee b/app/assets/javascripts/app/controllers/chat_widget.js.coffee index 8680b2b4d..f9d9b6d98 100644 --- a/app/assets/javascripts/app/controllers/chat_widget.js.coffee +++ b/app/assets/javascripts/app/controllers/chat_widget.js.coffee @@ -207,3 +207,4 @@ class App.ChatWidget extends App.Controller ) @render() +App.Config.set( 'chat', App.ChatWidget, 'Widgets' ) diff --git a/app/assets/javascripts/app/controllers/navigation.js.coffee b/app/assets/javascripts/app/controllers/navigation.js.coffee index da1f7c1a2..b8797cb30 100644 --- a/app/assets/javascripts/app/controllers/navigation.js.coffee +++ b/app/assets/javascripts/app/controllers/navigation.js.coffee @@ -1,5 +1,3 @@ -$ = jQuery.sub() - class App.Navigation extends App.Controller constructor: -> super @@ -292,3 +290,5 @@ class App.Navigation extends App.Controller } @Config.set( 'NavBarRight', NavBarRight ) + +App.Config.set( 'navigation', App.Navigation, 'Widgets' ) diff --git a/app/assets/javascripts/app/controllers/notify.js.coffee b/app/assets/javascripts/app/controllers/notify.js.coffee index 99e975e46..ef6f88770 100644 --- a/app/assets/javascripts/app/controllers/notify.js.coffee +++ b/app/assets/javascripts/app/controllers/notify.js.coffee @@ -1,5 +1,3 @@ -$ = jQuery.sub() - class App.Notify extends Spine.Controller events: 'click .alert': 'destroy' @@ -58,3 +56,4 @@ class App.Notify extends Spine.Controller $.noty.closeAll() # $(@el).find('.alert').remove(); +App.Config.set( 'notify', App.Notify, 'Widgets' ) diff --git a/app/assets/javascripts/app/lib/app_post/interface_handle.js.coffee b/app/assets/javascripts/app/lib/app_post/interface_handle.js.coffee index e8902cf23..a4a5a1f16 100644 --- a/app/assets/javascripts/app/lib/app_post/interface_handle.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/interface_handle.js.coffee @@ -13,18 +13,12 @@ class App.Run extends App.Controller # check if session already exists/try to get session data from server App.Auth.loginCheck() - # start navigation controller - new App.Navigation( el: @el.find('#navigation') ) - - # start notify controller - new App.Notify( el: @el.find('#notify') ) - - # start content - new App.Content( el: @el.find('#content') ) - - # start chat - if App.ChatWidget - new App.ChatWidget( el: @el.find('#chat') ) + # start widgets + widgets = App.Config.get( 'Widgets' ) + if widgets + for key, widget of widgets + @el.append('
') + new widget( el: @el.find("##{key}") ) # bind to fill selected text into App.ClipBoard.bind( @el ) @@ -85,4 +79,6 @@ class App.Content extends App.Controller # @scrollTo( 0, 0, 100 ) ) - Spine.Route.setup() \ No newline at end of file + Spine.Route.setup() + +App.Config.set( 'content', App.Content, 'Widgets' ) diff --git a/app/views/init/index.html.erb b/app/views/init/index.html.erb index 1521aa669..fe131c0e7 100644 --- a/app/views/init/index.html.erb +++ b/app/views/init/index.html.erb @@ -1,10 +1,5 @@ -
- -
-
-
-
+