circle_speech_balloon 0.0.7 → 0.0.8
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.
| @@ -5,37 +5,77 @@ $ -> | |
| 5 5 | 
             
                balloon_trace = '#panel' + $(wrapper).attr('panel_id') + 'speech_balloon' + $(wrapper).attr('element_id') + 'balloon' + $(wrapper).attr('element_part_id')
         | 
| 6 6 | 
             
                input_r = $(balloon_trace + 'r')
         | 
| 7 7 | 
             
                input_r
         | 
| 8 | 
            -
              balloon_r_step = ( | 
| 9 | 
            -
                 | 
| 10 | 
            -
             | 
| 11 | 
            -
                r_step
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                 | 
| 8 | 
            +
              balloon_r_step = ()  ->
         | 
| 9 | 
            +
                circle_speech_balloon_settings['speech_balloon']['r_step']
         | 
| 10 | 
            +
              balloon_next_index = (input_r, r_step, d)  ->
         | 
| 11 | 
            +
                v = parseInt(input_r.val()) + r_step * d
         | 
| 12 | 
            +
                tr = v % 360
         | 
| 13 | 
            +
                tr = 360 + tr if tr < 0
         | 
| 14 | 
            +
                offset = r_step / 2.0
         | 
| 15 | 
            +
                idx = Math.floor(((tr + offset) % 360) / r_step)
         | 
| 16 | 
            +
                if idx == 0
         | 
| 17 | 
            +
                  ir = 0
         | 
| 18 | 
            +
                else
         | 
| 19 | 
            +
                  if v < 0
         | 
| 20 | 
            +
                    ir = Math.floor(idx * r_step) - 360
         | 
| 21 | 
            +
                  else
         | 
| 22 | 
            +
                    ir = Math.floor(idx * r_step)
         | 
| 23 | 
            +
                input_r.val(ir)
         | 
| 24 | 
            +
                idx
         | 
| 25 | 
            +
              balloon_index = (input_r, r_step)  ->
         | 
| 26 | 
            +
                v = parseInt(input_r.val())
         | 
| 14 27 | 
             
                tr = v % 360
         | 
| 15 28 | 
             
                tr = 360 + tr if tr < 0
         | 
| 16 29 | 
             
                offset = r_step / 2.0
         | 
| 17 | 
            -
                idx = Math.floor((tr + offset) / r_step)
         | 
| 30 | 
            +
                idx = Math.floor(((tr + offset) % 360) / r_step)
         | 
| 18 31 | 
             
                idx
         | 
| 32 | 
            +
              refresh_balloon = (bln, idx)  ->
         | 
| 33 | 
            +
                sp_id = circle_speech_balloon_settings[String(idx)]['balloon']['system_picture_id']
         | 
| 34 | 
            +
                fn = '/system_pictures/' + String(sp_id) + '.png'
         | 
| 35 | 
            +
                ofn = bln.attr('src')
         | 
| 36 | 
            +
                if fn == ofn
         | 
| 37 | 
            +
                else
         | 
| 38 | 
            +
                  bln.attr('src', fn) 
         | 
| 19 39 |  | 
| 20 40 | 
             
              $('input').map  ->
         | 
| 21 41 | 
             
                if $(@).attr('element_type') and $(@).attr('element_type') == 'speech_balloon' and $(@).attr('column') == 'r'
         | 
| 22 | 
            -
                  $(@).spinner | 
| 42 | 
            +
                  $(@).spinner {
         | 
| 43 | 
            +
                    spin: ( event, ui ) ->
         | 
| 44 | 
            +
                      balloon_trace = '#panel' + $(@).attr('panel_id') + 'speech_balloon' + $(@).attr('element_id') + 'balloon' + $(@).attr('element_part_id')
         | 
| 45 | 
            +
                      r_step = balloon_r_step()
         | 
| 46 | 
            +
                      idx = balloon_index($(balloon_trace + 'r'), r_step)
         | 
| 47 | 
            +
                      refresh_balloon($(balloon_trace), idx)
         | 
| 48 | 
            +
                  }
         | 
| 49 | 
            +
             | 
| 23 50 |  | 
| 24 51 | 
             
              $('.r-down').map -> 
         | 
| 25 52 | 
             
                $(@).click -> 
         | 
| 26 | 
            -
                  r_step = balloon_r_step( | 
| 27 | 
            -
                  idx =  | 
| 28 | 
            -
                   | 
| 29 | 
            -
                   | 
| 53 | 
            +
                  r_step = balloon_r_step()
         | 
| 54 | 
            +
                  idx = balloon_next_index(balloon_input_r($(@)), r_step, -1)
         | 
| 55 | 
            +
                  wrapper = $(@).parent()
         | 
| 56 | 
            +
                  balloon_trace = '#panel' + $(wrapper).attr('panel_id') + 'speech_balloon' + $(wrapper).attr('element_id') + 'balloon' + $(wrapper).attr('element_part_id')
         | 
| 57 | 
            +
                  refresh_balloon($(balloon_trace), idx)
         | 
| 30 58 | 
             
              $('.r-up').map -> 
         | 
| 31 59 | 
             
                $(@).click -> 
         | 
| 32 | 
            -
                  r_step = balloon_r_step( | 
| 33 | 
            -
                  idx =  | 
| 34 | 
            -
                   | 
| 35 | 
            -
                   | 
| 60 | 
            +
                  r_step = balloon_r_step()
         | 
| 61 | 
            +
                  idx = balloon_next_index(balloon_input_r($(@)), r_step, 1)
         | 
| 62 | 
            +
                  wrapper = $(@).parent()
         | 
| 63 | 
            +
                  balloon_trace = '#panel' + $(wrapper).attr('panel_id') + 'speech_balloon' + $(wrapper).attr('element_id') + 'balloon' + $(wrapper).attr('element_part_id')
         | 
| 64 | 
            +
                  refresh_balloon($(balloon_trace), idx)
         | 
| 36 65 | 
             
              $('.r-reset').map -> 
         | 
| 37 66 | 
             
                $(@).click -> 
         | 
| 38 67 | 
             
                  wrapper = $(@).parent()
         | 
| 39 68 | 
             
                  balloon_trace = '#panel' + $(wrapper).attr('panel_id') + 'speech_balloon' + $(wrapper).attr('element_id') + 'balloon' + $(wrapper).attr('element_part_id')
         | 
| 40 | 
            -
                  $( | 
| 69 | 
            +
                  balloon_input_r($(@)).val(0)
         | 
| 70 | 
            +
                  refresh_balloon($(balloon_trace), 0)
         | 
| 41 71 |  | 
| 72 | 
            +
              # sync view 
         | 
| 73 | 
            +
              $('input').map  ->
         | 
| 74 | 
            +
                if $(@).attr('element_type') and $(@).attr('element_type') == 'speech_balloon'
         | 
| 75 | 
            +
                  $(@).focusout ->
         | 
| 76 | 
            +
                    switch $(@).attr('column')
         | 
| 77 | 
            +
                      when 'r'
         | 
| 78 | 
            +
                        balloon_trace = '#panel' + $(@).attr('panel_id') + 'speech_balloon' + $(@).attr('element_id') + 'balloon' + $(@).attr('element_part_id')
         | 
| 79 | 
            +
                        r_step = balloon_r_step()
         | 
| 80 | 
            +
                        idx = balloon_index($(balloon_trace + 'r'), r_step)
         | 
| 81 | 
            +
                        refresh_balloon($(balloon_trace), idx)
         |