circle_speech_balloon 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,6 +10,4 @@
10
10
  // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
11
  // GO AFTER THE REQUIRES BELOW.
12
12
  //
13
- //= require jquery
14
- //= require jquery_ujs
15
13
  //= require_tree .
@@ -0,0 +1,41 @@
1
+ $ ->
2
+ # balloon r helper
3
+ balloon_input_r = (btn) ->
4
+ wrapper = $(btn).parent()
5
+ balloon_trace = '#panel' + $(wrapper).attr('panel_id') + 'speech_balloon' + $(wrapper).attr('element_id') + 'balloon' + $(wrapper).attr('element_part_id')
6
+ input_r = $(balloon_trace + 'r')
7
+ input_r
8
+ balloon_r_step = (btn) ->
9
+ wrapper = $(btn).parent()
10
+ r_step = parseFloat(wrapper.attr('r_step'))
11
+ r_step
12
+ balloon_index = (btn, r_step) ->
13
+ v = parseInt(balloon_input_r(btn).val())
14
+ tr = v % 360
15
+ tr = 360 + tr if tr < 0
16
+ offset = r_step / 2.0
17
+ idx = Math.floor((tr + offset) / r_step)
18
+ idx
19
+
20
+ $('input').map ->
21
+ if $(@).attr('element_type') and $(@).attr('element_type') == 'speech_balloon' and $(@).attr('column') == 'r'
22
+ $(@).spinner()
23
+
24
+ $('.r-down').map ->
25
+ $(@).click ->
26
+ r_step = balloon_r_step($(@))
27
+ idx = balloon_index($(@), r_step)
28
+ rv = Math.floor((idx - 1) * r_step)
29
+ balloon_input_r($(@)).val(rv)
30
+ $('.r-up').map ->
31
+ $(@).click ->
32
+ r_step = balloon_r_step($(@))
33
+ idx = balloon_index($(@), r_step)
34
+ rv = Math.floor((idx + 1) * r_step)
35
+ balloon_input_r($(@)).val(rv)
36
+ $('.r-reset').map ->
37
+ $(@).click ->
38
+ wrapper = $(@).parent()
39
+ balloon_trace = '#panel' + $(wrapper).attr('panel_id') + 'speech_balloon' + $(wrapper).attr('element_id') + 'balloon' + $(wrapper).attr('element_part_id')
40
+ $(balloon_trace + 'r').val(0)
41
+
@@ -1,3 +1,4 @@
1
+ <%= javascript_include_tag "circle_speech_balloon/application" %>
1
2
 
2
3
  <div class="field">
3
4
  <%= f.label :x %><br />
@@ -22,6 +23,11 @@
22
23
  <div class="field">
23
24
  <%= f.label :r %><br />
24
25
  <%= f.number_field :r, :id => balloon.field_tag_id(:r), :panel_id => balloon.tag_panel_id, :element_id => balloon.tag_element_id, :element_type => balloon.tag_element_type, :element_part_id => balloon.tag_element_part_id, :element_part_type => balloon.tag_element_part_type, :column => :r, :tree => balloon.field_tree(:r) %>
26
+ <div class="r-wrap" panel_id="<%= balloon.tag_panel_id -%>" element_id="<%= balloon.tag_element_id -%>" element_type="<%= balloon.tag_element_type -%>" element_part_id="<%= balloon.tag_element_part_id -%>" element_part_type="<%= balloon.tag_element_part_type -%>" r_step="<%= balloon.r_step -%>">
27
+ <button class="r-down" value="0"><</button>
28
+ <button class="r-up" value="0">></button>
29
+ <button class="r-reset" value="0">reset</button>
30
+ </div>
25
31
  </div>
26
32
 
27
33
  <%= f.hidden_field :system_picture_id, :id => balloon.field_tag_id(:system_picture_id), :panel_id => balloon.tag_panel_id, :element_id => balloon.tag_element_id, :element_type => balloon.tag_element_type, :element_part_id => balloon.tag_element_part_id, :element_part_type => balloon.tag_element_part_type, :column => :system_picture_id, :tree => balloon.field_tree(:system_picture_id) %>
