1 define(function(require) {
5 var $ = require('libs/jquery'),
6 _ = require('libs/underscore'),
7 elementBase = require('plugins/core/edumed/elementBase'),
8 template = require('libs/text!./element.html');
11 var choiceBase = Object.create(elementBase);
12 _.extend(choiceBase, {
14 elementBase.init.call(this);
15 this.view = $(_.template(template)({type: this.type}));
16 this._container().append(this.view);
18 this.createContainer(this.wlxmlNode.contents().filter(function(n) {return !n.is('list');}), {
19 manages: function(node, removedFrom) {
20 if(node.is('list.orderable')) {
23 return this.wlxmlNode.sameNode(node.parent() || removedFrom);
25 dom: this.view.find('.description')
28 this.wlxmlNode.contents()
29 .filter(function(node) { return node.is('list'); })
30 .some(function(node) {
31 this.listView = this.createListView(node);
32 this.view.find('.list').append(this.listView.dom);
35 getVerticallyFirstTextElement: function() {
37 this.containers.some(function(container) {
38 toret = container.getVerticallyFirstTextElement();
43 onNodeAdded: function(event) {
44 var node = event.meta.node;
45 if(this.listView.listNode.sameNode(node.parent()) && node.is('item.answer')) {
46 this.listView.addItem(node);
49 onNodeDetached: function(event) {
50 var node = event.meta.node;
51 if(this.listView.listNode.sameNode(event.meta.parent) && node.is('item.answer')) {
52 this.listView.removeItem(node);