When clicking in a skill element it loads the skill children

skala
Julio Montoya 13 years ago
parent 03c5ddfcb7
commit 72f3dd93d6
  1. 40
      main/inc/lib/javascript/skills.js
  2. 28
      main/template/default/skill/skill_tree.tpl

@ -145,18 +145,24 @@ function load_children(my_id, top_value, load_user_data) {
if (my_id == 1) {
$('#skill_tree').append('<div id="block_'+my_id+ '" class="skill_root first_window" >Root </div>');
$('#skill_tree').append('<div id="block_'+my_id+ '" class="skill_root first_window" >Root </div>');
// jsPlumb.animate('block_'+my_id, { left: 500, top:50 }, { duration: 100 });
var root_end_point_options = {
// anchor:"Continuous",
maxConnections:100,
endpoint:"Dot",
paintStyle:{ fillStyle:"gray" },
};
skills.push({
element: "block_" + my_id
});
// jsPlumb.animate('block_'+my_id, { left: 500, top:50 }, { duration: 100 });
var root_end_point_options = {
// anchor:"Continuous",
maxConnections:100,
endpoint:"Dot",
paintStyle:{ fillStyle:"gray" },
};
//The root is the source
//jsPlumb.makeSource("block_" + my_id, root_end_point_options);
@ -168,6 +174,7 @@ function load_children(my_id, top_value, load_user_data) {
top: '100px'
});*/
}
$.getJSON(url+'&a=load_children&load_user_data='+load_user_data+'&id='+my_id, {},
function(json) {
console.log('getJSON reponse: ' + json)
@ -218,8 +225,11 @@ function load_children(my_id, top_value, load_user_data) {
}, { duration : duration_value });
ix++; */
});
jsPlumb.draggable(jsPlumb.getSelector(".skill_child"));
jsPlumb.draggable(jsPlumb.getSelector(".skill_root"));
//jsPlumb.draggable(jsPlumb.getSelector(".skill_root"));
console.log('draggable');
//Creating the organigram
var sum=0;
@ -231,8 +241,10 @@ function load_children(my_id, top_value, load_user_data) {
q = $(this).css('margin-left').replace("px", "");
});
sum = sum / 2 - normal_weight/2 + q/2;
//console.log(sum);
console.log('Calculating: ' + sum);
jsPlumb.animate('block_'+my_id, { left: sum, top:0 }, { duration: 100 });
console.log('setting aniemate for block_'+my_id);
//$('#block_'+my_id).css('margin-bottom', "20px");
}
);
@ -262,10 +274,10 @@ function load_parent(parent_id, id) {
jsPlumb.animate("block_" + item.id, { left: left_value, top : top_value }, { duration : duration_value});
if (item.parent_id) {
if (debug) console.log('setting hidden_parent '+item.parent_id);
hidden_parent = "block_" + item.parent_id;
if (debug) console.log('setting first_parent '+item.parent_id);
first_parent = "block_" + item.parent_id;
} else {
if (debug) console.log('setting NO--- hidden_parent ');
if (debug) console.log('setting NO--- first_parent ');
}
ix++;
});

@ -23,7 +23,7 @@ body {
var url = '{{url}}';
var skills = []; //current window divs
var parents = []; //list of parents normally there should be only 2
var hidden_parent = '';
var first_parent = '';
var duration_value = 500;
@ -139,9 +139,9 @@ jsPlumb.ready(function() {
//Clicking in a box skill (we use live instead of bind because we're creating divs on the fly )
$(".open_block").live('click', function() {
var id = $(this).attr('id');
console.log('id :' + id);
console.log('parent');
console.log(parents);
console.log('click.open_block id: ' + id);
console.log('parents: ' + parents);
//if is root
if (parents[0] == id) {
@ -152,16 +152,16 @@ jsPlumb.ready(function() {
console.log('parents.length ' +parents.length);
if (parents.length == 2 ) {
hidden_parent = parents[0];
first_parent = parents[0];
//console.log('deleting: '+parents[0]);
//removing father
console.log("hidden_parent " + hidden_parent);
console.log("first_parent " + first_parent);
for (var i = 0; i < skills.length; i++) {
console.log('looping '+skills[i].element + ': ');
console.log('looping '+skills[i].element + ' ');
if (skills[i].element == parents[0] ) {
console.log('deleting parent:'+ skills[i].element + ' here ');
//jsPlumb.deleteEndpoint(skills[i].endp);
jsPlumb.deleteEndpoint(skills[i].element);
jsPlumb.detachAllConnections(skills[i].element);
jsPlumb.removeAllEndpoints(skills[i].element);
$("#"+skills[i].element).remove();
@ -169,19 +169,21 @@ jsPlumb.ready(function() {
}
parents.splice(0,1);
parents.push(id);
console.log('parents after slice/push: ' + parents);
}
if ($(this).hasClass('first_window')) {
console.log('first_window');
//show the hidden_parent
//if (hidden_parent != '') {
parents = [hidden_parent, id];
//show the first_parent
//if (first_parent != '') {
parents = [first_parent, id];
// console.log(parents);
open_parent(hidden_parent, id);
open_parent(first_parent, id);
//}
}
if (jQuery.inArray(id, parents) == -1) {
parents.push(id);
console.log('parents push' + parents);
}
open_block(id, 0);
}
@ -200,7 +202,7 @@ jsPlumb.ready(function() {
console.log(parents);
// console.log(skills);
console.log('hidden_parent : ' + hidden_parent);
console.log('first_parent : ' + first_parent);
});
//Skill title click

Loading…
Cancel
Save