[-] BO : fixed js global conflict for categories tree

This commit is contained in:
vAugagneur
2011-12-22 11:01:24 +00:00
parent 6050219528
commit 2fb24a6bbb
+11 -11
View File
@@ -29,7 +29,7 @@ var needCheckAll = false;
var needUncheckAll = false; var needUncheckAll = false;
var interval = null; var interval = null;
var intervalCheck = null; var intervalCheck = null;
var id = 0; var id_tree = 0;
var arrayCatToExpand = new Array(); var arrayCatToExpand = new Array();
function buildTreeView() function buildTreeView()
@@ -113,7 +113,7 @@ function setCategoryToExpand()
{ {
var ret = false; var ret = false;
id = 0; id_tree = 0;
arrayCatToExpand = new Array(); arrayCatToExpand = new Array();
$('#categories-treeview').find('li.expandable:visible').each(function() { $('#categories-treeview').find('li.expandable:visible').each(function() {
arrayCatToExpand.push($(this).attr('id')); arrayCatToExpand.push($(this).attr('id'));
@@ -145,7 +145,7 @@ function openCategory()
{ {
// Check readyToExpand in order to don't clearInterval if AJAX request is in progress // Check readyToExpand in order to don't clearInterval if AJAX request is in progress
// readyToExpand = category has been expanded, go to next ;) // readyToExpand = category has been expanded, go to next ;)
if (id >= arrayCatToExpand.length && readyToExpand) if (id_tree >= arrayCatToExpand.length && readyToExpand)
{ {
if (!setCategoryToExpand()) if (!setCategoryToExpand())
{ {
@@ -170,10 +170,10 @@ function openCategory()
if (readyToExpand) if (readyToExpand)
{ {
if ($('#categories-treeview').find('li#'+arrayCatToExpand[id]+'.hasChildren').length > 0) if ($('#categories-treeview').find('li#'+arrayCatToExpand[id_tree]+'.hasChildren').length > 0)
readyToExpand = false; readyToExpand = false;
$('#categories-treeview').find('li#'+arrayCatToExpand[id]+'.expandable:visible span.category_label').trigger('click'); $('#categories-treeview').find('li#'+arrayCatToExpand[id_tree]+'.expandable:visible span.category_label').trigger('click');
id++; id_tree++;
} }
} }
@@ -311,8 +311,7 @@ function getParentCategoriesIdAndOpen(id_category)
function openParentCategories() function openParentCategories()
{ {
intervalCheck = setInterval(checkCategory, 20); intervalCheck = setInterval(checkCategory, 20);
if (id_tree >= arrayCatToExpand.length && !readyToExpand)
if (id >= arrayCatToExpand.length && !readyToExpand)
{ {
clearInterval(interval); clearInterval(interval);
// delete interval value // delete interval value
@@ -322,10 +321,11 @@ function openParentCategories()
if (readyToExpand) if (readyToExpand)
{ {
if ($('li#'+arrayCatToExpand[id]+'.hasChildren').length > 0) if ($('li#'+arrayCatToExpand[id_tree]+'.hasChildren').length > 0)
readyToExpand = false; readyToExpand = false;
$('li#'+arrayCatToExpand[id]+'.expandable span').trigger('click');
id++; $('li#'+arrayCatToExpand[id_tree]+'.expandable span').trigger('click');
id_tree++;
} }
} }