initialize: (options) ->\r
@field = options.field\r
@helper = options.helper\r
+ @hex = new Tag.Div({})\r
+ @rgb = new Tag.Div({})\r
\r
render: () ->\r
@attr = {\r
}\r
this.$el.attr(@attr)\r
\r
- @hex = new Tag.Div({})\r
- @rgb = new Tag.Div({})\r
this.$el.html('')\r
this.$el.append(@hex.render().el)\r
this.$el.append(@rgb.render().el)\r
super()\r
@values['item_name'] ||= @name\r
@values['foreign_key'] ||= @parent.item_name() + '_id'\r
+ @values['list_action_name'] ||= 'by_' + @parent.item_name()\r
\r
init: () ->\r
super()\r
@item_name = @values['item_name']\r
@foreign_key = @values['foreign_key']\r
+ @list_action_name = @values['list_action_name']\r
\r
is_through: () ->\r
- !@through\r
+ if @through \r
+ true\r
+ else\r
+ false\r
\r
model: () ->\r
Manifest.item_name_to_model @item_name\r
\r
defaults: {\r
id: null,\r
- code: 0,\r
+ code: 0xeeeeee,\r
+ orientation: 0\r
} \r
\r
+ @pick_item_name: () ->\r
+ 'ground_color'\r
+ \r
+ @traceable_item_names: () ->\r
+ []\r
+ \r
+ pick: (picked_item) ->\r
+ {\r
+ }\r
+ \r
@has_picture: () ->\r
false\r
\r
\r
has_one: (has_one_name) ->\r
has_one_manifest = @my_class().my_manifest().associations.has_one[has_one_name]\r
+ controller_name = has_one_manifest.model().table_name()\r
action_name = has_one_manifest.list_action_name\r
Locmare.ListGroup.list(\r
- has_one_name, action_name, {id: @get('id')}\r
+ controller_name, action_name, {id: @get('id')}\r
)\r
\r
boosts: (level) ->\r
initialize: (options) ->\r
@parent = options.parent\r
@target_model = options.target_model\r
- @pick_model = @target_model.pick_model()\r
\r
clear: () ->\r
- this.$el.html('new or inspire')\r
+ this.$el.html('')\r
+ @pick_icon = new Pettanr.Views.Common.PickIcon({name: 'pick'})\r
+ @inspire_icon = new Pettanr.Views.Common.PickIcon({name: 'inspire'})\r
+ @listenTo(@pick_icon, 'click', @pick_click)\r
+ @listenTo(@inspire_icon, 'click', @inspire_click)\r
+ this.$el.append(@pick_icon.render().el)\r
+ this.$el.append(@inspire_icon.render().el)\r
this\r
\r
- render: (form) ->\r
- this.$el.html('')\r
- this.$el.append(@form.render().el)\r
+ render: () ->\r
this\r
\r
+ pick_click: () ->\r
+ model = @target_model\r
+ new_item = new model()\r
+ # new_item.set({}, {silent: true})\r
+ @success(new_item)\r
+ \r
+ inspire_click: () ->\r
+ params = {\r
+ controller: @target_model.path_name(), action: 'index',\r
+ page_size: 6, format: 'html'\r
+ }\r
+ @dialog().start(@target_model, params, null)\r
+ @listenTo(@dialog(), 'pick', @pick)\r
+ \r
pick: (item) ->\r
- if item.item_name() == @target_model.item_name()\r
- # Inspire\r
- new_item = new @target_model(item.attributes)\r
- else if @target_model.is_traceable(item.item_name())\r
- # Trace\r
- n = @target_model['trace_from_' + item.item_name()]\r
- n()\r
- else if item.item_name() == @target_model.pick_item_name()\r
- # Pick\r
- model = @target_model.pick_model()\r
- new_item = new model()\r
+ new_item = new @target_model(item.attributes)\r
+ new_item.unset('id', {silent: true})\r
+ new_item.set({panel_id: @editor().item.get('id')}, {silent: true})\r
@dialog().stop()\r
+ @success(new_item)\r
+ \r
+ success: (new_item) ->\r
@set_form(new_item)\r
@trigger('pick', new_item)\r
\r
\r
render: () ->\r
this.$el.addClass(@class_name)\r
- this.$el.html(@fore_color())\r
+ this.$el.html(@bg_color())\r
attr = {\r
style: Pettanr.to_style(@style())\r
}\r
if item.item_name() == @target_model.item_name()\r
# Inspire\r
new_item = new @target_model(item.attributes)\r
+ new_item.unset('id', {silent: true})\r
+ new_item.set({panel_id: @editor().item.get('id')}, {silent: true})\r
else if @target_model.is_traceable(item.item_name())\r
# Trace\r
n = @target_model['trace_from_' + item.item_name()]\r
if item.item_name() == @target_model.item_name()\r
# Inspire\r
new_item = new @target_model(item.attributes)\r
+ new_item.unset('id', {silent: true})\r
+ new_item.set({panel_id: @editor().item.get('id')}, {silent: true})\r
else if @target_model.is_traceable(item.item_name())\r
# Trace\r
n = @target_model['trace_from_' + item.item_name()]\r
@listenTo(this, 'ready', @ready)\r
if item.item_name() == @target_model.item_name()\r
# Inspire\r
- new_item = new @target_model(item.attributes)\r
- @trigger('ready', new_item)\r
+ balloon_list = item.has_one('balloon')\r
+ speech_list = item.has_one('speech')\r
+ balloon_list.open(() =>\r
+ balloon = balloon_list.items()[0]\r
+ speech_list.open(() =>\r
+ speech = speech_list.items()[0]\r
+ new_item = new @target_model(item.attributes)\r
+ new_item.unset('id', {silent: true})\r
+ new_item.set({panel_id: @editor().item.get('id')}, {silent: true})\r
+ balloon.unset('id', {silent: true})\r
+ balloon.unset('speech_balloon_id', {silent: true})\r
+ speech.unset('id', {silent: true})\r
+ speech.unset('speech_balloon_id', {silent: true})\r
+ new_item.boosts 'post'\r
+ balloon.boosts 'post'\r
+ speech.boosts 'post'\r
+ new_item.set({balloon: balloon, speech: speech}, {silent: true})\r
+ @trigger('ready', new_item)\r
+ )\r
+ )\r
else if @target_model.is_traceable(item.item_name())\r
# Trace\r
n = @target_model['trace_from_' + item.item_name()]\r
'position' => 'absolute', 'top' => '0px', 'left' => '0px', 'z-index' => self.z,
'background-image' => "url(#{self.picture.url})",
'background-repeat' => self.repeat_text,
- 'background-position' => "#{self.x}px #{self.attr_y}px"
+ 'background-position' => "#{self.x}px #{self.y}px"
}
self.merge_opacity(r, opacity) if spot and spot != self
r