OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
authoryasushiito <yas@pen-chan.jp>
Tue, 12 Nov 2013 08:19:27 +0000 (17:19 +0900)
committeryasushiito <yas@pen-chan.jp>
Tue, 12 Nov 2013 08:19:27 +0000 (17:19 +0900)
47 files changed:
app/assets/images/item.png [new file with mode: 0644]
app/assets/javascripts/configurations.js.coffee
app/assets/javascripts/helpers/popup.js.coffee [new file with mode: 0644]
app/assets/javascripts/panels.js.coffee
app/controllers/artists_controller.rb
app/controllers/authors_controller.rb
app/controllers/balloons_controller.rb
app/controllers/comics_controller.rb
app/controllers/ground_colors_controller.rb
app/controllers/ground_pictures_controller.rb
app/controllers/license_groups_controller.rb
app/controllers/licenses_controller.rb
app/controllers/original_pictures_controller.rb
app/controllers/panel_pictures_controller.rb
app/controllers/panels_controller.rb
app/controllers/pictures_controller.rb
app/controllers/resource_pictures_controller.rb
app/controllers/scroll_panels_controller.rb
app/controllers/scrolls_controller.rb
app/controllers/sheet_panels_controller.rb
app/controllers/sheets_controller.rb
app/controllers/speech_balloon_templates_controller.rb
app/controllers/speech_balloons_controller.rb
app/controllers/speeches_controller.rb
app/controllers/stories_controller.rb
app/controllers/story_sheets_controller.rb
app/controllers/system_pictures_controller.rb
app/helpers/application_helper.rb
app/models/ground_color.rb
app/models/sheet.rb
app/models/sheet_panel.rb
app/views/comics/_list_item.html.erb
app/views/comics/show.prof.erb [new file with mode: 0644]
app/views/ground_colors/_form.html.erb
app/views/ground_colors/show.html.erb
app/views/layouts/test.prof.erb [new file with mode: 0644]
app/views/panels/_form.html.erb
app/views/panels/_popup_helper.html.erb [new file with mode: 0644]
app/views/sheets/show.html.erb
app/views/top/prof.prof.erb [new file with mode: 0644]
config/initializers/mime_types.rb
config/locales/pettanr.ja.yml
config/magic_number.yml
db/migrate/20131029021930_add_offset_on_ground_color.rb [new file with mode: 0644]
script/preup.rb
spec/factories.rb
spec/models/ground_color_spec.rb

diff --git a/app/assets/images/item.png b/app/assets/images/item.png
new file mode 100644 (file)
index 0000000..132ca25
Binary files /dev/null and b/app/assets/images/item.png differ
index 091a42a..d519e6d 100644 (file)
             range: [0, 0xffffff],\r
           }\r
         },\r
+        orientation: {\r
+          type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            range: [0, 1],\r
+          }\r
+        },\r
+        xy: {\r
+          type: 'number',\r
+          rules : {\r
+            number: true,\r
+          }\r
+        },\r
+        wh: {\r
+          type: 'number',\r
+          rules : {\r
+            number: true,\r
+          }\r
+        },\r
         z: {\r
           type: 'number',\r
           rules : {\r
           column: 'picture_id',\r
           type: 'hidden',\r
           label: {\r
-            type: 'hidden'\r
           },\r
+          helpers: {\r
+            popup: {\r
+              path: 'panels/popup_helper',\r
+              source: 'pictures',\r
+              options: {\r
+              }\r
+            }\r
+          }\r
           options: {\r
           }\r
         },\r
             }\r
           },\r
         },\r
+        orientation: {\r
+          column: 'orientation',\r
+          type: 'select',\r
+          label: {\r
+          },\r
+          options: {\r
+            source: 'magic_number',\r
+            key: 'ground_color_orientation_items',\r
+            row_break: true\r
+          }\r
+        },\r
+        xy: {\r
+          column: 'xy',\r
+          type: 'number',\r
+          label: {\r
+          },\r
+          options: {\r
+            size: 5, \r
+          }\r
+        },\r
+        wh: {\r
+          column: 'wh',\r
+          type: 'number',\r
+          label: {\r
+          },\r
+          options: {\r
+            size: 5, \r
+            row_break: true\r
+          }\r
+        },\r
         z: {\r
           column: 'z',\r
           type: 'hidden',\r
         'panel_id',\r
         'caption',\r
         'code',\r
+        'orientation',\r
+        'xy',\r
+        'wh',\r
         'z',\r
         't',\r
       ]\r
