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=340b564f74b35376c1e1be8e79a6a3d92316ed00;hpb=3b1bdc62cc8471efd44ced48e95a9aed7a5ee2ee;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 340b564f..36bda580 100644 --- a/app/assets/javascripts/models/system_picture.js.coffee +++ b/app/assets/javascripts/models/system_picture.js.coffee @@ -11,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') @@ -24,22 +27,23 @@ class Pettanr.SystemPicture extends Peta.SystemResource {src: @r_url(), width: @get('width'), height: @get('height')} tmb_opt_img_tag: () -> - new Pettanr.Picture.SymbolPicture({ + new Pettanr.Image.SymbolPicture({ attr: { src: @r_url() }, picture: this }) - symbol_option: (cb) -> - _this = this - this.fetch().done -> - cb(_this.tmb_opt_img_tag()) + symbol_option: () -> + 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'