X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fviews%2Fpanels%2Fshow.js.coffee;h=bbfb829ac743835e5d45831a096e4dbf1df7cee0;hb=319a56e9e17f9d71a64222ce3233a5e3e21a87e0;hp=6e34cdb191ff29ceb8db02fd8cf1758202136aa5;hpb=532fbc6f0fc4e336898e59d6e51723b36439697b;p=pettanr%2Fpettanr.git diff --git a/app/assets/javascripts/views/panels/show.js.coffee b/app/assets/javascripts/views/panels/show.js.coffee index 6e34cdb1..bbfb829a 100644 --- a/app/assets/javascripts/views/panels/show.js.coffee +++ b/app/assets/javascripts/views/panels/show.js.coffee @@ -9,16 +9,13 @@ class Pettanr.Views.Panel.Show extends Backbone.View @operators = options.operators @spot = options.spot - icon_url = Pettanr.url(@panel.table_name(), 'show', {id: @panel.get('id')}) - caption_url = Pettanr.url(@panel.table_name(), 'show', {id: @panel.get('id')}) - prof_url = Pettanr.url(@panel.table_name(), 'show', {id: @panel.get('id'), format: 'prof'}) - @header = new Pettanr.Views.Scroll.ShowModule.Header({ + @header = new Pettanr.Views.Panel.ShowModule.Header({ item: @panel, operators: @operators, caption: @panel.get('caption'), - icon_url: icon_url, - caption_url: caption_url, - prof_url: prof_url + icon_url: @panel.show_url(), + caption_url: @panel.show_url(), + prof_url: @panel.prof_url() }) @body = new Pettanr.Views.Panel.Body({ panel: @panel, @@ -29,9 +26,16 @@ class Pettanr.Views.Panel.Show extends Backbone.View panel: @panel, operators: @operators }) - @credits = new Pettanr.Views.Panel.Show.Credits({ + @credits = new Pettanr.Views.Panel.ShowModule.Credits({ pictures: @panel.licensed_pictures() }) + @listenTo(@header, 'click:icon', @click_show) + @listenTo(@header, 'click:caption', @click_show) + @listenTo(@header, 'click:prof', @click_prof) + @listenTo(@footer, 'click:panel', @click_show) + @listenTo(@footer, 'click:author', @click_author) + @listenTo(@footer, 'click:edit', @click_edit) + @listenTo(@credits, 'click:credit:icon', @click_credit_icon) render: () -> this.$el.html('') @@ -43,23 +47,52 @@ class Pettanr.Views.Panel.Show extends Backbone.View this.$el.append(rb.render().el) this -class Pettanr.Views.Panel.Show.Credits extends Backbone.View + click_show: () -> + window.router.navigate(@panel.show_url(), true) + + click_author: () -> + window.router.navigate(@panel.author().show_url(), true) + + click_edit: () -> + window.router.navigate(@panel.edit_url(), true) + + click_prof: () -> + window.router.navigate(@panel.prof_url(), true) + + click_credit_icon: (item) -> + window.router.navigate(item.show_url(), true) + +class Pettanr.Views.Panel.ShowModule +class Pettanr.Views.Panel.ShowModule.Header extends Pettanr.Views.Show.Header + + initialize: (options) -> + super(options) + +class Pettanr.Views.Panel.ShowModule.Credits extends Backbone.View tagName: 'div' className: 'credits' initialize: (options) -> @pictures = options.pictures + @credited = {} render: () -> this.$el.html('') - _.each @pictures, (picture) => + _.each @pictures, (picture, pid) => @add_picture(picture) this add_picture: (picture) -> - if not @pictures[picture.get('id')] + + add_picture: (picture) -> + pid = picture.get('id') + if not @credited[pid] picture.fetch({cache: true}).done => - @pictures[picture.get('id')] = picture + @credited[pid] = picture credit = picture.credit_view() + @listenTo(credit, 'click:icon', @click_credit_icon) this.$el.append(credit.render().el) + click_credit_icon: (item) -> + @trigger('click:credit:icon', item) +