OSDN Git Service

fix: new speechballoon
[pettanr/pettanr.git] / app / assets / javascripts / models / panel_picture.js.coffee
index 23f9d45..52b1fd0 100644 (file)
@@ -11,9 +11,35 @@ class Pettanr.PanelPicture extends Peta.Element
     id: null\r
   } \r
   \r
+  @pick_item_name: () ->\r
+    'resource_picture'\r
+  \r
+  @pick_model: () ->\r
+    Manifest.item_name_to_model(@pick_item_name())\r
+  \r
+  @traceable_item_names: () ->\r
+    ['ground_picture', 'picture']\r
+  \r
+  @is_traceable: (item_name) ->\r
+    _.contains(@traceable_item_names(), item_name)\r
+  \r
+  trace_from_ground_picture: () ->\r
+  \r
+  trace_from_picture: () ->\r
+  \r
+  pick: (picked_item) ->\r
+    {\r
+      picture_id: picked_item.get('picture_id'),\r
+      width: picked_item.get('width'),\r
+      height: picked_item.get('height')\r
+    }\r
+  \r
   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,51 +57,38 @@ 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
-  \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
+  filename: (picture) ->\r
+    q = if _.isEmpty(@flip())\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
+    else\r
+      '?subdir=' + @flip()\r
+    picture.filename() + q\r
+  \r
+  r_url: (picture) ->\r
+    '/pictures/' + @filename(picture)\r
   \r
   tmb_opt_img_tag: (picture) ->\r
     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
+  initialize: (attr, options) ->\r
+    super(attr, options)\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