Commit 92d83062 by Filippo Valsorda

Allow to set the items width and height

parent 53179a65
...@@ -284,6 +284,12 @@ ...@@ -284,6 +284,12 @@
margin-bottom: 20px; margin-bottom: 20px;
} }
.xblock--drag-and-drop .items-form .item-width,
.xblock--drag-and-drop .items-form .item-height {
width: 30px;
margin-right: 50px;
}
/** Buttons **/ /** Buttons **/
.xblock--drag-and-drop .btn { .xblock--drag-and-drop .btn {
......
...@@ -27,7 +27,14 @@ var dragAndDrop = (function() { ...@@ -27,7 +27,14 @@ var dragAndDrop = (function() {
// item template // item template
tpl: { tpl: {
item: '<li class="option" data-value="<%= id %>"><%= displayName %></li>', item: function() {
return [
'<li class="option" data-value="<%= id %>"',
'style="width: <%= size.width %>; height: <%= size.height %>">',
'<%= displayName %>',
'</li>'
].join('');
},
zoneInput: function() { zoneInput: function() {
return [ return [
'<div class="zone-row <%= name %>">', '<div class="zone-row <%= name %>">',
...@@ -81,6 +88,12 @@ var dragAndDrop = (function() { ...@@ -81,6 +88,12 @@ var dragAndDrop = (function() {
'<label>Error Feedback</label>', '<label>Error Feedback</label>',
'<textarea class="error-feedback"></textarea>', '<textarea class="error-feedback"></textarea>',
'</div>', '</div>',
'<div class="row">',
'<label>Width (px)</label>',
'<input type="text" class="item-width" value="190"></input>',
'<label>Height (px - 0 for auto)</label>',
'<input type="text" class="item-height" value="0"></input>',
'</div>',
'</div>' '</div>'
].join(''); ].join('');
} }
...@@ -396,6 +409,12 @@ var dragAndDrop = (function() { ...@@ -396,6 +409,12 @@ var dragAndDrop = (function() {
name = $el.find('.item-text').val(); name = $el.find('.item-text').val();
if (name.length > 0) { if (name.length > 0) {
var width = $el.find('.item-width').val() + 'px',
height = $el.find('.item-height').val();
if (height === '0') height = 'auto';
else height = height + 'px';
items.push({ items.push({
displayName: name, displayName: name,
zone: $el.find('.zone-select').val(), zone: $el.find('.zone-select').val(),
...@@ -403,6 +422,10 @@ var dragAndDrop = (function() { ...@@ -403,6 +422,10 @@ var dragAndDrop = (function() {
feedback: { feedback: {
correct: $el.find('.success-feedback').val(), correct: $el.find('.success-feedback').val(),
incorrect: $el.find('.error-feedback').val() incorrect: $el.find('.error-feedback').val()
},
size: {
width: width,
height: height
} }
}); });
} }
...@@ -522,7 +545,7 @@ var dragAndDrop = (function() { ...@@ -522,7 +545,7 @@ var dragAndDrop = (function() {
draw: function() { draw: function() {
var list = [], var list = [],
items = _fn.data.items, items = _fn.data.items,
tpl = _fn.tpl.item; tpl = _fn.tpl.item();
_.each(items, function(item) { _.each(items, function(item) {
list.push( _.template( tpl, item ) ); list.push( _.template( tpl, item ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment