OSDN Git Service

fix:asoc system
[pettanr/pettanr.git] / app / assets / javascripts / views / layout.js.coffee
index 69ac8c0..470e669 100644 (file)
@@ -1,13 +1,13 @@
 class Pettanr.Views.Layout\r
-class Pettanr.Views.Layout.Base extends Backbone.View\r
+class Pettanr.Views.Layout.Base extends Pettanr.View\r
   \r
 class Pettanr.Views.Layout.Sns extends Pettanr.Views.Layout.Base\r
   className: 'layout-sns'\r
   \r
   initialize: (options) ->\r
-    @operators = new Pettanr.Operator({})\r
-    @global_router = new Pettanr.GlobalRouter({operators: @operators})\r
+    @global_router = new Pettanr.GlobalRouter({})\r
     @listenTo(@global_router, 'go', @body_get)\r
+    @gate = new Pettanr.BeforeUnload()\r
     @header = new Pettanr.Views.Layout.Sns.Header({parent: this})\r
     @history = new Pettanr.Views.History({parent: this})\r
     @listenTo(@history, 'http_get', @body_http_get)\r
@@ -19,8 +19,7 @@ class Pettanr.Views.Layout.Sns extends Pettanr.Views.Layout.Base
     this.$el.html('')\r
     this.$el.append(@header.render().el)\r
     this.$el.append(@history.render().el)\r
-    rb = new Tag.RowBreak()\r
-    this.$el.append(rb.render().el)\r
+    @rb()\r
     this.$el.append(@body.render().el)\r
     this.$el.append(@footer.render().el)\r
     this\r
@@ -28,24 +27,22 @@ class Pettanr.Views.Layout.Sns extends Pettanr.Views.Layout.Base
   init_operators: (user) ->\r
     author = new Pettanr.Author(user.get('author')) if user.get('author')\r
     artist = new Pettanr.Artist(user.get('artist')) if user.get('artist')\r
-    @operators.init({\r
+    Pettanr.cache.operators.init({\r
       user: user, \r
       author: author, \r
       artist: artist\r
     })\r
-    @global_router.operators = @operators\r
   \r
   reset_operators: () ->\r
-    @operators.init({\r
+    Pettanr.cache.operators.init({\r
       user: null, \r
       author: null, \r
       artist: null\r
     })\r
-    @global_router.operators = @operators\r
   \r
   start: () ->\r
     # check current user signed in?\r
-    proxy = new Pettanr.Proxy({operators: @operators})\r
+    proxy = new Pettanr.Proxy({})\r
     @listenTo(proxy, 'redirect', @test_redirect)\r
     # @listenTo(proxy, 'success', @test_ok)\r
     @listenTo(proxy, 'fail', @test_ng)\r
@@ -53,9 +50,10 @@ class Pettanr.Views.Layout.Sns extends Pettanr.Views.Layout.Base
     proxy.http_post('users/test')\r
   \r
   test_ok: (user, response) ->\r
-    \r
+    @history.enable()\r
   \r
   test_ng: (response) ->\r
+    @history.disable()\r
     @head_http_get('users/guest')\r
     @body_http_get('user_sessions/new')\r
   \r
@@ -76,7 +74,7 @@ class Pettanr.Views.Layout.Sns extends Pettanr.Views.Layout.Base
     @history.disable()\r
   \r
   head_http_get: (url) ->\r
-    proxy = new Pettanr.Proxy({operators: @operators})\r
+    proxy = new Pettanr.Proxy({})\r
     @listenTo(proxy, 'ready', @head_ready)\r
     proxy.http_get(url, null)\r
   \r
@@ -86,12 +84,15 @@ class Pettanr.Views.Layout.Sns extends Pettanr.Views.Layout.Base
     @header.refresh(view)\r
   \r
   getter_proxy: () ->\r
-    proxy = new Pettanr.Proxy({operators: @operators})\r
+    proxy = new Pettanr.Proxy({gate: @gate})\r
     @listenTo(proxy, 'ready', @body_ready)\r
     @listenTo(proxy, 'title', @body_title)\r
     @listenTo(proxy, 'title', @push_history)\r
     @listenTo(proxy, 'done', @body_done)\r
+    @listenTo(proxy, 'deny', @body_deny)\r
     @listenTo(proxy, 'lock', @body_lock)\r
+    @listenTo(proxy, 'unlock', @body_unlock)\r
+    @listenTo(proxy, 'cancel', @cancel)\r
     proxy\r
   \r
   body_http_get: (url, form) ->\r
@@ -109,9 +110,6 @@ class Pettanr.Views.Layout.Sns extends Pettanr.Views.Layout.Base
     url = Pettanr.params_to_url(params)\r
     @global_router.navigate(url, {trigger: false})\r
   \r
-  body_lock: (params) ->\r
-    console.log('_lock')\r
-  \r
   push_history: (params, str = null) ->\r
     @history.push(params, str)\r
   \r
@@ -121,12 +119,14 @@ class Pettanr.Views.Layout.Sns extends Pettanr.Views.Layout.Base
     $(document).attr('title', t + ' - ' + site_caption)\r
   \r
   poster_proxy: () ->\r
-    proxy = new Pettanr.Proxy({operators: @operators})\r
+    proxy = new Pettanr.Proxy({})\r
     @listenTo(proxy, 'success', @body_success)\r
     @listenTo(proxy, 'fail', @body_fail)\r
     @listenTo(proxy, 'redirect', @body_redirect)\r
     @listenTo(proxy, 'sign_in', @sign_in)\r
     @listenTo(proxy, 'sign_out', @sign_out)\r
+    @listenTo(proxy, 'deny', @body_deny)\r
+    @listenTo(proxy, 'unlock', @body_unlock)\r
     proxy\r
   \r
   body_http_post: (url, form) ->\r
@@ -145,6 +145,17 @@ class Pettanr.Views.Layout.Sns extends Pettanr.Views.Layout.Base
     @global_router.navigate(url)\r
     @getter_proxy().http_get(url)\r
   \r
+  body_deny: (params, form, safe_url) ->\r
+    @getter_proxy().http_get(safe_url, params, form)\r
+  \r
+  body_lock: (params, form) ->\r
+    @gate.lock(params, form)\r
+  \r
+  body_unlock: (params, form) ->\r
+    @gate.unlock()\r
+  \r
+  cancel: (params, form) ->\r
+  \r
 class Pettanr.Views.Layout.Blog extends Pettanr.Views.Layout.Base\r
   className: 'layout-blog'\r
   \r
@@ -155,9 +166,7 @@ class Pettanr.Views.Layout.Blog extends Pettanr.Views.Layout.Base
     @body.navigate('top/demo')\r
   \r
   sign_in_fail: (user, response) ->\r
-    view = new Pettanr.Views.UserSeeeion.New({\r
-      operators: @operators\r
-    })\r
+    view = new Pettanr.Views.UserSeeeion.New({})\r
     view.render()\r
     @body.navigate('top/demo')\r
   \r