diff --git a/app/assets/javascripts/helpers/popup.js.coffee b/app/assets/javascripts/helpers/popup.js.coffee
new file mode 100644 (file)
index 0000000..85fd29b
--- /dev/null
@@ -0,0 +1,55 @@
+class PettanrPopupHelper\r
+  confirm_confirm_confirm = () ->\r
+    confirm(  )\r
+  \r
+  @speech_balloon_tag_id = (element_part) ->\r
+    window.PettanrEditor.element_tag_id(element_part)\r
+  \r
+  @speech_balloon_template_id = (element_part) ->\r
+    trace = PettanrBalloonRHelper.speech_balloon_tag_id(element_part)\r
+    parseInt($(trace + 'speech_balloon_template_id').val())\r
+  \r
+  @template_class = (element_part) ->\r
+    id = PettanrBalloonRHelper.speech_balloon_template_id(element_part)\r
+    engine_name = window.PettanrSpeechBalloonTemplate.speech_balloon_templates[id]\r
+    window.PettanrSpeechBalloonTemplate.scripts[engine_name]\r
+  \r
+  @settings = (element_part) ->\r
+    id = PettanrBalloonRHelper.speech_balloon_template_id(element_part)\r
+    window.PettanrSpeechBalloonTemplate.settings(id)\r
+  \r
+  @r_step = (element_part) ->\r
+    settings = PettanrBalloonRHelper.settings(element_part)\r
+    settings['speech_balloon']['r_step']\r
+  \r
+  @system_picture_id = (element_part, idx) ->\r
+    settings = PettanrBalloonRHelper.settings(element_part)\r
+    settings[idx]['balloon']['system_picture_id']\r
+  \r
+  # \r
+  @add_helper = () ->\r
+    editor = window.PettanrEditor\r
+    \r
+    $('.popup').map -> \r
+      panel = $(editor.panel_tag_id($(@)))\r
+      if editor.is_editable(panel)\r
+        $(@).html('<button>...</button>')\r
+        trace = editor.panel_tag_id($(@))\r
+        popup = $(trace + 'popup')\r
+        popup.dialog {\r
+          autoOpen: false,\r
+          modal: true,\r
+        }\r
+        $('button', $(@)).map -> \r
+          $(@).click -> \r
+            trace = editor.panel_tag_id($(@).parent())\r
+            popup = $(trace + 'popup')\r
+            popup.attr('data-value', '')\r
+            popup.dialog('open')\r
+            \r
+      else\r
+        $(@).css('display', 'none')\r
+    \r
+    \r
+  \r
+@PettanrPopupHelper = PettanrPopupHelper\r
index a0fd330..b541b22 100644 (file)
@@ -12,6 +12,7 @@ $ ->
     v.add_helper( n, '' )\r
   PictureSizeHelper = window.PettanrPictureSizeHelper\r
   ColorHelper = window.PettanrColorHelper\r
+  PopupHelper = window.PettanrPopupHelper\r
   \r
   #panel = new Panel\r
   #pp = new PanelPicture\r
@@ -44,6 +45,14 @@ $ ->
     if Object.keys(rules).length > 0\r
       v = form.validate({ignore:[],rules: rules})\r
   \r
+  display_panel = (panel, vis) ->\r
+    v = if vis\r
+      ''\r
+    else\r
+      'none'\r
+    trace = editor.panel_tag_id(panel)\r
+    $(trace).css('display', v)\r
+  \r
   validate_panel = (form) ->\r
     valid = form.valid()\r
     bc = if valid\r
@@ -52,14 +61,16 @@ $ ->
       '#ef29ef'\r
     $('a', $('#tabs-1-tab')).map ->\r
       $(@).css('background-color', bc)\r
+    display_panel(form, valid)\r
     valid\r
   \r
   display_element = (element, vis) ->\r
-    v = if vis\r
+    trace = editor.element_tag_id(element)\r
+    d = $(trace + '_destroy').val()\r
+    v = if vis and d.length < 1\r
       ''\r
     else\r
       'none'\r
-    trace = editor.element_tag_id(element)\r
     switch element.attr('element_type')\r
       when 'panel_picture'\r
         trace = trace + 'div'\r
@@ -208,6 +219,7 @@ $ ->
     \r
     # panel picture\r
     PictureSizeHelper.add_helper()\r
+    PopupHelper.add_helper()\r
     \r
     $('.pettanr-panel-picture-wrapper').map ->\r
       $(@).draggable {\r
@@ -421,16 +433,24 @@ $ ->
 \r
     \r
     # ground-picture\r
+    refresh_ground_picture = (element_trace)  ->\r
+      x = parseInt($(element_trace + 'x').val()).toString() + 'px'\r
+      y = parseInt($(element_trace + 'y').val()).toString() + 'px'\r
+      $(element_trace).css('background-position', x + ' ' + y)\r
+    \r
     # sync view \r
     $('input').map  ->\r
       if editor.element_is('ground_picture', $(@))\r
-        $(@).focusout ->\r
-          switch $(@).attr('column')\r
-            when 'x', 'y'\r
+        switch $(@).attr('column')\r
+          when 'x', 'y'\r
+            $(@).focusout ->\r
               trace = editor.element_tag_id($(@))\r
-              x = parseInt($(trace + 'x').val()).toString() + 'px'\r
-              y = parseInt($(trace + 'y').val()).toString() + 'px'\r
-              $(trace).css('background-position', x + ' ' + y)\r
+              refresh_ground_picture(trace)\r
+            $(@).spinner {\r
+              stop: ( event, ui ) ->\r
+                trace = editor.element_tag_id($(@))\r
+                refresh_ground_picture(trace)\r
+            }\r
     $('select').map  ->\r
       if editor.element_is('ground_picture', $(@))\r
         $(@).change ->\r
@@ -445,11 +465,65 @@ $ ->
     # ground_color\r
     ColorHelper.add_helper($('.ground_color-code-wrap'), 'code')\r
     \r
+    refresh_ground_color = (element_trace)  ->\r
+      orientation = parseInt( $(element_trace + 'orientation').val() )\r
+      xy = $(element_trace + 'xy').val()\r
+      wh = $(element_trace + 'wh').val()\r
+      div_offset = if xy\r
+        xy\r
+      else\r
+        0\r
+      div_size = if wh\r
+        wh\r
+      else\r
+        100 - div_offset\r
+      div_x = if orientation == 0\r
+        0\r
+      else\r
+        div_offset\r
+      div_y = if orientation == 0\r
+        div_offset\r
+      else\r
+        0\r
+      div_width = if orientation == 0\r
+        100\r
+      else\r
+        div_size\r
+      div_height = if orientation == 0\r
+        div_size\r
+      else\r
+        100\r
+      div = $(element_trace)\r
+      div.css('left', div_x.toString() + '%')\r
+      div.css('top', div_y.toString() + '%')\r
+      div.css('width', div_width.toString() + '%')\r
+      div.css('height', div_height.toString() + '%')\r
+    \r
     # sync view \r
     $('input').map  ->\r
       if editor.element_is('ground_color', $(@))\r
-        if $(@).attr('column') == 'code'\r
-          $(@).hide()\r
+        switch $(@).attr('column')\r
+          when 'code'\r
+            $(@).hide()\r
+          when 'xy', 'wh'\r
+            $(@).spinner {\r
+              stop: ( event, ui ) ->\r
+                trace = editor.element_tag_id($(@))\r
+                refresh_ground_color(trace)\r
+              , min: 0\r
+              , max: 100\r
+            }\r
+            $(@).focusout ->\r
+              trace = editor.element_tag_id($(@))\r
+              refresh_ground_color(trace)\r
+    \r
+    $('select').map  ->\r
+      if editor.element_is('ground_color', $(@))\r
+        switch $(@).attr('column')\r
+          when 'orientation'\r
+            $(@).change ->\r
+              trace = editor.element_tag_id($(@))\r
+              refresh_ground_color(trace)\r
 \r
     update_t = (ultrace) -> \r
       t = 0\r
index dbcfab5..d6c4a0a 100644 (file)
@@ -28,6 +28,7 @@ class ArtistsController < ApplicationController
 
     respond_to do |format|
       format.html # show.html.erb
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render :json => @ar.to_json(Artist.show_json_opt) }
     end
   end
