OSDN Git Service

redraw page title
[pettanr/pettanr.git] / app / assets / javascripts / main.js.coffee
index 1352297..b8b207f 100644 (file)
@@ -3,6 +3,12 @@ $ ->
     interpolate: /\<\&\=(.+?)\&\>/g,\r
     evaluate: /\<\&(.+?)\&\>/g\r
   }\r
+  locale = $("html").attr('lang')\r
+  I18n.defaultLocale = locale\r
+  I18n.locale = locale\r
+  I18n.fallbacks = true\r
+  jQuery.timeago.settings.lang = locale\r
+  Backbone.fetchCache.localStorage = false\r
   loaded_manifest = null\r
   loaded_local_manifest = null\r
   $.ajaxSetup({async: false})\r
@@ -12,21 +18,52 @@ $ ->
     loaded_local_manifest = new LocalManifest(data)\r
   )\r
   $.ajaxSetup({async: true})\r
-  Manifest.set_manifest(loaded_manifest)\r
-  LocalManifest.set_manifest(loaded_local_manifest)\r
-  loaded_manifest.init()\r
-  loaded_local_manifest.init()\r
+  author_id = $("#pettanr").attr('author_id')\r
+  artist_id = $("#pettanr").attr('artist_id')\r
   author = new Pettanr.Author({id: author_id})\r
-  author.fetch({})\r
-  artist = new Pettanr.Artist({id: artist_id})\r
-  artist.fetch({})\r
-  window.operators = new Pettanr.Operator([author, artist])\r
+  author.fetch({cache: true}).done ->\r
+    artist = new Pettanr.Artist({id: artist_id})\r
+    artist.fetch({cache: true}).done ->\r
+      user = new Pettanr.User({id: author.get('user_id')})\r
+      window.operators = new Pettanr.Operator({\r
+        author: author, \r
+        artist: artist, \r
+        user: user\r
+      })\r
+      Manifest.set_manifest(loaded_manifest)\r
+      LocalManifest.set_manifest(loaded_local_manifest)\r
+      loaded_manifest.init()\r
+      loaded_local_manifest.init()\r
+      \r
+      window.onbeforeunload = (e)->\r
+        return('leave?')\r
+      window.router = new Pettanr.Router()\r
+      Backbone.history.start({pushState: true})\r
+      window.router.navigate('', true)\r
   \r
-  #list_result = new Pettanr.Folder.Root({})\r
-  #new Pettanr.FilerRender('folder', list_result, 'default', window.operators)\r
-  window.router = new Pettanr.Router()\r
-  Backbone.history.start({pushState: true})\r
-  window.router.navigate('', true)\r
+  t: () ->\r
+    #i = new Pettanr.Balloon({id: 49})\r
+    #i = new Pettanr.Speech({id: 49})\r
+    #i = new Pettanr.GroundColor({id: 1})\r
+    #i = new Pettanr.PanelPicture({id: 21})\r
+    #i = new Pettanr.License({id: 4})\r
+    i = new Pettanr.SpeechBalloon({id: 49})\r
+    i.fetch().done ->\r
+      b = new Pettanr.Balloon({id: 49})\r
+      b.fetch().done ->\r
+        s = new Pettanr.Speech({id: 49})\r
+        s.fetch().done ->\r
+          i.speech = s\r
+          i.balloon= b\r
+          form = new Locmare.Bucket.factory(\r
+            i.item_name(), \r
+            i, \r
+            true, \r
+            'default', \r
+            window.operators,\r
+            '/' + i.table_name() + '/' + Pettanr.to_s(i.get('id'))\r
+          )\r
+          $("#pettanr").html(form.render().el)\r
   \r
   test_router: () ->\r
     window.router.navigate('folders/98', true)\r