Ver Mensaje Individual
  #11 (permalink)  
Antiguo 05/01/2011, 01:25
jesusjj
 
Fecha de Ingreso: noviembre-2007
Mensajes: 154
Antigüedad: 16 años, 5 meses
Puntos: 2
Respuesta: jQuery $.ajax y PHP con un CSV

Buenas, realmente no estoy utilizando ningún plugin, estoy utilizando uno que vi que era una capa oculta y luego con jQuery y CSS la mostraba y hacía el efecto.

Otras veces que intenté utilizar plugins, me dio problemas el tema de CSS y carga de funciones PHP, así que 'para asegurar' utilicé este.

El código es:

Código Javascript:
Ver original
  1. // Ventana Modal    
  2.    
  3.     //When you click on a link with class of poplight and the href starts with a #
  4.     $('a.poplight[href^=#]').click(function() {
  5.         var popID = $(this).attr('rel'); //Get Popup Name
  6.         var popURL = $(this).attr('href'); //Get Popup href to define size
  7.    
  8.         //Pull Query & Variables from href URL
  9.         var query= popURL.split('?');
  10.         var dim= query[1].split('&');
  11.         var popWidth = dim[0].split('=')[1]; //Gets the first query string value
  12.        
  13.         // Modifico script para asignar dinámicamente el id al div
  14.         $(".popup-block").attr('id', popID);
  15.        
  16.         // Envío por ajax el atributo id para indicar el contenido a cargar
  17.         $.post('index.php', {pag:'products', clave: popID},
  18.             function(data) {
  19.                 //Fade in the Popup and add close button
  20.                 $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="content/images/theme/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>');
  21.                    
  22.                 //Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
  23.                 var popMargTop = ($('#' + popID).height() + 80) / 2;
  24.                 var popMargLeft = ($('#' + popID).width() + 80) / 2;
  25.            
  26.                 //Apply Margin to Popup
  27.                 $('#' + popID).css({
  28.                     'margin-top' : -popMargTop,
  29.                     'margin-left' : -popMargLeft
  30.                 });
  31.            
  32.                 //Fade in Background
  33.                 $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
  34.                 //$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies
  35.                
  36.                 // modifico el filtro alpha por el fade del diaplay
  37.                 $('#fade').css({'display' : 'block'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies
  38.                
  39.                 //Generamos el listado de productos
  40.                 $('#' + popID).html(data);            
  41.         });
  42.                                    
  43.         return false;
  44.     });
  45.  
  46.     //Close Popups and Fade Layer
  47.     $('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
  48.         $('#fade , .popup-block').fadeOut(function() {
  49.             $('#fade, a.close').remove();  //fade them both out
  50.         });
  51.         return false;
  52.     });

Código CSS:
Ver original
  1. /* **************** jQuery ModalWindow ********************************************************* */
  2.  
  3. #fade { /*--Transparent background layer--*/
  4.     display: none; /*--hidden by default--*/
  5.     /*background: #000;*/
  6.     background: url('../../images/theme/modalBackground.png') repeat;
  7.     position: fixed; left: 0; top: 0;
  8.     width: 100&#37;; height: 100%;
  9.     /*opacity: .80;*/
  10.     z-index: 9999;
  11. }
  12.  
  13. .popup-block{
  14.     display: none; /*--hidden by default--*/
  15.     background: #fff;
  16.     padding: 20px;
  17.     border: 20px solid #ddd;
  18.     float: left;
  19.     font-size: 1.2em;
  20.     position: fixed;
  21.     top: 50%; left: 50%;
  22.     z-index: 99999;
  23.     /*--CSS3 Box Shadows--*/
  24.     -webkit-box-shadow: 0px 0px 20px #000;
  25.     -moz-box-shadow: 0px 0px 20px #000;
  26.     box-shadow: 0px 0px 20px #000;
  27.     /*--CSS3 Rounded Corners--*/
  28.     -webkit-border-radius: 10px;
  29.     -moz-border-radius: 10px;
  30.     border-radius: 10px;
  31. }
  32.  
  33. img.btn_close { float: right; margin: -55px -55px 0 0; }
  34.  
  35. /*--Making IE6 Understand Fixed Positioning--*/
  36. *html #fade { position: absolute; }
  37. *html .popup_block { position: absolute; }
  38.  
  39. /* **************** jQuery ModalWindow ********************************************************* */

Gracias