hi
i wrote my first (pretty useless:) plugin but i'm not sure what to
think about it, it just looks like it has "too much words"!!

Here's the plugin code (it's to make a glossary)

(function($){
        $.fn.glossario = function(options){
                                        var defaults = {
                                                stile: 'mark'
                                        };
                                        var options = $.extend(defaults, 
options);
                                        var classe = options.stile;
                                        var hash;
                                        if (document.location.hash)
                                                var hash = 
(document.location.hash).charAt(1);
                                        return this.each(function() {
                                                var obj = $(this);
                                                var anchors = obj.children("a");
                                                
obj.children('dl').css({display:'none'});
                                                if (hash) {
                                                        obj.children('a[href=#' 
+ hash + ']').addClass(classe);
                                                        obj.children('dl[id=' + 
hash + ']').css({display:'block'});
                                                } else {
                                                        
obj.children('a:first').addClass(classe);
                                                        
obj.children('dl:first').css({display:'block'});
                                                }
                                                anchors.click(function(){
                                                        var id = 
$(this).attr('href').charAt(1);
                                                        if 
(!($(this).hasClass(classe))){
                                                                
anchors.removeClass(classe);
                                                                
$(this).addClass(classe);
        
obj.children('dl').css({display:'none'}).end().children('dl[id=' + id
+ ']').fadeIn();
                                                        }
                                                        return false;
                                                });
                                        });
                                };
})(jQuery);

$("#glossario").glossario();



<div id="glossario"><a href="#a">A</a> <a href="#b">B</a>  ...  <span
class="no_link">Z</span>
        <dl id="a">
          <dt>A word</dt>
          <dd>A word meaning</dd>
          <dt>A word</dt>
          <dd>A word meaning</dd>
        </dl>
        <dl id="b">
         <dt>B word</dt>
          <dd>B word meaning</dd>
          <dt>B word</dt>
          <dd>B word meaning</dd>
        </dl>
        <dl id="c">
          <dt>Bear market</dt>
          <dd>Mercato orso, ossia ribassista.</dd>
          <dt>Benchmark</dt>
          <dd>Parametro di riferimento utilizzato per la valutazione
dei risultati di un fondo o di una gestione.</dd>
        </dl>
        ...
      </div>

Any suggestion or feedback?

Thanks Vitto

Reply via email to