Change file tree when changing submission
This commit is contained in:
@@ -3,13 +3,16 @@ $(function() {
|
|||||||
var ACE_FILES_PATH = '/assets/ace/';
|
var ACE_FILES_PATH = '/assets/ace/';
|
||||||
var THEME = 'ace/theme/textmate';
|
var THEME = 'ace/theme/textmate';
|
||||||
|
|
||||||
|
var currentSubmission = 0;
|
||||||
var active_file = undefined;
|
var active_file = undefined;
|
||||||
|
var fileTrees = []
|
||||||
|
|
||||||
var showFirstFile = function() {
|
var showFirstFile = function() {
|
||||||
var frame = $('.frame[data-role="main_file"]').isPresent() ? $('.frame[data-role="main_file"]') : $('.frame').first();
|
var frame = $('.frame[data-role="main_file"]').isPresent() ? $('.frame[data-role="main_file"]') : $('.frame').first();
|
||||||
var file_id = frame.find('.editor').data('file-id');
|
var file_id = frame.find('.editor').data('file-id');
|
||||||
$('#files').jstree().select_node(file_id);
|
$(fileTrees[currentSubmission]).jstree().select_node(file_id);
|
||||||
showFrame(frame);
|
showFrame(frame);
|
||||||
|
showFileTree(currentSubmission);
|
||||||
};
|
};
|
||||||
|
|
||||||
var showFrame = function(frame) {
|
var showFrame = function(frame) {
|
||||||
@@ -18,8 +21,9 @@ $(function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var initializeFileTree = function() {
|
var initializeFileTree = function() {
|
||||||
$('#files').jstree($('#files').data('entries'));
|
$('.files').each(function(index, element) {
|
||||||
$('#files').on('click', 'li.jstree-leaf', function() {
|
fileTree = $(element).jstree($(element).data('entries'));
|
||||||
|
fileTree.on('click', 'li.jstree-leaf', function() {
|
||||||
active_file = {
|
active_file = {
|
||||||
filename: $(this).text(),
|
filename: $(this).text(),
|
||||||
id: parseInt($(this).attr('id'))
|
id: parseInt($(this).attr('id'))
|
||||||
@@ -27,8 +31,15 @@ $(function() {
|
|||||||
var frame = $('[data-file-id="' + active_file.id + '"]').parent();
|
var frame = $('[data-file-id="' + active_file.id + '"]').parent();
|
||||||
showFrame(frame);
|
showFrame(frame);
|
||||||
});
|
});
|
||||||
|
fileTrees.push(fileTree);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var showFileTree = function(index) {
|
||||||
|
$('.files').hide();
|
||||||
|
$(fileTrees[index].context).show();
|
||||||
|
}
|
||||||
|
|
||||||
if ($.isController('exercises') && $('#timeline').isPresent()) {
|
if ($.isController('exercises') && $('#timeline').isPresent()) {
|
||||||
|
|
||||||
_.each(['modePath', 'themePath', 'workerPath'], function(attribute) {
|
_.each(['modePath', 'themePath', 'workerPath'], function(attribute) {
|
||||||
@@ -60,7 +71,8 @@ $(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
slider.on('change', function(event) {
|
slider.on('change', function(event) {
|
||||||
var currentSubmission = slider.val();
|
currentSubmission = slider.val();
|
||||||
|
showFileTree(currentSubmission);
|
||||||
var currentFiles = files[currentSubmission];
|
var currentFiles = files[currentSubmission];
|
||||||
|
|
||||||
editors.each(function(index, editor) {
|
editors.each(function(index, editor) {
|
||||||
|
Reference in New Issue
Block a user