OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / assets / javascripts / models / system_picture.js.coffee
index 628870b..e718fda 100644 (file)
@@ -1,25 +1,44 @@
-class SystemPicture extends Item\r
-  @single: () ->\r
+class Pettanr.SystemPicture extends Peta.SystemResource\r
+  url: '/system_pictures/'\r
+  \r
+  @singular: () ->\r
     'SystemPicture'\r
   \r
   @plural: () ->\r
     'SystemPictures'\r
   \r
   defaults: {\r
-    id: 11\r
+    id: null\r
   } \r
   \r
+  picture: () ->\r
+    new Pettanr.Picture({id: @get('picture_id')})\r
+  \r
+  filename: () ->\r
+    @get('id') + '.' + @get('ext')\r
+  \r
+  mime_type: () ->\r
+    'image/' + @get('ext')\r
+  \r
+  r_url: () ->\r
+    '/system_pictures/' + @filename()\r
+  \r
+  opt_img_tag: () ->\r
+    {src: @r_url(), width: @get('width'), height: @get('height')}\r
+  \r
+  tmb_opt_img_tag: () ->\r
+    new Pettanr.Image.SymbolPicture({\r
+      attr: {\r
+        src: @r_url()\r
+      },\r
+      picture: this\r
+    })\r
+  \r
+  symbol_option: () ->\r
+    @fetch({cache: true}).done =>\r
+      @trigger('ready:symbol', @tmb_opt_img_tag())\r
+  \r
   initialize: () ->\r
-    confirm("Welcome to Panel")\r
-  \r
-  @test: () ->\r
-    confirm( @single())\r
-    confirm( @plural() )\r
-    confirm( @class_name() )\r
-    confirm( @element_name() )\r
-    confirm( @table_name() )\r
-    \r
-  \r
-  test: () ->\r
-\r
-@Panel = Panel\r
+    if @id\r
+      @url = @url + @id\r
+  \r