Browse Source

Moved to module layer, to start not hard coded widgets, to start registured widgets.

Martin Edenhofer 12 years ago
parent
commit
73cebf8e4a

+ 1 - 0
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' )

+ 2 - 2
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' )

+ 1 - 2
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' )

+ 9 - 13
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('<div id="' + key + '"></div>')
+        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()
+    Spine.Route.setup()
+
+App.Config.set( 'content', App.Content, 'Widgets' )

+ 1 - 6
app/views/init/index.html.erb

@@ -1,10 +1,5 @@
 
-<div id="app">
-  <div id="navigation"></div>
-  <div id="notify"></div>
-  <div id="content"></div>
-  <div id="chat"></div>
-</div>
+<div id="app"></div>
 
 <div class="container">
   <footer class="footer">