OSDN Git Service

add cache
[pettanr/pettanr.git] / app / assets / javascripts / models / panel_picture.js.coffee
index 1a86e4a..eaac8a5 100644 (file)
@@ -14,8 +14,8 @@ class Pettanr.PanelPicture extends Peta.Element
   picture: () ->\r
     new Pettanr.Picture({id: @get('picture_id')})\r
   \r
-  panel: () ->\r
-    new Pettanr.Panel({id: @get('panel_id')})\r
+  panel: (options = {}) ->\r
+    new Pettanr.Panel({id: @get('panel_id')}, options)\r
   \r
   @has_picture: () ->\r
     true\r
@@ -35,7 +35,11 @@ class Pettanr.PanelPicture extends Peta.Element
     res\r
   \r
   filename: (picture) ->\r
-    picture.filename() + '?subdir=' + @flip()\r
+    q = if _.isEmpty(@flip())\r
+      ''\r
+    else\r
+      '?subdir=' + @flip()\r
+    picture.filename() + q\r
   \r
   r_url: (picture) ->\r
     '/pictures/' + @filename(picture)\r
@@ -44,22 +48,23 @@ class Pettanr.PanelPicture extends Peta.Element
     new Pettanr.Image.SymbolPicture({\r
       attr: {\r
         src: picture.r_url(), \r
-        alt: @get('caption')\r
+        alt: @escape('caption')\r
       },\r
       picture: picture\r
     })\r
   \r
-  symbol_option: (cb) ->\r
+  symbol_option: () ->\r
     i = @picture()\r
-    _this = this\r
-    i.fetch().done ->\r
-      cb(_this.tmb_opt_img_tag(i))\r
+    i.fetch({cache: true}).done =>\r
+      @trigger('ready:symbol', i.tmb_opt_img_tag())\r
+  \r
+  element_face: () ->\r
+    new Pettanr.Views.PanelPicture.ElementFace({element: this})\r
   \r
   initialize: () ->\r
     if @id\r
       @url = @url + @id\r
-  \r
-class Pettanr.PanelPictures extends Backbone.Collection\r
-  model: Pettanr.PanelPicture\r
-  url: '/panel_pictures/'\r
+    @bind('change:width', () ->\r
+      console.log('cng')\r
+    )\r
   \r