OSDN Git Service

v07
[pettanr/pettanr.git] / app / assets / javascripts / models / panel_picture.js.coffee
index 1dcb93e..962f2f5 100644 (file)
@@ -1,70 +1,64 @@
-class PanelPicture extends Element\r
-  @single: () ->\r
+class Pettanr.PanelPicture extends Peta.Element\r
+  \r
+  @singular: () ->\r
     'PanelPicture'\r
   \r
   @plural: () ->\r
     'PanelPictures'\r
   \r
-  @colum_structures: ->\r
-    {}\r
-  \r
   defaults: {\r
-    x: 11\r
+    id: null\r
   } \r
   \r
-  initialize: () ->\r
-    confirm("Welcome to this world")\r
+  @pick_item_name: () ->\r
+    'resource_picture'\r
+  \r
+  @traceable_item_names: () ->\r
+    ['ground_picture', 'picture']\r
+  \r
+  pick: (picked_item) ->\r
+    {\r
+      picture_id: picked_item.get('picture_id'),\r
+      width: picked_item.get('width'),\r
+      height: picked_item.get('height')\r
+    }\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
+  @trace_routes: () ->\r
+    {\r
+      resource_picture: ['picture', 'resource_picture_picture', 'resource_picture']\r
+      symbol: 'picture'\r
+    }\r
+  \r
+  @has_picture: () ->\r
     true\r
   \r
-  has_part: () ->\r
-    false\r
+  flip: () ->\r
+    v = if @get('height') > 0\r
+      ''\r
+    else\r
+      'v'\r
+    h = if @get('width') > 0\r
+      ''\r
+    else\r
+      'h'\r
+    res = v + h\r
+    res = res # format of /1.png?subdir=v\r
+    # res += '/' unless res.empty? # format of /v/1.png\r
+    res\r
+  \r
+  filename: (picture) ->\r
+    q = if _.isEmpty(@flip())\r
+      ''\r
+    else\r
+      '?subdir=' + @flip()\r
+    picture.filename() + q\r
+  \r
+  r_url: (picture) ->\r
+    '/pictures/' + @filename(picture)\r
+  \r
+  element_face: () ->\r
+    new Pettanr.Views.PanelPicture.ElementFace({element: this})\r
   \r
-  extend_column: () ->\r
-    null\r
+  initialize: (attr, options) ->\r
+    super(attr, options)\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