1 class Pettanr.Views.Balloon.Element extends Backbone.View
\r
3 className: 'pettanr-balloon'
\r
5 initialize: (options) ->
\r
6 @element = options.element
\r
9 @speech_balloon = options.parent
\r
16 retriever = @element.system_picture()
\r
17 @listenTo(retriever, 'retrieve', @retrieve_system_picture)
\r
18 retriever.retrieve()
\r
20 retrieve_system_picture: (@system_picture) ->
\r
25 src: @system_picture.r_url(),
\r
26 alt: @element.get('caption'),
\r
27 style: Pettanr.to_style(@style())
\r
35 'z-index': 1 # play case
\r
38 add_element: (element) ->
\r
41 class Pettanr.Views.Balloon.Element.Edit extends Pettanr.Views.Balloon.Element
\r
43 initialize: (options) ->
\r
45 @listenTo(@element, 'input:system_picture_id', @input_r)
\r
46 @listenTo(@element, 'input:width', @resize)
\r
47 @listenTo(@element, 'input:height', @resize)
\r
49 retrieve_system_picture: (@system_picture) ->
\r
50 super(@system_picture)
\r
51 sb = @speech_balloon
\r
53 this.$el.resizable {
\r
54 stop: (event, ui) ->
\r
56 speech_balloon_div = sb.$el
\r
58 resize_div.css('top', '0px')
\r
59 resize_div.css('left', '0px')
\r
60 resize_div.css('z-index', 1)
\r
61 width = ui.size.width
\r
62 height = ui.size.height
\r
63 top = speech_balloon_div.position().top
\r
64 if ui.originalPosition.top != ui.position.top
\r
65 top += ui.position.top
\r
66 speech_balloon_div.css('top', top.toString() + 'px')
\r
67 speech_balloon_div.css('height', height + 'px')
\r
68 left = speech_balloon_div.position().left
\r
69 if ui.originalPosition.left != ui.position.left
\r
70 left += ui.position.left
\r
71 speech_balloon_div.css('left', left.toString() + 'px')
\r
72 speech_balloon_div.css('width', width + 'px')
\r
73 speech_balloon_div.css('width', width.toString() + 'px')
\r
74 speech_balloon_div.css('height', height.toString() + 'px')
\r
76 x: Math.floor(left),
\r
77 y: Math.floor(top),
\r
81 elm.trigger('resize')
\r
82 resize: (event, ui) ->
\r
84 speech_balloon_div = resize_div.parent()
\r
92 width: Pettanr.to_s(@element.get('width')) + 'px',
\r
93 height: Pettanr.to_s(@element.get('height')) + 'px',
\r
94 'z-index': 1 # play case
\r
99 resize_div = this.$el.parent()
\r
100 resize_div.css('z-index', 1)
\r
103 resize_div = this.$el.parent()
\r
104 resize_div.css('width', '100%')
\r
105 resize_div.css('height', '100%')
\r
106 this.$el.css('width', '100%')
\r
107 this.$el.css('height', '100%')
\r