Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/09/2015, 04:16
rufus
 
Fecha de Ingreso: mayo-2009
Ubicación: Andalucia
Mensajes: 650
Antigüedad: 15 años
Puntos: 1
como modificar el siguiente script para ahorrar muchas lineas de codigo

tengo el siguiente script en jquery
Código Javascript:
Ver original
  1. <script>
  2.     $(function(){
  3.        
  4.         var ventana = $(window);
  5.         var doc = $(document);
  6.         var enlacesebusca_1 = $("#sebusca1");
  7.  
  8.  
  9.         $("#enlacesebusca1").on("click", mostrarLogin);
  10.  
  11.         ventana.on("resize", ajustarPosicionesLogin);
  12.         ventana.on("scroll", ajustarPosicionesLogin);
  13.    
  14.  
  15.         function ajustarPosicionesLogin(e){
  16.             enlacesebusca_1.css({
  17.               top: (((ventana.height() - enlacesebusca_1.height()) / 2) + ventana.scrollTop()) + "px",
  18.               left: ((ventana.width() - enlacesebusca_1.width()) / 2) + "px"
  19.             });
  20.             $("#capamodal").css({
  21.               width: "100%",
  22.               height: "100%"
  23.             });
  24.         }
  25.  
  26.         function mostrarLogin(e)
  27.         {
  28.             e.preventDefault();
  29.             enlacesebusca_1.css({
  30.               top: (((ventana.height() - enlacesebusca_1.height()) / 2) + ventana.scrollTop()) + "px",
  31.               left: ((ventana.width() - enlacesebusca_1.width()) / 2) + "px",
  32.               "z-index": 1000
  33.             });
  34.  
  35.            
  36.             enlacesebusca_1.fadeIn(2000);
  37.            
  38.  
  39.            var capamodal = $("<div>").attr("id", "capamodal");
  40.             capamodal.css({
  41.                 opacity: 0.80,
  42.                 "z-index": 900,
  43.                 width: doc.width(),
  44.                 height: doc.height(),
  45.                 backgroundColor: "#3fc",
  46.                 position: "fixed",
  47.                 top: "0px",
  48.                 left: "0px",
  49.                 display: "none",
  50.                 overflow: "hidden",
  51.             })
  52.             .appendTo("body")
  53.             .fadeIn(2000)
  54.             .on("click", function()
  55.             {
  56.               enlacesebusca_1.fadeOut(2000);
  57.            
  58.               capamodal.fadeOut(2000, function()
  59.               {
  60.                capamodal.remove();
  61.               });
  62.            
  63.         });
  64.  
  65.    }
  66.  
  67.  });
  68.    
  69.     </script>

Código HTML:
Ver original
  1. <a href="#" id="enlacesebusca1"  class="letraenlace">Letra</a>

como lo puedo modificar para hacer lo mismo con otras 11 canciones más ahorrando y reutilizando codigo??
gracias