index 7f70b72..345c6eb 100644 (file)
@@ -28,6 +28,7 @@ class AuthorsController < ApplicationController
 
     respond_to do |format|
       format.html
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render :json => @au.to_json(Author.show_json_opt) }
     end
   end
index d3c6727..885e055 100644 (file)
@@ -25,6 +25,7 @@ class BalloonsController < ApplicationController
     @balloon = Balloon.show(params[:id], [@user, @admin])
     respond_to do |format|
       format.html # show.html.erb
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @balloon.to_json(Balloon.show_json_opt) }
     end
   end
index d8729a3..d60fd81 100644 (file)
@@ -29,6 +29,7 @@ class ComicsController < ApplicationController
 
     respond_to do |format|
       format.html 
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @comic.to_json(Comic.show_json_opt) }
       format.atom 
       format.rss 
index e9456f9..f990f24 100644 (file)
@@ -26,6 +26,7 @@ class GroundColorsController < ApplicationController
     @ground_color = GroundColor.show(params[:id], [@user, @admin])
     respond_to do |format|
       format.html # show.html.erb
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @ground_color.to_json(GroundColor.show_json_opt) }
     end
   end
index 9cf4159..16989a0 100644 (file)
@@ -26,6 +26,7 @@ class GroundPicturesController < ApplicationController
     @ground_picture = GroundPicture.show(params[:id], [@user, @admin])
     respond_to do |format|
       format.html # show.html.erb
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @ground_picture.to_json(GroundPicture.show_json_opt) }
     end
   end
index 4433053..5e652a1 100644 (file)
@@ -19,6 +19,7 @@ class LicenseGroupsController < ApplicationController
     @license_group = LicenseGroup.show(params[:id])
     respond_to do |format|
       format.html # show.html.erb
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @license_group.to_json(LicenseGroup.show_json_opt) }
     end
   end
index d30b226..49e1112 100644 (file)
@@ -19,6 +19,7 @@ class LicensesController < ApplicationController
     @license = License.show(params[:id])
     respond_to do |format|
       format.html # show.html.erb
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @license.to_json(License.show_json_opt) }
     end
   end
index 2d0b463..6f70a0e 100644 (file)
@@ -32,6 +32,7 @@ class OriginalPicturesController < ApplicationController
         @original_picture_license_group  = OriginalPictureLicenseGroup.new :original_picture_id => @original_picture.id
         render
       }
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @original_picture.to_json(OriginalPicture.show_json_opt)}
     end
   end
index 5a98947..69f7cb5 100644 (file)
@@ -28,6 +28,7 @@ class PanelPicturesController < ApplicationController
 
     respond_to do |format|
       format.html
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render :json => @panel_picture.to_json(PanelPicture.show_json_opt) }
     end
   end
index 28a03fe..51f7b63 100644 (file)
@@ -39,6 +39,7 @@ class PanelsController < ApplicationController
           @fresh_sheets = SheetPanel.mylist(@author, 1, 5).map {|sp| sp.sheet}
         end
       }
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @panel.panel_elements_as_json }
       format.jsonp {
         render :json => "callback(" + @panel.panel_elements_as_json + ");"
index b8ab99d..d124c9e 100644 (file)
@@ -19,6 +19,7 @@ class PicturesController < ApplicationController
       format.gif { send_data(@picture.restore(params[:subdir]), opt ) }
       format.jpeg { send_data(@picture.restore(params[:subdir]), opt ) }
       format.html 
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render :json => @picture.to_json}
     end
   end
