OSDN Git Service

fix: show's destroy button
[pettanr/pettanr.git] / app / assets / javascripts / models / system_picture.js.coffee
index 340b564..20168d3 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.SystemPicture extends Peta.SystemResource\r
-  url: '/system_pictures/'\r
   \r
   @singular: () ->\r
     'SystemPicture'\r
@@ -11,6 +10,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,22 +26,21 @@ class Pettanr.SystemPicture extends Peta.SystemResource
     {src: @r_url(), width: @get('width'), height: @get('height')}\r
   \r
   tmb_opt_img_tag: () ->\r
-    new Pettanr.Picture.SymbolPicture({\r
+    new Pettanr.Image.SymbolPicture({\r
       attr: {\r
         src: @r_url()\r
       },\r
       picture: this\r
     })\r
   \r
-  symbol_option: (cb) ->\r
-    _this = this\r
-    this.fetch().done ->\r
-      cb(_this.tmb_opt_img_tag())\r
+  symbol_option: () ->\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
-    if @id\r
-      @url = @url + @id\r
+  initialize: (attr = {}, options = {}) ->\r
+    super(attr, options)\r
   \r
-class Pettanr.SystemPicture.Collection extends Backbone.Collection\r
-  model: Pettanr.SystemPicture\r
-  url: '/system_pictures'\r