OSDN Git Service

fix: new element tracer
[pettanr/pettanr.git] / app / assets / javascripts / views / ground_colors / symbol.js.coffee
1 class Pettanr.Views.GroundColor.Symbol extends Backbone.View\r
2   tagName: 'div'\r
3   \r
4   initialize: (options) ->\r
5     @item = options.item\r
6     @class_name = options.class_name || 'face'\r
7   \r
8   clear: () ->\r
9     @trigger('ready:symbol', symbol_picture)\r
10     this\r
11   \r
12   render: () ->\r
13     this.$el.addClass(@class_name)\r
14     linked_caption = new Tag.A({\r
15       attr: {href: '/' + @item.show_url()}, \r
16       content: @bg_color()\r
17     })\r
18     @listenTo(linked_caption, 'click', @click)\r
19     this.$el.html(linked_caption.render().el)\r
20     attr = {\r
21       style: Pettanr.to_style(@style())\r
22     }\r
23     this.$el.attr(attr)\r
24     this\r
25   \r
26   fore_color: () ->\r
27     c = @item.get('code') ^ 0xffffff\r
28     ('000000' + c.toString(16)).slice(-6)\r
29     \r
30   bg_color: () ->\r
31     c = @item.get('code')\r
32     ('000000' + c.toString(16)).slice(-6)\r
33     \r
34   style: (spot = null, opacity = 20) ->\r
35     width = Manifest.manifest().magic_numbers['thumbnail_width']\r
36     height = Manifest.manifest().magic_numbers['thumbnail_height']\r
37     {\r
38       width: Pettanr.to_s(width) + 'px', \r
39       height: Pettanr.to_s(height) + 'px', \r
40       color: '#' + @fore_color()\r
41       'background-color': '#' + @bg_color()\r
42     }\r
43   \r
44   click: () ->\r
45     @trigger('click')\r
46   \r