index 1612443..ae83fbd 100644 (file)
@@ -32,6 +32,7 @@ class ResourcePicturesController < ApplicationController
       format.gif { send_data(@resource_picture.restore(params[:subdir]), opt ) }
       format.jpeg { send_data(@resource_picture.restore(params[:subdir]), opt ) }
       format.html # show.html.erb
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render :json => @resource_picture.to_json(ResourcePicture.show_json_opt)}
     end
   end
index f694433..305638c 100644 (file)
@@ -28,6 +28,7 @@ class ScrollPanelsController < ApplicationController
 
     respond_to do |format|
       format.html # show.html.erb
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @scroll_panel.scroll_panel_as_json(@author) }
     end
   end
index 62a8413..9c255bd 100644 (file)
@@ -34,6 +34,7 @@ class ScrollsController < ApplicationController
         end
       }
       format.json { render json: @scroll.to_json(Scroll.show_json_opt) }
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.atom 
       format.rss 
     end
index 23320d6..d7a7961 100644 (file)
@@ -28,6 +28,7 @@ class SheetPanelsController < ApplicationController
 
     respond_to do |format|
       format.html # show.html.erb
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @sheet_panel.sheet_panel_as_json(@author) }
     end
   end
index 7c63a0b..b7cf892 100644 (file)
@@ -35,6 +35,7 @@ class SheetsController < ApplicationController
           @fresh_stories = StorySheet.mylist(@author, 1, 5).map {|ss| ss.story}
         end
       }
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @sheet.to_json(Sheet.show_json_opt) }
       format.atom 
       format.rss 
index ab39367..eb8d883 100644 (file)
@@ -26,6 +26,7 @@ class SpeechBalloonTemplatesController < ApplicationController
 
     respond_to do |format|
       format.html # show.html.erb
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json {
         render :json => @speech_balloon_template.to_json(SpeechBalloonTemplate.show_json_opt)
       }
index bc5aea8..9350511 100644 (file)
@@ -27,6 +27,8 @@ class SpeechBalloonsController < ApplicationController
     @speech_balloon = SpeechBalloon.show(params[:id], [@user, @admin])
     respond_to do |format|
       format.html # show.html.erb
+      format.prof  { render :template => 'top/prof', :layout => true }
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @speech_balloon.to_json(SpeechBalloon.show_json_opt) }
     end
   end
index 1095fdb..24ca971 100644 (file)
@@ -25,6 +25,7 @@ class SpeechesController < ApplicationController
     @speech = Speech.show(params[:id], [@user, @admin])
     respond_to do |format|
       format.html # show.html.erb
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @speech.to_json(Speech.show_json_opt) }
     end
   end
index 366c4a8..fba32e6 100644 (file)
@@ -32,6 +32,7 @@ class StoriesController < ApplicationController
           @new_sheets = Sheet.mylist(@author, 1, 5)
         end
       }
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @story.to_json(Story.show_json_opt) }
     end
   end
index cefa5a0..020fee1 100644 (file)
@@ -28,6 +28,7 @@ class StorySheetsController < ApplicationController
 
     respond_to do |format|
       format.html # show.html.erb
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @story_sheet.to_json(StorySheet.show_json_opt) }
     end
   end
index ae6a671..ad83b27 100644 (file)
@@ -34,6 +34,7 @@ class SystemPicturesController < ApplicationController
       format.gif { send_data(@system_picture.restore, opt ) }
       format.jpeg { send_data(@system_picture.restore, opt ) }
       format.html # show.html.erb
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @system_picture.to_json(SystemPicture.show_json_opt)}
     end
   end
index 2ad8c17..ce88098 100644 (file)
@@ -24,6 +24,10 @@ module ApplicationHelper
     t(MagicNumber[name][index][0])
   end
   
+  def item_tag 
+    tag :img, :src => asset_path('item.png'), :width => 35, :height => 35
+  end
+  
   def icon_tag name, opt = {}
     title = opt[:object] ? (name.to_s + ' ID:' + opt[:object].id.to_s) : name
     size = opt[:size] ? opt[:size].to_i : 35
@@ -125,8 +129,7 @@ module ApplicationHelper
                 },
                 "caption": {
                     "type": "text",
-                    "rules": {
-                    }
+                    "rules": {}
                 },
                 "publish": {
                     "type": "number",
@@ -591,6 +594,29 @@ module ApplicationHelper
                         ]
                     }
                 },
+                "orientation": {
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "range": [
+                            0,
+                            1
+                        ]
+                    }
+                },
+                "xy": {
+                    "type": "number",
+                    "rules": {
+                        "number": true
+                    }
+                },
+                "wh": {
+                    "type": "number",
+                    "rules": {
+                        "number": true
+                    }
+                },
                 "z": {
                     "type": "number",
                     "rules": {
@@ -856,8 +882,13 @@ module ApplicationHelper
                 "picture_id": {
                     "column": "picture_id",
                     "type": "hidden",
-                    "label": {
-                        "type": "hidden"
+                    "label": {},
+                    "helpers": {
+                        "popup": {
+                            "path": "panels/popup_helper",
+                            "source": "pictures",
+                            "options": {}
+                        }
                     },
                     "options": {}
                 },
@@ -1472,6 +1503,33 @@ module ApplicationHelper
                         }
                     }
                 },
