class Balloon < Peta::Content
load_manifest
- include Peta::ElementPart
belongs_to :speech_balloon
belongs_to :system_picture
# validates :caption, :presence => true
validates :settings, :extend_balloon => true
- def self.colum_structures
- @@colum_structures ||= {
- :r => {
- :helper => 'panels/tail_angle_helper'
- }
- }
- end
-
def url
'/system_pictures/' + self.system_picture.filename
end
self.get_parent.speech_balloon_template.symbol_option
end
- def get_parent
- self.speech_balloon || @new_parent
- end
-
- def tag_element_part_type
- 'balloon'
- end
-
def self.list_where
'panels.publish > 0'
end
validates :z, :presence => true, :numericality => {:greater_than => 0}
validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
- def self.colum_structures
- @@colum_structures ||= {
- :code => {
- :helper => 'panels/color_helper'
- }
- }
- end
-
def self.list_opt_for_panel
{
:ground_colors => {
r
end
- def boost
- end
-
- def tag_element_type
- 'ground_color'
- end
-
def self.list_where
'panels.publish > 0'
end
self.tmb_opt_img_tag
end
- def boost
- end
-
- def tag_element_type
- 'ground_picture'
- end
-
def repeat_text
@@repeat_texts[self.repeat]
end
validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
validates :publish, :presence => true, :numericality => true
- def self.valid_encode_columns
- super + ['caption']
- end
-
def self.each_element_class_names
Manifest.manifest.system_resources.elements.each do |k, n|
yield k
self.publish > 0
end
- # ground_picture element template
- def style_wh
+ def style
{
- 'width' => self.width.to_s + 'px', 'height' => self.height.to_s + 'px'
+ 'width' => self.width.to_s + 'px', 'height' => self.height.to_s + 'px',
+ 'border-style' => 'solid', 'border-width' => self.border.to_s + 'px',
+ 'border-color' => 'black', 'background-color' => 'white'
}
end
- def tag_id c = nil
- 'panel' + self.tag_panel_id + c.to_s
- end
-
- def tag_panel_id
- self.new_record? ? '0' : self.id.to_s
- end
-
- def field_tag_id f
- self.tag_id + f.to_s
- end
-
- def tag_attributes column = nil, opt = {}
+ # ground_picture element template
+ def style_wh
{
- :id => self.field_tag_id(column), :panel_id => self.tag_panel_id
- }.merge(opt)
- end
-
- def select_tag_attributes(selected, column, opt = {})
- [
- {:html => {:selected => selected}},
- self.field_tag_attributes(column, opt)
- ]
- end
-
- def field_tag_attributes column, no_attr, opt = {}
- self.tag_attributes(column).merge(
- {:column => column}
- ).merge(opt)
- end
-
- def tag_attr column = nil, opt = {}
- self.tag_attributes(column, opt).to_attr
- end
-
- def field_tag_attr column, no_attr, opt = {}
- self.field_tag_attributes(column, no_attr, opt).to_attr
+ 'width' => self.width.to_s + 'px', 'height' => self.height.to_s + 'px'
+ }
end
- def render_count
- @render_count ||= 1
- end
-
- def rendered
- @render_count = render_count + 1
- end
-
def self.list_where
'panels.publish > 0'
end
Panel.validate_elements_serial validate_serial_list
end
- def boost
- @new_element_index = 0
- self.panel_elements.each do |elm|
- if elm.new_record?
- elm.new_index = @new_element_index
- @new_element_index += 1
- end
- end
- end
-
def store attr, operators
if attr == false
self.errors.add :base, I18n.t('errors.invalid_json')
validates :z, :presence => true, :numericality => {:greater_than => 0}
validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
- def self.colum_structures
- @@colum_structures ||= {
- :width => {
- :helper => 'panels/size_helper'
- },
- :height => {
- :helper => 'panels/size_helper'
- }
- }
- end
-
def self.list_opt_for_panel
{
:panel_pictures => {
self.picture.symbol_option
end
- def boost
- end
-
- def tag_element_type
- 'panel_picture'
- end
-
def self.list_where
'panels.publish > 0'
end
validates :title, :presence => true, :length => {:maximum => 100}
validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
+
def supply_default
self.visible = 0 if self.visible.blank?
end
validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
- def tag_attributes column = nil, opt = {}
- {
- }
- end
-
def supply_default
self.scroll_id = nil
self.panel_id = nil
def symbol_filename
end
- def tag_id
- 'sheet' + self.tag_sheet_id
- end
-
- def tag_sheet_id
- self.new_record? ? '0' : self.id.to_s
- end
-
- def field_tag_id f
- self.tag_id + f.to_s
- end
-
def self.list_where
'sheets.visible > 0'
end
Sheet.validate_elements_serial validate_serial_list
end
- def boost
- @new_element_index = 0
- self.panel_elements.each do |elm|
- if elm.new_record?
- elm.new_index = @new_element_index
- @new_element_index += 1
- end
- end
- end
-
def store attr, operators
if attr == false
self.errors.add :base, I18n.t('errors.invalid_json')
end
end
- def boost operators
- if self.panel
- self.panel.author_id = operators.author.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}
res
end
- # element.rb
- def self.colum_structures
- @@colum_structures ||= {
- }
- end
-
- def self.path_name with_engine = false
- self.to_s.tableize
- end
-
- def new_index
- @new_index
- end
-
- def new_index= v
- @new_index = v
- end
-
- def new_sheet
- @new_sheet
- end
-
- def new_sheet= v
- @new_sheet = v
- end
-
- def get_sheet
- self.sheet || @new_sheet
- end
-
- def tag_id c = nil
- 'sheet' + self.tag_sheet_id + self.tag_element_type + self.tag_element_id + c.to_s
- end
-
- def field_tag_id f
- self.tag_id + f.to_s
- end
-
- def tag_sheet_id
- (self.get_sheet == nil or self.get_sheet.new_record?) ? '0' : self.get_sheet.id.to_s
- end
-
- def tag_element_id
- self.new_record? ? '0' : self.id.to_s
- end
-
- def tag_element_type
- 'sheet_panel'
- end
-
- def tag_new_index
- self.new_index.to_s
- end
-
- def path_name with_engine = false
- self.class.path_name(with_engine)
- end
-
- def form_template with_engine = false
- self.path_name(with_engine) + '/form'
- end
-
- def scenario_template with_engine = false
- self.path_name(with_engine) + '/scenario'
- end
-
- def element_face_template with_engine = false
- self.path_name(with_engine) + '/element_face'
- end
-
- def form_helper_template(colum_name)
- self.class.colum_structures[colum_name][:helper]
- end
-
- def tag_attributes column = nil, opt = {}
- {
- :id => self.field_tag_id(column), :sheet_id => self.tag_sheet_id,
- :element_id => self.tag_element_id, :element_type => self.tag_element_type
- }.merge(opt)
- end
-
- def field_tag_attributes column, no_attr, opt = {}
- self.tag_attributes(column).merge(
- {:column => column, :new_index => self.tag_new_index, :no_attr => no_attr}
- ).merge(opt)
- end
-
- #render element by body
- def any_tag_attributes name = nil, opt = {}
- r = self.tag_attributes(name)
- r.merge!(
- {:new_index => self.tag_new_index}
- ) if self.new_index
- r.merge(opt)
- end
-
- def select_tag_attributes(selected, column, no_attr)
- [
- :last, :first,
- {:html => {:selected => selected}},
- self.field_tag_attributes(column, no_attr)
- ]
- end
-
- def tag_attr column = nil, opt = {}
- self.tag_attributes(column, opt).to_attr
- end
-
- def field_tag_attr column, no_attr, opt = {}
- self.field_tag_attributes(column, no_attr, opt).to_attr
- end
-
- def any_tag_attr name = nil, opt = {}
- self.any_tag_attributes(name, opt).to_attr
- end
-
end
class Speech < Peta::Content
load_manifest
- include Peta::ElementPart
belongs_to :speech_balloon
belongs_to :writing_format
@@text_align_texts = ['left', 'left', 'right', 'center']
- def self.colum_structures
- @@colum_structures ||= {
- :fore_color => {
- :helper => 'panels/color_helper'
- }
- }
- end
-
def supply_default
self.x = 0
self.y = 0
self.get_parent.speech_balloon_template.symbol_option
end
- def get_parent
- self.speech_balloon || @new_parent
- end
-
- def tag_element_part_type
- 'speech'
- end
-
def outer_style
{
'top' => self.y, 'left' => self.x,
self.speech_balloon_template.symbol_option
end
- def new_balloon
- @new_balloon
- end
-
- def new_balloon= v
- @new_balloon = v
- end
-
- def get_balloon
- self.balloon || @new_balloon
- end
-
- def new_speech
- @new_speech
- end
-
- def new_speech= v
- @new_speech = v
- end
-
- def get_speech
- self.speech || @new_speech
- end
-
def boost
self.extend self.speech_balloon_template.engine_extend_module
if self.balloon
'speech_balloons.updated_at desc'
end
- def self.list_opt
- {:panel => {:author => {}}, :balloon => {}, :speech => {}, :speech_balloon_template => {} }
- end
-
def self.list_json_opt
{:include => {:panel => {:include => {:author => {} }}, :balloon => {}, :speech => {}, :speech_balloon_template => {} }}
end
validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
- def tag_attributes column = nil, opt = {}
- {
- }
- end
-
def supply_default
self.comic_id = nil
self.visible = 0 if self.visible.blank?
validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
- def tag_attributes column = nil, opt = {}
- {
- }
- end
-
def supply_default
self.story_id = nil
self.sheet_id = nil
-<%= content_tag :div, :id => panel.tag_id, :panel_id => panel.tag_panel_id, :class => "pettanr-comic-panel", :style => "width: #{panel.width}px; height: #{panel.height}px; border-style: solid; border-width: #{panel.border}px; border-color: black; background-color: white;" do %>
+<%= content_tag :div, panel.tag_attributes(nil, {:panel_id => panel.id, :class => "pettanr-comic-panel", :style => raw(panel.style.to_style)}) do %>
<% if panel.visible? operators -%>
<% panel.panel_elements.each do |element| %>
<%= render element.path_name + '/element', :element => element, :root => panel, :spot => spot %>
<h2><%= t('panels.hidden') %></h2>
<% end %>
<% end %>
-<% panel.rendered %>
def tag_attributes column = nil, opt = {}
r = super
- r.merge({'data-parent_dom_id' => self.parent.dom_item_id}) if self.editor
+ r.merge({'data-parent_dom_id' => self.parent.dom_item_id}) if self.editize?
r
end
end
def engine?
+ return false unless self.my_engine_resource
self.my_engine_resource.resource_items.include? self.attributes[self.extend_column_name]
end
}\r
},\r
"speech_balloon": {\r
- "extend": "classname",\r
+ "extend_column_name": "classname",\r
"associations": {\r
"belongs_to": {\r
"panel": {}\r
}\r
},\r
"speech_balloon_template": {\r
+ "extend_column_name": "classname",\r
"associations": {\r
"belongs_to": {\r
"system_picture": {}\r
}\r
},\r
"writing_format": {\r
+ "extend_column_name": "classname",\r
"associations": {\r
"belongs_to": {\r
"system_picture": {}\r
}\r
},\r
"license_group": {\r
+ "extend_column_name": "classname",\r
"associations": {\r
"belongs_to": {},\r
"has_many": {\r
"SquareSpeechBalloon": "square_speech_balloon"\r
}\r
},\r
+ "speech_balloons": {\r
+ "resource_items": {\r
+ "CircleSpeechBalloon": "circle_speech_balloon",\r
+ "PlainSpeechBalloon": "plain_speech_balloon",\r
+ "SquareSpeechBalloon": "square_speech_balloon"\r
+ }\r
+ },\r
"writing_formats": {\r
"has_route": 0,\r
"resource_items": {\r
"size": {\r
"type": "size",\r
"args": {\r
- "path": "panels/size_helper",\r
- "class": "panel_picture_width_tool"\r
+ "dom_class": "panel_picture_width_tool"\r
}\r
}\r
},\r
"size": {\r
"type": "size",\r
"args": {\r
- "path": "panels/size_helper",\r
- "class": "panel_picture_height_tool"\r
+ "dom_class": "panel_picture_height_tool"\r
}\r
}\r
},\r
},\r
"helpers": {\r
"popup": {\r
- "type": "size",\r
+ "type": "popup",\r
"args": {\r
- "path": "panels/popup_helper",\r
"source": "pictures"\r
}\r
}\r
"helpers": {\r
"tail_angle": {\r
"type": "size",\r
- "args": {\r
- "path": "panels/tail_angle_helper"\r
- }\r
+ "args": {}\r
}\r
},\r
"row_break": true\r
},\r
"helpers": {\r
"color": {\r
- "type": "size",\r
+ "type": "color",\r
"args": {\r
- "path": "panels/color_helper",\r
"wrapper": "speech-fore_color-wrap"\r
}\r
}\r
},\r
"helpers": {\r
"color": {\r
- "type": "size",\r
+ "type": "color",\r
"args": {\r
- "path": "panels/color_helper",\r
"wrapper": "ground_color-code-wrap"\r
}\r
}\r