OSDN Git Service

fix profiler
[pettanr/pettanr.git] / app / assets / javascripts / models / ground_color.js.coffee
index eaca96d..93ee926 100644 (file)
@@ -1,70 +1,73 @@
-class GroundColor extends Element\r
-  @single: () ->\r
+class Pettanr.GroundColor extends Peta.Element\r
+  url: '/ground_colors/'\r
+  \r
+  @singular: () ->\r
     'GroundColor'\r
   \r
   @plural: () ->\r
     'GroundColors'\r
   \r
-  @colum_structures: ->\r
-    {}\r
-  \r
   defaults: {\r
-    x: 11\r
+    id: null,\r
+    code: 0,\r
   } \r
   \r
-  initialize: () ->\r
-    confirm("Welcome to this world")\r
+  @has_picture: () ->\r
+    false\r
   \r
-  @test: () ->\r
-    confirm( @single())\r
-    confirm( @plural() )\r
-    confirm( @class_name() )\r
-    confirm( @element_name() )\r
-    confirm( @table_name() )\r
-    confirm( @path_name() )\r
-    confirm( @colum_structures() )\r
-    \r
-  has_picture: () ->\r
-    true\r
+  div_offset: () ->\r
+    if @get('xy')\r
+      @get('xy')\r
+    else\r
+      0\r
   \r
-  has_part: () ->\r
-    false\r
+  div_size: () ->\r
+    if @get('wh')\r
+      @get('wh')\r
+    else\r
+      100 - @div_offset()\r
+  \r
+  div_x: () ->\r
+    if @get('orientation') == 0\r
+      0\r
+    else\r
+      @div_offset()\r
   \r
-  extend_column: () ->\r
-    null\r
+  div_y: () ->\r
+    if @get('orientation') == 0\r
+      @div_offset()\r
+    else\r
+      0\r
+  \r
+  div_width: () ->\r
+    if @get('orientation') == 0\r
+      100\r
+    else\r
+      @div_size()\r
+  \r
+  div_height: () ->\r
+    if @get('orientation') == 0\r
+      @div_size()\r
+    else\r
+      100\r
+  \r
+  style: (spot = null, opacity = 20) ->\r
+    r = {\r
+      position: 'absolute', \r
+      'z-index': @get('z'), \r
+      top: Pettanr.to_s(@div_y()) + '%', \r
+      left: Pettanr.to_s(@div_x()) + '%', \r
+      width: Pettanr.to_s(@div_width()) + '%', \r
+      height: Pettanr.to_s(@div_height()) + '%', \r
+      'background-color': '#' + ('000000' + Pettanr.to_s(@get('code'))).slice(-6)\r
+    }\r
+    @merge_opacity(r, opacity) if spot and spot != this\r
+    r\r
+  \r
+  initialize: () ->\r
+    if @id\r
+      @url = @url + @id\r
   \r
-  test: () ->\r
-    confirm( @has_picture() )\r
-    confirm( @has_part() )\r
-    confirm( @parts() )\r
-    confirm( @has_helper('column_name') )\r
-    confirm( @element_name() )\r
-    confirm( @extend_column() )\r
-    confirm( @extend_element_name() )\r
-    confirm( @find_configurations(window.configurations,'v') )\r
-    confirm( @new_index() )\r
-    confirm( @set_new_index(3) )\r
-    confirm( @set_new_panel('v') )\r
-    confirm( @get_new_panel() )\r
-    confirm( '@get_panel()' )\r
-    confirm( @get_panel() )\r
-    confirm( @tag_id('c') )\r
-    confirm( @field_tag_id('f') )\r
-    confirm( @tag_panel_id() )\r
-    confirm( @tag_element_id() )\r
-    confirm( @tag_element_type() )\r
-    confirm( @tag_new_index() )\r
-    confirm( @path_name() )\r
-    confirm( @form_template() )\r
-    confirm( @scenario_template() )\r
-    confirm( @element_face_template() )\r
-    confirm( @form_helper_template('colum_name') )\r
-    confirm( @tag_attributes('column') )\r
-    confirm( @field_tag_attributes('column', 0, {}) )\r
-    confirm( @any_tag_attributes('name', {}) )\r
-    confirm( @select_tag_attributes(true, 'column', 0) )\r
-    confirm( @tag_attr('column', {}) )\r
-    confirm( @field_tag_attr('column', 1, {}) )\r
-    confirm( @any_tag_attr('name', {}) )\r
-\r
-@PanelPicture = PanelPicture\r
+class Pettanr.GroundColor.Collection extends Backbone.Collection\r
+  model: Pettanr.GroundColor\r
+  url: '/ground_colors'\r