smalruby-editor 0.3.5-x86-mingw32 → 0.4.0-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of smalruby-editor might be problematic. Click here for more details.
- checksums.yaml +4 -4
 - data/.gitignore +0 -0
 - data/.rspec +0 -0
 - data/.rubocop.yml +1 -0
 - data/.simplecov +7 -7
 - data/.travis.yml +0 -0
 - data/Guardfile +1 -1
 - data/LICENSE +0 -0
 - data/Procfile +1 -1
 - data/Rakefile +0 -0
 - data/app/assets/images/.keep +0 -0
 - data/app/assets/images/favicon.ico +0 -0
 - data/app/assets/javascripts/blocks/blockly.js.coffee.erb +0 -0
 - data/app/assets/javascripts/blocks/character.js.coffee.erb +3 -0
 - data/app/assets/javascripts/blocks/data.js.coffee.erb +0 -0
 - data/app/assets/javascripts/blocks/etc.js.coffee.erb +0 -0
 - data/app/assets/javascripts/blocks/field_character.js.coffee.erb +13 -1
 - data/app/assets/javascripts/blocks/field_costume.js.coffee.erb +84 -0
 - data/app/assets/javascripts/blocks/hardware.js.coffee.erb +26 -0
 - data/app/assets/javascripts/blocks/looks.js.coffee.erb +32 -0
 - data/app/assets/javascripts/collections/.keep +0 -0
 - data/app/assets/javascripts/collections/character_set.js.coffee +0 -0
 - data/app/assets/javascripts/generators/ruby.js.coffee.erb +10 -1
 - data/app/assets/javascripts/models/.keep +0 -0
 - data/app/assets/javascripts/models/character.js.coffee +45 -6
 - data/app/assets/javascripts/models/scene.js.coffee +0 -0
 - data/app/assets/javascripts/msg/en_us.js +4 -0
 - data/app/assets/javascripts/msg/ja.js +4 -0
 - data/app/assets/javascripts/routers/.keep +0 -0
 - data/app/assets/javascripts/smalruby.js.coffee.erb +5 -1
 - data/app/assets/javascripts/views/.keep +0 -0
 - data/app/assets/javascripts/views/character_modal_view.js.coffee.erb +357 -0
 - data/app/assets/javascripts/views/character_selector_view.js.coffee +2 -0
 - data/app/assets/stylesheets/editor.css.scss +201 -16
 - data/app/assets/stylesheets/flatstrap-custom.css.scss +0 -0
 - data/app/assets/stylesheets/load-modal.css.scss +0 -0
 - data/app/assets/templates/.keep +0 -0
 - data/app/controllers/application_controller.rb +8 -2
 - data/app/controllers/concerns/.keep +0 -0
 - data/app/controllers/costumes_controller.rb +58 -0
 - data/app/controllers/editor_controller.rb +2 -0
 - data/app/helpers/costumes_helper.rb +2 -0
 - data/app/helpers/editor_helper.rb +0 -0
 - data/app/helpers/sessions_helper.rb +0 -4
 - data/app/mailers/.keep +0 -0
 - data/app/models/.keep +0 -0
 - data/app/models/concerns/.keep +0 -0
 - data/app/models/concerns/ruby_to_block.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/base.rb +2 -0
 - data/app/models/concerns/ruby_to_block/block/character.rb +32 -11
 - data/app/models/concerns/ruby_to_block/block/character_event.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/character_method_call.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/character_new.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/character_operation.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/control_beark.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/control_if.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/control_loop.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/control_sleep.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/do.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/else.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/end.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/events_on_click.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/events_on_key_push_or_down.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/events_on_start.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_button_pressed_or_released.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_init_hardware.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_led_turn_off.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_led_turn_on.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_motor_driver.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_motor_driver_set_speed.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_motor_driver_speed.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_neo_pixel_set_rgb.rb +31 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_rgb_led_set_color.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_rgb_led_turn_off.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_sensor_value.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_two_wheel_drive_car.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_two_wheel_drive_car_commands.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_two_wheel_drive_car_run.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_two_wheel_drive_car_set_speed.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/hardware_two_wheel_drive_car_speed.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/looks_hide.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/looks_next_costume.rb +12 -0
 - data/app/models/concerns/ruby_to_block/block/looks_say.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/looks_show.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/looks_switch_costume.rb +22 -0
 - data/app/models/concerns/ruby_to_block/block/looks_vanish.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/math_number.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_change_x_by.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_change_y_by.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_go_to_character.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_go_to_mouse.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_move.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_point_towards_character.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_point_towards_mouse.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_rotate_left.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_rotate_right.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_self_angle.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_self_x.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_self_y.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_set_angle.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_set_x.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_set_x_y.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_set_y.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_turn.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_turn_if_reach_wall.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/motion_turn_xy.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/null.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/operators_compare.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/operators_false.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/operators_true.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/require_smalruby.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/ruby_comment.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/ruby_expression.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/ruby_p.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/ruby_statement.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/sensing_hit.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/sensing_reach_wall.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/sound_play.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/sound_preset_sounds.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/text.rb +0 -0
 - data/app/models/concerns/ruby_to_block/block/value.rb +0 -0
 - data/app/models/concerns/ruby_to_block/context.rb +0 -0
 - data/app/models/concerns/ruby_to_block/formatter.rb +0 -0
 - data/app/models/costume.rb +67 -0
 - data/app/models/source_code.rb +9 -1
 - data/app/models/user.rb +7 -0
 - data/app/views/costumes/index.html.haml +19 -0
 - data/app/views/editor/_character_modal.html.haml +35 -7
 - data/app/views/editor/_toolbox_default.html.haml +9 -0
 - data/app/views/editor/demo.html.erb +0 -0
 - data/app/views/editor/index.html.haml +1 -0
 - data/bin/smalruby-editor +1 -0
 - data/bin/spring +7 -9
 - data/config.ru +0 -0
 - data/config/boot.rb +0 -0
 - data/config/database.yml.mysql2 +0 -0
 - data/config/database.yml.sqlite3 +0 -0
 - data/config/database.yml.travis +0 -0
 - data/config/environment.rb +0 -0
 - data/config/environments/development.rb +0 -0
 - data/config/environments/production.rb +0 -0
 - data/config/environments/standalone.rb +0 -0
 - data/config/environments/test.rb +0 -0
 - data/config/initializers/backtrace_silencers.rb +0 -0
 - data/config/initializers/filter_parameter_logging.rb +0 -0
 - data/config/initializers/inflections.rb +0 -0
 - data/config/initializers/mime_types.rb +0 -0
 - data/config/initializers/secret_token.rb +0 -0
 - data/config/initializers/session_store.rb +0 -0
 - data/config/initializers/teaspoon.rb +0 -0
 - data/config/initializers/wrap_parameters.rb +0 -0
 - data/config/locales/en.yml +10 -1
 - data/config/locales/ja.yml +10 -0
 - data/config/routes.rb +2 -0
 - data/config/unicorn.rb +23 -23
 - data/db/migrate/20131216121603_create_source_codes.rb +0 -0
 - data/db/migrate/20131219045113_add_filename_to_source_code.rb +0 -0
 - data/db/migrate/20150513061250_add_index_name_on_users.rb +1 -1
 - data/db/migrate/20150607012053_create_costumes.rb +12 -0
 - data/db/migrate/20150607012707_add_indexes_on_costumes.rb +13 -0
 - data/db/migrate/20150607034013_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +31 -0
 - data/db/migrate/20150607034014_add_missing_unique_indices.acts_as_taggable_on_engine.rb +21 -0
 - data/db/migrate/20150607034015_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +15 -0
 - data/db/migrate/20150607034016_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
 - data/db/migrate/20150607034017_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +12 -0
 - data/db/migrate/20150607034018_insert_preset_costumes.rb +9 -0
 - data/db/schema.rb +35 -2
 - data/db/seeds.rb +2 -0
 - data/demos/car_chase.rb.xml +128 -128
 - data/demos/pong.rb.xml +379 -379
 - data/demos/star.rb.xml +115 -115
 - data/lib/assets/.keep +0 -0
 - data/lib/smalruby_editor/version.rb +1 -1
 - data/lib/tasks/.keep +0 -0
 - data/lib/tasks/gem.rake +0 -0
 - data/lib/tasks/rspec.rake +0 -0
 - data/lib/tasks/rubocop.rake +0 -0
 - data/log/.keep +0 -0
 - data/public/404.html +0 -0
 - data/public/422.html +0 -0
 - data/public/500.html +0 -0
 - data/public/apple-touch-icon.png +0 -0
 - data/public/blockly/media/1x1.gif +0 -0
 - data/public/blockly/media/click.mp3 +0 -0
 - data/public/blockly/media/click.ogg +0 -0
 - data/public/blockly/media/click.wav +0 -0
 - data/public/blockly/media/delete.mp3 +0 -0
 - data/public/blockly/media/delete.ogg +0 -0
 - data/public/blockly/media/delete.wav +0 -0
 - data/public/blockly/media/handopen.cur +0 -0
 - data/public/blockly/media/quote0.png +0 -0
 - data/public/blockly/media/quote1.png +0 -0
 - data/public/browserconfig.xml +0 -0
 - data/public/fonts/FontAwesome.otf +0 -0
 - data/public/fonts/fontawesome-webfont.eot +0 -0
 - data/public/fonts/fontawesome-webfont.ttf +0 -0
 - data/public/fonts/fontawesome-webfont.woff +0 -0
 - data/public/large.png +0 -0
 - data/public/robots.txt +0 -0
 - data/public/smalruby/assets/ball1.png +0 -0
 - data/public/smalruby/assets/ball2.png +0 -0
 - data/public/smalruby/assets/ball3.png +0 -0
 - data/public/smalruby/assets/ball4.png +0 -0
 - data/public/smalruby/assets/ball5.png +0 -0
 - data/public/smalruby/assets/ball6.png +0 -0
 - data/public/smalruby/assets/car1.png +0 -0
 - data/public/smalruby/assets/car2.png +0 -0
 - data/public/smalruby/assets/car3.png +0 -0
 - data/public/smalruby/assets/car4.png +0 -0
 - data/public/smalruby/assets/cat1.png +0 -0
 - data/public/smalruby/assets/cat2.png +0 -0
 - data/public/smalruby/assets/cat3.png +0 -0
 - data/public/smalruby/assets/frog1.png +0 -0
 - data/public/smalruby/assets/piano_do.wav +0 -0
 - data/public/smalruby/assets/piano_do_2.wav +0 -0
 - data/public/smalruby/assets/piano_fa.wav +0 -0
 - data/public/smalruby/assets/piano_mi.wav +0 -0
 - data/public/smalruby/assets/piano_ra.wav +0 -0
 - data/public/smalruby/assets/piano_re.wav +0 -0
 - data/public/smalruby/assets/piano_si.wav +0 -0
 - data/public/smalruby/assets/piano_so.wav +0 -0
 - data/public/smalruby/assets/ryu1.png +0 -0
 - data/public/smalruby/assets/ryu2.png +0 -0
 - data/public/smalruby/assets/taichi1.png +0 -0
 - data/public/smalruby/assets/taichi2.png +0 -0
 - data/public/square.png +0 -0
 - data/public/tiny.png +0 -0
 - data/public/wide.png +0 -0
 - data/smalruby-editor.gemspec +2 -1
 - data/spec/acceptance/block_mode/blocks/character/new.feature +5 -5
 - data/spec/acceptance/block_mode/blocks/control/await.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/control/await_until.feature +3 -3
 - data/spec/acceptance/block_mode/blocks/control/break.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/control/if.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/control/if_else.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/control/loop.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/control/next.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/control/redo.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/control/sleep.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/control/times.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/control/until.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/events/on_click.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/events/on_hit.feature +4 -4
 - data/spec/acceptance/block_mode/blocks/events/on_key_push_or_down.feature +4 -4
 - data/spec/acceptance/block_mode/blocks/events/on_start.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/hardware/init_hardware.feature +1 -1
 - data/spec/acceptance/block_mode/blocks/hardware/led_turn_off.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/hardware/led_turn_on.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/hardware/motor_driver.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/hardware/motor_driver_speed.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/hardware/neo_pixel_set_rgb.feature +100 -0
 - data/spec/acceptance/block_mode/blocks/hardware/rgb_led_set_color.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/hardware/rgb_led_turn_off.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/hardware/sensor_value.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/hardware/servo_set_position.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action_with_sec.feature +1 -1
 - data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_led_turn_on_or_off.feature +1 -1
 - data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_action_with_sec.feature +1 -1
 - data/spec/acceptance/block_mode/blocks/hardware/two_wheel_drive_car.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/hardware/two_wheel_drive_car_speed.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/looks/hide.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/looks/next_costume.feature +56 -0
 - data/spec/acceptance/block_mode/blocks/looks/say.feature +3 -3
 - data/spec/acceptance/block_mode/blocks/looks/show.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/looks/vanish.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/motion/change_x_by.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/motion/change_y_by.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/motion/move.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/motion/reach_wall.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/motion/rotate_left.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/motion/rotate_right.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/motion/self_angle.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/motion/self_x.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/motion/self_y.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/motion/set_angle.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/motion/set_x.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/motion/set_x_y.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/motion/set_y.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/motion/turn.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/motion/turn_if_reach_wall.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/operators/and_or.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/operators/four_arithmetic_and_compares.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/operators/index_of.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/operators/length.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/operators/math_method.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/operators/negate.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/operators/rand.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/operators/round.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/operators/text.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/operators/true_false.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/ruby/expression.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/ruby/p.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/ruby/statement_comment.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/sensing/character_property.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/sensing/hit.feature +6 -6
 - data/spec/acceptance/block_mode/blocks/sensing/input_key_push_or_down.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/sensing/input_mouse_pos_x.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/sensing/input_mouse_pos_y.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/sensing/input_mouse_push_or_down.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/sensing/reach_wall.feature +2 -2
 - data/spec/acceptance/block_mode/blocks/sensing/time_now.feature +0 -0
 - data/spec/acceptance/block_mode/blocks/sound/play.feature +2 -2
 - data/spec/acceptance/block_mode/character_modal_view.feature +164 -0
 - data/spec/acceptance/block_mode/demo.feature +2 -2
 - data/spec/acceptance/block_mode/translate.feature +0 -0
 - data/spec/acceptance/readme.md +0 -0
 - data/spec/acceptance/ruby_mode/check.feature +0 -0
 - data/spec/acceptance/ruby_mode/load.feature +0 -0
 - data/spec/acceptance/ruby_mode/translate.feature +2 -2
 - data/spec/acceptance/standalone/preference.feature +8 -8
 - data/spec/acceptance/standalone/run.feature +0 -0
 - data/spec/acceptance/standalone/save.feature +1 -1
 - data/spec/acceptance/standalone/signin.feature +1 -1
 - data/spec/controllers/source_codes_controller_spec.rb +0 -0
 - data/spec/fixtures/files/01.rb +0 -0
 - data/spec/fixtures/files/01.rb.xml +0 -0
 - data/spec/fixtures/files/01_remix.rb +0 -0
 - data/spec/fixtures/files/01_remix02.rb +0 -0
 - data/spec/fixtures/files/01_remix10.rb.xml +0 -0
 - data/spec/fixtures/files/extra_car.png +0 -0
 - data/spec/fixtures/files/favicon.ico +0 -0
 - data/spec/helpers/editor_helper_spec.rb +0 -0
 - data/spec/javascripts/collections/character_set_spec.coffee +0 -0
 - data/spec/javascripts/models/character_spec.coffee +2 -14
 - data/spec/javascripts/models/scene_spec.coffee +0 -0
 - data/spec/javascripts/spec_helper.js +0 -0
 - data/spec/lib/smalruby_editor_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block/block/character_method_call_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block/block/character_spec.rb +71 -0
 - data/spec/models/concerns/ruby_to_block/block/control_if_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block/block/control_loop_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block/block/events_on_start_spec.rb +6 -6
 - data/spec/models/concerns/ruby_to_block/block/hardware__neo_pixel_spec.rb +77 -0
 - data/spec/models/concerns/ruby_to_block/block/looks_say_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block/block/looks_spec.rb +26 -2
 - data/spec/models/concerns/ruby_to_block/block/motion_move_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block/block/motion_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block/block/motion_turn_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block/block/motion_turn_xy_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block/block/require_smalruby_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block/block/ruby_comment_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block/block/ruby_statement_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block/block/sensing_reach_wall_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block/block/shared/block_examples.rb +2 -2
 - data/spec/models/concerns/ruby_to_block/block/sound_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block/block/text_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block/block_spec.rb +0 -0
 - data/spec/models/concerns/ruby_to_block_spec.rb +0 -0
 - data/spec/spec_helper.rb +21 -10
 - data/spec/steps/block_mode_steps.rb +0 -0
 - data/spec/steps/fix_turnip.rb +0 -0
 - data/spec/steps/global_variable.rb +0 -0
 - data/spec/steps/standalone_steps.rb +3 -3
 - data/spec/steps/then_steps.rb +28 -0
 - data/spec/steps/when_steps.rb +15 -18
 - data/spec/support/capybara.rb +0 -0
 - data/spec/support/env.rb +0 -0
 - data/spec/support/ruby_to_block.rb +0 -0
 - data/spec/teaspoon_env.rb +0 -0
 - data/spec/turnip_helper.rb +0 -0
 - data/vendor/assets/javascripts/.keep +0 -0
 - data/vendor/assets/javascripts/jquery.blockUI.js +0 -0
 - data/vendor/assets/stylesheets/.keep +0 -0
 - metadata +56 -14
 - data/app/assets/javascripts/views/character_modal_view.js.coffee +0 -194
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: cbee9a425325f737e22db3012f74345ebeb348e1
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 775f01778a487113c6d933a27c31fe9a87da279a
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c6f42ac80f3556af63b2fa9da254b18366ca8f3f6281fc16d0deb2cf9b1c5ffe37efc65f9f2cc63ffd22da7ed47ba7c954e4abad1e82809ec6f1ea6b66cba7a7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 33ecb30aaf7c4de698f8294473d8d99741f9d3e45cc372bc2b2a708c3b2430daebb435126b8fa40fd47bcecd2b13129fa45cb942102e887f8ac3462f42794f1c
         
     | 
    
        data/.gitignore
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/.rspec
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/.rubocop.yml
    CHANGED
    
    
    
        data/.simplecov
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            if ENV['COVERALLS']
         
     | 
