OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / assets / javascripts / models / panel_picture.js.coffee
index 86d9642..eaac8a5 100644 (file)
@@ -1,18 +1,70 @@
 class Pettanr.PanelPicture extends Peta.Element\r
-  @single: () ->\r
+  url: '/panel_pictures/'\r
+  \r
+  @singular: () ->\r
     'PanelPicture'\r
   \r
   @plural: () ->\r
     'PanelPictures'\r
   \r
-  @colum_structures: ->\r
-    {}\r
-  \r
   defaults: {\r
-    x: 11\r
+    id: null\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
+  flip: () ->\r
+    v = if @get('height') > 0\r
+      ''\r
+    else\r
+      'v'\r
+    h = if @get('width') > 0\r
+      ''\r
+    else\r
+      'h'\r
+    res = v + h\r
+    res = res # format of /1.png?subdir=v\r
+    # res += '/' unless res.empty? # format of /v/1.png\r
+    res\r
+  \r
+  filename: (picture) ->\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
+  \r
+  tmb_opt_img_tag: (picture) ->\r
+    new Pettanr.Image.SymbolPicture({\r
+      attr: {\r
+        src: picture.r_url(), \r
+        alt: @escape('caption')\r
+      },\r
+      picture: picture\r
+    })\r
+  \r
+  symbol_option: () ->\r
+    i = @picture()\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
-    confirm("Welcome to this world")\r
+    if @id\r
+      @url = @url + @id\r
+    @bind('change:width', () ->\r
+      console.log('cng')\r
+    )\r
   \r
-\r