X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fpanels.js.coffee;h=37735c9d7f257ce86ea14b3ee978bfe90bef60bd;hp=c5466fe5bf98ec48b465d5dd6ff2401e216f0b75;hb=e25230e6f2fe934e47502621cf498640d58f429d;hpb=9692096a255031379b18d9b3eb2ca8da388eae20 diff --git a/app/assets/javascripts/panels.js.coffee b/app/assets/javascripts/panels.js.coffee index c5466fe5..37735c9d 100644 --- a/app/assets/javascripts/panels.js.coffee +++ b/app/assets/javascripts/panels.js.coffee @@ -416,16 +416,24 @@ $ -> # ground-picture + refresh_ground_picture = (element_trace) -> + x = parseInt($(element_trace + 'x').val()).toString() + 'px' + y = parseInt($(element_trace + 'y').val()).toString() + 'px' + $(element_trace).css('background-position', x + ' ' + y) + # sync view $('input').map -> if editor.element_is('ground_picture', $(@)) - $(@).focusout -> - switch $(@).attr('column') - when 'x', 'y' + switch $(@).attr('column') + when 'x', 'y' + $(@).focusout -> trace = editor.element_tag_id($(@)) - x = parseInt($(trace + 'x').val()).toString() + 'px' - y = parseInt($(trace + 'y').val()).toString() + 'px' - $(trace).css('background-position', x + ' ' + y) + refresh_ground_picture(trace) + $(@).spinner { + stop: ( event, ui ) -> + trace = editor.element_tag_id($(@)) + refresh_ground_picture(trace) + } $('select').map -> if editor.element_is('ground_picture', $(@)) $(@).change -> @@ -440,11 +448,65 @@ $ -> # ground_color ColorHelper.add_helper($('.ground_color-code-wrap'), 'code') + refresh_ground_color = (element_trace) -> + orientation = parseInt( $(element_trace + 'orientation').val() ) + xy = $(element_trace + 'xy').val() + wh = $(element_trace + 'wh').val() + div_offset = if xy + xy + else + 0 + div_size = if wh + wh + else + 100 - div_offset + div_x = if orientation == 0 + 0 + else + div_offset + div_y = if orientation == 0 + div_offset + else + 0 + div_width = if orientation == 0 + 100 + else + div_size + div_height = if orientation == 0 + div_size + else + 100 + div = $(element_trace) + div.css('left', div_x.toString() + '%') + div.css('top', div_y.toString() + '%') + div.css('width', div_width.toString() + '%') + div.css('height', div_height.toString() + '%') + # sync view $('input').map -> if editor.element_is('ground_color', $(@)) - if $(@).attr('column') == 'code' - $(@).hide() + switch $(@).attr('column') + when 'code' + $(@).hide() + when 'xy', 'wh' + $(@).spinner { + stop: ( event, ui ) -> + trace = editor.element_tag_id($(@)) + refresh_ground_color(trace) + , min: 0 + , max: 100 + } + $(@).focusout -> + trace = editor.element_tag_id($(@)) + refresh_ground_color(trace) + + $('select').map -> + if editor.element_is('ground_color', $(@)) + switch $(@).attr('column') + when 'orientation' + $(@).change -> + trace = editor.element_tag_id($(@)) + refresh_ground_color(trace) update_t = (ultrace) -> t = 0