OSDN Git Service

fix new element dialog
[pettanr/pettanr.git] / app / assets / javascripts / models / picture.js.coffee
index 2af7542..45924e5 100644 (file)
@@ -30,8 +30,12 @@ class Pettanr.Picture extends Peta.Content
     {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
   tail_opt_img_tag: (img) ->\r
     {src: img, width: @get('width'), height: @get('height')}\r
@@ -46,7 +50,7 @@ class Pettanr.Picture extends Peta.Content
     lgn + '[' + ln + ']'\r
   \r
   symbol_option: () ->\r
-    this\r
+    @tmb_opt_img_tag()\r
   \r
   is_enable: () ->\r
     if @head().resource_picture()\r
@@ -74,10 +78,23 @@ class Pettanr.Picture extends Peta.Content
     return true if @is_own(operators)\r
     #@is_enable() and @is_head()\r
   \r
+  credit_icon_view: () ->\r
+    new Pettanr.Views.Picture.CreditIcon({item: this})\r
+  \r
+  credit_view: (with_icon = true) ->\r
+    new Pettanr.Views.Picture.Credit({item: this, with_icon: with_icon})\r
+  \r
+  fetch: (options) ->\r
+    if @id\r
+      @credit_icon = @credit_icon_view()\r
+      @credit = null\r
+      f = (data, status) =>\r
+        @credit = data\r
+        @trigger('ready')\r
+      $.get(@url + '/credit', null, f, 'html')\r
+    super(options)\r
+  \r
   initialize: () ->\r
     if @id\r
       @url = @url + @id\r
   \r
-class Pettanr.Picture.Collection extends Backbone.Collection\r
-  model: Pettanr.Picture\r
-  url: '/pictures'\r