OSDN Git Service

fix filer
[pettanr/pettanr.git] / app / assets / javascripts / models / panel_picture.js.coffee
index 794797c..f8f9be3 100644 (file)
@@ -1,4 +1,6 @@
 class Pettanr.PanelPicture extends Peta.Element\r
+  url: '/panel_pictures/'\r
+  \r
   @singular: () ->\r
     'PanelPicture'\r
   \r
@@ -9,6 +11,9 @@ class Pettanr.PanelPicture extends Peta.Element
     id: null\r
   } \r
   \r
+  picture: () ->\r
+    new Pettanr.Picture({id: @get('picture_id')})\r
+  \r
   @has_picture: () ->\r
     true\r
   \r
@@ -52,12 +57,15 @@ class Pettanr.PanelPicture extends Peta.Element
       style: "#{o}"\r
     })\r
   \r
-  tmb_opt_img_tag: () ->\r
+  tmb_opt_img_tag: (picture) ->\r
     wh = Pettanr.Imager.thumbnail_size(@get('width'), @get('height'))\r
-    {src: @r_url(), width: Math.abs(wh[0]), height: Math.abs(wh[1]), alt: @get('caption')}\r
+    new Pettanr.AppHelperImg({src: picture.r_url(), size: Math.abs(wh[0]), alt: @get('caption')})\r
   \r
-  symbol_option: () ->\r
-    @picture().symbol_option()\r
+  symbol_option: (cb) ->\r
+    i = @picture()\r
+    _this = this\r
+    i.fetch().done ->\r
+      cb(_this.tmb_opt_img_tag(i))\r
   \r
   initialize: () ->\r
     if @id\r