');
child_group.append(children);
}
$(".child_list", children).append(part);
$("label", children).text(parseInt($("label", children).text())+1);
current_parent.data('recursive_children', get_children(current_parent,new Array()));
$(".child[name='"+current_parent.attr('id').replace("block_","")+"']").each(function(){
$this = $(this);
var grandchildren = parseInt($(".grandchildren", $this).text());
$(".grandchildren", $this).text(grandchildren + 1);
});
current_parent.activateChildren().alignChildIndicators();
}
}
$("input[name='concepts']", bF).each(function(){
var $this = $(this);
var $value = $this.siblings("input");
var insert = $('');
$("#conceptsContainer").find("li#"+$value.attr('name')).append(insert);
insert.aTOOLTIP({top:6, left:6});
});
// bF.wipe();
$line.data('last', $fresh);
$("#conceptsContainer a").hide();
// top =
column.scrollTo($fresh,500,{offset:-top});
$fresh.initiate().fokus().activate();
$fresh.removeClass('fresh',2000);
$(".block:not(.active)").each(function(){
$(this).activate();
});
count_columns();
count_blocks();
}
});
}
$.fn.wipe = function() {
bF = $(this);
bF.find(".temp").remove();
bF.find(".sliders li").remove();
$(":input:not([type='submit'], [name='csrfmiddlewaretoken'],#lineId,.relationId)", bF).val("");
}
$.fn.gradienceAdjustSlider = function() {
var $this = $(this);
if($this.closest(".gradiences").is(":visible")) {
var $line = $(".line");
var concept_id = $this.closest("li").data('concept');
var block_id = $this.closest(".block").attr('id').replace("block_","");
var val = parseFloat($this.find("input.value").val()) * 100;
var $index_concept = $("#conceptsContainer #concept_"+concept_id+" .dot[block='"+block_id+"']");
$this.slider({
value: val,
slide: function(e, ui){
val = ui.value/100;
$this.siblings("label").css('opacity',val+.2);
$this.find("input.value").val(val);
$index_concept.css('left',ui.value+"%");
},
change: function(e, ui){
$.ajax({
url: "/lines/gradiences/adjust/",
type: 'post',
dataType: 'json',
data: "block_id="+block_id+"&concept_id="+concept_id+"&value="+ui.value/100,
success: function(result){
var left = result.value * 100;
$index_concept.css('left',left+"%");
}
});
}
});
}
}
$.fn.authivate = function() {
var $t = $(this);
$line = $(".line");
$(".edit", $t).bind('mouseup', function(e){
e.stopPropagation();
});
$t.rejuvinate();
$(".editable.enabled").live('click',function(){
var $this = $(this);
});
$(".edit .grads", $t).bind('click', function(){
var $this = $(this);
if($this.hasClass('active')){
$this.removeClass('active');
$this.closest(".block").find(".gradiences").removeClass('open');
$("#conceptsContainer a.gradiencer").hide();
$("#conceptsContainer .edit a").show();
} else {
$(".menuItem[name=index]").tabTo();
$(".menuItem[name=concepts]").tabTo();
$("#conceptsContainer .edit a").hide();
$gradiences = $this.closest(".block").find(".gradiences");
$line.find(".gradiences.open").removeClass('open');
$line.find(".edit .grads").removeClass('active');
$this.addClass('active');
$gradiences.addClass('open').find(".slider").each(function(){
$(this).gradienceAdjustSlider();
});
$("#conceptsContainer li").each(function(){
var $c = $(this);
$("a.gradiencer",$c).hide();
if($gradiences.find(".cSlider_"+$c.data('id')).length > 0){
$c.find(".remove").show();
} else {
$c.find(".add").show();
}
});
}
});
$(".gradiences .slider", $t).each(function(){
// MOVED TO TOGGLE
// $(this).gradienceAdjustSlider();
});
$(".make_baby a", $t).bind('click',function(){
var $this = $(this);
var $block = $this.closest(".block");
var $line = $(".line");
$line.data('current_parent', $block);
var column_id = (!$this.closest(".column").next(".column").length) ? 0 : $this.closest(".column").next(".column").data('id');
$block.addClass('loading');
$.ajax({
url: '/lines/blocks/new/'+$line.data('id')+'/'+column_id+'/'+$block.data('id')+'/',
type: 'POST',
success: function(response){
if(response.error) {
alert(response.error);
} else {
var bF = $(response);
if(column_id == 0){
$line.data('width',parseFloat($line.data('width') + 35.2));
$line.css('width',$line.data('width') + 'em');
$("#scrollCover", $line).before($(response));
}
var $column = $block.closest(".column").next(".column");
if(column_id != 0){
$column.find(".block_list").append($(response));
}
bF = $("form",$column);
$block.fokus();
$(".block").deactivate();
bF.BFInit();
var pos = $block.offset();
var offset = (pos.top < 0) ? 24 : pos.top + 24;
var width = $block.width();
// bFC.find("textarea:visible").aWYSIWYG($line.data('WYSIWYG_options'));
// bFC.find("textarea:not(:visible)").data('aWYSIWYG').reload();
$column.scrollTo(bF,500,{offset:-offset});
$("#conceptsContainer .add").show();
$block.removeClass('loading');
}
}
});
return false;
});
$(".text", $t).bind('mouseup',function(){
var $line = $(".line");
if($line.hasClass('full-featured')) {
var selection = window.getSelection();
if(selection.toString().length > 0) {
var text = selection.toString();
var startNode = selection.startNode;
var endNode = selection.endNode;
var startOfs = selection.anchorOffset;
var endOfs = selection.focusOffset;
var $this = $(this);
var $block = $this.closest(".block");
var $column = $this.closest(".column")
var bF = $line.data('bF');
var bFC = $line.data('bFC');
var pos = $this.offset();
var offset = (pos.top < 0) ? 24 : pos.top + 24;
var width = $this.width();
// alert(startOfs + " : " + endOfs);
var range = window.getSelection().getRangeAt(0);
var newNode = document.createElement("section");
try {
range.surroundContents(newNode);
} catch(e) {
alert("\
Oups! \
\
It seems there was an error in creating the selection.\
\
\
Our guess is that you selected text spanning across different styles (such as italic or bold, or across two paragraphs). Is that correct?\
\
\
→ If yes, then this is an issue we can't solve right now, unfortunately. Please select text of the same style, or make a selection around a certain styled passage. Alternatively, use the + in the top-right corner of the entry.\
\
\
→ If no - interesting! Please send us an email, and tell us more.\