db8d0c59303f8f189296fe7de18d8f7a0538208b
[fnpeditor.git] / src / editor / plugins / core / edumed / gaps / element.js
1 define(function(require) {
2     
3 'use strict';
4
5
6 var $ = require('libs/jquery'),
7     _ = require('libs/underscore'),
8     elementBase = require('plugins/core/edumed/elementBase'),
9     viewTemplate = require('libs/text!./view.html');
10
11 var OrderExerciceElement = Object.create(elementBase);
12 _.extend(OrderExerciceElement, {
13     init: function() {
14         elementBase.init.call(this);
15         var view  = $(_.template(viewTemplate)());
16         this._container().append(view);
17
18         this.createContainer(this.wlxmlNode.contents(), {
19             resetBackground: true,
20             manages: function() {
21                 return true;
22             },
23             dom: view.find('.content')
24         });
25
26         this.addToContextMenu('core.createGap');
27         this.contextMenuActions[0].on('actionExecuted', function(ret) {
28             if(ret instanceof this.wlxmlNode.document.Fragment && ret.isValid()) {
29                 this.canvas.select(ret);
30             }
31         }.bind(this));
32         this.addToContextMenu('core.removeGap');
33     },
34     getVerticallyFirstTextElement: function() {
35         // doesnt container handle this?
36         var toret;
37         this.containers.some(function(container) {
38             toret = container.getVerticallyFirstTextElement();
39             return !!toret;
40         });
41         return toret;
42     }
43 });
44
45 return {tag: 'div', klass: 'exercise.gap', prototype: OrderExerciceElement};
46
47 });
48
49
50     
51
52
53