OSDN Git Service

add panel viewer
authoryasushiito <yas@pen-chan.jp>
Wed, 24 Sep 2014 23:11:53 +0000 (08:11 +0900)
committeryasushiito <yas@pen-chan.jp>
Wed, 24 Sep 2014 23:11:53 +0000 (08:11 +0900)
20 files changed:
app/assets/javascripts/controllers/panels.js.coffee
app/assets/javascripts/controllers/scrolls.js.coffee
app/assets/javascripts/manifest/model.js.coffee
app/assets/javascripts/manifest/model/association.js.coffee
app/assets/javascripts/models/balloon.js.coffee
app/assets/javascripts/models/panel.js.coffee
app/assets/javascripts/models/panel_picture.js.coffee
app/assets/javascripts/models/speech.js.coffee
app/assets/javascripts/peta/element_nestable_content.js.coffee
app/assets/javascripts/peta/item.js.coffee
app/assets/javascripts/peta/root.js.coffee
app/assets/javascripts/views/balloons/element.js.coffee
app/assets/javascripts/views/ground_colors/element.js.coffee
app/assets/javascripts/views/panel_pictures/element.js.coffee
app/assets/javascripts/views/panels/body.js.coffee
app/assets/javascripts/views/panels/show.js.coffee [new file with mode: 0644]
app/assets/javascripts/views/scrolls/show.js.coffee [new file with mode: 0644]
app/assets/javascripts/views/speech_balloons/element.js.coffee
app/assets/javascripts/views/speeches/element.js.coffee
lib/locmare/form/field/tag/select.rb

index a645252..60caf94 100644 (file)
@@ -19,8 +19,7 @@ class Pettanr.PanelsController extends Pettanr.AppController
     _this = this\r
     @item = new Pettanr.Panel({id: @item.get('id')}, {with_elements: true}) # retake panel for 'with_elements' mode\r
     @item.fetch().done ->\r
