diff --git a/main/inc/lib/javascript/skills.js b/main/inc/lib/javascript/skills.js index 11b0d86c26..c62de3e199 100644 --- a/main/inc/lib/javascript/skills.js +++ b/main/inc/lib/javascript/skills.js @@ -34,7 +34,6 @@ var editEndpointOptions = { connector:"Straight" }; - //Student arrows // If user completed the skill @@ -70,18 +69,8 @@ function cleanclass(obj) { function open_parent(parent_id, id) { console.log("open_parent call : id " + id + " parent_id:" + parent_id); var numeric_parent_id = parent_id.split('_')[1]; - var numeric_id = id.split('_')[1]; - + var numeric_id = id.split('_')[1]; $('#'+id).css('top', '0px'); - - // @todo move this in a function - var final_left =0; - var normal_width = 0; - - $('.skill_child').each( function(){ - normal_width = $(this).width(); - return true; - }); load_parent(numeric_parent_id, numeric_id); } @@ -93,9 +82,9 @@ function open_parent(parent_id, id) { function open_block(id, load_user_data, create_root) { if (debug) console.log("open_block id : " + id+" load_user_data: " +load_user_data + ', create_root ' + create_root); - var numeric_id = id.split('_')[1]; + var numeric_id = id.split('_')[1]; - for (var i = 0; i < skills.length; i++) { + for (var i = 0; i < skills.length; i++) {ranc //Remove everything except parents if (jQuery.inArray(skills[i].element, parents) == -1) { //if (debug) console.log('deleting this skill '+ skills[i].element + " id: " + i); @@ -103,25 +92,7 @@ function open_block(id, load_user_data, create_root) { jsPlumb.removeAllEndpoints(skills[i].element); $("#"+skills[i].element).remove(); } - } - - /*/Modifying current block position - pos = $('#'+id).position(); - left_value = center_x; - - if (parents.length == 2) { - top_value = space_between_blocks_y + offset_y; - } else { - top_value = 100; - } - - jsPlumb.animate(id, { left: left_value, top:top_value }, { duration:duration_value }); - - //Modifying root block position - pos_parent = $('#'+parents[0]).position(); - jsPlumb.animate(parents[0], { left: center_x, top:offset_y }, { duration:duration_value }); - top_value = 2*space_between_blocks_y +offset_y ; */ - + } load_children(numeric_id, 0, load_user_data, create_root); } @@ -129,28 +100,29 @@ function load_children(my_id, top_value, load_user_data, create_root) { if (debug) console.log("load_children : my_id " + my_id + ", top_value:" + top_value +", load_user_data: "+load_user_data+", create_root: "+create_root); //Fix the block vertical position - //$('#block_'+my_id).css('top', '150px'); - my_top_root = 150; - my_top_children = 250; + my_top_children = 250; + + console.log('Loading root info by ajax '+my_id); + var skill = null; + $.ajax({ + async: false,//very important other wise it would not work + url: url+'&a=get_skill_info&id='+my_id, + success: function(json) { + skill = jQuery.parseJSON(json); + } + }); //Creating the root if (create_root == 1) { + //Loading children for the first time my_top_root = 0; my_top_children = 150; + if (my_id == 1) { $('#skill_tree').append('