X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fspeech_balloon_template.js.coffee;h=f86a1677e7f41b51b7018340f04a4838380ba320;hb=2e1fe642e8bf2e237f6bcfb605d4d26da96fe2e9;hp=dcf4c9f1ac7903ce53a3fe51b06c82aed85628fb;hpb=70027b80e56b5fbea8d63d520fbbf92050959f28;p=pettanr%2Fpettanr.git diff --git a/app/assets/javascripts/models/speech_balloon_template.js.coffee b/app/assets/javascripts/models/speech_balloon_template.js.coffee index dcf4c9f1..f86a1677 100644 --- a/app/assets/javascripts/models/speech_balloon_template.js.coffee +++ b/app/assets/javascripts/models/speech_balloon_template.js.coffee @@ -1,2 +1,40 @@ class Pettanr.SpeechBalloonTemplate extends Peta.Template - + relations: [{ + type: Backbone.HasMany, + key: 'speech_balloons', + relatedModel: 'SpeechBalloon', + collectionType: 'SpeechBalloonCollection', + reverseRelation: { + key: 'livesIn', + includeInJSON: 'id' + } + }] + + @singular: () -> + 'SpeechBalloonTemplate' + + @plural: () -> + 'SpeechBalloonTemplates' + + defaults: { + id: null + } + + get_system_picture: () -> + new Pettanr.SystemPicture({id: @get('system_picture_id')}) + + symbol_option: () -> + _this = this + r = @get_system_picture() + r.fetch({}).done () -> + _this.system_picture = r + _this.system_picture.tmb_opt_img_tag() + + initialize: () -> + if @id + @url = @url + @id + @system_picture = null + +class Pettanr.SpeechBalloonTemplate.Collection extends Backbone.Collection + model: Pettanr.SpeechBalloonTemplate + url: '/speech_balloon_templates'