| 
       2 
     | 
    
         
            -
              require 'coveralls'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
              SimpleCov.formatter = Coveralls::SimpleCov::Formatter
         
     | 
| 
       5 
     | 
    
         
            -
            end
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            SimpleCov.start('rails')
         
     | 
| 
      
 1 
     | 
    
         
            +
            if ENV['COVERALLS']
         
     | 
| 
      
 2 
     | 
    
         
            +
              require 'coveralls'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
              SimpleCov.formatter = Coveralls::SimpleCov::Formatter
         
     | 
| 
      
 5 
     | 
    
         
            +
            end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            SimpleCov.start('rails')
         
     | 
    
        data/.travis.yml
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/Guardfile
    CHANGED
    
    | 
         @@ -13,7 +13,7 @@ ignore(TEMPFILE_BY_EMACS) 
     | 
|
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
            group :red_green_refactor, halt_on_fail: true do
         
     | 
| 
       15 
15 
     | 
    
         
             
              guard :rubocop, all_on_start: false do
         
     | 
| 
       16 
     | 
    
         
            -
                ignore(%r{^db/(?:schema|seeds)\.rb$})
         
     | 
| 
      
 16 
     | 
    
         
            +
                ignore(%r{^(?:db/(?:schema|seeds)\.rb|bin/spring)$})
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
                watch(%r{.+\.rb$})
         
     | 
| 
       19 
19 
     | 
    
         
             
                watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
         
     | 
    
        data/LICENSE
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/Procfile
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
         
     | 
| 
      
 1 
     | 
    
         
            +
            web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
         
     | 
    
        data/Rakefile
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/app/assets/images/.keep
    CHANGED
    
    | 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         @@ -106,7 +106,19 @@ Smalruby.FieldCharacter.dropdownChange = (value) -> 
     | 
|
| 
       106 
106 
     | 
    
         | 
| 
       107 
107 
     | 
    
         
             
            Smalruby.FieldCharacter.NullCharacter =
         
     | 
| 
       108 
108 
     | 
    
         
             
              get: (name) ->
         
     | 
| 
       109 
     | 
    
         
            -
                 
     | 
| 
      
 109 
     | 
    
         
            +
                switch name
         
     | 
| 
      
 110 
     | 
    
         
            +
                  when 'name'
         
     | 
| 
      
 111 
     | 
    
         
            +
                    <%= bm('.no_character') %>
         
     | 
