Skills: when clicking a skill element it load their parents and their children (blocks are not organized yet)

skala
Julio Montoya 13 years ago
parent 72f3dd93d6
commit 2a4293a36d
  1. 16
      main/inc/lib/javascript/skills.js
  2. 4
      main/template/default/skill/skill_tree.tpl

@ -88,17 +88,14 @@ function open_parent(parent_id, id) {
load_parent(numeric_parent_id, numeric_id); load_parent(numeric_parent_id, numeric_id);
} }
function open_block_student(id) { function open_block_student(id) {
open_block(id, 1) open_block(id, 1)
} }
/* /*
*
* When clicking a children block * When clicking a children block
@param string block id i.e "block_1" @param string block id i.e "block_1"
@param int load user data or not @param int load user data or not
*/ */
function open_block(id, load_user_data) { function open_block(id, load_user_data) {
if (debug) console.log("open_block id : " + id+" load_user_data: " +load_user_data); if (debug) console.log("open_block id : " + id+" load_user_data: " +load_user_data);
@ -261,17 +258,16 @@ function load_parent(parent_id, id) {
var json = jQuery.parseJSON(json); var json = jQuery.parseJSON(json);
$.each(json,function(i,item) { $.each(json,function(i,item) {
left_value = center_x + space_between_blocks_x * ix; /*left_value = center_x + space_between_blocks_x * ix;
top_value = offset_y; top_value = offset_y;*/
$('body').append('<div id="block_'+item.id+ '" class="open_block window " >'+item.name+'</div>'); $('body').append('<div id="block_'+item.id+ '" class="open_block skill_root first_window " >'+item.name+'</div>');
var es = prepare("block_" + item.id, editEndpoint);
var es2 = prepare("block_" + id, editEndpoint);
jsPlumb.connect({ jsPlumb.connect({
source: es, target:es2 source: 'block_'+parent_id, target:'block_'+id
}); });
jsPlumb.animate("block_" + item.id, { left: left_value, top : top_value }, { duration : duration_value});
//jsPlumb.animate("block_" + item.id, { left: left_value, top : top_value }, { duration : duration_value});
if (item.parent_id) { if (item.parent_id) {
if (debug) console.log('setting first_parent '+item.parent_id); if (debug) console.log('setting first_parent '+item.parent_id);

@ -173,11 +173,11 @@ jsPlumb.ready(function() {
} }
if ($(this).hasClass('first_window')) { if ($(this).hasClass('first_window')) {
console.log('first_window'); console.log('im in a first_window (root)');
//show the first_parent //show the first_parent
//if (first_parent != '') { //if (first_parent != '') {
parents = [first_parent, id]; parents = [first_parent, id];
// console.log(parents); console.log(parents);
open_parent(first_parent, id); open_parent(first_parent, id);
//} //}
} }

Loading…
Cancel
Save