+                "orientation": {
+                    "column": "orientation",
+                    "type": "select",
+                    "label": {},
+                    "options": {
+                        "source": "magic_number",
+                        "key": "ground_color_orientation_items",
+                        "row_break": true
+                    }
+                },
+                "xy": {
+                    "column": "xy",
+                    "type": "number",
+                    "label": {},
+                    "options": {
+                        "size": 5
+                    }
+                },
+                "wh": {
+                    "column": "wh",
+                    "type": "number",
+                    "label": {},
+                    "options": {
+                        "size": 5,
+                        "row_break": true
+                    }
+                },
                 "z": {
                     "column": "z",
                     "type": "hidden",
@@ -1494,6 +1552,9 @@ module ApplicationHelper
                 "panel_id",
                 "caption",
                 "code",
+                "orientation",
+                "xy",
+                "wh",
                 "z",
                 "t"
             ]
index 7f1a3f0..5204a02 100644 (file)
@@ -6,6 +6,9 @@ class GroundColor < ActiveRecord::Base
   
   validates :panel_id, :numericality => {:allow_blank => true}
   validates :code, :presence => true, :numericality => {:greater_than_or_equal_to => 0, :less_than => 0x1000000}
+  validates :orientation, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
+  validates :xy, :numericality => {:greater_than_or_equal_to => 0, :allow_blank => true}
+  validates :wh, :numericality => {:greater_than_or_equal_to => 0, :allow_blank => true}
   validates :z, :presence => true, :numericality => {:greater_than => 0}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
@@ -71,9 +74,49 @@ class GroundColor < ActiveRecord::Base
     self.panel.visible? roles
   end
   
+  def div_offset
+    xy ? xy : 0
+  end
+  
+  def div_size
+    wh ? wh : 100 - self.div_offset
+  end
+  
+  def div_x
+    if self.orientation == 0
+      0
+    else
+      self.div_offset
+    end
+  end
+  
+  def div_y
+    if self.orientation == 0
+      self.div_offset
+    else
+      0
+    end
+  end
+  
+  def div_width
+    if self.orientation == 0
+      100
+    else
+      self.div_size
+    end
+  end
+  
+  def div_height 
+    if self.orientation == 0
+      self.div_size
+    else
+      100
+    end
+  end
+  
   def opt_div_style spot = nil, opacity = 20
     o = (spot and spot != self) ? "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});" : ''
-    "position: absolute; width:#{self.get_panel.width}px; height:#{self.get_panel.height}px; z-index:#{self.z}; background-color:##{format("%06x", self.code)}; #{o}"
+    "position: absolute; left:#{self.div_x}%; top:#{self.div_y}%; width:#{self.div_width}%; height:#{self.div_height}%; z-index:#{self.z}; background-color:##{format("%06x", self.code)}; #{o}"
   end
   
   def boost
index f16d8ee..b24e920 100644 (file)
@@ -283,6 +283,7 @@ class Sheet < ActiveRecord::Base
     Sheet.transaction do
       self.sheet_elements.each do |elm|
         elm.new_sheet = self
+        elm.boost au
       end
       res = self.save
       unless validate_child
@@ -326,10 +327,28 @@ class Sheet < ActiveRecord::Base
     r
   end
   
+  def copyable?
+    r = true
+    Sheet.each_element_class_names do |n|
+      self.elements_by_class_name(n).each do |elm|
+        next if elm.copyable?
+        r = false
+        break
+      end
+      break unless r
+    end
+    r
+  end
+  
   def copy
     attr = self.copy_attributes
     Sheet.each_element_class_names do |n|
-      attr.merge! Sheet.class_name_to_class(n).panelize(self.elements_by_class_name(n).map {|elm|  elm.copy_attributes})
+      element_attr = Sheet.class_name_to_class(n).panelize(
+        self.elements_by_class_name(n).map {|elm|
+          elm.copy_attributes.merge elm.panel_attributes
+        }
+      )
+      attr.merge! element_attr
     end
     attr
   end
index cc91abf..b1b48ff 100644 (file)
@@ -2,6 +2,7 @@ class SheetPanel < ActiveRecord::Base
   belongs_to :author
   belongs_to :panel
   belongs_to :sheet
+  accepts_nested_attributes_for :panel, :allow_destroy => true
   
   validates :sheet_id, :numericality => {:allow_blank => true}
   validates :panel_id, :numericality => {:allow_blank => true}
@@ -216,11 +217,38 @@ class SheetPanel < ActiveRecord::Base
       r = self.attributes
       r.delete 'id'
       r.delete 'sheet_id'
+      r.delete 'panel_id'   # create panel
       r.delete 'created_at'
       r.delete 'updated_at'
       r
     end
-    
+  
+  def copyable?
+    if self.panel and self.panel.publish? == false
+      false
+    else
+      true
+    end
+  end
+  
+  def boost au
+    if self.panel
+      self.panel.author_id = au.id
+      self.panel.panel_elements.each do |elm|
+        elm.new_panel = self
+        elm.boost
+      end
+    end
+  end
+  
+  def panel_attributes
+    if self.panel
+      {'panel_attributes' => self.panel.copy}
+    else
+      {}
+    end
+  end
+  
   def self.new_t sheet_id
     r = SheetPanel.max_t(sheet_id)
     r.blank? ? 0 : r.to_i + 1
index 059b727..73ff51e 100644 (file)
@@ -1,5 +1,6 @@
 <tr>
   <td>