-      i = new Pettanr.RelationPanel(_this.item.attributes)\r
-      view = new Pettanr.Views.Panel.Body({\r
+      view = new Pettanr.Views.Panel.Show({\r
         el: "#pettanr",\r
         panel: _this.item,\r
         operators: _this.operators,\r
index 929c62f..3a62f1e 100644 (file)
@@ -10,6 +10,12 @@ class Pettanr.ScrollsController extends Pettanr.AppController
     @filer_list()\r
   \r
   show_html: () -> \r
+    view = new Pettanr.Views.Scroll.Show({\r
+      el: "#pettanr",\r
+      item: @item,\r
+      operators: @operators\r
+    })\r
+    view.render()\r
   \r
   show: () ->\r
     @set_show()\r
index bbbcc6a..f346b95 100644 (file)
@@ -53,21 +53,22 @@ class Manifest.Model extends ManifestBase.Base
   \r
   child_model_manifests: () ->\r
     r = []\r
-    _.each Manifest.items, (peta_manifest, peta_name) ->\r
-      next if not peta_manifest.is_element\r
-      next if not peta_manifest.parent_model_name == @name\r
-      r.push Manifest.models[peta_name]\r
+    _this = this\r
+    _.each Manifest.manifest().items, (peta_manifest, peta_name) ->\r
+      return if not peta_manifest.is_element()\r
+      return if peta_manifest.parent_model_name != _this.name\r
+      r.push Manifest.manifest().models[peta_name]\r
     r\r
   \r
   child_models: () ->\r
-    _.map @child_model_manifests, (child_model_manifest) ->\r
-      child_model_manifest.classify\r
+    _.map @child_model_manifests(), (child_model_manifest) ->\r
+      child_model_manifest.classify()\r
   \r
   child_element_names: () ->\r
-    _.map @child_models, (child_model) ->\r
+    _.map @child_models(), (child_model) ->\r
       @associations.child_element_name(child_model)\r
   \r
   child_element_name: (item_name) ->\r
-    @associations.child_element_name(child_model_manifest)\r
+    @associations.child_element_name(@child_model_manifest())\r
   \r
 class Manifest.ModelModule\r
index ac05eb3..688b259 100644 (file)
@@ -25,13 +25,13 @@ class Manifest.ModelModule.Association extends ManifestBase.Values
       #yield belongs_to_manifest.model\r
   \r
   child_element_name: (child_model) -> \r
-    if is_has_one child_model\r
-      child_model.item_name\r
+    if @is_has_one(child_model)\r
+      child_model.item_name()\r
     else\r
-      child_model.table_name\r
+      child_model.table_name()\r
   \r
   is_has_one: (child_model) ->\r
-    if @has_one[child_model.item_name]\r
+    if @has_one[child_model.item_name()]\r
       true\r
     else\r
       false\r
index 48fb028..e6986f4 100644 (file)
@@ -19,6 +19,9 @@ class Pettanr.Balloon extends Peta.Element
   speech_balloon: () ->\r
     new Pettanr.SpeechBalloon({id: @get('speech_balloon_id')})\r
   \r
+  system_picture: () ->\r
+    new Pettanr.SystemPicture({id: @get('system_picture_id')})\r
+  \r
   r_url: () ->\r
     '/system_pictures/' + @system_picture().filename()\r
   \r
index 2d90085..30a380c 100644 (file)
@@ -1,17 +1,5 @@
 class Pettanr.Panel extends Peta.Root\r
   url: '/panels/'\r
-  relations: [\r
-    {\r
-      type: Backbone.HasMany,\r
-      key: 'panel_pictures',\r
-      relatedModel: 'Pettanr.PanelPicture',\r
-      collectionType: 'Pettanr.PanelPictures',\r
-      reverseRelation: {\r
-        key: 'panel',\r
-        includeInJSON: 'id'\r
-      }\r
-    },\r
-  ]\r
   \r
   @singular: () ->\r
     'Panel'\r
@@ -54,17 +42,3 @@ class Pettanr.Panel extends Peta.Root
 class Pettanr.Panels extends Backbone.Collection\r
   model: Pettanr.Panel\r
   url: '/panels/'\r
-class Pettanr.RelationPanel extends Pettanr.Panel\r
-  relations: [\r
-    {\r
-      type: Backbone.HasMany,\r
-      key: 'panel_pictures',\r
-      relatedModel: 'Pettanr.PanelPicture',\r
-      collectionType: 'Pettanr.PanelPictures',\r
-      reverseRelation: {\r
-        key: 'panel',\r
-        includeInJSON: 'id'\r
-      }\r
-    },\r
-  ]\r
-  \r
index 7efdae1..84aa33b 100644 (file)
@@ -31,11 +31,11 @@ class Pettanr.PanelPicture extends Peta.Element
     # res += '/' unless res.empty? # format of /v/1.png\r
     res\r
   \r
-  filename: () ->\r
-    @picture().filename() + '?subdir=' + @flip()\r
+  filename: (picture) ->\r
+    picture.filename() + '?subdir=' + @flip()\r
   \r
-  r_url: () ->\r
-    '/pictures/' + @filename()\r
+  r_url: (picture) ->\r
+    '/pictures/' + @filename(picture)\r
   \r
   tmb_opt_img_tag: (picture) ->\r
     new Pettanr.Image.SymbolPicture({\r
index 9bdffa1..cd11afd 100644 (file)
@@ -35,7 +35,8 @@ class Pettanr.Speech extends Peta.Element
   \r
   scenario: () ->\r
     @boosts('read')\r
-    @render()\r
+    #@render()  using wf renderer\r
+    @get('content')\r
   \r
   initialize: () ->\r
     if @id\r
index 1d24423..c90638e 100644 (file)
@@ -1,7 +1,13 @@
 class Peta.ElementNestableContent extends Peta.Content\r
   element_items: (element_model) ->\r
     n = @my_class().my_manifest().associations.child_element_name(element_model)\r
-    @my_class()[n]()\r
+    attrs = @get(n)\r
+    if attrs\r
+      if @my_class().my_manifest().associations.is_has_one(element_model)\r
+        new element_model(attrs)\r
+      else\r
+        _.map attrs, (attr) ->\r
+          new element_model(attr)\r
   \r
   elements_items: () ->\r
     _this = this\r
index 2d5391a..a166731 100644 (file)
@@ -117,7 +117,7 @@ class Peta.Item extends Backbone.Model
     _this = this\r
     c = @my_class().my_peta().boost\r
     _.each c, (boost_manifest, boost_name) ->\r
-      next if level == 'read' and boost_manifest.level == 'post'\r
+      return if level == 'read' and boost_manifest.level == 'post'\r
       _this.boost boost_manifest\r
   \r
   boost: (boost_manifest) ->\r
index 25986f8..f6d2445 100644 (file)
@@ -2,8 +2,10 @@ class Peta.Root extends Peta.ElementNestableContent
   \r
   parts_element: () ->\r
     r = []\r
-    _.each @my_class.child_models, () ->\r
-      r += (@element_items(k) || [])\r
+    _this = this\r
+    _.each @my_class().child_models(), (k) ->\r
+      l = _this.element_items(k)\r
+      r = r.concat(l)\r
     r\r
   \r
   zorderd_elements: () ->\r
@@ -14,7 +16,7 @@ class Peta.Root extends Peta.ElementNestableContent
   \r
   scenario_elements: () ->\r
     res = []\r
-    _.each @parts_element, (e) ->\r
+    _.each @parts_element(), (e) ->\r
       res[e.get('t')] = e\r
     res\r
   \r
index 170f838..7a2d5e2 100644 (file)
@@ -8,10 +8,13 @@ class Pettanr.Views.Balloon.Element extends Backbone.View
     @spot = options.spot\r
   \r
   render: () ->\r
-    attr = {\r
-      src: @element.system_picture.url(), \r
-      alt: @element.get('caption')\r
-    }\r
-    this.$el.attr(attr)\r
+    _this = this\r
+    system_picture = @element.system_picture()\r
+    system_picture.fetch().done ->\r
+      attr = {\r
+        src: system_picture.r_url(), \r
+        alt: _this.element.get('caption')\r
+      }\r
+      _this.$el.attr(attr)\r
     this\r
   \r
index 90bbf61..d72481a 100644 (file)
@@ -58,7 +58,7 @@ class Pettanr.Views.GroundColor.Element extends Backbone.View
       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(@element.get('code'))).slice(-6)\r
+      'background-color': '#' + ('000000' + @element.get('code').toString(16)).slice(-6)\r
     }\r
     @merge_opacity(r, opacity) if spot and spot != @element\r
     r\r
index f979d25..91465de 100644 (file)
@@ -10,10 +10,13 @@ class Pettanr.Views.PanelPicture.Element extends Backbone.View
   render: () ->\r
     @attr = {style: Pettanr.to_style(@opt_div_style())}\r
     this.$el.attr(@attr)\r
-    @img = new Tag.Img({\r
-      attr: @opt_img_tag(@spot)\r
-    })\r
-    this.$el.html(@img.render().el)\r
+    @picture = @element.picture()\r
+    _this = this\r
+    @picture.fetch().done ->\r
+      _this.img = new Tag.Img({\r
+        attr: _this.opt_img_tag(_this.spot)\r
+      })\r
+      _this.$el.html(_this.img.render().el)\r
     this\r
   \r
   opt_div_style: () ->\r
@@ -30,7 +33,7 @@ class Pettanr.Views.PanelPicture.Element extends Backbone.View
       @merge_opacity(style, opacity)\r
     {\r
       vPicture: @element.get('id'), \r
-      src: @element.r_url(), \r
+      src: @element.r_url(@picture), \r
       width: Pettanr.to_s(Math.abs(@element.get('width'))) + 'px', \r
       height: Pettanr.to_s(Math.abs(@element.get('height'))) + 'px', \r
       alt: @element.get('caption'), \r
index d23ea44..090c095 100644 (file)
@@ -16,8 +16,9 @@ class Pettanr.Views.Panel.Body extends Backbone.View
     if @panel.is_visible(@operators)\r
       this.$el.html('')\r
       _this = this\r
-      _.each @panel.scenario_elements(), (element) ->\r
-        c = Pettanr[element.singular()].Element\r
+      l = @panel.scenario_elements()\r
+      _.each l, (element) ->\r
+        c = Pettanr.Views[element.singular()].Element\r
         tag = new c({element: element, root: _this.panel, spot: _this.spot})\r
         _this.$el.append(tag.render().el)\r
     else\r
diff --git a/app/assets/javascripts/views/panels/show.js.coffee b/app/assets/javascripts/views/panels/show.js.coffee
new file mode 100644 (file)
index 0000000..34fee5a
--- /dev/null
@@ -0,0 +1,21 @@
+# panel: panel item\r
+# operators: operators\r
+# spot: no opacity element\r
+class Pettanr.Views.Panel.Show extends Backbone.View\r
+  tagName: 'div'\r
+  \r
+  initialize: (options) ->\r
+    @panel = options.panel\r
+    @operators = options.operators\r
+    @spot = options.spot\r
+    @body = new Pettanr.Views.Panel.Body({\r
+      panel: @panel,\r
+      operators: @operators,\r
+      spot: @spot\r
+    })\r
+  \r
+  render: () ->\r
+    this.$el.html('')\r
+    this.$el.append(@body.render().el)\r
+    this\r
+  \r
diff --git a/app/assets/javascripts/views/scrolls/show.js.coffee b/app/assets/javascripts/views/scrolls/show.js.coffee
new file mode 100644 (file)
index 0000000..7649606
--- /dev/null
@@ -0,0 +1,10 @@
+class Pettanr.Views.Scroll.Show extends Backbone.View\r
+  tagName: 'div'\r
+  \r
+  initialize: (options) ->\r
+    @operators = options.operators\r
+  \r
+  render: () ->\r
+    this.$el.html('')\r
+    this\r
+  \r
index 92b7e67..d1a61df 100644 (file)
@@ -6,21 +6,25 @@ class Pettanr.Views.SpeechBalloon.Element extends Backbone.View
     @element = options.element\r
     @root = options.root\r
     @spot = options.spot\r
+    @balloon = new Pettanr.Balloon(@element.get('balloon'))\r
+    @speech = new Pettanr.Speech(@element.get('speech'))\r
   \r
   render: () ->\r
-    attr = {style: @style()}\r
-    @balloon = new Pettanr.Views.Balloon.Element({\r
-      element: @element\r
+    @attr = {style: Pettanr.to_style(@style())}\r
+    @b = new Pettanr.Views.Balloon.Element({\r
+      element: @balloon\r
       root: @root,\r
       spot: @spot\r
     })\r
-    @speech = new Pettanr.Views.Speech.Element({\r
-      element: @element\r
+    @s = new Pettanr.Views.Speech.Element({\r
+      element: @speech\r
       root: @root,\r
       spot: @spot\r
     })\r
     this.$el.attr(@attr)\r
-    this.$el.html(@img.render().el)\r
+    this.$el.html('')\r
+    this.$el.append(@b.render().el)\r
+    this.$el.append(@s.render().el)\r
     this\r
   \r
   style: () ->\r
index cf7110a..62099ac 100644 (file)
@@ -8,7 +8,7 @@ class Pettanr.Views.Speech.Element extends Backbone.View
     @spot = options.spot\r
   \r
   render: () ->\r
-    attr = {style: Pettanr.to_style(@outer_style())}\r
+    @outer_attr = {style: Pettanr.to_style(@outer_style())}\r
     @div = new Tag.Div({\r
       attr: {\r
         style: Pettanr.to_style(@inner_style())\r
@@ -16,7 +16,7 @@ class Pettanr.Views.Speech.Element extends Backbone.View
       content: @element.scenario(),\r
       class_name: 'pettanr-comic-speech-inner'\r
     })\r
-    this.$el.attr(@attr)\r
+    this.$el.attr(@outer_attr)\r
     this.$el.html(@div.render().el)\r
     this\r
   \r
index f487816..f3a629e 100644 (file)
@@ -21,8 +21,6 @@ module Locmare
           
           def items
             if self.source_by_model?
-              ::Manifest.manifest.system_resources.select_items[self.select_item_name]
-            else
               resource_model_name = self.model_attribute_manifest.source.resource_model_name
               resource_list_name = self.model_attribute_manifest.source.resource_list_name
               filter_column_name = self.model_attribute_manifest.source.filter_column_name
@@ -31,14 +29,16 @@ module Locmare
               list.items(nil, {:id => filter_id}, 
                 0, -1 # no limit
               ).map {|i| [i.caption, i.id] }
+            else
+              ::Manifest.manifest.system_resources.select_items[self.select_item_name]
             end
           end
           
           def source_by_model?
             case self.model_attribute_manifest.source.type
-            when 'model', 'filter'
+            when 'filter'
               true
-            when 'magic_number'
+            when 'model', 'magic_number'
               false
             else
               nil