OSDN Git Service

fix: show's destroy button
[pettanr/pettanr.git] / app / assets / javascripts / models / ground_picture.js.coffee
index d5820fa..77d074f 100644 (file)
-class GroundPicture extends Element\r
-  @single: () ->\r
+class Pettanr.GroundPicture extends Peta.Element\r
+  \r
+  @singular: () ->\r
     'GroundPicture'\r
   \r
   @plural: () ->\r
     'GroundPictures'\r
   \r
-  @colum_structures: ->\r
-    {}\r
-  \r
   defaults: {\r
-    x: 11\r
+    id: null,\r
+    x: 0,\r
+    y: 0,\r
+    repeat: 0\r
   } \r
   \r
-  initialize: () ->\r
-    confirm("Welcome to this world")\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
+  @repeat_texts: () -> \r
+    ['repeat', 'repeat-x', 'repeat-y', 'no-repeat']\r
+  \r
+  @pick_item_name: () ->\r
+    'resource_picture'\r
+  \r
+  @traceable_item_names: () ->\r
+    ['panel_picture', 'picture']\r
+  \r
+  pick: (picked_item) ->\r
+    {picture_id: picked_item.get('picture_id')}\r
+  \r
+  panel: () ->\r
+    new Pettanr.Cache.Retriever(Pettanr.Panel, @get('panel_id'))\r
+  \r
+  picture: () ->\r
+    new Pettanr.Cache.Retriever(Pettanr.Picture, @get('picture_id'))\r
+  \r
+  @has_picture: () ->\r
     true\r
   \r
-  has_part: () ->\r
-    false\r
-  \r
-  extend_column: () ->\r
-    null\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
+  tmb_opt_img_tag: (picture) ->\r
+    new Pettanr.Image.SymbolPicture({\r
+      attr: {\r
+        src: picture.r_url(), \r
+        alt: @escape('caption')\r
+      },\r
+      picture: picture\r
+    })\r
+  \r
+  symbol_option: () ->\r
+    retriever = @picture()\r
+    @listenTo(retriever, 'retrieve', @retrieve_symbol)\r
+    retriever.retrieve()\r
+  \r
+  retrieve_symbol: (picture) -> \r
+    @trigger('ready:symbol', picture.tmb_opt_img_tag())\r
+  \r
+  repeat_text: () ->\r
+    Pettanr.GroundPicture.repeat_texts()[@get('repeat')]\r
+  \r
+  element_face: () ->\r
+    new Pettanr.Views.GroundPicture.ElementFace({element: this})\r
+  \r
+  initialize: (attr, options) ->\r
+    super(attr, options)\r
+  \r
+class Pettanr.GroundPicture.TraceFromPicture\r
+  \r
+  constructor: (options) ->\r
+    _.extend(this, Backbone.Events)\r
+  \r
+  trace: (picture) ->\r
+    @picture(picture)\r
+  \r
+  picture: (picture) ->\r
+    resource_picture_picture_list = picture.has_one('resource_picture_picture')\r
+    resource_picture_picture_list.open(() =>\r
+      resource_picture_picture = resource_picture_picture_list.items()[0]\r
+      retriever = new Pettanr.Cache.Retriever(Pettanr.ResourcePicture, resource_picture_picture.get('resource_picture_id'))\r
+      @listenTo(retriever, 'retrieve', @resource_picture)\r
+      retriever.retrieve()\r
+    )\r
+  \r
+  resource_picture: (resource_picture) ->\r
+    @trigger('trace', resource_picture)\r
+  \r
+class Pettanr.GroundPicture.TraceFromPanelPicture extends Pettanr.GroundPicture.TraceFromPicture\r
+  \r
+  trace: (panel_picture) ->\r
+    @panel_picture(panel_picture)\r
+  \r
+  panel_picture: (panel_picture) ->\r
+    retriever = new Pettanr.Cache.Retriever(Pettanr.Picture, panel_picture.get('picture_id'))\r
+    @listenTo(retriever, 'retrieve', @picture)\r
+    retriever.retrieve()\r
+  \r
+  picture: (picture) ->\r
+    tracer = new Pettanr.GroundPicture.TraceFromPicture()\r
+    @listenTo(tracer, 'trace', @success)\r
+    tracer.trace(picture)\r
+  \r
+  success: (resource_picture) ->\r
+    @trigger('trace', resource_picture)\r
+  \r