Licitator 1.0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

109 lines
4.8 KiB

if ($('.content-wrapper .content .container').hasClass("exercise12n")){
//RECUPERAMOS EL ARRAY DE CUSTOMERS
$ex12customers = $("textarea[name='ex12n_customers[]']")
//RECUPERAMOS LAS TABS MENU
$ex12stage_tabs = $('#stage_tab > li');
//RECUPERAMOS LOS CONTENIDOS DE LAS TABS
$ex12stage_tab_content = $('#stage_tab_content > .tab-pane');
if($ex12customers.length>0){
//BORRAMOS LOS TABS MENU
$ex12stage_tabs.each(function( key, tabs ) {
if($ex12stage_tabs.lenght < 2){
tabs.remove()
}
});
// BORRAMOS LOS CONTENIDOS DE LAS TABS
$ex12stage_tab_content.each(function( key, tab_content ) {
if($ex12stage_tab_content.lenght < 2){
tab_content.remove()
}
});
}
//CONTADOR PARA SABER CUANTOS CUSTOMER DISTINTOS HAY
$numero_customers = 1;
if($ex12customers.length>0){
$customerAnterior = $ex12customers[0].value;
}else{
$customerAnterior = null;
}
$indexStage = 0;
$($ex12customers).each(function( $key, $customer ) {
if ($customer.value == $customerAnterior){
//si el stage es el 1 o más
if ($indexStage > 0){
//quitamos el active de la stage tab para dejar solo activa la 0
$($ex12stage_tabs[$key]).removeClass('active');
$($ex12stage_tab_content[$key]).removeClass('active');
}
//cambiamos el href y texto de la stage tab para que apunte al correcto
$($ex12stage_tabs[$key]).find('a').attr('href', '#stage' + $key);
// $($ex12stage_tabs[$key]).find('a').text('Stage' + ($indexStage+1));
$($ex12stage_tabs[$key]).find('a').text('Stage');
//cambiamos el id del contenido del stage para añadirle el numero
$ex12stage_tab_content[$key].id = 'stage' + $key;
//añadimos la stage tab
$('#' + $customer.value +' #stage_tab').append($ex12stage_tabs[$key]);
//añadimos el contenido del stage
$('#' + $customer.value +' #stage_tab_content').append($ex12stage_tab_content[$key]);
$indexStage = $indexStage + 1;
}else{
//reseteamos el indice del stage
$indexStage = 0;
//cambiamos el href y texto de la stage tab para que apunte al correcto
$($ex12stage_tabs[$key]).find('a').attr('href', '#stage' + $key);
// $($ex12stage_tabs[$key]).find('a').text('Stage' + ($indexStage+1));
$($ex12stage_tabs[$key]).find('a').text('Stage');
//cambiamos el id del contenido del stage para añadirle el numero
$ex12stage_tab_content[$key].id = 'stage' + $key;
//añadimos la stage tab
$('#' + $customer.value +' #stage_tab').append($ex12stage_tabs[$key]);
//añadimos el contenido del stage
$('#' + $customer.value +' #stage_tab_content').append($ex12stage_tab_content[$key]);
$indexStage = $indexStage + 1;
$numero_customers = $numero_customers + 1;
}
$customerAnterior = $customer.value;
});
$indexBorrar = 0;
if($ex12customers.length>0){
//BORRAMOS LAS PESTAÑAS QUE SOBREN DE LOS CUSTOMER
for (i=$numero_customers; i < $ex12customers.length; i++){
//console.log(i+'de'+$indexBorrar)
$('#wizard').steps('remove', i - $indexBorrar);
$indexBorrar = $indexBorrar + 1;
}
}
// updateWizard();
}