リビジョン | 9edc3731389bcae0de05ef6045cceb6b7581cc8f (tree) |
---|---|
日時 | 2015-10-13 07:05:35 |
作者 | ![]() |
コミッター | yasushiito |
fix: any
@@ -39,7 +39,7 @@ class Pettanr.Speech extends Peta.Element | ||
39 | 39 | |
40 | 40 | scenario: () -> |
41 | 41 | @boosts('read') |
42 | - @render(@escape('content')) | |
42 | + @render(Pettanr.to_s(@get('content'))) | |
43 | 43 | |
44 | 44 | plain_scenario: () -> |
45 | 45 | @escape('content') |
@@ -16,7 +16,7 @@ class Pettanr.Views.Scroll.PlayModule.FooterSwitch extends Pettanr.View | ||
16 | 16 | render: () -> |
17 | 17 | this.$el.html('') |
18 | 18 | attr = { |
19 | - style: Pettanr.to_style({height: Pettanr.to_s(@panel.get('height')) + 'px'}) | |
19 | + style: Pettanr.to_style({height: Pettanr.to_s(@height()) + 'px'}) | |
20 | 20 | } |
21 | 21 | this.$el.attr(attr) |
22 | 22 | face = if @visible |
@@ -28,6 +28,12 @@ class Pettanr.Views.Scroll.PlayModule.FooterSwitch extends Pettanr.View | ||
28 | 28 | this.$el.append(caption.render().el) if @enabled |
29 | 29 | this |
30 | 30 | |
31 | + height: () -> | |
32 | + if @panel | |
33 | + @panel.get('height') | |
34 | + else | |
35 | + 20 | |
36 | + | |
31 | 37 | click: () -> |
32 | 38 | return false if !@enabled |
33 | 39 | @visible = !@visible |
@@ -48,6 +54,7 @@ class Pettanr.Views.Scroll.PlayModule.Footer extends Pettanr.View | ||
48 | 54 | className: 'player-item-footer' |
49 | 55 | |
50 | 56 | initialize: (options) -> |
57 | + @parent = options.parent | |
51 | 58 | @scroll = options.scroll |
52 | 59 | @scroll_panel = options.scroll_panel |
53 | 60 | @panel = options.panel |
@@ -55,56 +62,63 @@ class Pettanr.Views.Scroll.PlayModule.Footer extends Pettanr.View | ||
55 | 62 | render: () -> |
56 | 63 | this.$el.html('') |
57 | 64 | @hide() |
58 | - @panel.get_parent('author', this, { | |
59 | - success: (@author) => | |
60 | - @panel_face_button = @panel.mini_face_button({ | |
61 | - context: this, | |
62 | - click: () -> | |
63 | - @trigger('click:panel') | |
64 | - }) | |
65 | - @author_face_button = @author.mini_face_button({ | |
66 | - context: this, | |
67 | - click: () -> | |
68 | - @trigger('click:author', @author) | |
69 | - }) | |
70 | - l1 = new Tag.H3({ | |
71 | - content: Pettanr.AppHelper.t_m('Panel') | |
72 | - }) | |
73 | - l2 = new Tag.H3({ | |
74 | - content: Pettanr.AppHelper.t_m('ScrollPanel') | |
75 | - }) | |
76 | - this.$el.append(l1.render().el) | |
77 | - this.$el.append(@panel_face_button.render().el) | |
78 | - this.$el.append(@author_face_button.render().el) | |
79 | - this.$el.append( | |
80 | - Pettanr.AppHelper.distance_of_time_in_words_to_now(@panel.get('updated_at')) | |
81 | - ) | |
82 | - this.$el.append(l2.render().el) | |
83 | - if @scroll.is_own() | |
84 | - @new_scroll_panel = new Pettanr.ScrollPanel() | |
85 | - @insert_button = new Pettanr.View.Button.ItemAction(@new_scroll_panel, 'new', 'scroll_panels.player.before_insert', { | |
65 | + if @panel | |
66 | + @panel.get_parent('author', this, { | |
67 | + success: (@author) => | |
68 | + @panel_face_button = @panel.mini_face_button({ | |
86 | 69 | context: this, |
87 | 70 | click: () -> |
88 | - @trigger('click:insert') | |
71 | + @trigger('click:panel') | |
89 | 72 | }) |
90 | - @move_button = new Pettanr.View.Button.ItemAction(@scroll_panel, 'edit', 'scroll_panels.player.move', { | |
73 | + @author_face_button = @author.mini_face_button({ | |
91 | 74 | context: this, |
92 | 75 | click: () -> |
93 | - @trigger('click:move') | |
76 | + @trigger('click:author', @author) | |
94 | 77 | }) |
95 | - @destroy_button = new Pettanr.View.Button.ItemAction(@scroll_panel, 'destroy', 'scroll_panels.player.destroy', { | |
96 | - context: this, | |
97 | - click: () -> | |
98 | - @trigger('click:destroy') | |
78 | + l1 = new Tag.H3({ | |
79 | + content: Pettanr.AppHelper.t_m('Panel') | |
99 | 80 | }) |
100 | - this.$el.append(@insert_button.render().el) | |
101 | - @append_rb() | |
102 | - this.$el.append(@move_button.render().el) | |
103 | - @append_rb() | |
104 | - this.$el.append(@destroy_button.render().el) | |
105 | - }) | |
81 | + this.$el.append(l1.render().el) | |
82 | + this.$el.append(@panel_face_button.render().el) | |
83 | + this.$el.append(@author_face_button.render().el) | |
84 | + this.$el.append( | |
85 | + Pettanr.AppHelper.distance_of_time_in_words_to_now(@panel.get('updated_at')) | |
86 | + ) | |
87 | + @append_scroll_panel() | |
88 | + }) | |
89 | + else | |
90 | + @append_scroll_panel() | |
106 | 91 | this |
107 | 92 | |
93 | + append_scroll_panel: () -> | |
94 | + l2 = new Tag.H3({ | |
95 | + content: Pettanr.AppHelper.t_m('ScrollPanel') | |
96 | + }) | |
97 | + this.$el.append(l2.render().el) | |
98 | + if @scroll.is_own() | |
99 | + @new_scroll_panel = new Pettanr.ScrollPanel() | |
100 | + @insert_button = new Pettanr.View.Button.ItemAction(@new_scroll_panel, 'new', 'scroll_panels.player.before_insert', { | |
101 | + context: this, | |
102 | + click: () -> | |
103 | + @trigger('click:insert') | |
104 | + }) | |
105 | + @move_button = new Pettanr.View.Button.ItemAction(@scroll_panel, 'edit', 'scroll_panels.player.move', { | |
106 | + context: this, | |
107 | + click: () -> | |
108 | + @trigger('click:move') | |
109 | + }) | |
110 | + @destroy_button = new Pettanr.View.Button.ItemAction(@scroll_panel, 'destroy', 'scroll_panels.player.destroy', { | |
111 | + context: this, | |
112 | + click: () -> | |
113 | + @trigger('click:destroy') | |
114 | + }) | |
115 | + this.$el.append(@insert_button.render().el) | |
116 | + @append_rb() | |
117 | + if @is_movable() | |
118 | + this.$el.append(@move_button.render().el) | |
119 | + @append_rb() | |
120 | + this.$el.append(@destroy_button.render().el) | |
121 | + | |
108 | 122 | hide: () -> |
109 | 123 | attr = { |
110 | 124 | style: Pettanr.to_style({display: 'none'}) |
@@ -117,6 +131,9 @@ class Pettanr.Views.Scroll.PlayModule.Footer extends Pettanr.View | ||
117 | 131 | } |
118 | 132 | this.$el.attr(attr) |
119 | 133 | |
134 | + is_movable: () -> | |
135 | + @parent.parent.views.length > 1 | |
136 | + | |
120 | 137 | class Pettanr.Views.Scroll.PlayModule.PanelBody extends Pettanr.View |
121 | 138 | tagName: 'div' |
122 | 139 | className: 'player-item-panel' |
@@ -130,22 +147,36 @@ class Pettanr.Views.Scroll.PlayModule.PanelBody extends Pettanr.View | ||
130 | 147 | panel: @panel, |
131 | 148 | spot: null |
132 | 149 | }) |
150 | + @listenTo(body, 'http_get', @http_get) | |
133 | 151 | this.$el.append(body.render().el) |
134 | 152 | this |
135 | 153 | |
154 | + http_get: (url) -> | |
155 | + @trigger('http_get', url) | |
156 | + | |
136 | 157 | class Pettanr.Views.Scroll.PlayModule.Panel extends Pettanr.View |
137 | 158 | tagName: 'li' |
138 | 159 | className: 'player-item' |
139 | 160 | |
140 | 161 | initialize: (options) -> |
162 | + @parent = options.parent | |
141 | 163 | @scroll = options.scroll |
142 | 164 | @scroll_panel = options.scroll_panel |
165 | + @panel = options.panel | |
143 | 166 | |
144 | 167 | clear: () -> |
145 | 168 | this.$el.html('') |
146 | 169 | @scroll_panel.get_parent('panel', this, { |
147 | 170 | success: (@panel) => |
171 | + @trigger('exist', this) | |
148 | 172 | @render() |
173 | + fail: (response, opt) => | |
174 | + @panel = null | |
175 | + @append_insert_point() | |
176 | + this.$el.append('Not found') | |
177 | + @append_footer_switch() | |
178 | + @append_footer() | |
179 | + @trigger('lost', response, opt) | |
149 | 180 | }) |
150 | 181 | this |
151 | 182 |
@@ -155,44 +186,56 @@ class Pettanr.Views.Scroll.PlayModule.Panel extends Pettanr.View | ||
155 | 186 | @panel.fetch({ |
156 | 187 | success: (model, response, opt) => |
157 | 188 | @panel.attributes = @panel.decoded_attributes() |
189 | + @append_insert_point() | |
158 | 190 | body = new Pettanr.Views.Scroll.PlayModule.PanelBody({ |
159 | 191 | panel: @panel |
160 | 192 | }) |
161 | - @footer_switch = new Pettanr.Views.Scroll.PlayModule.FooterSwitch({ | |
162 | - scroll_panel: @scroll_panel, | |
163 | - panel: @panel | |
164 | - }) | |
165 | - @listenTo(@footer_switch, 'click', @click_footer_switch) | |
166 | - move_to = new Tag.A({ | |
167 | - attr: {href: '/' + @scroll_panel.edit_url()}, | |
168 | - content: I18n.t('scroll_panels.player.move_to') | |
169 | - }) | |
170 | - @insert_point = new Pettanr.Views.Scroll.PlayModule.InsertPoint({ | |
171 | - class_name: 'insert-point', content: move_to.render().el | |
172 | - }) | |
173 | - @footer = new Pettanr.Views.Scroll.PlayModule.Footer({ | |
174 | - scroll: @scroll, | |
175 | - scroll_panel: @scroll_panel, | |
176 | - panel: @panel, | |
177 | - }) | |
178 | - @listenTo(move_to, 'click', @click_move_to) | |
179 | - @listenTo(@footer, 'click:panel', @click_show) | |
180 | - @listenTo(@footer, 'click:author', @click_author) | |
181 | - @listenTo(@footer, 'click:insert', @click_insert) | |
182 | - @listenTo(@footer, 'click:move', @click_move) | |
183 | - @listenTo(@footer, 'click:edit', @click_edit) | |
184 | - @listenTo(@footer, 'click:destroy', @click_destroy) | |
185 | - this.$el.append(@insert_point.clear().el) | |
186 | - @append_rb() | |
193 | + @listenTo(body, 'http_get', @http_get) | |
187 | 194 | this.$el.append(body.render().el) |
188 | - this.$el.append(@footer_switch.render().el) | |
189 | - this.$el.append(@footer.render().el) | |
195 | + @append_footer_switch() | |
196 | + @append_footer() | |
190 | 197 | @trigger('ready', @panel) |
191 | 198 | error: (item, response, opt) => |
192 | 199 | @open_error_dialog(response, opt) |
193 | 200 | }) |
194 | 201 | this |
195 | 202 | |
203 | + append_insert_point: () -> | |
204 | + move_to = new Tag.A({ | |
205 | + attr: {href: '/' + @scroll_panel.edit_url()}, | |
206 | + content: I18n.t('scroll_panels.player.move_to') | |
207 | + }) | |
208 | + @insert_point = new Pettanr.Views.Scroll.PlayModule.InsertPoint({ | |
209 | + class_name: 'insert-point', content: move_to.render().el | |
210 | + }) | |
211 | + @listenTo(move_to, 'click', @click_move_to) | |
212 | + this.$el.append(@insert_point.clear().el) | |
213 | + @append_rb() | |
214 | + | |
215 | + append_footer_switch: () -> | |
216 | + @footer_switch = new Pettanr.Views.Scroll.PlayModule.FooterSwitch({ | |
217 | + parent: this, | |
218 | + scroll_panel: @scroll_panel, | |
219 | + panel: @panel | |
220 | + }) | |
221 | + @listenTo(@footer_switch, 'click', @click_footer_switch) | |
222 | + this.$el.append(@footer_switch.render().el) | |
223 | + | |
224 | + append_footer: () -> | |
225 | + @footer = new Pettanr.Views.Scroll.PlayModule.Footer({ | |
226 | + parent: this, | |
227 | + scroll: @scroll, | |
228 | + scroll_panel: @scroll_panel, | |
229 | + panel: @panel, | |
230 | + }) | |
231 | + @listenTo(@footer, 'click:panel', @click_show) | |
232 | + @listenTo(@footer, 'click:author', @click_author) | |
233 | + @listenTo(@footer, 'click:insert', @click_insert) | |
234 | + @listenTo(@footer, 'click:move', @click_move) | |
235 | + @listenTo(@footer, 'click:edit', @click_edit) | |
236 | + @listenTo(@footer, 'click:destroy', @click_destroy) | |
237 | + this.$el.append(@footer.render().el) | |
238 | + | |
196 | 239 | hide: () -> |
197 | 240 | @set_style({display: 'none'}) |
198 | 241 |
@@ -240,6 +283,9 @@ class Pettanr.Views.Scroll.PlayModule.Panel extends Pettanr.View | ||
240 | 283 | click_move_to: () -> |
241 | 284 | @trigger('click:move_to', this) |
242 | 285 | |
286 | + http_get: (url) -> | |
287 | + @trigger('http_get', url) | |
288 | + | |
243 | 289 | class Pettanr.Views.Scroll.PlayModule.InsertPoint extends Tag.Div |
244 | 290 | |
245 | 291 | clear: () -> |
@@ -306,22 +352,28 @@ class Pettanr.Views.Scroll.PlayModule.Panels extends Pettanr.View | ||
306 | 352 | append_scroll_panel: (scroll_panel) -> |
307 | 353 | return if not scroll_panel.has_panel() |
308 | 354 | panel_view = @create_panel_view(scroll_panel) |
355 | + @views.push(panel_view) | |
309 | 356 | this.$el.append(panel_view.clear().el) |
310 | 357 | @refresh_empty_notice() |
311 | 358 | |
312 | 359 | create_panel_view: (scroll_panel) -> |
313 | 360 | panel_view = new Pettanr.Views.Scroll.PlayModule.Panel({ |
314 | - scroll: @binder, scroll_panel: scroll_panel, | |
361 | + parent: this, scroll: @binder, scroll_panel: scroll_panel, | |
315 | 362 | }) |
363 | + @listenTo(panel_view, 'exist', @exist) | |
364 | + @listenTo(panel_view, 'lost', @lost) | |
316 | 365 | @listenTo(panel_view, 'ready', @ready) |
317 | 366 | @listenTo(panel_view, 'http_get', @http_get) |
318 | 367 | @listenTo(panel_view, 'click:insert', @click_insert) |
319 | 368 | @listenTo(panel_view, 'click:move', @click_move) |
320 | 369 | @listenTo(panel_view, 'click:destroy', @click_destroy) |
321 | 370 | @listenTo(panel_view, 'click:move_to', @click_move_to) |
322 | - @views.push(panel_view) | |
323 | 371 | panel_view |
324 | 372 | |
373 | + exist: (panel_view) -> | |
374 | + | |
375 | + lost: (response, opt) -> | |
376 | + | |
325 | 377 | ready: (panel) -> |
326 | 378 | this.credits.push(panel.licensed_pictures()) |
327 | 379 |
@@ -545,8 +597,6 @@ class Pettanr.Views.Scroll.PlayModule.Body extends Pettanr.View | ||
545 | 597 | if !@pager.hasNextPage() |
546 | 598 | @appender.enable() |
547 | 599 | this.$el.append(@pager.render().el) |
548 | - this.$el.append(credits.render().el) | |
549 | - @append_rb() | |
550 | 600 | true |
551 | 601 | |
552 | 602 | click_credit_icon: (item) -> |
@@ -130,7 +130,7 @@ class PanelPicture < Peta::Element | ||
130 | 130 | if self.link =~ /\:\/\// |
131 | 131 | self.link |
132 | 132 | else |
133 | - '/' + self.link | |
133 | + '/' + self.link.to_s | |
134 | 134 | end |
135 | 135 | end |
136 | 136 |