@element = options.element\r
@root = options.root\r
@spot = options.spot\r
+ @add_element()\r
+ retriever = @element.picture()\r
+ @listenTo(retriever, 'retrieve', @retrieve_picture)\r
+ retriever.retrieve()\r
+ \r
+ retrieve_picture: (@picture) ->\r
+ @restyle()\r
+ \r
+ clear: () ->\r
+ this\r
\r
render: () ->\r
+ this\r
+ \r
+ restyle: () ->\r
s = @style(@spot)\r
_.extend(s, @style_wh())\r
attr = {\r
style: Pettanr.to_style(s)\r
}\r
this.$el.attr(attr)\r
- this\r
+ \r
+ add_element: () ->\r
+ null\r
\r
style: (spot = null, opacity = 20) ->\r
r = {\r
top: '0px', \r
left: '0px',\r
'z-index': @element.get('z'), \r
- 'background-image': 'url(' + @picture().r_url() + ')', \r
- 'background-repeat': @repeat_text(), \r
+ 'background-image': 'url(' + @picture.r_url() + ')', \r
+ 'background-repeat': @element.repeat_text(), \r
'background-position': Pettanr.to_s(@element.get('x')) + 'px ' + Pettanr.to_s(@element.get('y')) + 'px'\r
}\r
r\r
height: Pettanr.to_s(@root.get('height')) + 'px'\r
}\r
\r
+class Pettanr.Views.GroundPicture.Element.Edit extends Pettanr.Views.GroundPicture.Element\r
+ \r
+ initialize: (options) ->\r
+ super(options)\r
+ @listenTo(@root, 'resize', @restyle)\r
+ @listenTo(@root, 'input:width', @restyle)\r
+ @listenTo(@root, 'input:height', @restyle)\r
+ @listenTo(@element, 'input:repeat', @restyle)\r
+ @listenTo(@element, 'input:x', @restyle)\r
+ @listenTo(@element, 'input:y', @restyle)\r
+ @listenTo(@element, 'active', @active)\r
+ @listenTo(@element, 'inactive', @inactive)\r
+ \r
+ retrieve_picture: (picture) ->\r
+ @listenTo(@element, 'sort', @restyle)\r
+ super(picture)\r
+ \r
+ active: () ->\r
+ @root.trigger('active')\r
+ \r
+ inactive: () ->\r
+ @root.trigger('inactive')\r
+ \r