+++ /dev/null
-class Pettanr.Views.Common\r
- @replace_empty: (caption) ->\r
- if Pettanr.is_blank(caption)\r
- empty = new Pettanr.Views.Common.EmptyCaption()\r
- empty.render().el\r
- else\r
- caption\r
- \r
-class Pettanr.Views.Common.Logo extends Tag.Span\r
- id: 'logo'\r
- \r
- initialize: () ->\r
- title = Manifest.manifest().magic_numbers['profile']['users']['caption']\r
- @logo_button = new Tag.A({\r
- attr: {href: '/'}, \r
- class_name: 'logo',\r
- content: _.escape(title)\r
- })\r
- @listenTo(@logo_button, 'click', @click)\r
- \r
- render: () ->\r
- this.$el.html(@logo_button.render().el)\r
- this\r
- \r
- click: () ->\r
- @trigger('click')\r
- \r
-\r
-class Pettanr.Views.Common.EmptyIcon extends Tag.Img\r
- \r
- initialize: (options) ->\r
- @attr = {}\r
- @width = Manifest.manifest().magic_numbers['thumbnail_width']\r
- @height = Manifest.manifest().magic_numbers['thumbnail_height']\r
- @width = Pettanr.to_i(@width/2)\r
- @height = Pettanr.to_i(@height/2)\r
- @attr['src'] = @file_name()\r
- @attr['width'] = @width\r
- @attr['height'] = @height\r
- @attr['alt'] = 'Loading'\r
- @attr['title'] = 'Loading'\r
- opt = {\r
- attr: @attr,\r
- }\r
- super(opt)\r
- \r
- file_name: () ->\r
- '/images/empty.gif'\r
-\r
-class Pettanr.Views.Common.LoadIcon extends Pettanr.Views.Common.EmptyIcon\r
- \r
- file_name: () ->\r
- '/images/loading.gif'\r
- \r
-class Pettanr.Views.Common.RootIcon extends Pettanr.Views.Common.EmptyIcon\r
- \r
- file_name: () ->\r
- '/images/root.png'\r
- \r
-class Pettanr.Views.Common.PickIcon extends Pettanr.View\r
- \r
- initialize: (options) ->\r
- @class_name = options.class_name\r
- @name = options.name\r
- @half = options.half\r
- @button = if @is_button()\r
- @linked_icon()\r
- else\r
- @icon()\r
- \r
- render: () ->\r
- this.$el.html('')\r
- @el.className = @class_name if @class_name\r
- if @is_button()\r
- @listenTo(@button, 'click', @click)\r
- this.$el.append(@button.render().el)\r
- this\r
- \r
- is_button: () ->\r
- @name != 'none'\r
- \r
- icon: () ->\r
- new Pettanr.Image.SymbolImg({attr: {src: '/images/' + @name + '.gif'}, half: @half})\r
- \r
- linked_icon: () ->\r
- new Tag.A({\r
- attr: {href: '#'},\r
- content: @icon().render().el\r
- })\r
- \r
- click: () ->\r
- @trigger('click', this)\r
- \r
-class Pettanr.Views.Common.EmptyCaption extends Pettanr.View\r
- tagName: 'div'\r
- className: 'empty'\r
- \r
- render: () ->\r
- this.$el.html('empty')\r
- this\r
- \r
-class Pettanr.Views.Common.Icon extends Pettanr.View\r
- tagName: 'span'\r
- \r
- initialize: (options) ->\r
- @item = options.item\r
- @half = options.half\r
- @icon_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id')})\r
- @icon = new Pettanr.Image.Icon({item: @item, half: @half})\r
- @icon_button = new Tag.A({\r
- attr: {href: '/' + @icon_url}, \r
- class_name: 'icon',\r
- content: @icon.render().el\r
- })\r
- @listenTo(@icon_button, 'click', @click)\r
- \r
- render: () ->\r
- this.$el.html(@icon_button.render().el)\r
- this\r
- \r
- click: () ->\r
- @trigger('click')\r
- \r
- url: () ->\r
- @icon_url\r
- \r
-class Pettanr.Views.Common.Caption extends Pettanr.View\r
- tagName: 'span'\r
- \r
- initialize: (options) ->\r
- @item = options.item\r
- @column_name = options.column_name\r
- @length = options.length\r
- @name = Pettanr.truncate(@item.get(@column_name), @length)\r
- @url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id')})\r
- @linked_name = new Tag.A({\r
- attr: {href: '/' + @url}, \r
- content: _.escape(@name)\r
- })\r
- @listenTo(@linked_name, 'click', @click)\r
- \r
- render: () ->\r
- this.$el.html(@linked_name.render().el)\r
- this\r
- \r
- click: () ->\r
- @trigger('click')\r
- \r
- url: () ->\r
- @url\r
- \r
-class Pettanr.Views.Common.IconWithCaption extends Pettanr.View\r
- tagName: 'span'\r
- \r
- initialize: (options) ->\r
- @item = options.item\r
- @half = options.half\r
- @column_name = options.column_name\r
- @length = options.length\r
- @icon = new Pettanr.Views.Common.Icon({item: @item, half: @half})\r
- @caption = new Pettanr.Views.Common.Caption({item: @item, column_name: @column_name, length: @length})\r
- @listenTo(@icon, 'click', @click)\r
- @listenTo(@caption, 'click', @click)\r
- \r
- render: () ->\r
- this.$el.html('')\r
- this.$el.append(@icon.render().el)\r
- this.$el.append(@caption.render().el)\r
- this\r
- \r
- click: () ->\r
- @trigger('click')\r
- \r
- url: () ->\r
- @icon.url()\r
- \r
-class Pettanr.Views.Common.Summary extends Pettanr.View\r
- \r
- initialize: (options) ->\r
- @clear()\r
- @listenTo(this, 'ready', @render)\r
- \r
- clear: () ->\r
- icon = new Pettanr.Views.Common.LoadIcon()\r
- this.$el.html(icon.render().el)\r
- this\r
- \r
- render: () ->\r
- this.$el.html('')\r
- this\r
- \r
-class Pettanr.Views.Common.Binder\r
-class Pettanr.Views.Common.Binder.Summary extends Pettanr.Views.Common.Summary\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @item = options.item\r
- @visible_t = options.visible_t\r
- @visible_column_name = options.visible_column_name\r
- @load()\r
- \r
- load: () ->\r
- @visible = new Tag.Div({\r
- content: Pettanr.AppHelper.t_selected_item(@visible_t, @item.get(@visible_column_name))\r
- })\r
- @item.get_parent('author', this, {\r
- success: (@author) =>\r
- @author_icon_with_caption = @author.icon_with_caption_view(true, 'name', 12)\r
- @listenTo(@author_icon_with_caption, 'click', @author_click)\r
- @trigger('ready')\r
- })\r
- \r
- render: () ->\r
- this.$el.html('')\r
- this.$el.append(@visible.render().el)\r
- this.$el.append(@author_icon_with_caption.render().el)\r
- this\r
- \r
- author_click: () ->\r
- @trigger('http_get', @author_icon_with_caption.url())\r
- \r
-class Pettanr.Views.Common.Leaf\r
-class Pettanr.Views.Common.Leaf.Summary extends Pettanr.Views.Common.Summary\r
- \r
- initialize: (options) ->\r
- super(options)\r
- @item = options.item\r
- @binder_item_name = options.binder_item_name\r
- @destination_item_name = options.destination_item_name\r
- @binder_view = new Tag.Span({})\r
- @destination_view = new Tag.Span({})\r
- @load()\r
- \r
- load: () ->\r
- @listenTo(this, 'load_binder', @load_destination)\r
- @listenTo(this, 'load_destination', @ready)\r
- @load_binder()\r
- \r
- ready: () ->\r
- @trigger('ready')\r
- \r
- load_binder: () ->\r
- @item.get_parent(@binder_item_name, this, {\r
- success: (@binder) =>\r
- @binder_icon = @binder.icon_view(true)\r
- @listenTo(@binder_icon, 'click', @binder_click)\r
- @binder.get_parent('author', this, {\r
- success: (@binder_author) =>\r
- @binder_author_icon_with_caption = @binder_author.icon_with_caption_view(true, 'name', 12)\r
- @listenTo(@binder_author_icon_with_caption, 'click', @binder_author_click)\r
- @binder_view.$el.append(@binder_icon.render().el)\r
- @binder_view.$el.append(@binder_author_icon_with_caption.render().el)\r
- @trigger('load_binder')\r
- })\r
- })\r
- \r
- load_destination: () ->\r
- @item.get_parent(@destination_item_name, this, {\r
- success: (@destination) =>\r
- @destination_icon = @destination.icon_view(true)\r
- @listenTo(@destination_icon, 'click', @destination_click)\r
- @destination.get_parent('author', this, {\r
- success: (@destination_author) =>\r
- @destination_author_icon_with_caption = @destination_author.icon_with_caption_view(true, 'name', 12)\r
- @listenTo(@destination_author_icon_with_caption, 'click', @destination_author_click)\r
- @destination_view.$el.append(@destination_icon.render().el)\r
- @destination_view.$el.append(@destination_author_icon_with_caption.render().el)\r
- @trigger('load_destination')\r
- })\r
- })\r
- \r
- render: () ->\r
- this.$el.html('')\r
- this.$el.append(@binder_view.render().el)\r
- this.$el.append(@destination_view.render().el)\r
- this\r
- \r
- binder_click: () ->\r
- @trigger('http_get', @binder_icon.url())\r
- \r
- destination_click: () ->\r
- @trigger('http_get', @destination_icon.url())\r
- \r
- binder_author_click: () ->\r
- @trigger('http_get', @binder_author_icon_with_caption.url())\r
- \r
- destination_author_click: () ->\r
- @trigger('http_get', @destination_author_icon_with_caption.url())\r
- \r
-class Pettanr.Views.Common.Credits extends Pettanr.View\r
- tagName: 'div'\r
- className: 'credits'\r
- \r
- initialize: (options) ->\r
- @parent = options.parent\r
- @licensed_pictures = {}\r
- \r
- clear: () ->\r
- this.$el.html('')\r
- \r
- render: () ->\r
- this.$el.html('')\r
- this\r
- \r
- push: (retrievers) ->\r
- _.each retrievers, (retriever, pid) =>\r
- Pettanr.Picture.retrieve(pid, this, {\r
- success: (picture) =>\r
- pid = picture.get('id')\r
- return if @licensed_pictures[pid]\r
- @licensed_pictures[pid] = picture\r
- credit = picture.credit_view()\r
- @listenTo(credit, 'click:icon', @click_credit_icon)\r
- this.$el.append(credit.render().el)\r
- })\r
- \r
- click_credit_icon: (item) ->\r
- @trigger('click:credit:icon', item)\r
- \r