| 
      
 112 
     | 
    
         
            +
                  when 'costumes'
         
     | 
| 
      
 113 
     | 
    
         
            +
                    ['']
         
     | 
| 
      
 114 
     | 
    
         
            +
                  when 'costumeNames'
         
     | 
| 
      
 115 
     | 
    
         
            +
                    [<%= bm('.first_costume') %>]
         
     | 
| 
      
 116 
     | 
    
         
            +
                  when 'costumeIndex'
         
     | 
| 
      
 117 
     | 
    
         
            +
                    0
         
     | 
| 
      
 118 
     | 
    
         
            +
                  else
         
     | 
| 
      
 119 
     | 
    
         
            +
                    null
         
     | 
| 
      
 120 
     | 
    
         
            +
              costumeName: (index) ->
         
     | 
| 
      
 121 
     | 
    
         
            +
                ''
         
     | 
| 
       110 
122 
     | 
    
         
             
              on: -> $.noop
         
     | 
| 
       111 
123 
     | 
    
         
             
              off: -> $.noop
         
     | 
| 
       112 
124 
     | 
    
         
             
              link: -> $.noop
         
     | 
| 
         @@ -0,0 +1,84 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%
         
     | 
| 
      
 2 
     | 
    
         
            +
              require 'smalruby_editor'
         
     | 
| 
      
 3 
     | 
    
         
            +
              require 'smalruby_editor/blockly_message_helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
            %>
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            'use strict'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            goog.provide('Smalruby.FieldCostume')
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            goog.require('Blockly.FieldDropdown')
         
     | 
| 
      
 11 
     | 
    
         
            +
            goog.provide('Smalruby.FieldCharacter')
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            Smalruby.FieldCostume = (opt_character, opt_changeHandler) ->
         
     | 
| 
      
 15 
     | 
    
         
            +
              @character = Smalruby.FieldCharacter.NullCharacter
         
     | 
| 
      
 16 
     | 
    
         
            +
              @costumeIndex = 0
         
     | 
| 
      
 17 
     | 
    
         
            +
              if opt_character
         
     | 
| 
      
 18 
     | 
    
         
            +
                @setCharacter(opt_character)
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              if opt_changeHandler
         
     | 
| 
      
 21 
     | 
    
         
            +
                changeHandler = (value) =>
         
     | 
| 
      
 22 
     | 
    
         
            +
                  retVal = Smalruby.FieldCostume.dropdownChange.call(@, value)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  if retVal
         
     | 
| 
      
 24 
     | 
    
         
            +
                    newVal = retVal
         
     | 
| 
      
 25 
     | 
    
         
            +
                  else
         
     | 
| 
      
 26 
     | 
    
         
            +
                    retVal = @getValue()
         
     | 
| 
      
 27 
     | 
    
         
            +
                  opt_changeHandler.call(@, newVal)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  retVal
         
     | 
| 
      
 29 
     | 
    
         
            +
              else
         
     | 
| 
      
 30 
     | 
    
         
            +
                changeHandler = Smalruby.FieldCostume.dropdownChange
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              Smalruby.FieldCostume.superClass_.constructor
         
     | 
| 
      
 33 
     | 
    
         
            +
                .call(@, Smalruby.FieldCostume.dropdownCreate, changeHandler)
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            goog.inherits(Smalruby.FieldCostume, Blockly.FieldDropdown)
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            Smalruby.FieldCostume.prototype.setCharacter = (character) ->
         
     | 
| 
      
 38 
     | 
    
         
            +
              return if character == @character
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              @character.off('change:costumeNames', @onCharacterChangeCostumeNames_, @)
         
     | 
| 
      
 41 
     | 
    
         
            +
              @character = if character then character else Smalruby.FieldCharacter.NullCharacter
         
     | 
| 
      
 42 
     | 
    
         
            +
              @character.on('change:costumeNames', @onCharacterChangeCostumeNames_, @)
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              @costumeIndex = 0
         
     | 
| 
      
 45 
     | 
    
         
            +
              @setValue(@character.costumeName(@costumeIndex))
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            Smalruby.FieldCostume.prototype.onCharacterChangeCostumeNames_ = (model, costumeNames, options) ->
         
     | 
| 
      
 48 
     | 
    
         
            +
              if @costumeIndex < costumeNames.length
         
     | 
| 
      
 49 
     | 
    
         
            +
                @setValue(costumeNames[@costumeIndex])
         
     | 
| 
      
 50 
     | 
    
         
            +
              else
         
     | 
| 
      
 51 
     | 
    
         
            +
                @setValue(costumeNames[0])
         
     | 
| 
      
 52 
     | 
    
         
            +
                @costumeIndex = 0
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            Smalruby.FieldCostume.prototype.clone = ->
         
     | 
| 
      
 55 
     | 
    
         
            +
              new Smalruby.FieldCostume(null, @changeHandler_)
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            Smalruby.FieldCostume.prototype.dispose = ->
         
     | 
| 
      
 58 
     | 
    
         
            +
              @setCharacter(Smalruby.FieldCharacter.NullCharacter)
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              Blockly.FieldDropdown.prototype.dispose.call(@)
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            Smalruby.FieldCostume.prototype.getCharacterFromParentBlocks_ = ->
         
     | 
| 
      
 63 
     | 
    
         
            +
              block = @sourceBlock_
         
     | 
| 
      
 64 
     | 
    
         
            +
              while block
         
     | 
| 
      
 65 
     | 
    
         
            +
                if block.getCharacter
         
     | 
| 
      
 66 
     | 
    
         
            +
                  return block.getCharacter()
         
     | 
| 
      
 67 
     | 
    
         
            +
                block = block.getSurroundParent()
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
              Smalruby.FieldCharacter.NullCharacter
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
            Smalruby.FieldCostume.dropdownCreate = ->
         
     | 
| 
      
 72 
     | 
    
         
            +
              @setCharacter(@getCharacterFromParentBlocks_())
         
     | 
| 
      
 73 
     | 
    
         
            +
              ([costume, costume] for costume in @character.get('costumeNames'))
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
            Smalruby.FieldCostume.dropdownChange = (value) ->
         
     | 
| 
      
 76 
     | 
    
         
            +
              costumeIndex = -1
         
     | 
| 
      
 77 
     | 
    
         
            +
              if (costumeNames = @character.get('costumeNames'))
         
     | 
| 
      
 78 
     | 
    
         
            +
                costumeIndex = _.indexOf(costumeNames, value)
         
     | 
| 
      
 79 
     | 
    
         
            +
              if costumeIndex == -1
         
     | 
| 
      
 80 
     | 
    
         
            +
                @costumeIndex = 0
         
     | 
| 
      
 81 
     | 
    
         
            +
                null
         
     | 
| 
      
 82 
     | 
    
         
            +
              else
         
     | 
| 
      
 83 
     | 
    
         
            +
                @costumeIndex = costumeIndex
         
     | 
| 
      
 84 
     | 
    
         
            +
                value
         
     | 
| 
         @@ -96,6 +96,32 @@ Blockly.Ruby['<%= n %>'] = (block) -> 
     | 
|
| 
       96 
96 
     | 
    
         
             
              Blockly.Ruby.characterMethodCall_("led(#{Blockly.Ruby.quote_(pin)}).<%= method %>")
         
     | 
| 
       97 
97 
     | 
    
         
             
            <% end %>
         
     | 
| 
       98 
98 
     | 
    
         | 
| 
      
 99 
     | 
    
         
            +
            # Adafruit Pixel
         
     | 
| 
      
 100 
     | 
    
         
            +
            <% subcategory = 'neo_pixel' %>
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
            <% n = "#{category}_#{subcategory}_set_rgb" %>
         
     | 
| 
      
 103 
     | 
    
         
            +
            Blockly.Blocks['<%= n %>'] =
         
     | 
| 
      
 104 
     | 
    
         
            +
              init: ()->
         
     | 
| 
      
 105 
     | 
    
         
            +
                @setHelpUrl('')
         
     | 
| 
      
 106 
     | 
    
         
            +
                @setColour(<%= colors[:looks] %>)
         
     | 
| 
      
 107 
     | 
    
         
            +
                @interpolateMsg(<%= bm(".#{subcategory}_set_rgb") %>,
         
     | 
| 
      
 108 
     | 
    
         
            +
                                ['PIN', new Blockly.FieldDropdown(pwmPinDropdown)],
         
     | 
| 
      
 109 
     | 
    
         
            +
                                ['RED', ['Number'], Blockly.ALIGN_RIGHT],
         
     | 
| 
      
 110 
     | 
    
         
            +
                                ['GREEN', ['Number'], Blockly.ALIGN_RIGHT],
         
     | 
| 
      
 111 
     | 
    
         
            +
                                ['BLUE', ['Number'], Blockly.ALIGN_RIGHT],
         
     | 
| 
      
 112 
     | 
    
         
            +
                                Blockly.ALIGN_RIGHT)
         
     | 
| 
      
 113 
     | 
    
         
            +
                @setPreviousStatement(true)
         
     | 
| 
      
 114 
     | 
    
         
            +
                @setNextStatement(true)
         
     | 
| 
      
 115 
     | 
    
         
            +
                @setTooltip('')
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
            Blockly.Ruby['<%= n %>'] = (block) ->
         
     | 
| 
      
 118 
     | 
    
         
            +
              pin = @getFieldValue('PIN')
         
     | 
| 
      
 119 
     | 
    
         
            +
              red = Blockly.Ruby.valueToCode(@, 'RED', Blockly.Ruby.ORDER_NONE) || '0'
         
     | 
| 
      
 120 
     | 
    
         
            +
              green = Blockly.Ruby.valueToCode(@, 'GREEN', Blockly.Ruby.ORDER_NONE) || '0'
         
     | 
| 
      
 121 
     | 
    
         
            +
              blue = Blockly.Ruby.valueToCode(@, 'BLUE', Blockly.Ruby.ORDER_NONE) || '0'
         
     | 
| 
      
 122 
     | 
    
         
            +
              Blockly.Ruby.characterMethodCall_("<%= subcategory %>(#{Blockly.Ruby.quote_(pin)}).set(color: [#{red}, #{green}, #{blue}])")
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
       99 
125 
     | 
    
         
             
            # 「RGB LED」サブジャンル
         
     | 
| 
       100 
126 
     | 
    
         | 
| 
       101 
127 
     | 
    
         
             
            # RGB LED[▼アノード]コモン[▼PIN]を[カラー]にする
         
     | 
