1 class Pettanr.Views.SpeechBalloon.NewElementLauncher extends Editor.EditorModule.DockModule.NewElementLauncher
\r
3 initialize: (options) ->
\r
6 _.extend(@links_conf, {
\r
10 controller: @model.pick_model().path_name(), action: 'index',
\r
11 page_size: 6, format: 'html'
\r
15 _.extend(@links_conf, {
\r
17 caption: "Inspire recent item",
\r
19 controller: @model.path_name(), action: 'index',
\r
20 page_size: 6, format: 'html'
\r
24 if Pettanr.cache.operators.author
\r
25 _.extend(@links_conf, {
\r
26 inspire_my_recent: {
\r
27 caption: 'Inspire my recent item',
\r
29 controller: @model.path_name(), action: 'by_author', id: Pettanr.cache.operators.author.get('id'),
\r
30 page_size: 6, format: 'html'
\r
40 click_template: () ->
\r
41 @click_default(@links_conf.template.params)
\r
43 click_inspire_recent: () ->
\r
44 @click_default(@links_conf.inspire_recent.params)
\r
46 click_inspire_my_recent: () ->
\r
47 @click_default(@links_conf.inspire_my_recent.params)
\r
49 class Pettanr.Views.SpeechBalloon.NewElement extends Pettanr.View
\r
51 initialize: (options) ->
\r
52 @parent = options.parent
\r
53 @target_model = options.target_model
\r
54 @pick_model = @target_model.pick_model()
\r
56 start: (@dialog, params) ->
\r
57 @dialog.start(@target_model, params, null)
\r
58 @listenTo(@dialog, 'pick', @pick)
\r
59 @trigger('dialog:open', @dialog)
\r
62 if item.item_name() == @target_model.item_name()
\r
64 @listenTo(this, 'ready', @ready)
\r
65 item.get_child('balloon', this, {
\r
66 success: (balloon) =>
\r
67 item.get_child('speech', this, {
\r
68 success: (speech) =>
\r
69 new_item = new @target_model(item.attributes)
\r
70 new_item.unset('id', {silent: true})
\r
71 new_item.set({panel_id: @editor().item.get('id')}, {silent: true})
\r
72 new_balloon = balloon.clone()
\r
73 new_balloon.unset('id', {silent: true})
\r
74 new_balloon.unset('speech_balloon_id', {silent: true})
\r
75 new_speech = speech.clone()
\r
76 new_speech.unset('id', {silent: true})
\r
77 new_speech.unset('speech_balloon_id', {silent: true})
\r
78 new_item.boosts 'post'
\r
79 new_balloon.boosts 'post'
\r
80 new_speech.boosts 'post'
\r
81 new_item.set({balloon: new_balloon, speech: new_speech}, {silent: true})
\r
82 @trigger('ready', new_item)
\r
85 else if @target_model.is_traceable(item.item_name())
\r
87 item.trace_to(item.my_class().pick_item_name(), this, {
\r
88 success: (pick_item) =>
\r
89 @dialog.http_get(pick_item.show_url())
\r
91 else if item.item_name() == @target_model.pick_item_name()
\r
93 @listenTo(this, 'ready', @ready)
\r
94 speech_balloon_template = item
\r
95 writing_format_list = Locmare.ListGroup.list(
\r
96 'writing_formats', 'index', {}
\r
98 writing_format_list.open(this, {
\r
99 success: (writing_formats) =>
\r
100 writing_format = writing_formats[0]
\r
102 speech_balloon_template: speech_balloon_template,
\r
103 writing_format: writing_format
\r
105 new_item = new @target_model()
\r
106 new_item.templates = templates
\r
107 new_item.set(new_item.pick(), {silent: true})
\r
108 new_item.boosts 'post'
\r
109 new_item.supply_default()
\r
111 balloon = new Pettanr.Balloon()
\r
112 balloon.templates = templates
\r
113 balloon.set(balloon.pick(), {silent: true})
\r
114 balloon.boosts 'post'
\r
115 balloon.supply_default()
\r
117 speech = new Pettanr.Speech()
\r
118 speech.templates = templates
\r
119 speech.set(speech.pick(), {silent: true})
\r
120 speech.boosts 'post'
\r
121 speech.supply_default()
\r
123 new_item.set({balloon: balloon, speech: speech}, {silent: true})
\r
124 @trigger('ready', new_item)
\r
127 ready: (new_item) ->
\r
129 @trigger('pick', new_item)
\r