f068de9bff292814ef132a75404b3d454cbc4fff
[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     documentElement = require('modules/documentCanvas/canvas/documentElement'),
9     viewTemplate = require('libs/text!./view.html');
10
11 var OrderExerciceElement = Object.create(documentElement.DocumentNodeElement.prototype);
12 _.extend(OrderExerciceElement, {
13     init: function() {
14         documentElement.DocumentNodeElement.prototype.init.call(this);
15         var view  = $(_.template(viewTemplate)());
16         this._container().append(view);
17
18         this.createContainer(this.wlxmlNode.contents(), {
19             manages: function() {
20                 return true;
21             },
22             dom: view.find('.content')
23         });
24
25         this.addToContextMenu('core.createGap');
26         this.contextMenuActions[0].on('actionExecuted', function(ret) {
27             if(ret instanceof this.wlxmlNode.document.Fragment && ret.isValid()) {
28                 this.canvas.select(ret);
29             }
30         }.bind(this));
31         this.addToContextMenu('core.removeGap');
32     },
33     getVerticallyFirstTextElement: function() {
34         // doesnt container handle this?
35         var toret;
36         this.containers.some(function(container) {
37             toret = container.getVerticallyFirstTextElement();
38             return !!toret;
39         });
40         return toret;
41     }
42 });
43
44 return {tag: 'div', klass: 'exercise.gap', prototype: OrderExerciceElement};
45
46 });
47
48
49     
50
51
52