Commit dae644a9 by Filippo Valsorda

Kill some Studio unused code

parent f6237815
......@@ -3,28 +3,7 @@ function DragAndDropEditBlock(runtime, element) {
var _fn = {
// DOM Elements
$block: $('.xblock--drag-and-drop', element),
$app: $('.xblock--drag-and-drop .drag-container', element),
$ul: $('.xblock--drag-and-drop .items', element),
$target: $('.xblock--drag-and-drop .target-img', element),
$feedback: $('.xblock--drag-and-drop .feedback .message', element),
// Cannot set until items added to DOM
$items: {}, // $('.xblock--drag-and-drop .items .option'),
$zones: {}, // $('.xblock--drag-and-drop .target .zone'),
// jQuery UI Draggable options
options: {
drag: {
containment: '.xblock--drag-and-drop .drag-container',
cursor: 'move',
stack: '.xblock--drag-and-drop .items .option'
},
drop: {
accept: '.xblock--drag-and-drop .items .option',
tolerance: 'pointer'
}
},
// item template
tpl: {
......@@ -455,176 +434,6 @@ function DragAndDropEditBlock(runtime, element) {
}
},
finish: function() {
// Disable any decoy items
_fn.$items.draggable('disable');
// Show final feedback
_fn.feedback.set(_fn.data.feedback.finish);
},
clickHandlers: {
init: function($drag, $dropzone) {
var clk = _fn.clickHandlers;
$drag.on('dragstart', clk.drag.start);
$drag.on('dragstop', clk.drag.stop);
$dropzone.on('drop', clk.drop.success);
$dropzone.on('dropover', clk.drop.hover.in);
$dropzone.on('dropout', clk.drop.hover.out);
},
drag: {
start: function(event, ui) {
$(event.currentTarget).removeClass('within-dropzone fade');
},
stop: function(event, ui) {
var $el = $(event.currentTarget),
val = $el.data('value'),
zone = $el.data('zone') || null;
if ($el.hasClass('within-dropzone') && _fn.test.match(val, zone)) {
$el.removeClass('hover')
.draggable('disable');
_fn.test.completed++;
_fn.feedback.popup(_fn.feedback.get(val, true), true);
if (_fn.items.allSubmitted()) {
_fn.finish();
}
} else {
// Return to original position
_fn.clickHandlers.drag.reset($el);
_fn.feedback.popup(_fn.feedback.get(val, false), false);
}
},
reset: function($el) {
$el.removeClass('within-dropzone fade hover')
.css({
top: '',
left: ''
});
}
},
drop: {
hover: {
in: function(event, ui) {
var zone = $(event.currentTarget).data('zone');
ui.draggable.addClass('hover').data('zone', zone);
},
out: function(event, ui) {
ui.draggable.removeClass('hover');
}
},
success: function(event, ui) {
ui.draggable.addClass('within-dropzone')
}
}
},
items: {
count: 0,
init: function() {
var items = _fn.data.items,
i,
len = items.length,
total = 0;
for (i=0; i<len; i++) {
if (items[i].zone !== 'none') {
total++;
}
}
_fn.items.count = total;
},
allSubmitted: function() {
return _fn.test.completed === _fn.items.count;
},
draw: function() {
var list = [],
items = _fn.data.items,
tpl = _fn.tpl.item(),
img_tpl = _fn.tpl.image_item();
_.each(items, function(item) {
if (item.backgroundImage.length > 0) {
list.push(_.template(img_tpl, item));
} else {
list.push(_.template(tpl, item));
}
});
// Update DOM
_fn.$ul.html(list.join(''));
// Set variable
_fn.$items = $('.xblock--drag-and-drop .items .option', element);
}
},
zones: {
draw: function() {
var html = [],
zones = _fn.data.zones,
tpl = _fn.tpl.zoneElement(),
i,
len = zones.length;
for (i=0; i<len; i++) {
html.push(_.template(tpl, zones[i]));
}
// Update DOM
_fn.$target.html(html.join(''));
// Set variable
_fn.$zones = _fn.$target.find('.zone');
}
},
test: {
completed: 0,
match: function(id, zone) {
var item = _.findWhere(_fn.data.items, { id: id });
return item.zone === zone;
}
},
feedback: {
// Returns string based on user's answer
get: function(id, boo) {
var item,
type = boo ? 'correct' : 'incorrect';
// Null loses its string-ness
if (id === null) {
id = 'null';
}
// Get object from data.items that matches val
item = _.findWhere(_fn.data.items, { id: id });
return item.feedback[type];
},
// Update DOM with feedback
set: function(str) {
return _fn.$feedback.html(str);
},
// Show a feedback popup
popup: function(str, boo) {
if (str === undefined || str === '') return;
return $("<div>").attr('title', boo ? 'Correct' : 'Error').text(str).dialog();
}
},
data: null
};
......
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