+    <%= link_to item_tag, comic_path(comic, :format => :prof) %>
     <%= link_to comic_icon(:object => comic, :size => 25), comic_path(comic) %>
     <%= link_to h(truncate(comic.title, :length => 40)), comic_path(comic) %>
     (<%= comic.stories.size -%>)
diff --git a/app/views/comics/show.prof.erb b/app/views/comics/show.prof.erb
new file mode 100644 (file)
index 0000000..b38609f
--- /dev/null
@@ -0,0 +1,53 @@
+<% @page_title = t('.title') + ':' + @comic.title %>
+<h1><%= t('.title') %></h1>
+<p id="notice"><%= notice %></p>
+
+<p>
+  <b><%= t_m 'Comic.title' -%>:</b>
+  <%= link_to h(@comic.title), comic_path(@comic) %>
+</p>
+
+<p>
+  <b><%= t_m 'Comic.description' -%>:</b>
+  <%= h(@comic.description) %>
+</p>
+
+<p>
+  <b><%= t_m 'Comic.visible' -%>:</b>
+  <%= t_selected_item('comic_visible_items', @comic.visible) %>
+</p>
+
+<p>
+  <b><%= t_m 'Comic.author_id' -%>:</b>
+  <%= link_to h(@comic.author.name), author_path(@comic.author) %>
+</p>
+
+<% @comic.stories.each do |story| %>
+  <% if story.visible? @author -%>
+    <div>
+      <%= link_to t('stories.show.t', :t => story.disp_t), story_path(story) %>
+      <%= link_to h(story.title), play_story_path(story) %>
+    </div>
+  <% end %>
+<% end %>
+<p>
+  <b><%= t_m 'Comic.created_at' -%>:</b>
+  <%= l @comic.created_at %>
+</p>
+
+<p>
+  <b><%= t_m 'Comic.updated_at' -%>:</b>
+  <%= l @comic.updated_at %>
+</p>
+
+<% if @comic.own? @author -%>
+  <%= link_to t('link.edit'), edit_comic_path(@comic) %>
+  <%= link_to t('link.destroy'), comic_path(@comic), :method => :delete %>
+
+  <h2>
+    <%= t('stories.index.new') %>
+  </h2>
+  <% @story = Story.new -%>
+  <% @story.supply_default -%>
+  <% @story.attributes = {:comic_id => @comic.id} -%>
+<% end %>
index 4e39557..b8aadcf 100644 (file)
   <div class="row_break">
   </div>
   <div class="field">
+    <%= f.label :orientation %>
+    <%= f.collection_select :orientation, t_select_items(MagicNumber['ground_color_orientation_items']), :last, :first, :html => {:selected => elm.orientation} %>
+
+    <%= f.label :xy %>
+    <%= f.number_field :xy, elm.field_tag_attributes(:xy, no_attr, :size => 5) %>
+
+    <%= f.label :wh %>
+    <%= f.number_field :wh, elm.field_tag_attributes(:wh, no_attr, :size => 5) %>
+  </div>
+  <div class="row_break">
+  </div>
+  <div class="field">
     <%= f.label :z %>
     <%= f.number_field :z, elm.field_tag_attributes(:z, no_attr, :size => 5) %>
   </div>
index e7fec19..0b9b3d0 100644 (file)
@@ -9,6 +9,21 @@
 </p>
 
 <p>
+  <b><%= t_m 'GroundColor.orientation' -%>:</b>
+  <%= t_selected_item('ground_color_orientation_items', @ground_color.orientation) %>
+</p>
+
+<p>
+  <b><%= t_m 'GroundColor.xy' -%>:</b>
+  <%= @ground_color.xy %>
+</p>
+
+<p>
+  <b><%= t_m 'GroundColor.wh' -%>:</b>
+  <%= @ground_color.wh %>
+</p>
+
+<p>
   <b><%= t_m 'GroundColor.z' -%>:</b>
   <%= @ground_color.z %>
 </p>
