var $ = require('libs/jquery'),
_ = require('libs/underscore'),
- documentElement = require('modules/documentCanvas/canvas/documentElement'),
+ elementBase = require('plugins/core/edumed/elementBase'),
template = require('libs/text!./element.html');
-var choiceBase = Object.create(documentElement.DocumentNodeElement.prototype);
+var choiceBase = Object.create(elementBase);
_.extend(choiceBase, {
init: function() {
- documentElement.DocumentNodeElement.prototype.init.call(this);
+ elementBase.init.call(this);
this.view = $(_.template(template)({type: this.type}));
this._container().append(this.view);
.btn {
line-height: 12px;
}
+}
+
+.edumed-exercise-remove {
+ position: absolute;
+ top: 20px;
+ right: 5px;
+ padding: 0 3px;
+ line-height: 15px;
}
\ No newline at end of file
--- /dev/null
+define(function(require) {
+
+'use strict';
+
+/* globals gettext */
+
+var $ = require('libs/jquery'),
+ _ = require('libs/underscore'),
+ documentElement = require('modules/documentCanvas/canvas/documentElement'),
+ Dialog = require('views/dialog/dialog');
+
+
+var choiceBase = Object.create(documentElement.DocumentNodeElement.prototype);
+_.extend(choiceBase, {
+ init: function() {
+ var el = this;
+ documentElement.DocumentNodeElement.prototype.init.call(this);
+ this.x = $('<div class="edumed-exercise-remove btn btn-mini btn-danger">x</div>');
+ this.x.on('click', function() {
+ var dialog = Dialog.create({
+ title: 'Removing exercise',
+ text: gettext('Do you really want to remove this exercise?'),
+ executeButtonText: gettext('Yes'),
+ cancelButtonText: gettext('No, don\'t do anything!')
+ });
+ dialog.on('execute', function(event) {
+ el.canvas.wlxmlDocument.transaction(function() {
+ el.wlxmlNode.detach();
+ }, {
+ metadata: {
+ description: gettext('Removing exercise')
+ },
+ success: function() {
+ event.success();
+ }
+ });
+ });
+ dialog.show();
+
+ });
+
+ this.addWidget(this.x);
+ },
+});
+
+return choiceBase;
+
+});
\ No newline at end of file
var $ = require('libs/jquery'),
_ = require('libs/underscore'),
- documentElement = require('modules/documentCanvas/canvas/documentElement'),
+ elementBase = require('plugins/core/edumed/elementBase'),
viewTemplate = require('libs/text!./view.html');
-var OrderExerciceElement = Object.create(documentElement.DocumentNodeElement.prototype);
+var OrderExerciceElement = Object.create(elementBase);
_.extend(OrderExerciceElement, {
init: function() {
- documentElement.DocumentNodeElement.prototype.init.call(this);
+ elementBase.init.call(this);
var view = $(_.template(viewTemplate)());
this._container().append(view);
var _ = require('libs/underscore');
-var documentElement = require('modules/documentCanvas/canvas/documentElement'),
+var elementBase = require('plugins/core/edumed/elementBase'),
OrderExerciseView = require('./view');
-var OrderExerciceElement = Object.create(documentElement.DocumentNodeElement.prototype);
+var OrderExerciceElement = Object.create(elementBase);
_.extend(OrderExerciceElement, {
init: function() {
- documentElement.DocumentNodeElement.prototype.init.call(this);
+ elementBase.init.call(this);
this.view = new OrderExerciseView(this, this.wlxmlNode);
this._container().append(this.view.dom);
var $ = require('libs/jquery'),
_ = require('libs/underscore'),
- documentElement = require('modules/documentCanvas/canvas/documentElement'),
+ elementBase = require('plugins/core/edumed/elementBase'),
genericElement = require('modules/documentCanvas/canvas/genericElement'),
viewTemplate = require('libs/text!./view.html'),
tipTemplate = require('libs/text!./tip.html');
}
});
-var ReplaceExerciseElement = Object.create(documentElement.DocumentNodeElement.prototype);
+var ReplaceExerciseElement = Object.create(elementBase);
_.extend(ReplaceExerciseElement, {
init: function() {
- documentElement.DocumentNodeElement.prototype.init.call(this);
+ elementBase.init.call(this);
var view = $(_.template(viewTemplate)());
this._container().append(view);