1 class Pettanr.Panel extends Peta.Root
\r
17 with_elements: () ->
\r
18 new Pettanr.Panel.WithElements({id: @get('id')})
\r
20 overwrite: (options) ->
\r
21 operators = Pettanr.cache.operators
\r
22 return false if not operators.author
\r
23 @set('author_id', operators.author.id)
\r
25 is_visible: (operators = Pettanr.cache.operators) ->
\r
26 switch super(operators)
\r
27 when null # super return
\r
32 return true if @isNew()
\r
35 overwrite: (options) ->
\r
36 @set('author_id', Pettanr.cache.operators.author.id)
\r
38 is_usable: (operators = Pettanr.cache.operators) ->
\r
39 @is_visible(operators)
\r
44 @licensed_pictures: (panels) ->
\r
46 _.each panels, (panel) ->
\r
47 _.extend r, panel.licensed_pictures()
\r
50 licensed_pictures: () ->
\r
52 _.each @scenario_elements(), (elm) ->
\r
53 return if not elm.my_class().has_picture()
\r
54 pid = elm.get('picture_id')
\r
55 r[pid] = true if not r[pid]
\r
58 label: (shorten_length) ->
\r
59 @_label('caption', shorten_length)
\r
62 new Pettanr.Panel.Play({id: @get('id')})
\r
65 i = new Pettanr.Panel.Edit({id: @get('id')})
\r
68 initialize: (attr = {}, options = {}) ->
\r
69 super(attr, options)
\r
72 class Pettanr.Panel.Play extends Pettanr.Panel
\r
75 @url = @default_url() + '?with_elements=true'
\r
78 class Pettanr.Panel.Edit extends Pettanr.Panel.Play
\r
82 @attributes = @decoded_attributes()
\r
83 @load_elements(options)
\r
86 @url = @default_url()
\r
87 method = if @isNew()
\r
92 xhr = @sync(method, this, {
\r
93 attrs: {panel: attrs},
\r
94 success: (model, response, options) =>
\r
95 _this.set(model, {silent: true})
\r
96 _this.trigger('save:success', _this, response)
\r
97 error: (model, response, options) =>
\r
98 _this.trigger('save:fail', _this, response)
\r
102 destroy: (options) ->
\r