@@ -1,7 +1,7 @@
1
1
 
2
2
  <div class="field">
3
3
  <%= f.label :content %><br />
4
- <%= f.text_area :content, :id => speech.field_tag_id(:content), :panel_id => speech.tag_panel_id, :element_type => speech.tag_element_type, :element_part_id => speech.tag_element_part_id, :element_part_type => speech.tag_element_part_type, :column => :content, :tree => speech.field_tree(:content) %>
4
+ <%= f.text_area :content, :id => speech.field_tag_id(:content), :panel_id => speech.tag_panel_id, :element_id => speech.tag_element_id, :element_type => speech.tag_element_type, :element_part_id => speech.tag_element_part_id, :element_part_type => speech.tag_element_part_type, :column => :content, :tree => speech.field_tree(:content) %>
5
5
  </div>
6
6
 
7
7
  <%= f.hidden_field :x, :id => speech.field_tag_id(:x), :panel_id => speech.tag_panel_id, :element_id => speech.tag_element_id, :element_type => speech.tag_element_type, :element_part_id => speech.tag_element_part_id, :element_part_type => speech.tag_element_part_type, :column => :x, :tree => speech.field_tree(:x) %>
@@ -1,3 +1,3 @@
1
1
  module CircleSpeechBalloon
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -36,13 +36,16 @@ module CircleSpeechBalloon
36
36
  self.speech_balloon || @new_speech_balloon
37
37
  end
38
38
 
39
+ def parsed_settings
40
+ @parsed_settings ||= get_speech_balloon.speech_balloon_template.parsed_settings
41
+ end
42
+
39
43
  def supply_default
40
- parsed_settings = get_speech_balloon.speech_balloon_template.parsed_settings
41
44
  self.x = 0
42
45
  self.y = 0
43
- self.width = parsed_settings['speech_balloon']['default_width']
44
- self.height = parsed_settings['speech_balloon']['default_height']
45
- self.r = parsed_settings['speech_balloon']['default_r']
46
+ self.width = self.parsed_settings['speech_balloon']['default_width']
47
+ self.height = self.parsed_settings['speech_balloon']['default_height']
48
+ self.r = self.parsed_settings['speech_balloon']['default_r']
46
49
  end
47
50
 
48
51
  def extend_balloon
@@ -54,14 +57,17 @@ module CircleSpeechBalloon
54
57
  end
55
58
 
56
59
  def select_system_picture
57
- parsed_settings = get_speech_balloon.speech_balloon_template.parsed_settings
58
60
  tr = self.r % 360
59
61
  tr = 360 - tr if tr < 0
60
- br = (tr / parsed_settings['speech_balloon']['r_step']).to_i
61
- self.system_picture_id = parsed_settings[br.to_s]['balloon']['system_picture_id']
62
+ br = (tr / self.r_step).to_i
63
+ self.system_picture_id = self.parsed_settings[br.to_s]['balloon']['system_picture_id']
62
64
  self.system_picture_id
63
65
  end
64
66
 
67
+ def r_step
68
+ @r_step ||= self.parsed_settings['speech_balloon']['r_step']
69
+ end
70
+
65
71
  end
66
72
 
67
73
  module SpeechModule
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circle_speech_balloon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-06 00:00:00.000000000 Z
12
+ date: 2013-07-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -51,9 +51,7 @@ extensions: []
51
51
  extra_rdoc_files: []
52
52
  files:
53
53
  - app/assets/javascripts/circle_speech_balloon/application.js
54
- - app/assets/javascripts/circle_speech_balloon/balloons.js
55
- - app/assets/javascripts/circle_speech_balloon/speeches.js
56
- - app/assets/javascripts/circle_speech_balloon/speech_balloons.js
54
+ - app/assets/javascripts/circle_speech_balloon/balloons.js.coffee
57
55
  - app/assets/stylesheets/circle_speech_balloon/application.css
58
56
  - app/assets/stylesheets/circle_speech_balloon/balloons.css
59
57
  - app/assets/stylesheets/circle_speech_balloon/speeches.css
@@ -1,2 +0,0 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
@@ -1,2 +0,0 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
@@ -1,2 +0,0 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.