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.

108 lines
4.8 KiB

5 years ago
  1. if ($('.content-wrapper .content .container').hasClass("exercise12n")){
  2. //RECUPERAMOS EL ARRAY DE CUSTOMERS
  3. $ex12customers = $("textarea[name='ex12n_customers[]']")
  4. //RECUPERAMOS LAS TABS MENU
  5. $ex12stage_tabs = $('#stage_tab > li');
  6. //RECUPERAMOS LOS CONTENIDOS DE LAS TABS
  7. $ex12stage_tab_content = $('#stage_tab_content > .tab-pane');
  8. if($ex12customers.length>0){
  9. //BORRAMOS LOS TABS MENU
  10. $ex12stage_tabs.each(function( key, tabs ) {
  11. if($ex12stage_tabs.lenght < 2){
  12. tabs.remove()
  13. }
  14. });
  15. // BORRAMOS LOS CONTENIDOS DE LAS TABS
  16. $ex12stage_tab_content.each(function( key, tab_content ) {
  17. if($ex12stage_tab_content.lenght < 2){
  18. tab_content.remove()
  19. }
  20. });
  21. }
  22. //CONTADOR PARA SABER CUANTOS CUSTOMER DISTINTOS HAY
  23. $numero_customers = 1;
  24. if($ex12customers.length>0){
  25. $customerAnterior = $ex12customers[0].value;
  26. }else{
  27. $customerAnterior = null;
  28. }
  29. $indexStage = 0;
  30. $($ex12customers).each(function( $key, $customer ) {
  31. if ($customer.value == $customerAnterior){
  32. //si el stage es el 1 o más
  33. if ($indexStage > 0){
  34. //quitamos el active de la stage tab para dejar solo activa la 0
  35. $($ex12stage_tabs[$key]).removeClass('active');
  36. $($ex12stage_tab_content[$key]).removeClass('active');
  37. }
  38. //cambiamos el href y texto de la stage tab para que apunte al correcto
  39. $($ex12stage_tabs[$key]).find('a').attr('href', '#stage' + $key);
  40. // $($ex12stage_tabs[$key]).find('a').text('Stage' + ($indexStage+1));
  41. $($ex12stage_tabs[$key]).find('a').text('Stage');
  42. //cambiamos el id del contenido del stage para añadirle el numero
  43. $ex12stage_tab_content[$key].id = 'stage' + $key;
  44. //añadimos la stage tab
  45. $('#' + $customer.value +' #stage_tab').append($ex12stage_tabs[$key]);
  46. //añadimos el contenido del stage
  47. $('#' + $customer.value +' #stage_tab_content').append($ex12stage_tab_content[$key]);
  48. $indexStage = $indexStage + 1;
  49. }else{
  50. //reseteamos el indice del stage
  51. $indexStage = 0;
  52. //cambiamos el href y texto de la stage tab para que apunte al correcto
  53. $($ex12stage_tabs[$key]).find('a').attr('href', '#stage' + $key);
  54. // $($ex12stage_tabs[$key]).find('a').text('Stage' + ($indexStage+1));
  55. $($ex12stage_tabs[$key]).find('a').text('Stage');
  56. //cambiamos el id del contenido del stage para añadirle el numero
  57. $ex12stage_tab_content[$key].id = 'stage' + $key;
  58. //añadimos la stage tab
  59. $('#' + $customer.value +' #stage_tab').append($ex12stage_tabs[$key]);
  60. //añadimos el contenido del stage
  61. $('#' + $customer.value +' #stage_tab_content').append($ex12stage_tab_content[$key]);
  62. $indexStage = $indexStage + 1;
  63. $numero_customers = $numero_customers + 1;
  64. }
  65. $customerAnterior = $customer.value;
  66. });
  67. $indexBorrar = 0;
  68. if($ex12customers.length>0){
  69. //BORRAMOS LAS PESTAÑAS QUE SOBREN DE LOS CUSTOMER
  70. for (i=$numero_customers; i < $ex12customers.length; i++){
  71. //console.log(i+'de'+$indexBorrar)
  72. $('#wizard').steps('remove', i - $indexBorrar);
  73. $indexBorrar = $indexBorrar + 1;
  74. }
  75. }
  76. // updateWizard();
  77. }