| 
         @@ -89,6 +89,38 @@ Blockly.Blocks['<%= n %>'] = 
     | 
|
| 
       89 
89 
     | 
    
         
             
            Blockly.Ruby['<%= n %>'] = (block) ->
         
     | 
| 
       90 
90 
     | 
    
         
             
              Blockly.Ruby.characterMethodCall_('vanish')
         
     | 
| 
       91 
91 
     | 
    
         | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
            <% n = "#{category}_next_costume" %>
         
     | 
| 
      
 94 
     | 
    
         
            +
            Blockly.Blocks['<%= n %>'] =
         
     | 
| 
      
 95 
     | 
    
         
            +
              init: ()->
         
     | 
| 
      
 96 
     | 
    
         
            +
                @setHelpUrl('')
         
     | 
| 
      
 97 
     | 
    
         
            +
                @setColour(<%= color %>)
         
     | 
| 
      
 98 
     | 
    
         
            +
                @appendDummyInput().appendField(<%= bm('.next_costume') %>)
         
     | 
| 
      
 99 
     | 
    
         
            +
                @setPreviousStatement(true)
         
     | 
| 
      
 100 
     | 
    
         
            +
                @setNextStatement(true)
         
     | 
| 
      
 101 
     | 
    
         
            +
                @setTooltip('')
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
            Blockly.Ruby['<%= n %>'] = (block) ->
         
     | 
| 
      
 104 
     | 
    
         
            +
              Blockly.Ruby.characterMethodCall_('next_costume')
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
            <% n = "#{category}_switch_costume" %>
         
     | 
| 
      
 108 
     | 
    
         
            +
            Blockly.Blocks['<%= n %>'] =
         
     | 
| 
      
 109 
     | 
    
         
            +
              init: ()->
         
     | 
| 
      
 110 
     | 
    
         
            +
                @setHelpUrl('')
         
     | 
| 
      
 111 
     | 
    
         
            +
                @setColour(<%= color %>)
         
     | 
| 
      
 112 
     | 
    
         
            +
                @interpolateMsg(<%= bm('.switch_costume') %>,
         
     | 
| 
      
 113 
     | 
    
         
            +
                                ['COSTUME', new Smalruby.FieldCostume()],
         
     | 
| 
      
 114 
     | 
    
         
            +
                                Blockly.ALIGN_RIGHT)
         
     | 
| 
      
 115 
     | 
    
         
            +
                @setPreviousStatement(true)
         
     | 
| 
      
 116 
     | 
    
         
            +
                @setNextStatement(true)
         
     | 
| 
      
 117 
     | 
    
         
            +
                @setTooltip('')
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
            Blockly.Ruby['<%= n %>'] = (block) ->
         
     | 
| 
      
 120 
     | 
    
         
            +
              costume = Blockly.Ruby.quote_(@getFieldValue('COSTUME'))
         
     | 
| 
      
 121 
     | 
    
         
            +
              Blockly.Ruby.characterMethodCall_("switch_costume(#{costume})")
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
       92 
124 
     | 
    
         
             
            # 大きさを( )%ずつ変える
         
     | 
| 
       93 
125 
     | 
    
         
             
            # 大きさを( )%にする
         
     | 
| 
       94 
126 
     | 
    
         
             
            <%
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         @@ -62,8 +62,17 @@ Blockly.Ruby.defineCharacter = (c) -> 
     | 
|
| 
       62 
62 
     | 
    
         
             
                    rotationStyle = ', rotation_style: :none'
         
     | 
| 
       63 
63 
     | 
    
         
             
                  else
         
     | 
| 
       64 
64 
     | 
    
         
             
                    rotationStyle = ''
         
     | 
| 
      
 65 
     | 
    
         
            +
                costumeParam = ['costume: ']
         
     | 
| 
      
 66 
     | 
    
         
            +
                costumes = (Blockly.Ruby.quote_(costume) for costume in c.costumesWithName())
         
     | 
| 
      
 67 
     | 
    
         
            +
                if costumes.length > 1
         
     | 
| 
      
 68 
     | 
    
         
            +
                  costumeParam.push("[#{costumes.join(', ')}]")
         
     | 
| 
      
 69 
     | 
    
         
            +
                else
         
     | 
| 
      
 70 
     | 
    
         
            +
                  costumeParam.push(costumes[0])
         
     | 
| 
      
 71 
     | 
    
         
            +
                costumeIndex = c.get('costumeIndex')
         
     | 
| 
      
 72 
     | 
    
         
            +
                if costumeIndex > 0
         
     | 
| 
      
 73 
     | 
    
         
            +
                  costumeParam.push(", costume_index: #{costumeIndex}")
         
     | 
| 
       65 
74 
     | 
    
         
             
                Blockly.Ruby.definitions_[blockName] =
         
     | 
| 
       66 
     | 
    
         
            -
                  "#{name} = Character.new( 
     | 
| 
      
 75 
     | 
    
         
            +
                  "#{name} = Character.new(#{costumeParam.join('')}, x: #{c.get('x')}, y: #{c.get('y')}, angle: #{c.get('angle')}#{rotationStyle})"
         
     | 
| 
       67 
76 
     | 
    
         | 
| 
       68 
77 
     | 
    
         
             
            Blockly.Ruby.characterStack = ->
         
     | 
| 
       69 
78 
     | 
    
         
             
              @definitions_['character_stack']
         
     | 
| 
         
            File without changes
         
     | 
