1 class Pettanr.Views.SpeechBalloon.Element extends Pettanr.View
\r
3 className: 'pettanr-comic-balloon'
\r
5 initialize: (options) ->
\r
6 @element = options.element
\r
9 @balloon = @element.get('balloon')
\r
10 klass = @balloon_class()
\r
11 @balloon_view = new klass({
\r
17 @speech = @element.get('speech')
\r
18 klass = @speech_class()
\r
19 @speech_view = new klass({
\r
28 @balloon.get_parent('system_picture', this, {
\r
29 success: (system_picture) =>
\r
30 @balloon_view.system_picture = system_picture
\r
31 this.$el.append(@balloon_view.render().el)
\r
32 @balloon_view.init_picture()
\r
34 this.$el.append(@speech_view.render().el)
\r
39 attr = {style: Pettanr.to_style(@style())}
\r
44 width: Pettanr.to_s(@balloon.get('width')) + 'px',
\r
45 height: Pettanr.to_s(@balloon.get('height')) + 'px',
\r
46 top: Pettanr.to_s(@balloon.get('y')) + 'px',
\r
47 left: Pettanr.to_s(@balloon.get('x')) + 'px',
\r
48 'z-index': @element.get('z')
\r
51 balloon_class: () ->
\r
52 Pettanr.Views.Balloon.Element
\r
55 Pettanr.Views.Speech.Element
\r
57 class Pettanr.Views.SpeechBalloon.Element.Edit extends Pettanr.Views.SpeechBalloon.Element
\r
59 initialize: (options) ->
\r
61 @listenTo(@element, 'sort', @set_style)
\r
62 @listenTo(@element, 'active', @active)
\r
63 @listenTo(@element, 'inactive', @inactive)
\r
64 @listenTo(@balloon, 'input:r', @input_r)
\r
65 @listenTo(@balloon, 'input:x', @set_style)
\r
66 @listenTo(@balloon, 'input:y', @set_style)
\r
67 @listenTo(@balloon, 'input:width', @set_style)
\r
68 @listenTo(@balloon, 'input:height', @set_style)
\r
73 this.$el.draggable {
\r
74 stop: (event, ui) ->
\r
75 left = Math.floor($(@).position().left)
\r
76 top = Math.floor($(@).position().top)
\r
77 bln.set({x: left, y: top}, {silent: true})
\r
89 $('.ui-resizable-handle', this.el).map ->
\r
90 $(@).css('display', 'block')
\r
93 $('.ui-resizable-handle', this.el).map ->
\r
94 $(@).css('display', 'none')
\r
96 element_class: (element) ->
\r
97 Pettanr.Views[element.singular()].Element.Edit
\r
99 balloon_class: () ->
\r
100 Pettanr.Views.Balloon.Element.Edit
\r
102 speech_class: () ->
\r
103 Pettanr.Views.Speech.Element.Edit
\r