More skill fixes

skala
Julio Montoya 14 years ago
parent 4768cc9d40
commit fb3ec5d61b
  1. 30
      main/inc/lib/javascript/skills.js
  2. 28
      main/template/default/skill/skill_tree.tpl
  3. 73
      main/template/default/skill/skill_tree_student.tpl

@ -1,6 +1,27 @@
/* For licensing terms, see /license.txt */
var debug = 1;
var skills = []; //current window divs
var parents = []; //list of parents normally there should be only 2
var first_parent = '';
var duration_value = 500;
//Setting the parent by default
var parents = ['block_1'];
function clean_values() {
skills = []; //current window divs
parents = ['block_1'];
first_parent = '';
//Reseting jsplumb
jsPlumb.reset();
//Deletes all windows
$('.skill_root').remove();
$('.skill_child').remove();
open_block('block_1', 0, 1);
}
//Admin/normal arrows
var editEndpointOptions = {
@ -60,17 +81,10 @@ function open_parent(parent_id, id) {
$('.skill_child').each( function(){
normal_width = $(this).width();
return true;
});
});
load_parent(numeric_parent_id, numeric_id);
}
function open_block_student(id) {
open_block(id, 1)
}
/*
* When clicking a children block
@param string block id i.e "block_1"

@ -19,13 +19,8 @@ body {
</style>
<script type="text/javascript">
//js settings
//js settings (see the skills.js for more)
var url = '{{url}}';
var skills = []; //current window divs
var parents = []; //list of parents normally there should be only 2
var first_parent = '';
var duration_value = 500;
//Block settings see the SkillVisualizer Class
var offset_x = {{skill_visualizer.offset_x}};
@ -35,24 +30,6 @@ var space_between_blocks_y = {{skill_visualizer.space_between_blocks_y}};
var center_x = {{skill_visualizer.center_x}};
var block_size = {{skill_visualizer.block_size}};
//Setting the parent by default
var parents = ['block_1'];
function clean_values() {
skills = []; //current window divs
parents = ['block_1'];
first_parent = '';
//Reseting jsplumb
jsPlumb.reset();
//Deletes all windows
$('.skill_root').remove();
$('.skill_child').remove();
open_block('block_1', 0, 1);
}
$(window).resize(function() {
jsPlumb.repaintEverything();
/*jsPlumb.repaint(".skill_root");
@ -342,8 +319,7 @@ jsPlumb.ready(function() {
resetRenderMode(jsPlumb.CANVAS);
});
;(function() {
;(function() {
prepare = function(div, endpointOptions) {
console.log('preparing = '+div);
console.log('endpointOptions = '+endpointOptions);

@ -21,11 +21,6 @@ body {
//js settings
var url = '{{url}}';
var skills = []; //current window divs
var parents = []; //list of parents normally there should be only 2
var hidden_parent = '';
var duration_value = 500;
//Block settings see the SkillVisualizer Class
var offset_x = {{skill_visualizer.offset_x}};
@ -35,9 +30,6 @@ var space_between_blocks_y = {{skill_visualizer.space_between_blocks_y}};
var center_x = {{skill_visualizer.center_x}};
var block_size = {{skill_visualizer.block_size}};
//Setting the parent by default
var parents = ['block_1'];
jsPlumb.bind("ready", function() {
//Open dialog
@ -48,66 +40,85 @@ jsPlumb.bind("ready", function() {
height : 350,
});
//On box click -(we use live instead of bind because we're creating divs on the fly )
$(".open_block").live('click', 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('click.open_block id: ' + id);
console.log('parents: ' + parents);
//if is root
if (parents[0] == id) {
parents = [id];
}
if (parents[1] != id) {
if (parents[1] != id) {
console.log('parents.length ' +parents.length);
//If there are 2 parents in the skill_tree
if (parents.length == 2 ) {
hidden_parent = parents[0];
first_parent = parents[0];
$('#'+parents[1]).css('top', '0px');
//console.log('deleting: '+parents[0]);
//removing father
for (var i = 0; i < skills.length; i++) {
if ( skills[i].element == parents[0] ) {
//console.log('deleting :'+ skills[i].element + ' here ');
jsPlumb.deleteEndpoint(skills[i].endp);
$("#"+skills[i].element).remove();
//skills.splice(i,1)
console.log("first_parent " + first_parent);
for (var i = 0; i < skills.length; i++) {
//console.log('looping '+skills[i].element + ' ');
if (skills[i].element == parents[0] ) {
console.log('deleting parent:'+ skills[i].element + ' here ');
jsPlumb.deleteEndpoint(skills[i].element);
jsPlumb.detachAllConnections(skills[i].element);
jsPlumb.removeAllEndpoints(skills[i].element);
$("#"+skills[i].element).remove();
}
}
parents.splice(0,1);
parents.push(id);
console.log('parents after slice/push: ' + parents);
}
if ($(this).hasClass('first_window')) {
//show the hidden_parent
//if (hidden_parent != '') {
parents = [hidden_parent, id];
// console.log(parents);
open_parent(hidden_parent, id);
if ($(this).hasClass('first_window')) {
console.log('im in a first_window (root)');
$('#'+first_parent).css('top', '0px');
//show the first_parent
//if (first_parent != '') {
parents = [first_parent, id];
open_parent(first_parent, id);
//}
}
if (jQuery.inArray(id, parents) == -1) {
parents.push(id);
console.log('parents push: ' + parents);
}
open_block_student(id);
open_block(id, 0, 0);
}
//Setting class
cleanclass($(this));
$(this).addClass('second_window');
cleanclass($(this));
$(this).addClass('second_window');
parent_div = $("#"+parents[0]);
cleanclass(parent_div);
parent_div.addClass('first_window');
parent_div.addClass('skill_root');
parent_div = $("#"+parents[1]);
cleanclass(parent_div);
parent_div.addClass('second_window');
console.log(parents);
//console.log(parents);
// console.log(skills);
console.log('hidden_parent : ' + hidden_parent);
console.log('first_parent : ' + first_parent);
//redraw
jsPlumb.repaintEverything();
jsPlumb.repaint(id);
});
$(".edit_block").live('click',function() {
var my_id = $(this).attr('id');
my_id = my_id.split('_')[2];

Loading…
Cancel
Save