| 
         @@ -2,6 +2,7 @@ Smalruby.Character = Backbone.Model.extend({ 
     | 
|
| 
       2 
2 
     | 
    
         
             
              defaults:
         
     | 
| 
       3 
3 
     | 
    
         
             
                name: null
         
     | 
| 
       4 
4 
     | 
    
         
             
                costumes: [],
         
     | 
| 
      
 5 
     | 
    
         
            +
                costumeNames: [],
         
     | 
| 
       5 
6 
     | 
    
         
             
                costumeIndex: 0
         
     | 
| 
       6 
7 
     | 
    
         
             
                x: 0
         
     | 
| 
       7 
8 
     | 
    
         
             
                y: 0
         
     | 
| 
         @@ -14,6 +15,23 @@ Smalruby.Character = Backbone.Model.extend({ 
     | 
|
| 
       14 
15 
     | 
    
         
             
                @objects = []
         
     | 
| 
       15 
16 
     | 
    
         
             
                if @get('costumes').length == 0
         
     | 
| 
       16 
17 
     | 
    
         
             
                  @set({ costumes: [Smalruby.Character.PRESET_COSTUMES[0]] })
         
     | 
| 
      
 18 
     | 
    
         
            +
                else
         
     | 
| 
      
 19 
     | 
    
         
            +
                  costumes = []
         
     | 
| 
      
 20 
     | 
    
         
            +
                  costumeNames = []
         
     | 
| 
      
 21 
     | 
    
         
            +
                  index = 1
         
     | 
| 
      
 22 
     | 
    
         
            +
                  for costume in (costume.split(':') for costume in @get('costumes'))
         
     | 
| 
      
 23 
     | 
    
         
            +
                    do (costume) ->
         
     | 
| 
      
 24 
     | 
    
         
            +
                      if costume.length == 1
         
     | 
| 
      
 25 
     | 
    
         
            +
                        costumeNames.push("costume#{index}")
         
     | 
| 
      
 26 
     | 
    
         
            +
                        costumes.push(costume[0])
         
     | 
| 
      
 27 
     | 
    
         
            +
                      else
         
     | 
| 
      
 28 
     | 
    
         
            +
                        costumeNames.push(costume[0])
         
     | 
| 
      
 29 
     | 
    
         
            +
                        costumes.push(costume[1])
         
     | 
| 
      
 30 
     | 
    
         
            +
                      index++
         
     | 
| 
      
 31 
     | 
    
         
            +
                  @set({ costumes: costumes, costumeNames: costumeNames })
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                if @get('costumeNames').length == 0
         
     | 
| 
      
 34 
     | 
    
         
            +
                  @set({ costumeNames: ['costume1'] })
         
     | 
| 
       17 
35 
     | 
    
         | 
| 
       18 
36 
     | 
    
         
             
              validate: (attrs, options) ->
         
     | 
| 
       19 
37 
     | 
    
         
             
                errors = []
         
     | 
| 
         @@ -31,6 +49,23 @@ Smalruby.Character = Backbone.Model.extend({ 
     | 
|
| 
       31 
49 
     | 
    
         
             
                    attr: 'name'
         
     | 
| 
       32 
50 
     | 
    
         
             
                    message: 'Name is invalid'
         
     | 
| 
       33 
51 
     | 
    
         | 
| 
      
 52 
     | 
    
         
            +
                i = 0
         
     | 
| 
      
 53 
     | 
    
         
            +
                costumeNames = attrs.costumeNames
         
     | 
| 
      
 54 
     | 
    
         
            +
                for name in costumeNames
         
     | 
| 
      
 55 
     | 
    
         
            +
                  do (name) ->
         
     | 
| 
      
 56 
     | 
    
         
            +
                    if _.isUndefined(name) || _.isNull(name) ||
         
     | 
| 
      
 57 
     | 
    
         
            +
                       (_.isString(name) && name.length == 0)
         
     | 
| 
      
 58 
     | 
    
         
            +
                      errors.push
         
     | 
| 
      
 59 
     | 
    
         
            +
                        attr: 'costumeNames'
         
     | 
| 
      
 60 
     | 
    
         
            +
                        index: i
         
     | 
| 
      
 61 
     | 
    
         
            +
                        message: 'costumeNames is required'
         
     | 
| 
      
 62 
     | 
    
         
            +
                    else if _.indexOf(costumeNames, name) != _.lastIndexOf(costumeNames, name)
         
     | 
| 
      
 63 
     | 
    
         
            +
                      errors.push
         
     | 
| 
      
 64 
     | 
    
         
            +
                        attr: 'costumeNames'
         
     | 
| 
      
 65 
     | 
    
         
            +
                        index: i
         
     | 
| 
      
 66 
     | 
    
         
            +
                        message: 'costumeNames is duplicated'
         
     | 
| 
      
 67 
     | 
    
         
            +
                    i++
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
       34 
69 
     | 
    
         
             
                if errors.length > 0
         
     | 
| 
       35 
70 
     | 
    
         
             
                  return errors
         
     | 
| 
       36 
71 
     | 
    
         | 
| 
         @@ -50,15 +85,19 @@ Smalruby.Character = Backbone.Model.extend({ 
     | 
|
| 
       50 
85 
     | 
    
         
             
              namePrefix: ->
         
     | 
| 
       51 
86 
     | 
    
         
             
                Smalruby.Character.costumeToNamePrefix(@get('name'))
         
     | 
| 
       52 
87 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
              costume: ->
         
     | 
| 
       54 
     | 
    
         
            -
                @get('costumes')[ 
     | 
| 
      
 88 
     | 
    
         
            +
              costume: (index = @get('costumeIndex')) ->
         
     | 
| 
      
 89 
     | 
    
         
            +
                @get('costumes')[index]
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
              costumeName: (index = @get('costumeIndex')) ->
         
     | 
| 
      
 92 
     | 
    
         
            +
                @get('costumeNames')[index]
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
              costumesWithName: ->
         
     | 
| 
      
 95 
     | 
    
         
            +
                costumeNames = @get('costumeNames')
         
     | 
| 
      
 96 
     | 
    
         
            +
                ("#{costumeNames[i]}:#{costume}" for costume, i in @get('costumes'))
         
     | 
| 
       55 
97 
     | 
    
         | 
| 
       56 
98 
     | 
    
         
             
              costumeUrl: (index = @get('costumeIndex')) ->
         
     | 
| 
       57 
99 
     | 
    
         
             
                basename = @get('costumes')[index]
         
     | 
| 
       58 
     | 
    
         
            -
                 
     | 
| 
       59 
     | 
    
         
            -
                  basename
         
     | 
| 
       60 
     | 
    
         
            -
                else
         
     | 
| 
       61 
     | 
    
         
            -
                  "/smalruby/assets/#{basename}"
         
     | 
| 
      
 100 
     | 
    
         
            +
                "/smalruby/assets/#{basename}"
         
     | 
| 
       62 
101 
     | 
    
         | 
| 
       63 
102 
     | 
    
         
             
              nextCostume: ->
         
     | 
| 
       64 
103 
     | 
    
         
             
                i = @get('costumeIndex') + 1
         
     | 
| 
         
            File without changes
         
     | 
| 
         @@ -191,6 +191,7 @@ Blockly.Msg.BLOCKS_RUBY_P = 'p %1'; 
     | 
|
| 
       191 
191 
     | 
    
         | 
| 
       192 
192 
     | 
    
         
             
            // blocks/field_character.js.coffee.erb
         
     | 
| 
       193 
193 
     | 
    
         
             
            Blockly.Msg.BLOCKS_FIELD_CHARACTER_NO_CHARACTER = 'no character';
         
     | 
| 
      
 194 
     | 
    
         
            +
            Blockly.Msg.BLOCKS_FIELD_CHARACTER_FIRST_COSTUME = 'first costume';
         
     | 
| 
       194 
195 
     | 
    
         | 
| 
       195 
196 
     | 
    
         | 
| 
       196 
197 
     | 
    
         
             
            // blocks/sound.js.coffee.erb
         
     | 
| 
         @@ -214,6 +215,8 @@ Blockly.Msg.BLOCKS_LOOKS_THINK_WITH_SECOND = 'think %1 for %2 secs'; 
     | 
|
| 
       214 
215 
     | 
    
         
             
            Blockly.Msg.BLOCKS_LOOKS_SHOW = 'show';
         
     | 
| 
       215 
216 
     | 
    
         
             
            Blockly.Msg.BLOCKS_LOOKS_HIDE = 'hide';
         
     | 
| 
       216 
217 
     | 
    
         
             
            Blockly.Msg.BLOCKS_LOOKS_VANISH = 'vanish';
         
     | 
| 
      
 218 
     | 
    
         
            +
            Blockly.Msg.BLOCKS_LOOKS_NEXT_COSTUME = 'next costume';
         
     | 
| 
      
 219 
     | 
    
         
            +
            Blockly.Msg.BLOCKS_LOOKS_SWITCH_COSTUME = 'switch costume to %1';
         
     | 
| 
       217 
220 
     | 
    
         | 
| 
       218 
221 
     | 
    
         | 
| 
       219 
222 
     | 
    
         
             
            // blocks/hardware.js.coffee.erb
         
     | 
| 
         @@ -224,6 +227,7 @@ Blockly.Msg.BLOCKS_HARDWARE_CATHODE = 'cathode'; 
     | 
|
| 
       224 
227 
     | 
    
         
             
            Blockly.Msg.BLOCKS_HARDWARE_LEFT = 'left';
         
     | 
| 
       225 
228 
     | 
    
         
             
            Blockly.Msg.BLOCKS_HARDWARE_RIGHT = 'right';
         
     | 
| 
       226 
229 
     | 
    
         
             
            Blockly.Msg.BLOCKS_HARDWARE_INIT_HARDWARE = 'setup hardware';
         
     | 
| 
      
 230 
     | 
    
         
            +
            Blockly.Msg.BLOCKS_HARDWARE_NEO_PIXEL_SET_RGB = 'Adfruit NeoPixel RGB LED %1 set color to red %2 green %3 blue %4';
         
     | 
| 
       227 
231 
     | 
    
         
             
            Blockly.Msg.BLOCKS_HARDWARE_RGB_LED_SET_COLOR = 'set RGB LED %1 common %2 color to %3';
         
     | 
| 
       228 
232 
     | 
    
         
             
            Blockly.Msg.BLOCKS_HARDWARE_RGB_LED_TURN_OFF = 'turn off RGB LED %1 common %2';
         
     | 
| 
       229 
233 
     | 
    
         
             
            Blockly.Msg.BLOCKS_HARDWARE_SEVEN_SEGMENT_DISPLAY_SHOW = 'show 7 segment display %1';
         
     | 
| 
         @@ -195,6 +195,7 @@ Blockly.Msg.BLOCKS_RUBY_P = '♠p %1'; 
     | 
|
| 
       195 
195 
     | 
    
         | 
| 
       196 
196 
     | 
    
         
             
            // blocks/field_character.js.coffee.erb
         
     | 
| 
       197 
197 
     | 
    
         
             
            Blockly.Msg.BLOCKS_FIELD_CHARACTER_NO_CHARACTER = 'キャラクターなし';
         
     | 
| 
      
 198 
     | 
    
         
            +
            Blockly.Msg.BLOCKS_FIELD_CHARACTER_FIRST_COSTUME = '最初のコスチューム';
         
     | 
| 
       198 
199 
     | 
    
         | 
| 
       199 
200 
     | 
    
         | 
| 
       200 
201 
     | 
    
         
             
            // blocks/sound.js.coffee.erb
         
     | 
| 
         @@ -218,6 +219,8 @@ Blockly.Msg.BLOCKS_LOOKS_THINK_WITH_SECOND = '★%1 と %2 秒と考える'; 
     | 
|
| 
       218 
219 
     | 
    
         
             
            Blockly.Msg.BLOCKS_LOOKS_SHOW = '★表示する';
         
     | 
| 
       219 
220 
     | 
    
         
             
            Blockly.Msg.BLOCKS_LOOKS_HIDE = '★隠す';
         
     | 
| 
       220 
221 
     | 
    
         
             
            Blockly.Msg.BLOCKS_LOOKS_VANISH = '★消滅する';
         
     | 
| 
      
 222 
     | 
    
         
            +
            Blockly.Msg.BLOCKS_LOOKS_NEXT_COSTUME = '★次のコスチュームにする';
         
     | 
| 
      
 223 
     | 
    
         
            +
            Blockly.Msg.BLOCKS_LOOKS_SWITCH_COSTUME = '★コスチュームを %1 にする';
         
     | 
| 
       221 
224 
     | 
    
         | 
| 
       222 
225 
     | 
    
         | 
| 
       223 
226 
     | 
    
         
             
            // blocks/hardware.js.coffee.erb
         
     | 
| 
         @@ -228,6 +231,7 @@ Blockly.Msg.BLOCKS_HARDWARE_CATHODE = 'カソード'; 
     | 
|
| 
       228 
231 
     | 
    
         
             
            Blockly.Msg.BLOCKS_HARDWARE_LEFT = ' 左';
         
     | 
| 
       229 
232 
     | 
    
         
             
            Blockly.Msg.BLOCKS_HARDWARE_RIGHT = '右';
         
     | 
| 
       230 
233 
     | 
    
         
             
            Blockly.Msg.BLOCKS_HARDWARE_INIT_HARDWARE = '♠ハードウェアを準備する';
         
     | 
| 
      
 234 
     | 
    
         
            +
            Blockly.Msg.BLOCKS_HARDWARE_NEO_PIXEL_SET_RGB = '★マイコン内蔵RGB LED %1 を赤 %2 緑 %3 青 %4 にする';
         
     | 
| 
       231 
235 
     | 
    
         
             
            Blockly.Msg.BLOCKS_HARDWARE_RGB_LED_SET_COLOR = '★RGB LED %1 コモン %2 を %3 にする';
         
     | 
| 
       232 
236 
     | 
    
         
             
            Blockly.Msg.BLOCKS_HARDWARE_RGB_LED_TURN_OFF = '★RGB LED %1 コモン %2 をオフにする';
         
     | 
| 
       233 
237 
     | 
    
         
             
            Blockly.Msg.BLOCKS_HARDWARE_SEVEN_SEGMENT_DISPLAY_SHOW = '★7セグディスプレイに %1 を表示する';
         
     | 
| 
         
            File without changes
         
     | 
| 
         @@ -135,6 +135,7 @@ window.Smalruby = 
     | 
|
| 
       135 
135 
     | 
    
         
             
                    c = new Smalruby.Character
         
     | 
| 
       136 
136 
     | 
    
         
             
                      name: xmlChild.getAttribute('name')
         
     | 
| 
       137 
137 
     | 
    
         
             
                      costumes: xmlChild.getAttribute('costumes').split(',')
         
     | 
| 
      
 138 
     | 
    
         
            +
                      costumeIndex: parseInt(xmlChild.getAttribute('costume_index') || 0, 10)
         
     | 
| 
       138 
139 
     | 
    
         
             
                      x: parseInt(xmlChild.getAttribute('x'), 10)
         
     | 
| 
       139 
140 
     | 
    
         
             
                      y: parseInt(xmlChild.getAttribute('y'), 10)
         
     | 
| 
       140 
141 
     | 
    
         
             
                      angle: parseInt(xmlChild.getAttribute('angle'), 10)
         
     | 
| 
         @@ -152,7 +153,10 @@ window.Smalruby = 
     | 
|
| 
       152 
153 
     | 
    
         
             
                  e.setAttribute('x', c.get('x'))
         
     | 
| 
       153 
154 
     | 
    
         
             
                  e.setAttribute('y', c.get('y'))
         
     | 
| 
       154 
155 
     | 
    
         
             
                  e.setAttribute('name', c.get('name'))
         
     | 
| 
       155 
     | 
    
         
            -
                  e.setAttribute('costumes', c. 
     | 
| 
      
 156 
     | 
    
         
            +
                  e.setAttribute('costumes', c.costumesWithName().join(','))
         
     | 
| 
      
 157 
     | 
    
         
            +
                  costumeIndex = c.get('costumeIndex')
         
     | 
| 
      
 158 
     | 
    
         
            +
                  if costumeIndex != 0
         
     | 
| 
      
 159 
     | 
    
         
            +
                    e.setAttribute('costume_index', costumeIndex)
         
     | 
| 
       156 
160 
     | 
    
         
             
                  e.setAttribute('angle', c.get('angle'))
         
     | 
| 
       157 
161 
     | 
    
         
             
                  rotationStyle = c.get('rotationStyle')
         
     | 
| 
       158 
162 
     | 
    
         
             
                  if rotationStyle != 'free'
         
     | 
| 
         
            File without changes
         
     | 
| 
         @@ -0,0 +1,357 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%
         
     | 
| 
      
 2 
     | 
    
         
            +
              require 'smalruby_editor'
         
     | 
| 
      
 3 
     | 
    
         
            +
              require 'smalruby_editor/blockly_message_helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
            %>
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            # キャラクター設定ダイアログを表現するビュー
         
     | 
| 
      
 7 
     | 
    
         
            +
            Smalruby.CharacterModalView = Backbone.View.extend
         
     | 
| 
      
 8 
     | 
    
         
            +
              model: new Smalruby.Character()
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              events:
         
     | 
| 
      
 11 
     | 
    
         
            +
                'click #character-modal-costume-selector a.thumbnail': 'onSelectCostume'
         
     | 
| 
      
 12 
     | 
    
         
            +
                'click #character-modal-costume-selector a#character-modal-upload-costume': 'onUploadCostume'
         
     | 
| 
      
 13 
     | 
    
         
            +
                'click #character_rotation_style_free': 'onRotationStyleFree'
         
     | 
| 
      
 14 
     | 
    
         
            +
                'click #character_rotation_style_left_right': 'onRotationStyleLeftRight'
         
     | 
| 
      
 15 
     | 
    
         
            +
                'click #character_rotation_style_none': 'onRotationStyleNone'
         
     | 
| 
      
 16 
     | 
    
         
            +
                'click #character-modal-ok-button': 'onOk'
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              previewZoomLevel: 0.5
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              initialize: ->
         
     | 
| 
      
 21 
     | 
    
         
            +
                Smalruby.removeBackdropOnHidden(@$el)
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                @target = null
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                $('#character-modal-costume-selector img').on 'dragstart', (e) ->
         
     | 
| 
      
 26 
     | 
    
         
            +
                  e.preventDefault()
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                setPosition = (pos) =>
         
     | 
| 
      
 29 
     | 
    
         
            +
                  @model.set
         
     | 
| 
      
 30 
     | 
    
         
            +
                    x: parseInt(pos.left / @previewZoomLevel)
         
     | 
| 
      
 31 
     | 
    
         
            +
                    y: parseInt(pos.top / @previewZoomLevel)
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                $('#character-modal-character').draggable
         
     | 
| 
      
 34 
     | 
    
         
            +
                  containment: '#character-modal-preview'
         
     | 
| 
      
 35 
     | 
    
         
            +
                  cursor: 'move'
         
     | 
| 
      
 36 
     | 
    
         
            +
                  drag: (event, ui) ->
         
     | 
| 
      
 37 
     | 
    
         
            +
                    setPosition(ui.position)
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                $('#character-modal-preview').droppable
         
     | 
| 
      
 40 
     | 
    
         
            +
                  drop: (event, ui) ->
         
     | 
| 
      
 41 
     | 
    
         
            +
                    setPosition(ui.draggable.position())
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                Smalruby.ignoreEnterKey(@$el)
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                @templateText = $('#character-modal-costume-template').text()
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                $('#character-modal-add-costume-button').click (e) =>
         
     | 
| 
      
 48 
     | 
    
         
            +
                  e.preventDefault()
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                  costumes = @model.get('costumes').slice(0)
         
     | 
| 
      
 51 
     | 
    
         
            +
                  costumes.push(@model.costume())
         
     | 
| 
      
 52 
     | 
    
         
            +
                  costumeNames = @model.get('costumeNames').slice(0)
         
     | 
| 
      
 53 
     | 
    
         
            +
                  costumeNames.push("costume#{costumes.length}")
         
     | 
| 
      
 54 
     | 
    
         
            +
                  @model.set
         
     | 
| 
      
 55 
     | 
    
         
            +
                    costumes: costumes
         
     | 
| 
      
 56 
     | 
    
         
            +
                    costumeNames: costumeNames
         
     | 
| 
      
 57 
     | 
    
         
            +
                    costumeIndex: costumes.length - 1
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                self = @
         
     | 
| 
      
 60 
     | 
    
         
            +
                changeNameFunc = (e) ->
         
     | 
| 
      
 61 
     | 
    
         
            +
                  self.model.set({ name: $(@).val() })
         
     | 
| 
      
 62 
     | 
    
         
            +
                  self.nameChanged = true
         
     | 
| 
      
 63 
     | 
    
         
            +
                @$el.find('input[name="character[name]"]').change(changeNameFunc)
         
     | 
| 
      
 64 
     | 
    
         
            +
                @$el.find('input[name="character[name]"]').keyup(changeNameFunc)
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                @$el.find('input[name="character[x]"]').change (e) ->
         
     | 
| 
      
 67 
     | 
    
         
            +
                  self.model.set({ x: $(@).val() })
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                @$el.find('input[name="character[y]"]').change (e) ->
         
     | 
| 
      
 70 
     | 
    
         
            +
                  self.model.set({ y: $(@).val() })
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                @$el.find('input[name="character[angle]"]').change (e) ->
         
     | 
| 
      
 73 
     | 
    
         
            +
                  self.model.set({ angle: $(@).val() })
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                changeCostumeNameFunc = (e) ->
         
     | 
| 
      
 76 
     | 
    
         
            +
                  val = $(@).val()
         
     | 
| 
      
 77 
     | 
    
         
            +
                  costumeNames = _.clone(self.model.get('costumeNames'))
         
     | 
| 
      
 78 
     | 
    
         
            +
                  costumeNames[self.model.get('costumeIndex')] = val
         
     | 
| 
      
 79 
     | 
    
         
            +
                  self.model.set({ costumeNames: costumeNames })
         
     | 
| 
      
 80 
     | 
    
         
            +
                @$el.find('input[name="costume[name]"]').change(changeCostumeNameFunc)
         
     | 
| 
      
 81 
     | 
    
         
            +
                @$el.find('input[name="costume[name]"]').keyup(changeCostumeNameFunc)
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                @listenTo(@model, 'change:name', @onChangeName)
         
     | 
| 
      
 84 
     | 
    
         
            +
                @listenTo(@model, 'change:x', @onChangeX)
         
     | 
| 
      
 85 
     | 
    
         
            +
                @listenTo(@model, 'change:y', @onChangeY)
         
     | 
| 
      
 86 
     | 
    
         
            +
                @listenTo(@model, 'change:angle', @onChangeAngle)
         
     | 
| 
      
 87 
     | 
    
         
            +
                @listenTo(@model, 'change:costumes', @onChangeCostumes)
         
     | 
| 
      
 88 
     | 
    
         
            +
                @listenTo(@model, 'change:costumeNames', @onChangeCostumeNames)
         
     | 
| 
      
 89 
     | 
    
         
            +
                @listenTo(@model, 'change:costumeIndex', @onChangeCostumeIndex)
         
     | 
| 
      
 90 
     | 
    
         
            +
                @listenTo(@model, 'change:rotationStyle', @onChangeRotationStyle)
         
     | 
| 
      
 91 
     | 
    
         
            +
                @listenTo(@model, 'change', @onChange)
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                @callAllOnChangeAttributes_()
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
              render: ->
         
     | 
| 
      
 96 
     | 
    
         
            +
                @onChange(@model)
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                @$el.find('.modal-body').block
         
     | 
| 
      
 99 
     | 
    
         
            +
                  message: null
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
                unblock = =>
         
     | 
| 
      
 102 
     | 
    
         
            +
                  @$el.find('.modal-body').unblock()
         
     | 
| 
      
 103 
     | 
    
         
            +
                  null # HACK: if return unblock(), does not call fail().
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                @$el.modal
         
     | 
| 
      
 106 
     | 
    
         
            +
                  backdrop: 'static'
         
     | 
| 
      
 107 
     | 
    
         
            +
                @$el.modal('show')
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                dfr = $.Deferred()
         
     | 
| 
      
 110 
     | 
    
         
            +
                $.ajax
         
     | 
| 
      
 111 
     | 
    
         
            +
                  url: '/costumes/'
         
     | 
| 
      
 112 
     | 
    
         
            +
                  type: 'GET'
         
     | 
| 
      
 113 
     | 
    
         
            +
                  cache: false
         
     | 
| 
      
 114 
     | 
    
         
            +
                  success: (data, textStatus, jqXHR) -> dfr.resolve(data)
         
     | 
| 
      
 115 
     | 
    
         
            +
                  error: dfr.reject
         
     | 
| 
      
 116 
     | 
    
         
            +
                dfr.promise()
         
     | 
| 
      
 117 
     | 
    
         
            +
                  .then (data) =>
         
     | 
| 
      
 118 
     | 
    
         
            +
                    @replaceCostumeSelectorHtml_(data)
         
     | 
| 
      
 119 
     | 
    
         
            +
                  .then(unblock, unblock)
         
     | 
| 
      
 120 
     | 
    
         
            +
                  .fail =>
         
     | 
| 
      
 121 
     | 
    
         
            +
                    @$el.modal('hide')
         
     | 
| 
      
 122 
     | 
    
         
            +
                    errorMessage(<%= bm('.error') %>)
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
              replaceCostumeSelectorHtml_: (html) ->
         
     | 
| 
      
 125 
     | 
    
         
            +
                @$el.find('#character-modal-costume-selector').replaceWith(html)
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
                self = @
         
     | 
| 
      
 128 
     | 
    
         
            +
                @$el.find('#character-modal-costume-selector a.remove-button').click (e) ->
         
     | 
| 
      
 129 
     | 
    
         
            +
                  e.preventDefault()
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                  link = $(@)
         
     | 
| 
      
 132 
     | 
    
         
            +
                  if confirm(link.attr("data-message"))
         
     | 
| 
      
 133 
     | 
    
         
            +
                    dfr = $.Deferred()
         
     | 
| 
      
 134 
     | 
    
         
            +
                    $.ajax
         
     | 
| 
      
 135 
     | 
    
         
            +
                      url: link.attr("data-url")
         
     | 
| 
      
 136 
     | 
    
         
            +
                      type: "DELETE"
         
     | 
| 
      
 137 
     | 
    
         
            +
                      cache: false
         
     | 
| 
      
 138 
     | 
    
         
            +
                      data: { "_method": "DELETE" },
         
     | 
| 
      
 139 
     | 
    
         
            +
                      success: (data, textStatus, jqXHR) -> dfr.resolve(data)
         
     | 
| 
      
 140 
     | 
    
         
            +
                      error: dfr.reject
         
     | 
| 
      
 141 
     | 
    
         
            +
                    dfr.promise()
         
     | 
| 
      
 142 
     | 
    
         
            +
                      .then (data) ->
         
     | 
| 
      
 143 
     | 
    
         
            +
                        self.replaceCostumeSelectorHtml_(data)
         
     | 
| 
      
 144 
     | 
    
         
            +
                      .fail ->
         
     | 
| 
      
 145 
     | 
    
         
            +
                        errorMessage(<%= bm('.error_remove_costume') %>)
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
                @$el.find('#character-modal-upload-costume-form').fileupload
         
     | 
| 
      
 148 
     | 
    
         
            +
                  dataType: "html"
         
     | 
| 
      
 149 
     | 
    
         
            +
                  done: (e, data) =>
         
     | 
| 
      
 150 
     | 
    
         
            +
                    @replaceCostumeSelectorHtml_(data.result)
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
                @setActiveCostume_()
         
     | 
| 
      
 153 
     | 
    
         
            +
                @renderCostumeSet_()
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
                # HACK: ダイアログを表示して50ms程度待たないと画像のサイズが取得できなかった
         
     | 
| 
      
 156 
     | 
    
         
            +
                f = ->
         
     | 
| 
      
 157 
     | 
    
         
            +
                  if @readImageSizeflag
         
     | 
| 
      
 158 
     | 
    
         
            +
                    img = $('#character-modal-costume-selector .active img')
         
     | 
| 
      
 159 
     | 
    
         
            +
                    if img.width() > 0
         
     | 
| 
      
 160 
     | 
    
         
            +
                      $('#character-modal-character').css
         
     | 
| 
      
 161 
     | 
    
         
            +
                        width: "#{img.width() / 2}px"
         
     | 
| 
      
 162 
     | 
    
         
            +
                        height: "#{img.height() / 2}px"
         
     | 
| 
      
 163 
     | 
    
         
            +
                      @readImageSizeflag = false
         
     | 
| 
      
 164 
     | 
    
         
            +
                    else
         
     | 
| 
      
 165 
     | 
    
         
            +
                      setTimeout(_.bind(f, @), 50)
         
     | 
| 
      
 166 
     | 
    
         
            +
                if @readImageSizeflag
         
     | 
| 
      
 167 
     | 
    
         
            +
                  setTimeout(_.bind(f, @), 1)
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
              setActiveCostume_: ->
         
     | 
| 
      
 170 
     | 
    
         
            +
                @$el.find('#character-modal-costume-selector a.thumbnail').removeClass('active')
         
     | 
| 
      
 171 
     | 
    
         
            +
                thumb = @$el.find("#character-modal-costume-selector img[alt=\"#{@model.costume()}\"]")
         
     | 
| 
      
 172 
     | 
    
         
            +
                thumb.parent().addClass('active')
         
     | 
| 
      
 173 
     | 
    
         
            +
                if thumb.width() > 0
         
     | 
| 
      
 174 
     | 
    
         
            +
                  $('#character-modal-character').css
         
     | 
| 
      
 175 
     | 
    
         
            +
                    width: "#{thumb.width() / 2}px"
         
     | 
| 
      
 176 
     | 
    
         
            +
                    height: "#{thumb.height() / 2}px"
         
     | 
| 
      
 177 
     | 
    
         
            +
                else
         
     | 
| 
      
 178 
     | 
    
         
            +
                  @readImageSizeflag = true
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
              renderCostumeSet_: ->
         
     | 
| 
      
 181 
     | 
    
         
            +
                costumesEl = @$el.find('#character-modal-costume-set')
         
     | 
| 
      
 182 
     | 
    
         
            +
                costumesEl.children().remove()
         
     | 
| 
      
 183 
     | 
    
         
            +
             
     | 
| 
      
 184 
     | 
    
         
            +
                costumes = @model.get('costumes')
         
     | 
| 
      
 185 
     | 
    
         
            +
                $.each costumes, (i, name) =>
         
     | 
| 
      
 186 
     | 
    
         
            +
                  costume =
         
     | 
| 
      
 187 
     | 
    
         
            +
                    name: @model.costumeName(i)
         
     | 
| 
      
 188 
     | 
    
         
            +
                    basename: name
         
     | 
| 
      
 189 
     | 
    
         
            +
                    path: @model.costumeUrl(i)
         
     | 
| 
      
 190 
     | 
    
         
            +
                    index: i + 1
         
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
      
 192 
     | 
    
         
            +
                  html = $(_.template(@templateText, costume))
         
     | 
| 
      
 193 
     | 
    
         
            +
                  costumesEl.append(html)
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
                  html.find('a.costume').click (e) =>
         
     | 
| 
      
 196 
     | 
    
         
            +
                    e.preventDefault()
         
     | 
| 
      
 197 
     | 
    
         
            +
                    @model.set({ costumeIndex: i })
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
                  removeButton = html.find('a.remove-button')
         
     | 
| 
      
 200 
     | 
    
         
            +
                  if costumes.length <= 1
         
     | 
| 
      
 201 
     | 
    
         
            +
                    removeButton.hide()
         
     | 
| 
      
 202 
     | 
    
         
            +
                  else
         
     | 
| 
      
 203 
     | 
    
         
            +
                    removeButton.click (e) =>
         
     | 
| 
      
 204 
     | 
    
         
            +
                      e.preventDefault()
         
     | 
| 
      
 205 
     | 
    
         
            +
                      @removeCostume_(i)
         
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
                @renderActiveCostume_()
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
      
 209 
     | 
    
         
            +
              removeCostume_: (i) ->
         
     | 
| 
      
 210 
     | 
    
         
            +
                costumes = @model.get('costumes').slice(0)
         
     | 
| 
      
 211 
     | 
    
         
            +
                costumes.splice(i, 1)
         
     | 
| 
      
 212 
     | 
    
         
            +
                costumeNames = @model.get('costumeNames').slice(0)
         
     | 
| 
      
 213 
     | 
    
         
            +
                costumeNames.splice(i, 1)
         
     | 
| 
      
 214 
     | 
    
         
            +
                costumeIndex = @model.get('costumeIndex')
         
     | 
| 
      
 215 
     | 
    
         
            +
                if costumeIndex >= costumes.length
         
     | 
| 
      
 216 
     | 
    
         
            +
                  costumeIndex = costumes.length - 1
         
     | 
| 
      
 217 
     | 
    
         
            +
                @model.set
         
     | 
| 
      
 218 
     | 
    
         
            +
                  costumes: costumes
         
     | 
| 
      
 219 
     | 
    
         
            +
                  costumeNames: costumeNames
         
     | 
| 
      
 220 
     | 
    
         
            +
                  costumeIndex: costumeIndex
         
     | 
| 
      
 221 
     | 
    
         
            +
             
     | 
| 
      
 222 
     | 
    
         
            +
              renderActiveCostume_: ->
         
     | 
| 
      
 223 
     | 
    
         
            +
                costumesEl = @$el.find('#character-modal-costume-set')
         
     | 
| 
      
 224 
     | 
    
         
            +
                costumesEl.find('.item').removeClass('active')
         
     | 
| 
      
 225 
     | 
    
         
            +
                costumeIndex = @model.get('costumeIndex')
         
     | 
| 
      
 226 
     | 
    
         
            +
                costumesEl.find(".item:nth-child(#{costumeIndex + 1})").addClass('active')
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
              callAllOnChangeAttributes_: ->
         
     | 
| 
      
 229 
     | 
    
         
            +
                @onChangeName(@model, @model.get('name'))
         
     | 
| 
      
 230 
     | 
    
         
            +
                @onChangeX(@model, @model.get('x'))
         
     | 
| 
      
 231 
     | 
    
         
            +
                @onChangeY(@model, @model.get('y'))
         
     | 
| 
      
 232 
     | 
    
         
            +
                @onChangeAngle(@model, @model.get('angle'))
         
     | 
| 
      
 233 
     | 
    
         
            +
                @onChangeCostumes(@model, @model.get('costumes'))
         
     | 
| 
      
 234 
     | 
    
         
            +
                @onChangeRotationStyle(@model, @model.get('rotationStyle'))
         
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
      
 236 
     | 
    
         
            +
              onChangeName: (model, value, options) ->
         
     | 
| 
      
 237 
     | 
    
         
            +
                @$el.find('input[name="character[name]"]').val(value)
         
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
      
 239 
     | 
    
         
            +
              onChangeX: (model, value, options) ->
         
     | 
| 
      
 240 
     | 
    
         
            +
                @$el.find('input[name="character[x]"]').val(value)
         
     | 
| 
      
 241 
     | 
    
         
            +
                $('#character_x_value').text(value)
         
     | 
| 
      
 242 
     | 
    
         
            +
                $('#character-modal-character').css('left', parseInt(value * @previewZoomLevel))
         
     | 
| 
      
 243 
     | 
    
         
            +
             
     | 
| 
      
 244 
     | 
    
         
            +
              onChangeY: (model, value, options) ->
         
     | 
| 
      
 245 
     | 
    
         
            +
                @$el.find('input[name="character[y]"]').val(value)
         
     | 
| 
      
 246 
     | 
    
         
            +
                $('#character_y_value').text(value)
         
     | 
| 
      
 247 
     | 
    
         
            +
                $('#character-modal-character').css('top', parseInt(value * @previewZoomLevel))
         
     | 
| 
      
 248 
     | 
    
         
            +
             
     | 
| 
      
 249 
     | 
    
         
            +
              onChangeAngle: (model, value, options) ->
         
     | 
| 
      
 250 
     | 
    
         
            +
                @$el.find('input[name="character[angle]"]').val(value)
         
     | 
| 
      
 251 
     | 
    
         
            +
                $('#character_angle_value').text("#{value}°")
         
     | 
| 
      
 252 
     | 
    
         
            +
                rotate = "rotate(#{value}deg)"
         
     | 
| 
      
 253 
     | 
    
         
            +
                $('#character_angle_vector').css
         
     | 
| 
      
 254 
     | 
    
         
            +
                  '-moz-transform': rotate
         
     | 
| 
      
 255 
     | 
    
         
            +
                  '-webkit-transform': rotate
         
     | 
| 
      
 256 
     | 
    
         
            +
                  transform: rotate
         
     | 
| 
      
 257 
     | 
    
         
            +
             
     | 
| 
      
 258 
     | 
    
         
            +
                @model.rotateImage('#character-modal-character')
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
              onChangeCostumes: (model, value, options) ->
         
     | 
| 
      
 261 
     | 
    
         
            +
                @renderCostumeSet_()
         
     | 
| 
      
 262 
     | 
    
         
            +
                @onChangeCostumeIndex(model, model.get('costumeIndex'))
         
     | 
| 
      
 263 
     | 
    
         
            +
             
     | 
| 
      
 264 
     | 
    
         
            +
              onChangeCostumeNames: (model, value, options) ->
         
     | 
| 
      
 265 
     | 
    
         
            +
                $.each value, (i, costumeName) =>
         
     | 
| 
      
 266 
     | 
    
         
            +
                  @$el.find("#character-modal-costume-set .item:nth-child(#{i + 1}) .name").text(costumeName)
         
     | 
| 
      
 267 
     | 
    
         
            +
             
     | 
| 
      
 268 
     | 
    
         
            +
              onChangeCostumeIndex: (model, value, options) ->
         
     | 
| 
      
 269 
     | 
    
         
            +
                img = $('<img>').attr
         
     | 
| 
      
 270 
     | 
    
         
            +
                  src: model.costumeUrl()
         
     | 
| 
      
 271 
     | 
    
         
            +
                  alt: model.costume()
         
     | 
| 
      
 272 
     | 
    
         
            +
                $('#character-modal-character img').replaceWith(img)
         
     | 
| 
      
 273 
     | 
    
         
            +
                $('#character-modal input[name="costume[name]"]').val(model.costumeName())
         
     | 
| 
      
 274 
     | 
    
         
            +
             
     | 
| 
      
 275 
     | 
    
         
            +
                @setActiveCostume_()
         
     | 
| 
      
 276 
     | 
    
         
            +
                @renderActiveCostume_()
         
     | 
| 
      
 277 
     | 
    
         
            +
             
     | 
| 
      
 278 
     | 
    
         
            +
              onChangeRotationStyle: (model, value, options) ->
         
     | 
| 
      
 279 
     | 
    
         
            +
                $('#character_rotation_style button.btn').removeClass('btn-primary')
         
     | 
| 
      
 280 
     | 
    
         
            +
                $("#character_rotation_style_#{value}").addClass('btn-primary')
         
     | 
| 
      
 281 
     | 
    
         
            +
                @onChangeAngle(@model, @model.get('angle'))
         
     | 
| 
      
 282 
     | 
    
         
            +
             
     | 
| 
      
 283 
     | 
    
         
            +
              onChange: (model, options) ->
         
     | 
| 
      
 284 
     | 
    
         
            +
                @validate_()
         
     | 
| 
      
 285 
     | 
    
         
            +
             
     | 
| 
      
 286 
     | 
    
         
            +
              validate_: ->
         
     | 
| 
      
 287 
     | 
    
         
            +
                return unless @target
         
     | 
| 
      
 288 
     | 
    
         
            +
             
     | 
| 
      
 289 
     | 
    
         
            +
                valid = true
         
     | 
| 
      
 290 
     | 
    
         
            +
             
     | 
| 
      
 291 
     | 
    
         
            +
                @$el.find('.control-group').removeClass('error')
         
     | 
| 
      
 292 
     | 
    
         
            +
                @$el.find('#character-modal-costume-set .item').removeClass('error')
         
     | 
| 
      
 293 
     | 
    
         
            +
             
     | 
| 
      
 294 
     | 
    
         
            +
                unless @model.isValid()
         
     | 
| 
      
 295 
     | 
    
         
            +
                  valid = false
         
     | 
| 
      
 296 
     | 
    
         
            +
                  $.each @model.validationError, (i, error) =>
         
     | 
| 
      
 297 
     | 
    
         
            +
                    if error.attr == 'name'
         
     | 
| 
      
 298 
     | 
    
         
            +
                      @$el.find('.control-group[for="character[name]"]').addClass('error')
         
     | 
| 
      
 299 
     | 
    
         
            +
                    if error.attr == 'costumeNames'
         
     | 
| 
      
 300 
     | 
    
         
            +
                      if error.index == @model.get('costumeIndex')
         
     | 
| 
      
 301 
     | 
    
         
            +
                        @$el.find('.control-group[for="costume[name]"]').addClass('error')
         
     | 
| 
      
 302 
     | 
    
         
            +
                      @$el.find("#character-modal-costume-set .item:nth-child(#{error.index + 1})").addClass('error')
         
     | 
| 
      
 303 
     | 
    
         
            +
             
     | 
| 
      
 304 
     | 
    
         
            +
                name = @model.get('name')
         
     | 
| 
      
 305 
     | 
    
         
            +
                if @target.get('name') != name &&
         
     | 
| 
      
 306 
     | 
    
         
            +
                   Smalruby.Collections.CharacterSet.findWhere({ name: name })
         
     | 
| 
      
 307 
     | 
    
         
            +
                  valid = false
         
     | 
| 
      
 308 
     | 
    
         
            +
                  @$el.find('.control-group[for="character[name]"]').addClass('error')
         
     | 
| 
      
 309 
     | 
    
         
            +
             
     | 
| 
      
 310 
     | 
    
         
            +
                valid
         
     | 
| 
      
 311 
     | 
    
         
            +
             
     | 
| 
      
 312 
     | 
    
         
            +
              onSelectCostume: (e) ->
         
     | 
| 
      
 313 
     | 
    
         
            +
                e.preventDefault()
         
     | 
| 
      
 314 
     | 
    
         
            +
             
     | 
| 
      
 315 
     | 
    
         
            +
                attrs = {}
         
     | 
| 
      
 316 
     | 
    
         
            +
             
     | 
| 
      
 317 
     | 
    
         
            +
                costume = $(e.target).attr('alt') || $(e.target).find('img').attr('alt')
         
     | 
| 
      
 318 
     | 
    
         
            +
                if @model.costume() != costume
         
     | 
| 
      
 319 
     | 
    
         
            +
                  costumes = @model.get('costumes').slice(0)
         
     | 
| 
      
 320 
     | 
    
         
            +
                  costumes[@model.get('costumeIndex')] = costume
         
     | 
| 
      
 321 
     | 
    
         
            +
                  attrs['costumes'] = costumes
         
     | 
| 
      
 322 
     | 
    
         
            +
             
     | 
| 
      
 323 
     | 
    
         
            +
                unless @nameChanged
         
     | 
| 
      
 324 
     | 
    
         
            +
                  prefix = Smalruby.Character.costumeToNamePrefix(costume)
         
     | 
| 
      
 325 
     | 
    
         
            +
                  if prefix != @model.namePrefix()
         
     | 
| 
      
 326 
     | 
    
         
            +
                    if prefix == @target.namePrefix()
         
     | 
| 
      
 327 
     | 
    
         
            +
                      attrs['name'] = @target.get('name')
         
     | 
| 
      
 328 
     | 
    
         
            +
                    else
         
     | 
| 
      
 329 
     | 
    
         
            +
                      attrs['name'] = Smalruby.Collections.CharacterSet.uniqueName(costume)
         
     | 
| 
      
 330 
     | 
    
         
            +
             
     | 
| 
      
 331 
     | 
    
         
            +
                @model.set(attrs)
         
     | 
| 
      
 332 
     | 
    
         
            +
             
     | 
| 
      
 333 
     | 
    
         
            +
              onUploadCostume: (e) ->
         
     | 
| 
      
 334 
     | 
    
         
            +
                e.preventDefault()
         
     | 
| 
      
 335 
     | 
    
         
            +
             
     | 
| 
      
 336 
     | 
    
         
            +
                @$el.find('input[name="costume[file]"]').click()
         
     | 
| 
      
 337 
     | 
    
         
            +
             
     | 
| 
      
 338 
     | 
    
         
            +
              onRotationStyleFree: ->
         
     | 
| 
      
 339 
     | 
    
         
            +
                @model.set({ rotationStyle: 'free' })
         
     | 
| 
      
 340 
     | 
    
         
            +
             
     | 
| 
      
 341 
     | 
    
         
            +
              onRotationStyleLeftRight: ->
         
     | 
| 
      
 342 
     | 
    
         
            +
                @model.set({ rotationStyle: 'left_right' })
         
     | 
| 
      
 343 
     | 
    
         
            +
             
     | 
| 
      
 344 
     | 
    
         
            +
              onRotationStyleNone: ->
         
     | 
| 
      
 345 
     | 
    
         
            +
                @model.set({ rotationStyle: 'none' })
         
     | 
| 
      
 346 
     | 
    
         
            +
             
     | 
| 
      
 347 
     | 
    
         
            +
              onOk: ->
         
     | 
| 
      
 348 
     | 
    
         
            +
                if @validate_()
         
     | 
| 
      
 349 
     | 
    
         
            +
                  @$el.modal('hide')
         
     | 
| 
      
 350 
     | 
    
         
            +
                  if @target
         
     | 
| 
      
 351 
     | 
    
         
            +
                    @target.set(_.clone(@model.attributes))
         
     | 
| 
      
 352 
     | 
    
         
            +
             
     | 
| 
      
 353 
     | 
    
         
            +
              setCharacter: (character)->
         
     | 
| 
      
 354 
     | 
    
         
            +
                @target = character
         
     | 
| 
      
 355 
     | 
    
         
            +
                @model.set(_.clone(@target.attributes))
         
     | 
| 
      
 356 
     | 
    
         
            +
                @nameChanged = false
         
     | 
| 
      
 357 
     | 
    
         
            +
                @
         
     |