',
152 | ].join(''),
153 |
154 | initialize: function()
155 | {
156 |
157 |
158 | _.bindAll(this, 'updateBox');
159 | joint.shapes.devs.ModelView.prototype.initialize.apply(this, arguments);
160 |
161 | this.$box = $(_.template(this.template)());
162 | // Prevent paper from handling pointerdown.
163 | this.$box.find('input').on('mousedown click', function (evt) { evt.stopPropagation(); });
164 |
165 | // Prevent paper from handling pointerdown.
166 | this.$box.find('textarea').on('mousedown click', function (evt) { evt.stopPropagation(); });
167 |
168 |
169 | // This is an example of reacting on the input change and storing the input data in the cell model.
170 | this.$box.find('input.name').on('input', _.bind(function(evt)
171 | {
172 | this.model.set('name', $(evt.target).val());
173 | }, this));
174 |
175 | // This is an example of reacting on the input change and storing the input data in the cell model.
176 | this.$box.find('input.actor').on('input', _.bind(function (evt) {
177 | this.model.set('actor', $(evt.target).val());
178 | }, this));
179 |
180 |
181 | // This is an example of reacting on the input change and storing the input data in the cell model. TEXTAREA
182 | this.$box.find('textarea.name').on('input', _.bind(function (evt) {
183 | this.model.set('name', $(evt.target).val());
184 | }, this));
185 |
186 | this.$box.find('.delete').on('click', _.bind(this.model.remove, this.model));
187 | // Update the box position whenever the underlying model changes.
188 | this.model.on('change', this.updateBox, this);
189 | // Remove the box when the model gets removed from the graph.
190 | this.model.on('remove', this.removeBox, this);
191 |
192 | this.updateBox();
193 | },
194 |
195 | render: function()
196 | {
197 | joint.shapes.devs.ModelView.prototype.render.apply(this, arguments);
198 | this.paper.$el.prepend(this.$box);
199 | this.updateBox();
200 | return this;
201 | },
202 |
203 | updateBox: function()
204 | {
205 | // Set the position and dimension of the box so that it covers the JointJS element.
206 | var bbox = this.model.getBBox();
207 |
208 | // Example of updating the HTML with a data stored in the cell model.
209 | var nameField = this.$box.find('input.name');
210 | if (!nameField.is(':focus'))
211 | nameField.val(this.model.get('name'));
212 |
213 | // Example of updating the HTML with a data stored in the cell model.
214 | var actorField = this.$box.find('input.actor');
215 | if (!actorField.is(':focus'))
216 | actorField.val(this.model.get('actor'));
217 |
218 | // Example of updating the HTML with a data stored in the cell model.
219 | var textAreaField = this.$box.find('textarea.name');
220 | if (!textAreaField.is(':focus'))
221 | textAreaField.val(this.model.get('name'));
222 |
223 | var label = this.$box.find('.label');
224 | var type = this.model.get('type').slice('dialogue.'.length);
225 | label.text(type);
226 | label.attr('class', 'label ' + type);
227 | this.$box.css({ width: bbox.width, height: bbox.height, left: bbox.x, top: bbox.y, transform: 'rotate(' + (this.model.get('angle') || 0) + 'deg)' });
228 | },
229 |
230 | removeBox: function(evt)
231 | {
232 | this.$box.remove();
233 | },
234 | });
235 |
236 |
237 | joint.shapes.dialogue.ChoiceView = joint.shapes.devs.ModelView.extend(
238 | {
239 | template:
240 | [
241 | '
',
242 | '',
243 | '',
244 | '',
245 | '
',
246 | '
',
247 |
248 | ].join(''),
249 |
250 | initialize: function () {
251 |
252 |
253 | _.bindAll(this, 'updateBox');
254 | joint.shapes.devs.ModelView.prototype.initialize.apply(this, arguments);
255 |
256 | this.$box = $(_.template(this.template)());
257 | // Prevent paper from handling pointerdown.
258 | this.$box.find('textarea').on('mousedown click', function (evt) { evt.stopPropagation(); });
259 | this.$box.find('input').on('mousedown click', function (evt) { evt.stopPropagation(); });
260 | this.$box.find('idd').on('mousedown click', function (evt) { evt.stopPropagation(); });
261 |
262 | // This is an example of reacting on the input change and storing the input data in the cell model.
263 | this.$box.find('textarea.name').on('input', _.bind(function (evt) {
264 | this.model.set('name', $(evt.target).val());
265 | }, this));
266 |
267 | // This is an example of reacting on the input change and storing the input data in the cell model.
268 | this.$box.find('input.title').on('input', _.bind(function (evt) {
269 | this.model.set('title', $(evt.target).val());
270 | }, this));
271 |
272 | this.$box.find('.delete').on('click', _.bind(this.model.remove, this.model));
273 | // Update the box position whenever the underlying model changes.
274 | this.model.on('change', this.updateBox, this);
275 | // Remove the box when the model gets removed from the graph.
276 | this.model.on('remove', this.removeBox, this);
277 |
278 | this.updateBox();
279 | },
280 |
281 | render: function () {
282 | joint.shapes.devs.ModelView.prototype.render.apply(this, arguments);
283 | this.paper.$el.prepend(this.$box);
284 | this.updateBox();
285 | return this;
286 | },
287 |
288 | updateBox: function () {
289 | // Set the position and dimension of the box so that it covers the JointJS element.
290 | var bbox = this.model.getBBox();
291 | // Example of updating the HTML with a data stored in the cell model.
292 | var nameField = this.$box.find('textarea.name');
293 | if (!nameField.is(':focus'))
294 | nameField.val(this.model.get('name'));
295 |
296 | // Example of updating the HTML with a data stored in the cell model.
297 | var nameField = this.$box.find('input.title');
298 | if (!nameField.is(':focus'))
299 | nameField.val(this.model.get('title'));
300 |
301 |
302 | var label = this.$box.find('.label');
303 | var type = this.model.get('type').slice('dialogue.'.length);
304 | label.text(type);
305 | label.attr('class', 'label ' + type);
306 |
307 |
308 | this.$box.css({ width: bbox.width, height: bbox.height, left: bbox.x, top: bbox.y, transform: 'rotate(' + (this.model.get('angle') || 0) + 'deg)' });
309 | },
310 |
311 | removeBox: function (evt) {
312 | this.$box.remove();
313 | },
314 | });
315 |
316 |
317 | joint.shapes.dialogue.Node = joint.shapes.devs.Model.extend(
318 | {
319 | defaults: joint.util.deepSupplement
320 | (
321 | {
322 | type: 'dialogue.Node',
323 | inPorts: ['input'],
324 | outPorts: ['output'],
325 | attrs:
326 | {
327 | '.outPorts circle': { unlimitedConnections: ['dialogue.Choice'], }
328 | },
329 | },
330 | joint.shapes.dialogue.Base.prototype.defaults
331 | ),
332 | });
333 | joint.shapes.dialogue.NodeView = joint.shapes.dialogue.BaseView;
334 |
335 | joint.shapes.dialogue.Text = joint.shapes.devs.Model.extend(
336 | {
337 | defaults: joint.util.deepSupplement
338 | (
339 | {
340 | type: 'dialogue.Text',
341 | inPorts: ['input'],
342 | outPorts: ['output'],
343 | actor: '',
344 | textarea: 'Start writing',
345 | attrs:
346 | {
347 |
348 | '.outPorts circle': { unlimitedConnections: ['dialogue.Choice'], }
349 | },
350 | },
351 | joint.shapes.dialogue.Base.prototype.defaults
352 | ),
353 | });
354 | joint.shapes.dialogue.TextView = joint.shapes.dialogue.BaseView;
355 |
356 |
357 | joint.shapes.dialogue.Choice = joint.shapes.devs.Model.extend(
358 | {
359 | defaults: joint.util.deepSupplement
360 | (
361 | {
362 | size: { width: 250, height: 135 },
363 | type: 'dialogue.Choice',
364 | inPorts: ['input'],
365 | outPorts: ['output'],
366 | title: '',
367 | name: '',
368 | },
369 | joint.shapes.dialogue.Base.prototype.defaults
370 | ),
371 | });
372 | joint.shapes.dialogue.ChoiceView = joint.shapes.dialogue.ChoiceView;
373 |
374 |
375 | joint.shapes.dialogue.Branch = joint.shapes.devs.Model.extend(
376 | {
377 | defaults: joint.util.deepSupplement
378 | (
379 | {
380 | type: 'dialogue.Branch',
381 | size: { width: 200, height: 100, },
382 | inPorts: ['input'],
383 | outPorts: ['output0'],
384 | values: [],
385 | },
386 | joint.shapes.dialogue.Base.prototype.defaults
387 | ),
388 | });
389 | joint.shapes.dialogue.BranchView = joint.shapes.dialogue.BaseView.extend(
390 | {
391 | template:
392 | [
393 | '