OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / assets / javascripts / views / ground_pictures / element.js.coffee
index 5b9ceb0..52911b5 100644 (file)
@@ -6,19 +6,15 @@ class Pettanr.Views.GroundPicture.Element extends Pettanr.View
     @element = options.element\r
     @root = options.root\r
     @spot = options.spot\r
-    @add_element()\r
+  \r
+  init_picture: () ->\r
+  \r
+  render: () ->\r
     @element.get_parent('picture', this, {\r
       success: (@picture) =>\r
         @init_picture()\r
         @restyle()\r
     })\r
-  \r
-  init_picture: () ->\r
-  \r
-  clear: () ->\r
-    this\r
-  \r
-  render: () ->\r
     this\r
   \r
   restyle: () ->\r
@@ -29,18 +25,15 @@ class Pettanr.Views.GroundPicture.Element extends Pettanr.View
     }\r
     this.$el.attr(attr)\r
   \r
-  add_element: () ->\r
-    null\r
-  \r
   style: (spot = null, opacity = 20) ->\r
     r = {\r
       position: 'absolute', \r
       top: '0px', \r
       left: '0px',\r
       'z-index': @element.get('z'), \r
-      'background-image': 'url(' + @picture.picture_file.src() + ')', \r
+      'background-image': 'url(' + @picture.picture_file().src() + ')', \r
       'background-repeat': @element.repeat_text(), \r
-      'background-position': Pettanr.to_s(@element.get('x')) + 'px ' + Pettanr.to_s(@element.get('y')) + 'px'\r
+      'background-position': Pettanr.to_s(@element.get('x')) + '% ' + Pettanr.to_s(@element.get('y')) + '%'\r
     }\r
     r\r
   \r
@@ -54,6 +47,9 @@ class Pettanr.Views.GroundPicture.Element.Edit extends Pettanr.Views.GroundPictu
   \r
   initialize: (options) ->\r
     super(options)\r
+  \r
+  init_picture: () ->\r
+    super()\r
     @listenTo(@root, 'resize', @restyle)\r
     @listenTo(@root, 'input:width', @restyle)\r
     @listenTo(@root, 'input:height', @restyle)\r
@@ -62,10 +58,7 @@ class Pettanr.Views.GroundPicture.Element.Edit extends Pettanr.Views.GroundPictu
     @listenTo(@element, 'input:y', @restyle)\r
     @listenTo(@element, 'active', @active)\r
     @listenTo(@element, 'inactive', @inactive)\r
-  \r
-  init_picture: () ->\r
     @listenTo(@element, 'sort', @restyle)\r
-    super()\r
   \r
   active: () ->\r
     @root.trigger('active')\r