X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fsystem_picture.js.coffee;h=36bda580ad0a2e8b8f5563ebda026814e2e401ab;hb=cc2dbf353c285c78423a8a29d7adf233e1651c6e;hp=debf30b0d608333de0ce2a6c3a26b7ad2773f4ec;hpb=2e1fe642e8bf2e237f6bcfb605d4d26da96fe2e9;p=pettanr%2Fpettanr.git diff --git a/app/assets/javascripts/models/system_picture.js.coffee b/app/assets/javascripts/models/system_picture.js.coffee index debf30b0..36bda580 100644 --- a/app/assets/javascripts/models/system_picture.js.coffee +++ b/app/assets/javascripts/models/system_picture.js.coffee @@ -1,5 +1,6 @@ class Pettanr.SystemPicture extends Peta.SystemResource url: '/system_pictures/' + @singular: () -> 'SystemPicture' @@ -10,6 +11,9 @@ class Pettanr.SystemPicture extends Peta.SystemResource id: null } + picture: () -> + new Pettanr.Cache.Retriever(Pettanr.Picture, @get('picture_id')) + filename: () -> @get('id') + '.' + @get('ext') @@ -23,16 +27,23 @@ class Pettanr.SystemPicture extends Peta.SystemResource {src: @r_url(), width: @get('width'), height: @get('height')} tmb_opt_img_tag: () -> - wh = Pettanr.Imager.thumbnail_size(@get('width'), @get('height')) - {src: @r_url(), width: wh[0], height: wh[1]} + new Pettanr.Image.SymbolPicture({ + attr: { + src: @r_url() + }, + picture: this + }) symbol_option: () -> - @tmb_opt_img_tag() + retriever = @retriever() + @listenTo(retriever, 'retrieve', @retrieve_symbol) + retriever.retrieve() + + retrieve_symbol: (item) -> + @trigger('ready:symbol', item.tmb_opt_img_tag()) - initialize: () -> + initialize: (attr = {}, options = {}) -> + super(attr, options) if @id @url = @url + @id -class Pettanr.SystemPicture.Collection extends Backbone.Collection - model: Pettanr.SystemPicture - url: '/system_pictures'