Ver Mensaje Individual
  #2  
Antiguo 20-04-2008
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.107
Reputación: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola,

Me levanto y me pongo con el plugin, de modo que me doy cuenta de algo que he soñado esta noche: no hacía falta, en realidad, una de las funciones, de hecho el plugin puede hacer su trabajo con una sola función. Y así es como queda el plugin ahora mismo, copio aquí el código fuente, por si alguien está interesado... que lo dudo.

Código PHP:
(function($){

  $.
fn.StyleSwichter = function(options){
    var 
opts = $.extend({}, $.fn.StyleSwichter.defaultsoptions);
    var 
= $.meta ? $.extend({}, opts$this.data()) : opts;
    $(
'link').each(function(i){
      if(
this.rel == 'stylesheet' && this.title == o.linkTitle){
        if(
o.cssPath != ''){
          
this.href o.cssPath;
          $.
cookie(o.cookieName,this.href,{
            
patho.cookiePath,
            
expireso.cookieDays,
            
domaino.cookieDomain,
            
secureo.cookieSecure
          
});
        }else if($.
cookie(o.cookieName)){
          
this.href = $.cookie(o.cookieName);
        }
        return 
true;
      }
    });
    return 
false;
  };
  
  $.
fn.StyleSwichter.defaults={
    
cssPath'',
    
cookiePath'',
    
cookieDays30,
    
cookieDomain'',
    
cookieSecurefalse,
    
linkTitle'styleswichter',
    
cookieName'selected-style'
  
};
  
})(
jQuery); 
Esto reduce también el tamaño del plugin, que, comprimido, queda en unos 600 bytes.
__________________
David Esperalta
www.decsoftutils.com

Última edición por dec fecha: 20-04-2008 a las 19:08:14.
Responder Con Cita