OSDN Git Service

try editor event dispatching
[pettanr/pettanr.git] / app / assets / javascripts / models / panel_picture.js.coffee
index 3545bd2..22465d2 100644 (file)
@@ -14,6 +14,9 @@ class Pettanr.PanelPicture extends Peta.Element
   picture: () ->\r
     new Pettanr.Picture({id: @get('picture_id')})\r
   \r
+  panel: (options = {}) ->\r
+    new Pettanr.Panel({id: @get('panel_id')}, options)\r
+  \r
   @has_picture: () ->\r
     true\r
   \r
@@ -31,34 +34,14 @@ class Pettanr.PanelPicture extends Peta.Element
     # res += '/' unless res.empty? # format of /v/1.png\r
     res\r
   \r
-  filename: () ->\r
-    @picture().filename() + '?subdir=' + @flip()\r
-  \r
-  r_url: () ->\r
-    '/pictures/' + @filename()\r
+  filename: (picture) ->\r
+    picture.filename() + '?subdir=' + @flip()\r
   \r
-  opt_div_style: () ->\r
-    "top:#{@get('y')}px; left:#{@get('x')}px; z-index:#{@get('z')}; position: absolute;"\r
-  \r
-  opt_img_tag: (spot = null, opacity = 20) ->\r
-    o = if spot and spot != this\r
-      "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});"\r
-    else\r
-      ''\r
-    @tag_attributes('img', {\r
-      class: "panel-picture", \r
-      vPicture: @get('id'), \r
-      src: @r_url(), \r
-      width: Math.abs(@get('width')), \r
-      height: Math.abs(@get('height')), \r
-      picture_id: @get('picture_id'), \r
-      ext: @picture.ext, \r
-      alt: @get('caption'), \r
-      style: "#{o}"\r
-    })\r
+  r_url: (picture) ->\r
+    '/pictures/' + @filename(picture)\r
   \r
   tmb_opt_img_tag: (picture) ->\r
-    new Pettanr.Picture.SymbolPicture({\r
+    new Pettanr.Image.SymbolPicture({\r
       attr: {\r
         src: picture.r_url(), \r
         alt: @get('caption')\r
@@ -66,16 +49,19 @@ class Pettanr.PanelPicture extends Peta.Element
       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
+      @symbol_picture = i.tmb_opt_img_tag()\r
+      @trigger('ready:symbol')\r
+  \r
+  element_face: () ->\r
+    new Pettanr.Views.PanelPicture.ElementFace({element: this})\r
   \r
   initialize: () ->\r
     if @id\r
       @url = @url + @id\r
+    @bind('change:width', () ->\r
+      console.log('cng')\r
+    )\r
   \r
-class Pettanr.PanelPicture.Collection extends Backbone.Collection\r
-  model: Pettanr.PanelPicture\r
-  url: '/panel_pictures'\r