X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Flicense.js.coffee;h=e3ba76f71f05304493c53a9aeba4ef135f224e1d;hp=c5f32ebaa7a7e51c5c6b69d62eafc38c79850c43;hb=aa9eca25671c772ffec8f2f65aecc8a978a2f375;hpb=3f4cd8c9a4ce4336a659d7ad7f7093c0c1cd6ee9 diff --git a/app/assets/javascripts/models/license.js.coffee b/app/assets/javascripts/models/license.js.coffee index c5f32eba..e3ba76f7 100644 --- a/app/assets/javascripts/models/license.js.coffee +++ b/app/assets/javascripts/models/license.js.coffee @@ -1,5 +1,4 @@ class Pettanr.License extends Peta.SystemResource - url: '/licenses/' @singular: () -> 'License' @@ -12,32 +11,31 @@ class Pettanr.License extends Peta.SystemResource } license_group: () -> - r = new Pettanr.LicenseGroup({id: @get('license_group_id')}) + new Pettanr.Cache.Retriever(Pettanr.LicenseGroup, @get('license_group_id')) system_picture: () -> - new Pettanr.SystemPicture({id: @get('system_picture_id')}) + new Pettanr.Cache.Retriever(Pettanr.SystemPicture, @get('system_picture_id')) - symbol_option: (cb) -> - i = @system_picture() - i.fetch({cache: true}).done -> - cb(i.tmb_opt_img_tag()) + symbol_option: () -> + retriever = @system_picture() + @listenTo(retriever, 'retrieve', @retrieve_symbol) + retriever.retrieve() + + retrieve_symbol: (item) -> + @trigger('ready:symbol', item.tmb_opt_img_tag()) caption_with_group: () -> - new Pettanr.License.Caption({license: this, license_group: @license_group()}) - - initialize: () -> - if @id - @url = @url + @id - -class Pettanr.License.Caption extends Backbone.View - tagName: 'span' - initialize: (options) -> - @license = options.license - @license_group = options.license_group - - render: () -> - _this = this - @license_group.fetch({cache: true}).done -> - _this.$el.html(_this.license_group.get('caption') + '/' + _this.license.get('caption')) - this + retriever = @license_group() + @listenTo(retriever, 'retrieve', @retrieve_license_group) + retriever.retrieve() + + retrieve_license_group: (license_group) -> + caption = license_group.escape('caption') + '/' + @escape('caption') + @trigger('ready:caption', caption) + + is_own: () -> + true + + initialize: (attr = {}, options = {}) -> + super(attr, options)