I'm trying to make the jump to a more OOP style javascript approach, but I have just not gotten it right in javascript.
Take the following function as an example.
function positionalCSS(array, cs, lcs){
/* Define css for circle based on number of circles */
//Count array
var arrCount = array.length;
var T = [];
var L = [];
if(arrCount == 3){
T[0] ='15px';
L[0] = '240px';
T[1] = '345px';
L[1] = '440px';
T[2] = '345px';
L[2] = '40px';
}
if(arrCount == 4){
T[0] ='-135px';
L[0] = '90px';
T[1] = '-10px';
L[1] = '290px';
T[2] = '220px';
L[2] = '270px';
T[3] = '315px';
L[3] = '90px';
}
if(arrCount == 6){
T[0] ='-135px';
L[0] = '90px';
T[1] = '-10px';
L[1] = '290px';
T[2] = '220px';
L[2] = '270px';
T[3] = '315px';
L[3] = '90px';
T[4] = '210px';
L[4] = '-100px';
T[5] = '-10px';
L[5] = '-110px';
}
$.each(array, function(i) {
var num = parseInt(i);
// console.log('$("' + lcs + ' ' + cs + '.handle-' + num + '").first().children("div");');
$(lcs + ' ' + cs + '.handle-' + num).first().children('div').css({
'position': 'absolute',
'top': T[num],
'left': L[num]
});
});
}
It's pretty horrendous, I want to pass in an array, and depending on how many there are, organise the positions of the items based on this. SO I guess based on its size I would give it some properties? Where each TL represents a Top and Left position of an object?