diff --git a/app/views/layouts/test.prof.erb b/app/views/layouts/test.prof.erb
new file mode 100644 (file)
index 0000000..2a17f1d
--- /dev/null
@@ -0,0 +1,81 @@
+<!DOCTYPE html>\r
+<html>\r
+<head>\r
+  <title>\r
+    <% if @page_title %>\r
+      <%= h @page_title %>\r
+    <% else %>\r
+      <%= t("#{params[:controller]}.#{params[:action]}.title") %>\r
+    <% end %>\r
+    - <%= h(MagicNumber['profile']['users']['caption']) %>\r
+  </title>\r
+  <%= stylesheet_link_tag "application" %>\r
+  <%= javascript_include_tag "application" %>\r
+  <%= raw panel_editor_javascript_include_tags %>\r
+  <%= csrf_meta_tags %>\r
+</head>\r
+<body>\r
+\r
+<div width="100%">\r
+<table class="no-border">\r
+  <tr>\r
+    <td width="50%">\r
+      <h3><%= link_to MagicNumber['profile']['users']['caption'], main_app.root_path %></h3>\r
+    </td>\r
+    <td width="30%">\r
+      <% if user_signed_in? %>\r
+        <%# link_to t('top.metro.title'), '/top/metro' %>\r
+      <% end %>\r
+    </td>\r
+    <td>\r
+      <div>\r
+        <% if @author %>\r
+          <%= link_to h(truncate(@author.name, :length => 12)), main_app.author_path(@author) %>\r
+        <% end %>\r
+      </div>\r
+      <div>\r
+        <% if @artist %>\r
+          <%= link_to h(truncate(@artist.name, :length => 12)), main_app.artist_path(@artist) %>\r
+        <% end %>\r
+      </div>\r
+    </td>\r
+    <td>\r
+      <% if user_signed_in? %>\r
+        <%= link_to t('home.configure.title'), '/home/configure' %>\r
+        <%= link_to t('home.sign_out.title'), main_app.destroy_user_session_path, :method => :delete %>\r
+      <% else %>\r
+        <%= link_to "sign in", main_app.new_user_session_path %>\r
+      <% end %>\r
+  </td>\r
+  </tr>\r
+</table>\r
+</div>\r
+<%= yield %>\r
+<div width="100%" style="background-color: #faddfa; padding: 5px;">\r
+  <%= link_to t('tab.demander.title'), main_app.demanders_path %>\r
+  <% if demand_user_signed_in? %>\r
+    <%= link_to t_m('Demander'), main_app.demanders_path %>\r
+    <%= link_to t('home.sign_out.title'), main_app.destroy_demand_user_session_path, :method => :delete %>\r
+  <% else %>\r
+    <%= link_to t('home.sign_in.title'), main_app.new_demand_user_session_path %>\r
+  <% end %>\r
+</div>\r
+<div width="100%" style="background-color: #ddddfa; padding: 5px;">\r
+  <%= link_to t('tab.system.title'), '/system' %>\r
+  <% if admin_signed_in? %>\r
+    <%= link_to t('tab.system.browse'), '/system/browse' %>\r
+    <%= link_to t('tab.system.approve'), '/system/waiting_list' %>\r
+    <%= link_to t('tab.system.port'), '/system/import' %>\r
+    <%= link_to t('tab.system.token'), '/system/auth_token' %>\r
+    <%= t('tab.system.layout') %>:\r
+    <%= link_to t('tab.system.test'), '/system/test_layout' %>\r
+    <%= link_to t('tab.system.production'), '/system/production_layout' %>\r
+    <%= link_to t('home.sign_out.title'), main_app.destroy_admin_session_path, :method => :delete %>\r
+  <% else %>\r
+    <%= link_to t('home.sign_in.title'), main_app.new_admin_session_path %>\r
+  <% end %>\r
+</div>\r
+<%= javascript_tag 'var server_result=' + @server_result.to_json + ';' %>\r
+\r
+</body>\r
+</html>\r
index 31e9e58..63ae9db 100644 (file)
@@ -10,7 +10,7 @@
     <li id="tabs-5-tab"><a href="#tabs-5">new</a></li>
   </ul>
   <div id="tabs-1">
-    <%= form_for(@panel, :html => {:id => @panel.tag_id('form'), 'data-form-name' => 'panel'}) do |f| %>
+    <%= form_for(@panel, :html => @panel.tag_attributes('form', 'data-form-name' => 'panel')) do |f| %>
       <%= render 'system/error_explanation', :obj => @panel %>
 
       <div class="field">
     </div>
   <% end %>
 </div>
-  <%# text_field_tag "json", '', :id => 'pettanr-configurations' %>
+  <%= text_field_tag "json", '', :id => 'pettanr-configurations' %>
+  <%# %>
+<div <%= raw @panel.tag_attr('popup') -%> style="display: none;" >
+</div>
diff --git a/app/views/panels/_popup_helper.html.erb b/app/views/panels/_popup_helper.html.erb
new file mode 100644 (file)
index 0000000..48753dc
--- /dev/null
@@ -0,0 +1,2 @@
+<span class="popup" <%= raw elm.tag_attr -%>>
+</span>
index 0b297fe..5caa8e9 100644 (file)
@@ -4,19 +4,23 @@
 
 <%= render 'standard', :sheet => @sheet, :author => @author %>
 
+<% if @author %>
+  <% if @sheet.copyable? %>
+    <h2><%= t('sheets.show.copy') -%></h2>
+    <%= form_for(Sheet.new, :html => {:jqform => 'pettanr-sheet-form'}) do |f| %>
+
+      <%= hidden_field_tag "json", @sheet.copy().to_json %>
+      <div>
+        <%= submit_tag t('sheets.show.inspire') -%>
+      </div>
+    <% end %>
+  <% end %>
+<% end %>
+
 <% if @sheet.own? @author %>
   <%= link_to t('link.edit'), edit_sheet_path(@sheet) %>
   <%= link_to t('link.destroy'), sheet_path(@sheet), :method => :delete %>
 
-  <h2><%= t('sheets.show.copy') -%></h2>
-  <%= form_for(Sheet.new, :html => {:jqform => 'pettanr-sheet-form'}) do |f| %>
-
-    <%= hidden_field_tag "json", @sheet.copy().to_json %>
-    <div>
-      <%= submit_tag t('sheets.show.inspire') -%>
-    </div>
-  <% end %>
-  
   <h3><%= t('sheet_panels.append.new_panels') -%></h3>
   <table>
     <% @new_panels.each do |panel| %>
diff --git a/app/views/top/prof.prof.erb b/app/views/top/prof.prof.erb
new file mode 100644 (file)
index 0000000..c8d5ec2
--- /dev/null
@@ -0,0 +1 @@
+prof\r
index 8f16e73..0876b14 100644 (file)
@@ -7,3 +7,4 @@ Mime::Type.register_alias "image/png", :png
 Mime::Type.register_alias "image/gif", :gif
 Mime::Type.register_alias "image/jpeg", :jpeg
 Mime::Type.register_alias "application/javascript", :jsonp
