1 class Pettanr.Views.Balloon.Element extends Backbone.View
\r
3 className: 'pettanr-balloon'
\r
5 'ready:picture': 'set_style'
\r
8 initialize: (options) ->
\r
9 @element = options.element
\r
10 @root = options.root
\r
11 @spot = options.spot
\r
12 @speech_balloon = options.parent
\r
13 @system_picture = @element.system_picture()
\r
16 @system_picture.fetch({cache: true}).done =>
\r
26 src: @system_picture.r_url(),
\r
27 alt: @element.get('caption'),
\r
28 style: Pettanr.to_style(@style())
\r
36 'z-index': 1 # play case
\r
39 add_element: (element) ->
\r
42 class Pettanr.Views.Balloon.Element.Edit extends Pettanr.Views.Balloon.Element
\r
44 initialize: (options) ->
\r
46 @listenTo(@element, 'input:system_picture_id', @input_r)
\r
47 @listenTo(@element, 'input:width', @resize)
\r
48 @listenTo(@element, 'input:height', @resize)
\r
52 sb = @speech_balloon
\r
54 this.$el.resizable {
\r
55 stop: (event, ui) ->
\r
57 speech_balloon_div = sb.$el
\r
59 resize_div.css('top', '0px')
\r
60 resize_div.css('left', '0px')
\r
61 resize_div.css('z-index', 1)
\r
62 width = ui.size.width
\r
63 height = ui.size.height
\r
64 top = speech_balloon_div.position().top
\r
65 if ui.originalPosition.top != ui.position.top
\r
66 top += ui.position.top
\r
67 speech_balloon_div.css('top', top.toString() + 'px')
\r
68 speech_balloon_div.css('height', height + 'px')
\r
69 left = speech_balloon_div.position().left
\r
70 if ui.originalPosition.left != ui.position.left
\r
71 left += ui.position.left
\r
72 speech_balloon_div.css('left', left.toString() + 'px')
\r
73 speech_balloon_div.css('width', width + 'px')
\r
74 speech_balloon_div.css('width', width.toString() + 'px')
\r
75 speech_balloon_div.css('height', height.toString() + 'px')
\r
77 x: Math.floor(left),
\r
78 y: Math.floor(top),
\r
82 elm.trigger('resize')
\r
83 resize: (event, ui) ->
\r
85 speech_balloon_div = resize_div.parent()
\r
92 @system_picture = @element.system_picture()
\r
94 resize_div = this.$el.parent()
\r
95 resize_div.css('z-index', 1)
\r
98 resize_div = this.$el.parent()
\r
99 resize_div.css('width', '100%')
\r
100 resize_div.css('height', '100%')
\r
101 this.$el.css('width', '100%')
\r
102 this.$el.css('height', '100%')
\r