From f2de6606262cd76e637dbf54581634fab3be205a Mon Sep 17 00:00:00 2001 From: yasushiito Date: Thu, 23 Jul 2015 11:57:17 +0900 Subject: [PATCH] fix: view --- .../filer/body/file_body/file_item.js.coffee | 11 +- .../file_body/file_item/caption/default.js.coffee | 2 +- .../file_item/caption/default/face/base.js.coffee | 2 +- .../caption/default/face/column.js.coffee | 2 +- .../caption/default/face/method.js.coffee | 2 +- .../file_body/file_item/symbol/default.js.coffee | 2 +- app/assets/javascripts/main.js.coffee | 4 +- app/assets/javascripts/models/artist.js.coffee | 3 - app/assets/javascripts/models/author.js.coffee | 3 - app/assets/javascripts/peta/item.js.coffee | 11 +- app/assets/javascripts/peta/leaf.js.coffee | 16 ++ app/assets/javascripts/view.js.coffee | 7 + app/assets/javascripts/view/empty_div.js.coffee | 8 + app/assets/javascripts/view/image.js.coffee | 17 +- .../javascripts/{views => view}/layout.js.coffee | 14 +- .../{views/layouts => view/layout}/blog.js.coffee | 6 +- app/assets/javascripts/view/layout/logo.js.coffee | 16 ++ .../{views/layouts => view/layout}/sns.js.coffee | 6 +- app/assets/javascripts/view/pick.js.coffee | 29 ++ app/assets/javascripts/view/show/header.js.coffee | 10 +- app/assets/javascripts/view/summary.js.coffee | 2 +- .../javascripts/view/summary/binder.js.coffee | 10 +- app/assets/javascripts/view/summary/leaf.js.coffee | 55 ++-- .../javascripts/views/artists/show.js.coffee | 5 - .../javascripts/views/authors/icon.js.coffee | 5 - .../javascripts/views/authors/show.js.coffee | 2 +- .../javascripts/views/balloons/summary.js.coffee | 24 +- app/assets/javascripts/views/comics/icon.js.coffee | 5 - app/assets/javascripts/views/comics/play.js.coffee | 10 - app/assets/javascripts/views/common.js.coffee | 319 --------------------- .../views/ground_colors/summary.js.coffee | 24 +- .../views/ground_pictures/summary.js.coffee | 12 +- app/assets/javascripts/views/history.js.coffee | 14 +- .../views/original_pictures/img.js.coffee | 18 -- .../views/original_pictures/show.js.coffee | 110 ++----- .../views/panel_pictures/icon.js.coffee | 5 - .../views/panel_pictures/summary.js.coffee | 4 +- app/assets/javascripts/views/panels/body.js.coffee | 52 ++-- app/assets/javascripts/views/panels/icon.js.coffee | 5 - .../views/resource_pictures/img.js.coffee | 18 -- .../javascripts/views/scroll_panels/icon.js.coffee | 5 - .../javascripts/views/scrolls/icon.js.coffee | 5 - .../javascripts/views/scrolls/play.js.coffee | 10 - app/assets/javascripts/views/sheets/icon.js.coffee | 5 - app/assets/javascripts/views/sheets/play.js.coffee | 10 - app/assets/javascripts/views/show.js.coffee | 212 -------------- .../views/speech_balloons/summary.js.coffee | 24 +- .../javascripts/views/speeches/summary.js.coffee | 24 +- .../javascripts/views/stories/icon.js.coffee | 5 - .../javascripts/views/stories/play.js.coffee | 10 - .../javascripts/views/users/account.js.coffee | 10 +- app/assets/javascripts/views/users/guest.js.coffee | 28 +- app/assets/javascripts/yasapp.js | 2 +- 53 files changed, 300 insertions(+), 920 deletions(-) create mode 100644 app/assets/javascripts/view/empty_div.js.coffee rename app/assets/javascripts/{views => view}/layout.js.coffee (89%) rename app/assets/javascripts/{views/layouts => view/layout}/blog.js.coffee (88%) create mode 100644 app/assets/javascripts/view/layout/logo.js.coffee rename app/assets/javascripts/{views/layouts => view/layout}/sns.js.coffee (70%) create mode 100644 app/assets/javascripts/view/pick.js.coffee delete mode 100644 app/assets/javascripts/views/authors/icon.js.coffee delete mode 100644 app/assets/javascripts/views/comics/icon.js.coffee delete mode 100644 app/assets/javascripts/views/common.js.coffee delete mode 100644 app/assets/javascripts/views/original_pictures/img.js.coffee delete mode 100644 app/assets/javascripts/views/panel_pictures/icon.js.coffee delete mode 100644 app/assets/javascripts/views/panels/icon.js.coffee delete mode 100644 app/assets/javascripts/views/resource_pictures/img.js.coffee delete mode 100644 app/assets/javascripts/views/scroll_panels/icon.js.coffee delete mode 100644 app/assets/javascripts/views/scrolls/icon.js.coffee delete mode 100644 app/assets/javascripts/views/sheets/icon.js.coffee delete mode 100644 app/assets/javascripts/views/show.js.coffee delete mode 100644 app/assets/javascripts/views/stories/icon.js.coffee diff --git a/app/assets/javascripts/locmare/filer/body/file_body/file_item.js.coffee b/app/assets/javascripts/locmare/filer/body/file_body/file_item.js.coffee index fd73c7f1..767c0ee3 100644 --- a/app/assets/javascripts/locmare/filer/body/file_body/file_item.js.coffee +++ b/app/assets/javascripts/locmare/filer/body/file_body/file_item.js.coffee @@ -57,15 +57,14 @@ class Locmare.FilerModule.BodyModule.FileBodyModule.FileItem extends Pettanr.Vie @filer().items add_pick: (target_model) -> - @pick = new Pettanr.Views.Common.PickIcon({ - name: target_model.pick_type(@item_name()), class_name: 'filer-item-pick' + @pick = new Pettanr.View.Pick(target_model.pick_type(@item_name()), { + class_name: 'filer-item-pick', + context: this, + click: () => + @trigger('click:pick', this) }) - @listenTo(@pick, 'click', @click_pick) @render() - click_pick: () -> - @trigger('click:pick', this) - click_symbol: () -> @trigger('click:symbol', this) diff --git a/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default.js.coffee b/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default.js.coffee index f97aa416..5aa518ed 100644 --- a/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default.js.coffee +++ b/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default.js.coffee @@ -6,7 +6,7 @@ class Locmare.FilerModule.BodyModule.FileBodyModule.FileItemModule.CaptionItemCo @listenTo(@face, 'ready:caption', @ready_caption) render: () -> - icon = new Pettanr.Views.Common.LoadIcon() + icon = new Pettanr.View.Minicon(Pettanr.View.Image.icon_loading_file()) this.$el.html(icon.render().el) @face.render() this diff --git a/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default/face/base.js.coffee b/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default/face/base.js.coffee index 1da63a43..d1bd84fc 100644 --- a/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default/face/base.js.coffee +++ b/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default/face/base.js.coffee @@ -12,7 +12,7 @@ class Locmare.FilerModule.BodyModule.FileBodyModule.FileItemModule.CaptionItemCo replace_empty: () -> if Pettanr.is_blank(@caption()) - empty = new Pettanr.Views.Common.EmptyCaption() + empty = new Pettanr.View.EmptyDiv() this.$el.html(empty.render().el) else this.$el.html(@caption()) diff --git a/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default/face/column.js.coffee b/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default/face/column.js.coffee index f979f8ce..7df05fc9 100644 --- a/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default/face/column.js.coffee +++ b/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default/face/column.js.coffee @@ -6,6 +6,6 @@ class Locmare.FilerModule.BodyModule.FileBodyModule.FileItemModule.CaptionItemCo # not render # get caption data and send message render: () -> - caption = Pettanr.Views.Common.replace_empty(@item.escape(@my_manifest.column_name)) + caption = Pettanr.View.replace_empty(@item.escape(@my_manifest.column_name)) @trigger('ready:caption', caption) diff --git a/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default/face/method.js.coffee b/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default/face/method.js.coffee index 4aabfe2c..6948aa7a 100644 --- a/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default/face/method.js.coffee +++ b/app/assets/javascripts/locmare/filer/body/file_body/file_item/caption/default/face/method.js.coffee @@ -9,7 +9,7 @@ class Locmare.FilerModule.BodyModule.FileBodyModule.FileItemModule.CaptionItemCo if @item[@method_name()] @item[@method_name()].call(@item, this, { success: (caption) => - @trigger('ready:caption', Pettanr.Views.Common.replace_empty(caption)) + @trigger('ready:caption', Pettanr.View.replace_empty(caption)) }) this diff --git a/app/assets/javascripts/locmare/filer/body/file_body/file_item/symbol/default.js.coffee b/app/assets/javascripts/locmare/filer/body/file_body/file_item/symbol/default.js.coffee index 6dffc039..9e385016 100644 --- a/app/assets/javascripts/locmare/filer/body/file_body/file_item/symbol/default.js.coffee +++ b/app/assets/javascripts/locmare/filer/body/file_body/file_item/symbol/default.js.coffee @@ -6,7 +6,7 @@ class Locmare.FilerModule.BodyModule.FileBodyModule.FileItemModule.SymbolItemCol @listenTo(@face, 'ready:symbol', @ready_symbol) render: () -> - icon = new Pettanr.Views.Common.LoadIcon() + icon = new Pettanr.View.Minicon(Pettanr.View.Image.icon_loading_file()) this.$el.html(icon.render().el) @face.render() this diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index fda39bbf..97981186 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -30,9 +30,9 @@ $ -> Pettanr.cache = new Pettanr.Cache({operators: new Pettanr.Operator({})}) layout = if Pettanr.is_sns() - new Pettanr.Views.Layout.Sns() + new Pettanr.View.Layout.Sns() else - new Pettanr.Views.Layout.Blog() + new Pettanr.View.Layout.Blog() $('#pettanr').html(layout.render().el) layout.start() diff --git a/app/assets/javascripts/models/artist.js.coffee b/app/assets/javascripts/models/artist.js.coffee index c3b42980..027b4a78 100644 --- a/app/assets/javascripts/models/artist.js.coffee +++ b/app/assets/javascripts/models/artist.js.coffee @@ -13,9 +13,6 @@ class Pettanr.Artist extends Peta.Owner overwrite: (options) -> - icon_with_caption_view: (half = true, column_name = 'name', length = 12) -> - new Pettanr.Views.Common.IconWithCaption({item: this, half: half, column_name: column_name, length: length}) - initialize: (attr = {}, options = {}) -> super(attr, options) diff --git a/app/assets/javascripts/models/author.js.coffee b/app/assets/javascripts/models/author.js.coffee index e0e3a680..5a92917c 100644 --- a/app/assets/javascripts/models/author.js.coffee +++ b/app/assets/javascripts/models/author.js.coffee @@ -13,9 +13,6 @@ class Pettanr.Author extends Peta.Owner overwrite: (options) -> - icon_with_caption_view: (half = true, column_name = 'name', length = 12) -> - new Pettanr.Views.Common.IconWithCaption({item: this, half: half, column_name: column_name, length: length}) - initialize: (attr = {}, options = {}) -> super(attr, options) diff --git a/app/assets/javascripts/peta/item.js.coffee b/app/assets/javascripts/peta/item.js.coffee index fa8ae555..c3e10843 100644 --- a/app/assets/javascripts/peta/item.js.coffee +++ b/app/assets/javascripts/peta/item.js.coffee @@ -290,9 +290,12 @@ class Peta.Item extends Backbone.Model options.success.call(context, symbol_item.symbol_file()) }) - face_file: () -> + @face_file: () -> new Pettanr.ImageFile('/images/' + @item_name() + '.gif') + face_file: () -> + @my_class().face_file() + # thumbnail size picture symbol_file: (subdir) -> new Pettanr.PictureFile(this, subdir) @@ -331,6 +334,12 @@ class Peta.Item extends Backbone.Model url = options.url || @show_url() new Pettanr.View.Button(url, _.escape(@label()), options) + # faced_label({ + # url: @show_url(), + # context: this, + # click: () => + # # ... + # }) faced_label: (options) -> new Pettanr.View.FacedLabel(this, options) diff --git a/app/assets/javascripts/peta/leaf.js.coffee b/app/assets/javascripts/peta/leaf.js.coffee index 6ac0c082..a9bf4870 100644 --- a/app/assets/javascripts/peta/leaf.js.coffee +++ b/app/assets/javascripts/peta/leaf.js.coffee @@ -1 +1,17 @@ class Peta.Leaf extends Peta.Content + + parent_model: () -> + Manifest.manifest().models[@my_class().my_peta().parent_item_name].classify() + + binder_model: () -> + @parent_model() + + destination_model: () -> + Manifest.manifest().models[@my_class().my_peta().destination_item_name].classify() + + binder_key: () -> + @my_class().my_peta().parent_item_name + '_id' + + destination_key: () -> + @my_class().my_peta().destination_item_name + '_id' + diff --git a/app/assets/javascripts/view.js.coffee b/app/assets/javascripts/view.js.coffee index 26ec9373..df7de310 100644 --- a/app/assets/javascripts/view.js.coffee +++ b/app/assets/javascripts/view.js.coffee @@ -14,6 +14,13 @@ class Pettanr.View extends Backbone.View options.content = content new Tag.Div(options) + @replace_empty: (caption) -> + if Pettanr.is_blank(caption) + empty = new Pettanr.View.EmptyDiv() + empty.render().el + else + caption + @face_button: (item, image, options = {}) -> icon = new Pettanr.View.Icon(image) new Pettanr.View.Button(item.show_url(), icon.render().el, options) diff --git a/app/assets/javascripts/view/empty_div.js.coffee b/app/assets/javascripts/view/empty_div.js.coffee new file mode 100644 index 00000000..cd7fc149 --- /dev/null +++ b/app/assets/javascripts/view/empty_div.js.coffee @@ -0,0 +1,8 @@ +class Pettanr.View.EmptyDiv extends Pettanr.View + tagName: 'div' + className: 'empty' + + render: () -> + this.$el.html('empty') + this + diff --git a/app/assets/javascripts/view/image.js.coffee b/app/assets/javascripts/view/image.js.coffee index cd9ce13b..474e6fba 100644 --- a/app/assets/javascripts/view/image.js.coffee +++ b/app/assets/javascripts/view/image.js.coffee @@ -29,6 +29,21 @@ class Pettanr.View.Image [Math.floor(w*hr/100), Math.floor(h*hr/100)] r + @image_dir: () -> + '/images/' + @icon_prof_file: () -> - new Pettanr.ImageFile('/images/prof.gif') + new Pettanr.ImageFile(@image_dir() + 'prof.gif') + + @icon_inspire_file: () -> + new Pettanr.ImageFile(@image_dir() + 'inspire.gif') + + @icon_loading_file: () -> + new Pettanr.ImageFile(@image_dir() + 'loading.gif') + + @icon_root_file: () -> + new Pettanr.ImageFile(@image_dir() + 'root.png') + + @icon_pick_file: (type) -> + new Pettanr.ImageFile(@image_dir() + type + '.png') diff --git a/app/assets/javascripts/views/layout.js.coffee b/app/assets/javascripts/view/layout.js.coffee similarity index 89% rename from app/assets/javascripts/views/layout.js.coffee rename to app/assets/javascripts/view/layout.js.coffee index 470e6699..6f58ac4d 100644 --- a/app/assets/javascripts/views/layout.js.coffee +++ b/app/assets/javascripts/view/layout.js.coffee @@ -1,19 +1,19 @@ -class Pettanr.Views.Layout -class Pettanr.Views.Layout.Base extends Pettanr.View +class Pettanr.View.Layout +class Pettanr.View.Layout.Base extends Pettanr.View -class Pettanr.Views.Layout.Sns extends Pettanr.Views.Layout.Base +class Pettanr.View.Layout.Sns extends Pettanr.View.Layout.Base className: 'layout-sns' initialize: (options) -> @global_router = new Pettanr.GlobalRouter({}) @listenTo(@global_router, 'go', @body_get) @gate = new Pettanr.BeforeUnload() - @header = new Pettanr.Views.Layout.Sns.Header({parent: this}) + @header = new Pettanr.View.Layout.Sns.Header({parent: this}) @history = new Pettanr.Views.History({parent: this}) @listenTo(@history, 'http_get', @body_http_get) @listenTo(@history, 'get', @body_get) - @body = new Pettanr.Views.Layout.Sns.Body({parent: this}) - @footer = new Pettanr.Views.Layout.Sns.Footer({parent: this}) + @body = new Pettanr.View.Layout.Sns.Body({parent: this}) + @footer = new Pettanr.View.Layout.Sns.Footer({parent: this}) render: () -> this.$el.html('') @@ -156,7 +156,7 @@ class Pettanr.Views.Layout.Sns extends Pettanr.Views.Layout.Base cancel: (params, form) -> -class Pettanr.Views.Layout.Blog extends Pettanr.Views.Layout.Base +class Pettanr.View.Layout.Blog extends Pettanr.View.Layout.Base className: 'layout-blog' start: () -> diff --git a/app/assets/javascripts/views/layouts/blog.js.coffee b/app/assets/javascripts/view/layout/blog.js.coffee similarity index 88% rename from app/assets/javascripts/views/layouts/blog.js.coffee rename to app/assets/javascripts/view/layout/blog.js.coffee index 03775922..4832ca6e 100644 --- a/app/assets/javascripts/views/layouts/blog.js.coffee +++ b/app/assets/javascripts/view/layout/blog.js.coffee @@ -1,4 +1,4 @@ -class Pettanr.Views.Layout.Blog.Header extends Pettanr.View +class Pettanr.View.Layout.Blog.Header extends Pettanr.View tagName: 'div' id: 'header' @@ -35,7 +35,7 @@ class Pettanr.Views.Layout.Blog.Header extends Pettanr.View @router.navigate(url, {trigger: true, replace: false}) @trigger('navigate', url) -class Pettanr.Views.Layout.Blog.Body extends Pettanr.View +class Pettanr.View.Layout.Blog.Body extends Pettanr.View tagName: 'div' id: 'body' @@ -68,7 +68,7 @@ class Pettanr.Views.Layout.Blog.Body extends Pettanr.View @router.navigate(url, {trigger: true, replace: false}) @trigger('navigate', url) -class Pettanr.Views.Layout.Blog.Footer extends Pettanr.View +class Pettanr.View.Layout.Blog.Footer extends Pettanr.View tagName: 'div' id: 'footer' diff --git a/app/assets/javascripts/view/layout/logo.js.coffee b/app/assets/javascripts/view/layout/logo.js.coffee new file mode 100644 index 00000000..e8d99bec --- /dev/null +++ b/app/assets/javascripts/view/layout/logo.js.coffee @@ -0,0 +1,16 @@ +class Pettanr.View.Layout.Logo extends Tag.Span + id: 'logo' + + constructor: (options) -> + super(options) + + initialize: (options) -> + options.class_name ||= 'logo' + title = Manifest.manifest().magic_numbers['profile']['users']['caption'] + url = '/' + @logo_button = new Pettanr.View.Button(url, _.escape(title), options) + + render: () -> + this.$el.html(@logo_button.render().el) + this + diff --git a/app/assets/javascripts/views/layouts/sns.js.coffee b/app/assets/javascripts/view/layout/sns.js.coffee similarity index 70% rename from app/assets/javascripts/views/layouts/sns.js.coffee rename to app/assets/javascripts/view/layout/sns.js.coffee index c82ec6c3..5cd21428 100644 --- a/app/assets/javascripts/views/layouts/sns.js.coffee +++ b/app/assets/javascripts/view/layout/sns.js.coffee @@ -1,4 +1,4 @@ -class Pettanr.Views.Layout.Sns.Header extends Pettanr.View +class Pettanr.View.Layout.Sns.Header extends Pettanr.View tagName: 'div' id: 'header' @@ -12,7 +12,7 @@ class Pettanr.Views.Layout.Sns.Header extends Pettanr.View refresh: (view) -> this.$el.html(view.el) -class Pettanr.Views.Layout.Sns.Body extends Pettanr.View +class Pettanr.View.Layout.Sns.Body extends Pettanr.View tagName: 'div' id: 'body' @@ -26,7 +26,7 @@ class Pettanr.Views.Layout.Sns.Body extends Pettanr.View refresh: (view) -> this.$el.html(view.el) -class Pettanr.Views.Layout.Sns.Footer extends Pettanr.View +class Pettanr.View.Layout.Sns.Footer extends Pettanr.View tagName: 'div' id: 'footer' diff --git a/app/assets/javascripts/view/pick.js.coffee b/app/assets/javascripts/view/pick.js.coffee new file mode 100644 index 00000000..349d6cf8 --- /dev/null +++ b/app/assets/javascripts/view/pick.js.coffee @@ -0,0 +1,29 @@ +class Pettanr.View.Pick extends Pettanr.View + + constructor: (@type, options) -> + super(options) + + initialize: (options) -> + @class_name = options.class_name + @content = if @is_button() + new Pettanr.View.Button('/pick', @icon().render().el, options) + else + @icon() + + render: () -> + this.$el.html('') + @el.className = @class_name if @class_name + this.$el.append(@content.render().el) + this + + is_button: () -> + @type != 'none' + + icon: () -> + new Pettanr.View.Icon(Pettanr.View.Image.icon_pick_file(@type)) + +class Pettanr.View.MiniPick extends Pettanr.View.Pick + + icon: () -> + new Pettanr.View.Minicon(Pettanr.View.Image.icon_pick_file(@type)) + diff --git a/app/assets/javascripts/view/show/header.js.coffee b/app/assets/javascripts/view/show/header.js.coffee index 794e429c..83eaa62c 100644 --- a/app/assets/javascripts/view/show/header.js.coffee +++ b/app/assets/javascripts/view/show/header.js.coffee @@ -38,13 +38,11 @@ class Pettanr.View.Show.Header extends Pettanr.View this.$el.append(@prof_button.render().el) this - click_pick: () -> - @trigger('click:pick') - add_pick: (target_model) -> - @pick = new Pettanr.Views.Common.PickIcon({ - name: target_model.pick_type(@item.item_name()), half: true + @pick = new Pettanr.View.MiniPick(target_model.pick_type(@item.item_name()), { + context: this, + click: () => + @trigger('click:pick') }) - @listenTo(@pick, 'click', @click_pick) @render() diff --git a/app/assets/javascripts/view/summary.js.coffee b/app/assets/javascripts/view/summary.js.coffee index a4e3aeb5..16dba531 100644 --- a/app/assets/javascripts/view/summary.js.coffee +++ b/app/assets/javascripts/view/summary.js.coffee @@ -8,7 +8,7 @@ class Pettanr.View.Summary extends Pettanr.View @listenTo(this, 'ready', @render) clear: () -> - icon = new Pettanr.Views.Common.LoadIcon() + icon = new Pettanr.View.Minicon(Pettanr.View.Image.icon_loading_file()) this.$el.html(icon.render().el) this diff --git a/app/assets/javascripts/view/summary/binder.js.coffee b/app/assets/javascripts/view/summary/binder.js.coffee index 5bf5e8da..291ac055 100644 --- a/app/assets/javascripts/view/summary/binder.js.coffee +++ b/app/assets/javascripts/view/summary/binder.js.coffee @@ -13,15 +13,19 @@ class Pettanr.View.Summary.Binder extends Pettanr.View }) @item.get_parent('author', this, { success: (@author) => - @author_icon_with_caption = @author.icon_with_caption_view(true, 'name', 12) - @listenTo(@author_icon_with_caption, 'click', @author_click) + @author_mini_faced_label = @author.mini_faced_label({ + context: this, + click: () => + @trigger('http_get', @author.show_url()) + }) + this.$el.append(@author_mini_faced_label.render().el) @trigger('ready') }) render: () -> this.$el.html('') this.$el.append(@visible.render().el) - this.$el.append(@author_icon_with_caption.render().el) + this.$el.append(@author_mini_faced_label.render().el) this author_click: () -> diff --git a/app/assets/javascripts/view/summary/leaf.js.coffee b/app/assets/javascripts/view/summary/leaf.js.coffee index 35dfb0a7..7adf4eda 100644 --- a/app/assets/javascripts/view/summary/leaf.js.coffee +++ b/app/assets/javascripts/view/summary/leaf.js.coffee @@ -3,10 +3,8 @@ class Pettanr.View.Summary.Leaf extends Pettanr.View initialize: (options) -> super(options) @item = options.item - @binder_item_name = options.binder_item_name - @destination_item_name = options.destination_item_name - @binder_view = new Tag.Span({}) - @destination_view = new Tag.Span({}) + @binder = new Pettanr.View.Summary.Leaf.Binder(@item, {}) + @destination = new Pettanr.View.Summary.Leaf.Binder(@item, options.destination_item_name, {}) @load() load: () -> @@ -18,19 +16,6 @@ class Pettanr.View.Summary.Leaf extends Pettanr.View @trigger('ready') load_binder: () -> - @item.get_parent(@binder_item_name, this, { - success: (@binder) => - @binder_icon = @binder.icon_view(true) - @listenTo(@binder_icon, 'click', @binder_click) - @binder.get_parent('author', this, { - success: (@binder_author) => - @binder_author_icon_with_caption = @binder_author.icon_with_caption_view(true, 'name', 12) - @listenTo(@binder_author_icon_with_caption, 'click', @binder_author_click) - @binder_view.$el.append(@binder_icon.render().el) - @binder_view.$el.append(@binder_author_icon_with_caption.render().el) - @trigger('load_binder') - }) - }) load_destination: () -> @item.get_parent(@destination_item_name, this, { @@ -39,18 +24,20 @@ class Pettanr.View.Summary.Leaf extends Pettanr.View @listenTo(@destination_icon, 'click', @destination_click) @destination.get_parent('author', this, { success: (@destination_author) => - @destination_author_icon_with_caption = @destination_author.icon_with_caption_view(true, 'name', 12) - @listenTo(@destination_author_icon_with_caption, 'click', @destination_author_click) - @destination_view.$el.append(@destination_icon.render().el) - @destination_view.$el.append(@destination_author_icon_with_caption.render().el) + @destination_author_mini_faced_label = @destination_author.mini_faced_label({ + context: this, + click: () => + @trigger('http_get', @destination_author.show_url()) + }) + this.$el.append(@destination_author_mini_faced_label.render().el) @trigger('load_destination') }) }) render: () -> this.$el.html('') - this.$el.append(@binder_view.render().el) - this.$el.append(@destination_view.render().el) + this.$el.append(@binder_author_mini_faced_label.render().el) + this.$el.append(@destination_author_mini_faced_label.render().el) this binder_click: () -> @@ -65,3 +52,25 @@ class Pettanr.View.Summary.Leaf extends Pettanr.View destination_author_click: () -> @trigger('http_get', @destination_author_icon_with_caption.url()) +class Pettanr.View.Summary.Leaf.Binder extends Tag.Span + + constructor: (@item, @binder_item_name, options) -> + super(options) + @binder_model = @item.my_class().binder_model() + + initialize: (options) -> + @item.get_parent(@binder_model.item_name(), this, { + success: (@binder) => + @face_button = @binder.mini_face_button(true) + @binder.get_parent('author', this, { + success: (@author) => + @author_mini_faced_label = @author.mini_faced_label({ + context: this, + click: () => + @trigger('http_get', @author.show_url()) + }) + this.$el.append(@author_mini_faced_label.render().el) + @trigger('load_binder') + }) + }) + diff --git a/app/assets/javascripts/views/artists/show.js.coffee b/app/assets/javascripts/views/artists/show.js.coffee index 0761d9f5..b8926094 100644 --- a/app/assets/javascripts/views/artists/show.js.coffee +++ b/app/assets/javascripts/views/artists/show.js.coffee @@ -1,9 +1,4 @@ class Pettanr.Views.Artist.ShowModule -class Pettanr.Views.Artist.ShowModule.Header extends Pettanr.Views.Show.Header - - initialize: (options) -> - super(options) - class Pettanr.Views.Artist.ShowModule.ResourcePictures extends Pettanr.View initialize: (options) -> diff --git a/app/assets/javascripts/views/authors/icon.js.coffee b/app/assets/javascripts/views/authors/icon.js.coffee deleted file mode 100644 index ff07fcc6..00000000 --- a/app/assets/javascripts/views/authors/icon.js.coffee +++ /dev/null @@ -1,5 +0,0 @@ -class Pettanr.Views.Author.Icon extends Pettanr.Views.Common.Icon - - initialize: (options) -> - super(options) - diff --git a/app/assets/javascripts/views/authors/show.js.coffee b/app/assets/javascripts/views/authors/show.js.coffee index 88872247..4b932df4 100644 --- a/app/assets/javascripts/views/authors/show.js.coffee +++ b/app/assets/javascripts/views/authors/show.js.coffee @@ -60,7 +60,7 @@ class Pettanr.Views.Author.ShowModule.Panels extends Pettanr.View super(options) @item = options.item @panels_body = new Pettanr.Views.Author.ShowModule.PanelsBody({item: @item}) - @credits = new Pettanr.View.Credits({parent: this}) + @credits = new Pettanr.View.Credits(this, {icon: true}) render: () -> @listenTo(@panels_body, 'ready', @ready) diff --git a/app/assets/javascripts/views/balloons/summary.js.coffee b/app/assets/javascripts/views/balloons/summary.js.coffee index bc5aa9bd..c83ab0ae 100644 --- a/app/assets/javascripts/views/balloons/summary.js.coffee +++ b/app/assets/javascripts/views/balloons/summary.js.coffee @@ -7,12 +7,18 @@ class Pettanr.Views.Balloon.Summary extends Pettanr.View.Summary success: (@speech_balloon) => @speech_balloon.get_parent('panel', this, { success: (@panel) => - @panel_icon = new Pettanr.Views.Common.Icon({item: @panel, half: true}) - @listenTo(@panel_icon, 'click', @panel_click) + @panel_face_button = @panel.mini_face_button({ + context: this, + click: () -> + @trigger('http_get', @panel.show_url()) + }) @panel.get_parent('author', this, { success: (@author) => - @author_icon_with_caption = @author.icon_with_caption_view(true, 'name', 12) - @listenTo(@author_icon_with_caption, 'click', @author_click) + @author_faced_label = @author.mini_faced_label({ + context: this, + click: () -> + @trigger('http_get', @author.show_url()) + }) @trigger('ready') }) }) @@ -20,13 +26,7 @@ class Pettanr.Views.Balloon.Summary extends Pettanr.View.Summary render: () -> this.$el.html('') - this.$el.append(@panel_icon.render().el) - this.$el.append(@author_icon_with_caption.render().el) + this.$el.append(@panel_face_button.render().el) + this.$el.append(@author_faced_label.render().el) this - panel_click: () -> - @trigger('http_get', @panel_icon.url()) - - author_click: () -> - @trigger('http_get', @author_icon_with_caption.url()) - diff --git a/app/assets/javascripts/views/comics/icon.js.coffee b/app/assets/javascripts/views/comics/icon.js.coffee deleted file mode 100644 index e060500c..00000000 --- a/app/assets/javascripts/views/comics/icon.js.coffee +++ /dev/null @@ -1,5 +0,0 @@ -class Pettanr.Views.Comic.Icon extends Pettanr.Views.Common.Icon - - initialize: (options) -> - super(options) - diff --git a/app/assets/javascripts/views/comics/play.js.coffee b/app/assets/javascripts/views/comics/play.js.coffee index ea1eff0f..958409de 100644 --- a/app/assets/javascripts/views/comics/play.js.coffee +++ b/app/assets/javascripts/views/comics/play.js.coffee @@ -1,14 +1,4 @@ class Pettanr.Views.Comic.PlayModule -class Pettanr.Views.Comic.PlayModule.Header extends Pettanr.Views.Show.Header - - initialize: (options) -> - super(options) - -class Pettanr.Views.Comic.PlayModule.Owner extends Pettanr.Views.Show.Owner - - initialize: (options) -> - super(options) - class Pettanr.Views.Comic.PlayModule.Footer extends Pettanr.View tagName: 'table' className: 'no-border' diff --git a/app/assets/javascripts/views/common.js.coffee b/app/assets/javascripts/views/common.js.coffee deleted file mode 100644 index 96cb72ce..00000000 --- a/app/assets/javascripts/views/common.js.coffee +++ /dev/null @@ -1,319 +0,0 @@ -class Pettanr.Views.Common - @replace_empty: (caption) -> - if Pettanr.is_blank(caption) - empty = new Pettanr.Views.Common.EmptyCaption() - empty.render().el - else - caption - -class Pettanr.Views.Common.Logo extends Tag.Span - id: 'logo' - - initialize: () -> - title = Manifest.manifest().magic_numbers['profile']['users']['caption'] - @logo_button = new Tag.A({ - attr: {href: '/'}, - class_name: 'logo', - content: _.escape(title) - }) - @listenTo(@logo_button, 'click', @click) - - render: () -> - this.$el.html(@logo_button.render().el) - this - - click: () -> - @trigger('click') - - -class Pettanr.Views.Common.EmptyIcon extends Tag.Img - - initialize: (options) -> - @attr = {} - @width = Manifest.manifest().magic_numbers['thumbnail_width'] - @height = Manifest.manifest().magic_numbers['thumbnail_height'] - @width = Pettanr.to_i(@width/2) - @height = Pettanr.to_i(@height/2) - @attr['src'] = @file_name() - @attr['width'] = @width - @attr['height'] = @height - @attr['alt'] = 'Loading' - @attr['title'] = 'Loading' - opt = { - attr: @attr, - } - super(opt) - - file_name: () -> - '/images/empty.gif' - -class Pettanr.Views.Common.LoadIcon extends Pettanr.Views.Common.EmptyIcon - - file_name: () -> - '/images/loading.gif' - -class Pettanr.Views.Common.RootIcon extends Pettanr.Views.Common.EmptyIcon - - file_name: () -> - '/images/root.png' - -class Pettanr.Views.Common.PickIcon extends Pettanr.View - - initialize: (options) -> - @class_name = options.class_name - @name = options.name - @half = options.half - @button = if @is_button() - @linked_icon() - else - @icon() - - render: () -> - this.$el.html('') - @el.className = @class_name if @class_name - if @is_button() - @listenTo(@button, 'click', @click) - this.$el.append(@button.render().el) - this - - is_button: () -> - @name != 'none' - - icon: () -> - new Pettanr.Image.SymbolImg({attr: {src: '/images/' + @name + '.gif'}, half: @half}) - - linked_icon: () -> - new Tag.A({ - attr: {href: '#'}, - content: @icon().render().el - }) - - click: () -> - @trigger('click', this) - -class Pettanr.Views.Common.EmptyCaption extends Pettanr.View - tagName: 'div' - className: 'empty' - - render: () -> - this.$el.html('empty') - this - -class Pettanr.Views.Common.Icon extends Pettanr.View - tagName: 'span' - - initialize: (options) -> - @item = options.item - @half = options.half - @icon_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id')}) - @icon = new Pettanr.Image.Icon({item: @item, half: @half}) - @icon_button = new Tag.A({ - attr: {href: '/' + @icon_url}, - class_name: 'icon', - content: @icon.render().el - }) - @listenTo(@icon_button, 'click', @click) - - render: () -> - this.$el.html(@icon_button.render().el) - this - - click: () -> - @trigger('click') - - url: () -> - @icon_url - -class Pettanr.Views.Common.Caption extends Pettanr.View - tagName: 'span' - - initialize: (options) -> - @item = options.item - @column_name = options.column_name - @length = options.length - @name = Pettanr.truncate(@item.get(@column_name), @length) - @url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id')}) - @linked_name = new Tag.A({ - attr: {href: '/' + @url}, - content: _.escape(@name) - }) - @listenTo(@linked_name, 'click', @click) - - render: () -> - this.$el.html(@linked_name.render().el) - this - - click: () -> - @trigger('click') - - url: () -> - @url - -class Pettanr.Views.Common.IconWithCaption extends Pettanr.View - tagName: 'span' - - initialize: (options) -> - @item = options.item - @half = options.half - @column_name = options.column_name - @length = options.length - @icon = new Pettanr.Views.Common.Icon({item: @item, half: @half}) - @caption = new Pettanr.Views.Common.Caption({item: @item, column_name: @column_name, length: @length}) - @listenTo(@icon, 'click', @click) - @listenTo(@caption, 'click', @click) - - render: () -> - this.$el.html('') - this.$el.append(@icon.render().el) - this.$el.append(@caption.render().el) - this - - click: () -> - @trigger('click') - - url: () -> - @icon.url() - -class Pettanr.Views.Common.Summary extends Pettanr.View - - initialize: (options) -> - @clear() - @listenTo(this, 'ready', @render) - - clear: () -> - icon = new Pettanr.Views.Common.LoadIcon() - this.$el.html(icon.render().el) - this - - render: () -> - this.$el.html('') - this - -class Pettanr.Views.Common.Binder -class Pettanr.Views.Common.Binder.Summary extends Pettanr.Views.Common.Summary - - initialize: (options) -> - super(options) - @item = options.item - @visible_t = options.visible_t - @visible_column_name = options.visible_column_name - @load() - - load: () -> - @visible = new Tag.Div({ - content: Pettanr.AppHelper.t_selected_item(@visible_t, @item.get(@visible_column_name)) - }) - @item.get_parent('author', this, { - success: (@author) => - @author_icon_with_caption = @author.icon_with_caption_view(true, 'name', 12) - @listenTo(@author_icon_with_caption, 'click', @author_click) - @trigger('ready') - }) - - render: () -> - this.$el.html('') - this.$el.append(@visible.render().el) - this.$el.append(@author_icon_with_caption.render().el) - this - - author_click: () -> - @trigger('http_get', @author_icon_with_caption.url()) - -class Pettanr.Views.Common.Leaf -class Pettanr.Views.Common.Leaf.Summary extends Pettanr.Views.Common.Summary - - initialize: (options) -> - super(options) - @item = options.item - @binder_item_name = options.binder_item_name - @destination_item_name = options.destination_item_name - @binder_view = new Tag.Span({}) - @destination_view = new Tag.Span({}) - @load() - - load: () -> - @listenTo(this, 'load_binder', @load_destination) - @listenTo(this, 'load_destination', @ready) - @load_binder() - - ready: () -> - @trigger('ready') - - load_binder: () -> - @item.get_parent(@binder_item_name, this, { - success: (@binder) => - @binder_icon = @binder.icon_view(true) - @listenTo(@binder_icon, 'click', @binder_click) - @binder.get_parent('author', this, { - success: (@binder_author) => - @binder_author_icon_with_caption = @binder_author.icon_with_caption_view(true, 'name', 12) - @listenTo(@binder_author_icon_with_caption, 'click', @binder_author_click) - @binder_view.$el.append(@binder_icon.render().el) - @binder_view.$el.append(@binder_author_icon_with_caption.render().el) - @trigger('load_binder') - }) - }) - - load_destination: () -> - @item.get_parent(@destination_item_name, this, { - success: (@destination) => - @destination_icon = @destination.icon_view(true) - @listenTo(@destination_icon, 'click', @destination_click) - @destination.get_parent('author', this, { - success: (@destination_author) => - @destination_author_icon_with_caption = @destination_author.icon_with_caption_view(true, 'name', 12) - @listenTo(@destination_author_icon_with_caption, 'click', @destination_author_click) - @destination_view.$el.append(@destination_icon.render().el) - @destination_view.$el.append(@destination_author_icon_with_caption.render().el) - @trigger('load_destination') - }) - }) - - render: () -> - this.$el.html('') - this.$el.append(@binder_view.render().el) - this.$el.append(@destination_view.render().el) - this - - binder_click: () -> - @trigger('http_get', @binder_icon.url()) - - destination_click: () -> - @trigger('http_get', @destination_icon.url()) - - binder_author_click: () -> - @trigger('http_get', @binder_author_icon_with_caption.url()) - - destination_author_click: () -> - @trigger('http_get', @destination_author_icon_with_caption.url()) - -class Pettanr.Views.Common.Credits extends Pettanr.View - tagName: 'div' - className: 'credits' - - initialize: (options) -> - @parent = options.parent - @licensed_pictures = {} - - clear: () -> - this.$el.html('') - - render: () -> - this.$el.html('') - this - - push: (retrievers) -> - _.each retrievers, (retriever, pid) => - Pettanr.Picture.retrieve(pid, this, { - success: (picture) => - pid = picture.get('id') - return if @licensed_pictures[pid] - @licensed_pictures[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) - diff --git a/app/assets/javascripts/views/ground_colors/summary.js.coffee b/app/assets/javascripts/views/ground_colors/summary.js.coffee index 14a1e987..4793d034 100644 --- a/app/assets/javascripts/views/ground_colors/summary.js.coffee +++ b/app/assets/javascripts/views/ground_colors/summary.js.coffee @@ -5,25 +5,25 @@ class Pettanr.Views.GroundColor.Summary extends Pettanr.View.Summary @item = options.item @item.get_parent('panel', this, { success: (@panel) => - @panel_icon = new Pettanr.Views.Common.Icon({item: @panel, half: true}) - @listenTo(@panel_icon, 'click', @panel_click) + @panel_face_button = @panel.mini_face_button({ + context: this, + click: () -> + @trigger('http_get', @panel.show_url()) + }) @panel.get_parent('author', this, { success: (@author) => - @author_icon_with_caption = @author.icon_with_caption_view(true, 'name', 12) - @listenTo(@author_icon_with_caption, 'click', @author_click) + @author_faced_label = @author.mini_faced_label({ + context: this, + click: () -> + @trigger('http_get', @author.show_url()) + }) @trigger('ready') }) }) render: () -> this.$el.html('') - this.$el.append(@panel_icon.render().el) - this.$el.append(@author_icon_with_caption.render().el) + this.$el.append(@panel_face_button.render().el) + this.$el.append(@author_faced_label.render().el) this - panel_click: () -> - @trigger('http_get', @panel_icon.url()) - - author_click: () -> - @trigger('http_get', @author_icon_with_caption.url()) - diff --git a/app/assets/javascripts/views/ground_pictures/summary.js.coffee b/app/assets/javascripts/views/ground_pictures/summary.js.coffee index 0ce9dbbb..ff79981c 100644 --- a/app/assets/javascripts/views/ground_pictures/summary.js.coffee +++ b/app/assets/javascripts/views/ground_pictures/summary.js.coffee @@ -8,8 +8,11 @@ class Pettanr.Views.GroundPicture.Summary extends Pettanr.View.Summary @credit = new Pettanr.View.Credit(@picture, {}) @item.get_parent('panel', this, { success: (@panel) => - @panel_icon = new Pettanr.Views.Common.Icon({item: @panel, half: true}) - @listenTo(@panel_icon, 'click', @panel_click) + @panel_face_button = @panel.mini_face_button({ + context: this, + click: () -> + @trigger('http_get', @panel.show_url()) + }) @trigger('ready') }) }) @@ -17,9 +20,6 @@ class Pettanr.Views.GroundPicture.Summary extends Pettanr.View.Summary render: () -> this.$el.html('') this.$el.append(@credit.render().el) - this.$el.append(@panel_icon.render().el) + this.$el.append(@panel_face_button.render().el) this - panel_click: () -> - @trigger('http_get', @panel_icon.url()) - diff --git a/app/assets/javascripts/views/history.js.coffee b/app/assets/javascripts/views/history.js.coffee index 384732b3..843c93e8 100644 --- a/app/assets/javascripts/views/history.js.coffee +++ b/app/assets/javascripts/views/history.js.coffee @@ -116,18 +116,16 @@ class Pettanr.Views.History.Root extends Pettanr.View tagName: 'div' initialize: (options) -> - icon = new Pettanr.Views.Common.RootIcon() - @button = new Tag.A({ - attr: {href: '/'}, - content: icon.render().el + image = new Pettanr.ImageFile(Pettanr.View.Image.icon_root_file()) + icon = new Pettanr.View.Icon(image) + @button = new Pettanr.View.Button('/', icon.render().el, { + context: this, + click: () => + @trigger('click') }) - @listenTo(@button, 'click', @click) render: () -> this.$el.html('') this.$el.append(@button.render().el) this - click: () -> - @trigger('click') - diff --git a/app/assets/javascripts/views/original_pictures/img.js.coffee b/app/assets/javascripts/views/original_pictures/img.js.coffee deleted file mode 100644 index d0e2c4f4..00000000 --- a/app/assets/javascripts/views/original_pictures/img.js.coffee +++ /dev/null @@ -1,18 +0,0 @@ -class Pettanr.Views.OriginalPicture.Img extends Pettanr.View - tagName: 'img' - - initialize: (options) -> - @item = options.item - - render: () -> - this.$el.html('') - this.$el.attr(@attr()) - this - - attr: () -> - { - src: @item.src(), - width: Pettanr.to_s(Math.abs(@item.get('width'))) + 'px', - height: Pettanr.to_s(Math.abs(@item.get('height'))) + 'px', - } - diff --git a/app/assets/javascripts/views/original_pictures/show.js.coffee b/app/assets/javascripts/views/original_pictures/show.js.coffee index 3d68e790..2e04f4d2 100644 --- a/app/assets/javascripts/views/original_pictures/show.js.coffee +++ b/app/assets/javascripts/views/original_pictures/show.js.coffee @@ -1,76 +1,4 @@ class Pettanr.Views.OriginalPicture.ShowModule -class Pettanr.Views.OriginalPicture.ShowModule.LinkedLicenseButton extends Tag.A - - initialize: (options) -> - item = options.item - super({ - attr: {href: '/' + item.license_url()}, - content: I18n.t('original_pictures.show.select') - }) - -class Pettanr.Views.OriginalPicture.ShowModule.LinkedReplaceButton extends Tag.A - - initialize: (options) -> - item = options.item - super({ - attr: {href: '/' + item.edit_url()}, - content: I18n.t('original_pictures.show.replace') - }) - -class Pettanr.Views.OriginalPicture.ShowModule.LinkedDropButton extends Tag.A - - initialize: (options) -> - item = options.item - super({ - attr: {href: '/' + item.destroy_url()}, - content: I18n.t('link.destroy') - }) - -class Pettanr.Views.OriginalPicture.ShowModule.OwnerFooter extends Pettanr.View - tagName: 'div' - className: 'show-owner-footer' - - initialize: (@item, options) -> - @license = new Pettanr.Views.OriginalPicture.ShowModule.LinkedLicenseButton({item: @item}) - @edit = new Pettanr.Views.OriginalPicture.ShowModule.LinkedReplaceButton({item: @item}) - @destroy = new Pettanr.Views.OriginalPicture.ShowModule.LinkedDropButton({item: @item}) - @listenTo(@license, 'click', @click_license) - @listenTo(@edit, 'click', @click_edit) - @listenTo(@destroy, 'click', @click_destroy) - - render: () -> - super() - this.$el.append(@license.render().el) - this.$el.append(@edit.render().el) - dh = new Tag.H3({ - content: 'expert only' - }) - this.$el.append(dh.render().el) - this.$el.append(@destroy.render().el) - this - - click_license: () -> - @trigger('click:license') - - click_edit: () -> - @trigger('click:edit') - - click_destroy: () -> - @trigger('click:destroy') - -class Pettanr.Views.OriginalPicture.ShowModule.Owner extends Pettanr.Views.Show.Owner - - initialize: (options) -> - super(options) - @listenTo(@footer, 'click:license', @click_license) - - click_license: () -> - @trigger('click:footer:license') - @trigger('click:license') - - footer_class: () -> - Pettanr.Views.OriginalPicture.ShowModule.OwnerFooter - class Pettanr.Views.OriginalPicture.ShowModule.History extends Pettanr.View initialize: (options) -> @@ -97,23 +25,28 @@ class Pettanr.Views.OriginalPicture.ShowModule.History extends Pettanr.View class Pettanr.Views.OriginalPicture.Show extends Pettanr.View.Show initialize: (options) -> - @header = new Pettanr.View.Show.Header(@item, this, @binder_header_options()) + @header = new Pettanr.View.Show.Header(@item, this, @default_header_options()) @authored_by = @item.authored_by() - @img = new Pettanr.Views.OriginalPicture.Img({item: @item}) + @img = @item.real_picture() + @listenTo(@header, 'click:pick', @click_pick) + @listenTo(@authored_by, 'click', @click_authored_by) @owner = new Pettanr.View.Show.Footer(@item, this, { actions: { - license: { + select: { + url: @original_picture.license_url(), dic_name: 'original_pictures.show.select', click: () => @create_dialog() @trigger('click:license', @dialog) }, - edit: { + replace: { + url: @original_picture.edit_url(), dic_name: 'original_pictures.show.replace', click: () => @trigger('http_get', @item.edit_url()) }, destroy: { + url: @item.destroy_url(), click: () => redirect = (url) => @trigger('http_get', url) @@ -122,7 +55,6 @@ class Pettanr.Views.OriginalPicture.Show extends Pettanr.View.Show }, }) @history = new Pettanr.Views.OriginalPicture.ShowModule.History({item: @item}) - @listenTo(@authored_by, 'click', @click_authored_by) @listenTo(@history, 'http_get', @http_get) render: () -> @@ -130,22 +62,20 @@ class Pettanr.Views.OriginalPicture.Show extends Pettanr.View.Show this.$el.append(@header.render().el) this.$el.append(@authored_by.render().el) this.$el.append(@img.render().el) - this.$el.append(@owner.render().el) + @item.get_parent('picture', this, { + success: (@picture) => + @credit = new Pettanr.View.Credit(@picture, { + icon: { + click: () => + @trigger('http_get', @picture.show_url()) + } + }) + this.$el.append(@credit.render().el) + this.$el.append(@owner.render().el) + }) this.$el.append(@history.render().el) this - click_license: () -> - @create_dialog() - @trigger('click:license', @dialog) - - click_edit: () -> - @trigger('http_get', @item.edit_url()) - - click_destroy: () -> - redirect = (url) => - @trigger('http_get', url) - Pettanr.Proxy.destroy(@item, {redirect: redirect}) - http_get: (url) -> @trigger('http_get', url) diff --git a/app/assets/javascripts/views/panel_pictures/icon.js.coffee b/app/assets/javascripts/views/panel_pictures/icon.js.coffee deleted file mode 100644 index 2b14b44e..00000000 --- a/app/assets/javascripts/views/panel_pictures/icon.js.coffee +++ /dev/null @@ -1,5 +0,0 @@ -class Pettanr.Views.SpeechBalloon.Icon extends Pettanr.Views.Common.Icon - - initialize: (options) -> - super(options) - diff --git a/app/assets/javascripts/views/panel_pictures/summary.js.coffee b/app/assets/javascripts/views/panel_pictures/summary.js.coffee index f25ee8f5..b8bf1944 100644 --- a/app/assets/javascripts/views/panel_pictures/summary.js.coffee +++ b/app/assets/javascripts/views/panel_pictures/summary.js.coffee @@ -8,7 +8,7 @@ class Pettanr.Views.PanelPicture.Summary extends Pettanr.View.Summary @credit = new Pettanr.View.Credit(@picture, {}) @item.get_parent('panel', this, { success: (@panel) => - @mini_face_button =@panel.mini_face_button({ + @panel_face_button =@panel.mini_face_button({ context: this, click: () -> @trigger('http_get', @panel.show_url()) @@ -20,6 +20,6 @@ class Pettanr.Views.PanelPicture.Summary extends Pettanr.View.Summary render: () -> this.$el.html('') this.$el.append(@credit.render().el) - this.$el.append(@mini_face_button.render().el) + this.$el.append(@panel_face_button.render().el) this diff --git a/app/assets/javascripts/views/panels/body.js.coffee b/app/assets/javascripts/views/panels/body.js.coffee index 1462849b..d458d4f9 100644 --- a/app/assets/javascripts/views/panels/body.js.coffee +++ b/app/assets/javascripts/views/panels/body.js.coffee @@ -123,35 +123,39 @@ class Pettanr.Views.Panel.Footer extends Pettanr.View this.$el.html('') @panel.get_parent('author', this, { success: (@author) => - @panel_icon = new Pettanr.Views.Panel.Icon({item: @panel, half: true}) - @author_icon = new Pettanr.Views.Author.Icon({item: @author, half: true}) - @inspire_icon = new Pettanr.Views.Show.LinkedInspireIcon({item: @panel, half: true}) - @edit_button = new Pettanr.Views.Show.LinkedEditButton({item: @panel}) - @listenTo(@panel_icon, 'click', @click_panel) - @listenTo(@author_icon, 'click', @click_author) - @listenTo(@edit_button, 'click', @click_edit) - @listenTo(@inspire_icon, 'click', @click_inspire) - this.$el.append(@panel_icon.render().el) - this.$el.append(@author_icon.render().el) + panel_face_button = @panel.mini_face_button({ + context: this, + click: () -> + @trigger('click:panel') + }) + author_face_button = @author.mini_face_button({ + context: this, + click: () -> + @trigger('click:author') + }) + this.$el.append(panel_face_button.render().el) + this.$el.append(author_face_button.render().el) this.$el.append( Pettanr.AppHelper.distance_of_time_in_words_to_now(@panel.get('updated_at')) ) if Pettanr.cache.operators.is_author() - this.$el.append(@inspire_icon.render().el) + inspire_button = Pettanr.View.mini_face_button( + @panel, + Pettanr.View.Image.icon_inspire_file(), + { + context: this, + click: () => + @trigger('click:inspire') + } + ) + this.$el.append(inspire_icon.render().el) if @panel.is_own() - this.$el.append(@edit_button.render().el) + edit_button = new Pettanr.View.Button.ItemAction(@panel, 'edit', { + context: this, + click: () => + @trigger('click:edit') + }) + this.$el.append(edit_button.render().el) }) this - click_panel: () -> - @trigger('click:panel') - - click_author: () -> - @trigger('click:author') - - click_edit: () -> - @trigger('click:edit') - - click_inspire: () -> - @trigger('click:inspire') - diff --git a/app/assets/javascripts/views/panels/icon.js.coffee b/app/assets/javascripts/views/panels/icon.js.coffee deleted file mode 100644 index 121b7521..00000000 --- a/app/assets/javascripts/views/panels/icon.js.coffee +++ /dev/null @@ -1,5 +0,0 @@ -class Pettanr.Views.Panel.Icon extends Pettanr.Views.Common.Icon - - initialize: (options) -> - super(options) - diff --git a/app/assets/javascripts/views/resource_pictures/img.js.coffee b/app/assets/javascripts/views/resource_pictures/img.js.coffee deleted file mode 100644 index 3d274cb7..00000000 --- a/app/assets/javascripts/views/resource_pictures/img.js.coffee +++ /dev/null @@ -1,18 +0,0 @@ -class Pettanr.Views.ResourcePicture.Img extends Pettanr.View - tagName: 'img' - - initialize: (options) -> - @item = options.item - - render: () -> - this.$el.html('') - this.$el.attr(@attr()) - this - - attr: () -> - { - src: @item.full_src(), - width: Pettanr.to_s(Math.abs(@item.get('width'))) + 'px', - height: Pettanr.to_s(Math.abs(@item.get('height'))) + 'px', - } - diff --git a/app/assets/javascripts/views/scroll_panels/icon.js.coffee b/app/assets/javascripts/views/scroll_panels/icon.js.coffee deleted file mode 100644 index 977407e5..00000000 --- a/app/assets/javascripts/views/scroll_panels/icon.js.coffee +++ /dev/null @@ -1,5 +0,0 @@ -class Pettanr.Views.ScrollPanel.Icon extends Pettanr.Views.Common.Icon - - initialize: (options) -> - super(options) - diff --git a/app/assets/javascripts/views/scrolls/icon.js.coffee b/app/assets/javascripts/views/scrolls/icon.js.coffee deleted file mode 100644 index c899532c..00000000 --- a/app/assets/javascripts/views/scrolls/icon.js.coffee +++ /dev/null @@ -1,5 +0,0 @@ -class Pettanr.Views.Scroll.Icon extends Pettanr.Views.Common.Icon - - initialize: (options) -> - super(options) - diff --git a/app/assets/javascripts/views/scrolls/play.js.coffee b/app/assets/javascripts/views/scrolls/play.js.coffee index ce430e7a..87d56258 100644 --- a/app/assets/javascripts/views/scrolls/play.js.coffee +++ b/app/assets/javascripts/views/scrolls/play.js.coffee @@ -1,14 +1,4 @@ class Pettanr.Views.Scroll.PlayModule -class Pettanr.Views.Scroll.PlayModule.Header extends Pettanr.Views.Show.Header - - initialize: (options) -> - super(options) - -class Pettanr.Views.Scroll.PlayModule.Owner extends Pettanr.Views.Show.Owner - - initialize: (options) -> - super(options) - class Pettanr.Views.Scroll.PlayModule.FooterSwitch extends Pettanr.View tagName: 'div' className: 'player-item-switch' diff --git a/app/assets/javascripts/views/sheets/icon.js.coffee b/app/assets/javascripts/views/sheets/icon.js.coffee deleted file mode 100644 index c3271f61..00000000 --- a/app/assets/javascripts/views/sheets/icon.js.coffee +++ /dev/null @@ -1,5 +0,0 @@ -class Pettanr.Views.Sheet.Icon extends Pettanr.Views.Common.Icon - - initialize: (options) -> - super(options) - diff --git a/app/assets/javascripts/views/sheets/play.js.coffee b/app/assets/javascripts/views/sheets/play.js.coffee index fb44be7d..ba8d7661 100644 --- a/app/assets/javascripts/views/sheets/play.js.coffee +++ b/app/assets/javascripts/views/sheets/play.js.coffee @@ -1,14 +1,4 @@ class Pettanr.Views.Sheet.PlayModule -class Pettanr.Views.Sheet.PlayModule.Header extends Pettanr.Views.Show.Header - - initialize: (options) -> - super(options) - -class Pettanr.Views.Sheet.PlayModule.Owner extends Pettanr.Views.Show.Owner - - initialize: (options) -> - super(options) - class Pettanr.Views.Sheet.PlayModule.Footer extends Pettanr.View tagName: 'table' className: 'no-border' diff --git a/app/assets/javascripts/views/show.js.coffee b/app/assets/javascripts/views/show.js.coffee deleted file mode 100644 index f397f295..00000000 --- a/app/assets/javascripts/views/show.js.coffee +++ /dev/null @@ -1,212 +0,0 @@ -class Pettanr.Views.Show -class Pettanr.Views.Show.Header extends Pettanr.View - tagName: 'h1' - className: 'show-header' - - initialize: (options) -> - @item = options.item - @title = options.caption - @icon_url = options.icon_url - @caption_url = options.caption_url - @prof_url = options.prof_url - - @pick = null - @icon = new Pettanr.Image.Icon({item: @item, half: true}) - @icon_button = new Tag.A({ - attr: {href: '/' + @icon_url}, - class_name: 'icon', - content: @icon.render().el - }) - @caption = new Tag.A({ - attr: {href: '/' + @caption_url}, - class_name: 'caption', - content: _.escape(@title) - }) - @prof = new Pettanr.Image.SymbolImg({attr: {src: '/images/prof.gif'}, half: true}) - @prof_button = new Tag.A({ - attr: {href: '/' + @prof_url}, - class_name: 'prof', - content: @prof.render().el - }) - @listenTo(@icon_button, 'click', @click_icon) - @listenTo(@caption, 'click', @click_caption) - @listenTo(@prof_button, 'click', @click_prof) - - render: () -> - this.$el.html('') - this.$el.append(@pick.render().el) if @pick - this.$el.append(@icon_button.render().el) - this.$el.append(@caption.render().el) - this.$el.append(@prof_button.render().el) - this - - click_pick: () -> - @trigger('click:pick') - - click_icon: () -> - @trigger('click:icon') - - click_caption: () -> - @trigger('click:caption') - - click_prof: () -> - @trigger('click:prof') - - add_pick: (target_model) -> - @pick = new Pettanr.Views.Common.PickIcon({ - name: target_model.pick_type(@item.item_name()), half: true - }) - @listenTo(@pick, 'click', @click_pick) - @render() - -class Pettanr.Views.Show.HeaderAuthor extends Pettanr.View - tagName: 'div' - - initialize: (options) -> - @item = options.item - @item.get_parent('author', this, { - success: (@author) => - name = @author.escape('name') - author_url = @author.show_url() - @linked_author = new Tag.A({ - attr: {href: '/' + author_url}, - content: name - }) - @listenTo(@linked_author, 'click', @click) - @render() - }) - - render: () -> - this.$el.html('') - this.$el.append(Pettanr.AppHelper.t_a(@item.item_name(), 'author_id')) - this.$el.append(@linked_author.render().el) if @linked_author - this - - click: () -> - @trigger('click:author') - -class Pettanr.Views.Show.HeaderArtist extends Pettanr.View - tagName: 'div' - - initialize: (options) -> - @item = options.item - @item.get_parent('artist', this, { - success: (@artist) => - name = @artist.escape('name') - artist_url = @artist.show_url() - @linked_artist = new Tag.A({ - attr: {href: '/' + artist_url}, - content: name - }) - @listenTo(@linked_artist, 'click', @click) - @render() - }) - - render: () -> - this.$el.html('') - this.$el.append(Pettanr.AppHelper.t_a(@item.item_name(), 'artist_id')) - this.$el.append(@linked_artist.render().el) if @linked_artist - this - - click: () -> - @trigger('click:artist') - -class Pettanr.Views.Show.LinkedNewButton extends Tag.A - - initialize: (options) -> - item = options.item - dn = options.dic_name || 'link.new' - super({ - attr: {href: '/' + item.new_url()}, - content: I18n.t(dn) - }) - -class Pettanr.Views.Show.LinkedEditButton extends Tag.A - - initialize: (options) -> - item = options.item - dn = options.dic_name || 'link.edit' - super({ - attr: {href: '/' + item.edit_url()}, - content: I18n.t(dn) - }) - -class Pettanr.Views.Show.LinkedDestroyButton extends Tag.A - - initialize: (options) -> - item = options.item - dn = options.dic_name || 'link.destroy' - super({ - attr: {href: '/' + item.destroy_url()}, - content: I18n.t(dn) - }) - -class Pettanr.Views.Show.LinkedInspireIcon extends Tag.A - - initialize: (options) -> - item = options.item - half = options.half - img = new Pettanr.Image.SymbolImg({ - attr: {src: '/images/inspire.gif'}, half: half - }) - super({ - attr: {href: '/' + item.index_url() + '/inspire'}, - content: img.render().el - }) - -class Pettanr.Views.Show.OwnerFooter extends Pettanr.View - tagName: 'div' - className: 'show-owner-footer' - - initialize: (options) -> - super(options) - @item = options.item - @edit = new Pettanr.Views.Show.LinkedEditButton({item: @item}) - @destroy = new Pettanr.Views.Show.LinkedDestroyButton({item: @item}) - @listenTo(@edit, 'click', @click_edit) - @listenTo(@destroy, 'click', @click_destroy) - - render: () -> - this.$el.html('') - this.$el.append(@edit.render().el) - this.$el.append(@destroy.render().el) - this - - click_edit: () -> - @trigger('click:edit') - - click_destroy: () -> - @trigger('click:destroy') - -class Pettanr.Views.Show.Owner extends Pettanr.View - tagName: 'div' - - initialize: (options) -> - super(options) - @item = options.item - @header = new Tag.H3({ - class_name: 'owner-header', - content: I18n.t('editor') - }) - fc = @footer_class() - @footer = new fc({item: @item}) - @listenTo(@footer, 'click:edit', @click_edit) - @listenTo(@footer, 'click:destroy', @click_destroy) - - render: () -> - this.$el.html('') - this.$el.append(@header.render().el) - this.$el.append(@footer.render().el) - this - - click_edit: () -> - @trigger('click:footer:edit') - @trigger('click:edit') - - click_destroy: () -> - @trigger('click:footer:destroy') - @trigger('click:destroy') - - footer_class: () -> - Pettanr.Views.Show.OwnerFooter - diff --git a/app/assets/javascripts/views/speech_balloons/summary.js.coffee b/app/assets/javascripts/views/speech_balloons/summary.js.coffee index cc212b2f..89948a65 100644 --- a/app/assets/javascripts/views/speech_balloons/summary.js.coffee +++ b/app/assets/javascripts/views/speech_balloons/summary.js.coffee @@ -5,25 +5,25 @@ class Pettanr.Views.SpeechBalloon.Summary extends Pettanr.View.Summary @item = options.item @item.get_parent('panel', this, { success: (@panel) => - @panel_icon = new Pettanr.Views.Common.Icon({item: @panel, half: true}) - @listenTo(@panel_icon, 'click', @panel_click) + @panel_face_button = @panel.mini_face_button({ + context: this, + click: () -> + @trigger('http_get', @panel.show_url()) + }) @panel.get_parent('author', this, { success: (@author) => - @author_icon_with_caption = @author.icon_with_caption_view(true, 'name', 12) - @listenTo(@author_icon_with_caption, 'click', @author_click) + @author_faced_label = @author.mini_faced_label({ + context: this, + click: () -> + @trigger('http_get', @author.show_url()) + }) @trigger('ready') }) }) render: () -> this.$el.html('') - this.$el.append(@panel_icon.render().el) - this.$el.append(@author_icon_with_caption.render().el) + this.$el.append(@panel_face_button.render().el) + this.$el.append(@author_faced_label.render().el) this - panel_click: () -> - @trigger('http_get', @panel_icon.url()) - - author_click: () -> - @trigger('http_get', @author_icon_with_caption.url()) - diff --git a/app/assets/javascripts/views/speeches/summary.js.coffee b/app/assets/javascripts/views/speeches/summary.js.coffee index 0dc37956..aab236a1 100644 --- a/app/assets/javascripts/views/speeches/summary.js.coffee +++ b/app/assets/javascripts/views/speeches/summary.js.coffee @@ -7,12 +7,18 @@ class Pettanr.Views.Speech.Summary extends Pettanr.View.Summary success: (@speech_balloon) => @speech_balloon.get_parent('panel', this, { success: (@panel) => - @panel_icon = new Pettanr.Views.Common.Icon({item: @panel, half: true}) - @listenTo(@panel_icon, 'click', @panel_click) + @panel_face_button = @panel.mini_face_button({ + context: this, + click: () -> + @trigger('http_get', @panel.show_url()) + }) @panel.get_parent('author', this, { success: (@author) => - @author_icon_with_caption = @author.icon_with_caption_view(true, 'name', 12) - @listenTo(@author_icon_with_caption, 'click', @author_click) + @author_faced_label = @author.mini_faced_label({ + context: this, + click: () -> + @trigger('http_get', @author.show_url()) + }) @trigger('ready') }) }) @@ -20,13 +26,7 @@ class Pettanr.Views.Speech.Summary extends Pettanr.View.Summary render: () -> this.$el.html('') - this.$el.append(@panel_icon.render().el) - this.$el.append(@author_icon_with_caption.render().el) + this.$el.append(@panel_face_button.render().el) + this.$el.append(@author_faced_label.render().el) this - panel_click: () -> - @trigger('http_get', @panel_icon.url()) - - author_click: () -> - @trigger('http_get', @author_icon_with_caption.url()) - diff --git a/app/assets/javascripts/views/stories/icon.js.coffee b/app/assets/javascripts/views/stories/icon.js.coffee deleted file mode 100644 index dd6260ee..00000000 --- a/app/assets/javascripts/views/stories/icon.js.coffee +++ /dev/null @@ -1,5 +0,0 @@ -class Pettanr.Views.Story.Icon extends Pettanr.Views.Common.Icon - - initialize: (options) -> - super(options) - diff --git a/app/assets/javascripts/views/stories/play.js.coffee b/app/assets/javascripts/views/stories/play.js.coffee index 04be484c..074a1439 100644 --- a/app/assets/javascripts/views/stories/play.js.coffee +++ b/app/assets/javascripts/views/stories/play.js.coffee @@ -1,14 +1,4 @@ class Pettanr.Views.Story.PlayModule -class Pettanr.Views.Story.PlayModule.Header extends Pettanr.Views.Show.Header - - initialize: (options) -> - super(options) - -class Pettanr.Views.Story.PlayModule.Owner extends Pettanr.Views.Show.Owner - - initialize: (options) -> - super(options) - class Pettanr.Views.Story.PlayModule.Footer extends Pettanr.View tagName: 'table' className: 'no-border' diff --git a/app/assets/javascripts/views/users/account.js.coffee b/app/assets/javascripts/views/users/account.js.coffee index 0f752d5e..5f20f468 100644 --- a/app/assets/javascripts/views/users/account.js.coffee +++ b/app/assets/javascripts/views/users/account.js.coffee @@ -8,8 +8,11 @@ class Pettanr.Views.User.Account extends Pettanr.View render: () -> this.$el.html('') - @logo = new Pettanr.Views.Common.Logo({}) - @listenTo(@logo, 'click', @logo_click) + @logo = new Pettanr.View.Layout.Logo({ + context: this, + click: () -> + @trigger('http_get', '') + }) this.$el.append(@logo.render().el) if @author @author_mini_faced_label = @author.mini_faced_label({ @@ -39,9 +42,6 @@ class Pettanr.Views.User.Account extends Pettanr.View this.$el.append(sign_out.render().el) this - logo_click: () -> - @trigger('http_get', '') - sign_out_click: () -> @trigger('http_post', 'users/sign_out') return false diff --git a/app/assets/javascripts/views/users/guest.js.coffee b/app/assets/javascripts/views/users/guest.js.coffee index 0049fc03..abc5209a 100644 --- a/app/assets/javascripts/views/users/guest.js.coffee +++ b/app/assets/javascripts/views/users/guest.js.coffee @@ -4,26 +4,22 @@ class Pettanr.Views.User.Guest extends Pettanr.View className: 'account' initialize: (options) -> + super(options) render: () -> this.$el.html('') - @logo = new Pettanr.Views.Common.Logo({}) - @listenTo(@logo, 'click', @logo_click) - this.$el.append(@logo.render().el) - sign_in = new Tag.A({ - attr: {href: '/users/sign_in'}, + @logo = new Pettanr.View.Layout.Logo({ + context: this, + click: () -> + @trigger('http_get', '') + }) + @sign_in_button = new Pettanr.View.Button('/users/sign_in', 'sign in', { + context: this, class_name: 'sign_in', - content: 'sign in' + click: () -> + @trigger('http_get', 'user_sessions/new') }) - @listenTo(sign_in, 'click', @sign_in_click) - this.$el.append(sign_in.render().el) + this.$el.append(@logo.render().el) + this.$el.append(@sign_in_button.render().el) this - logo_click: () -> - @trigger('http_get', '') - return false - - sign_in_click: () -> - @trigger('http_get', 'user_sessions/new') - return false - diff --git a/app/assets/javascripts/yasapp.js b/app/assets/javascripts/yasapp.js index 12877aa2..2370cfb7 100644 --- a/app/assets/javascripts/yasapp.js +++ b/app/assets/javascripts/yasapp.js @@ -307,6 +307,7 @@ //= require_directory ./models //= require_directory ./view //= require_directory ./view/button +//= require_directory ./view/layout //= require_directory ./view/show //= require_directory ./view/show/header //= require_directory ./view/show/footer @@ -322,7 +323,6 @@ //= require_directory ./views/ground_colors //= require_directory ./views/ground_pictures //= require_directory ./views/home -//= require_directory ./views/layouts //= require_directory ./views/licenses //= require_directory ./views/license_groups //= require_directory ./views/original_pictures -- 2.11.0