+Mime::Type.register_alias "text/html", :prof
index 1a79c17..9fc3344 100644 (file)
@@ -200,6 +200,9 @@ ja:
       ground_color:
         panel_id: コマ
         code: カラーコード
+        orientation: 方向
+        xy: オフセット
+        wh: サイズ
         z: 重なり
         t: 話順
         caption: 様子
@@ -386,6 +389,10 @@ ja:
         repeat-x: 横方向
         repeat-y: 縦方向
         no-repeat: なし
+    ground_color:
+      orientation:
+        horizontal: 横方向
+        vertical: 縦方向
     speeches:
       font_size:
         ultra_small: 極小
index 2e9f9c2..418e7c3 100644 (file)
     ['select_items.ground_pictures.repeat.repeat-y', 2], 
     ['select_items.ground_pictures.repeat.no-repeat', 3]
   ]
+  ground_color_orientation_items: [
+    ['select_items.ground_color.orientation.horizontal', 0], 
+    ['select_items.ground_color.orientation.vertical', 1]
+  ]
   speech_font_size_items: [
     ['select_items.speeches.font_size.ultra_small', 0.2], 
     ['select_items.speeches.font_size.very_small', 0.4], 
diff --git a/db/migrate/20131029021930_add_offset_on_ground_color.rb b/db/migrate/20131029021930_add_offset_on_ground_color.rb
new file mode 100644 (file)
index 0000000..37ef518
--- /dev/null
@@ -0,0 +1,13 @@
+class AddOffsetOnGroundColor < ActiveRecord::Migration
+  def up
+    add_column :ground_colors, :orientation, :integer, :null => false, :default => 0
+    add_column :ground_colors, :xy, :integer
+    add_column :ground_colors, :wh, :integer
+  end
+
+  def down
+    remove_column :ground_colors, :orientation
+    remove_column :ground_colors, :xy
+    remove_column :ground_colors, :wh
+  end
+end
index cc55dcc..c902cb4 100644 (file)
@@ -32,14 +32,14 @@ Dir.glob(dirname + '/*') do |fn|
         puts 'get attributes.json'\r
         attr = nil\r
         File.open(attrfn, 'r') do |f|\r
-          attr = f.read\r
+          attr = JSON.parse(f.read)\r
         end\r
         json = JSON.parse(open(ls).read)\r
         if json['attributes'] and attr\r
           json['attributes'] = attr\r
         end\r
         File.open(lsfn, 'w') do |f|\r
-          f.write json.to_json.to_s\r
+          f.write JSON.pretty_generate(json)\r
         end\r
       else\r
         FileUtils.cp ls, lsfn\r
index fd19cfa..1a66ab1 100644 (file)
@@ -233,6 +233,7 @@ FactoryGirl.define do
   factory :ground_color, :class => GroundColor do |gc|
     gc.panel_id 1
     gc.code 1
+    gc.orientation 0
     gc.z 1
   end
 
index 7f0567e..f1020d0 100644 (file)
@@ -29,12 +29,18 @@ describe GroundColor do
     context 'オーソドックスなデータのとき' do
       it '下限データが通る' do
         @gc.code = 0
+        @gc.orientation = 0
+        @gc.xy = 0
+        @gc.wh = 0
         @gc.z = 1
         @gc.t = 0
         @gc.should be_valid
       end
       it '上限データが通る' do
         @gc.code = 99999
+        @gc.orientation = 1
+        @gc.xy = 100
+        @gc.wh = 100
         @gc.z = 99999
         @gc.t = 99999
         @gc.should be_valid
@@ -70,6 +76,52 @@ describe GroundColor do
         @gc.should_not be_valid
       end
     end
+    context 'orientationを検証するとき' do
+      it 'nullなら失敗する' do
+        @gc.orientation = nil
+        @gc.should_not be_valid
+      end
+      it '数値でなければ失敗する' do
+        @gc.orientation = 'a'
+        @gc.should_not be_valid
+      end
+      it '負なら失敗する' do
+        @gc.orientation = -1
+        @gc.should_not be_valid
+      end
+      it '2以上なら失敗する' do
+        @gc.orientation = 2
+        @gc.should_not be_valid
+      end
+    end
+    context 'xyを検証するとき' do
+      it 'nullでも通る' do
+        @gc.xy = nil
+        @gc.should be_valid
+      end
+      it '数値でなければ失敗する' do
+        @gc.xy = 'a'
+        @gc.should_not be_valid
+      end
+      it '負なら失敗する' do
+        @gc.xy = -1
+        @gc.should_not be_valid
+      end
+    end
+    context 'whを検証するとき' do
+      it 'nullでも通る' do
+        @gc.wh = nil
+        @gc.should be_valid
+      end
+      it '数値でなければ失敗する' do
+        @gc.wh = 'a'
+        @gc.should_not be_valid
+      end
+      it '負なら失敗する' do
+        @gc.wh = -1
+        @gc.should_not be_valid
+      end
+    end
     context 'zを検証するとき' do
       it 'nullなら失敗する' do
         @gc.z = nil
@@ -83,7 +135,7 @@ describe GroundColor do
         @gc.z = -1
         @gc.should_not be_valid
       end
-      it 'なら失敗する' do
+      it '0なら失敗する' do
         @gc.z = 0
         @gc.should_not be_valid
       end