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 82e60c8..36bda58 100644 (file)
@@ -11,6 +11,9 @@ class Pettanr.SystemPicture extends Peta.SystemResource
     id: null\r
   } \r
   \r
+  picture: () ->\r
+    new Pettanr.Cache.Retriever(Pettanr.Picture, @get('picture_id'))\r
+  \r
   filename: () ->\r
     @get('id') + '.' + @get('ext')\r
   \r
@@ -24,16 +27,23 @@ class Pettanr.SystemPicture extends Peta.SystemResource
     {src: @r_url(), width: @get('width'), height: @get('height')}\r
   \r
   tmb_opt_img_tag: () ->\r
-    wh = Pettanr.Imager.thumbnail_size(@get('width'), @get('height'))\r
-    {src: @r_url(), width: wh[0], height: wh[1]}\r
+    new Pettanr.Image.SymbolPicture({\r
+      attr: {\r
+        src: @r_url()\r
+      },\r
+      picture: this\r
+    })\r
   \r
   symbol_option: () ->\r
-    @tmb_opt_img_tag()\r
+    retriever = @retriever()\r
+    @listenTo(retriever, 'retrieve', @retrieve_symbol)\r
+    retriever.retrieve()\r
+  \r
+  retrieve_symbol: (item) -> \r
+    @trigger('ready:symbol', item.tmb_opt_img_tag())\r
   \r
-  initialize: () ->\r
+  initialize: (attr = {}, options = {}) ->\r
+    super(attr, options)\r
     if @id\r
       @url = @url + @id\r
   \r
-class Pettanr.SystemPicture.Collection extends Backbone.Collection\r
-  model: Pettanr.SystemPicture\r
-  url: '/system_pictures'\r