rulu ruru

post Tooltip, hovertip - prostě přejížděčky s Prototype / script.aculo.us

January 6th, 2009

Filed under: javascript — starenka @ 01:18
Tags: , , ,

Potřeboval jsem nutně “tuhletu přejížděčku” a nechtělo se mi guuuglovat a guuglovat. Není to samozřejmě nic extra, ale za deset minut jsem nebyl schopnej spáchat nic lepšího. Tipy se zobrazují u všech elementů se třídou tip a s atributem alt, který je textem tipu. Tip cca klonuje pozici prvku, ke kterému patří a taky přebírá jeho šířku. Pokud to není žádoucí, navrhuju prostudovat volání metody clonePosition().

JavaScript:

document.observe(‘dom:loaded’, function() {

    $$(‘*.tip[alt]’).each(function(el){
        el.observe(‘mouseover’, show_tip.bindAsEventListener(el))
    }, this);

    $$(‘*.tip[alt]’).each(function(el){
        el.observe(‘mouseout’, hide_tip.bindAsEventListener(el))
    }, this);   
});

function show_tip(ev)
{
    var tip = Builder.node(‘div’, {
                            style:  ‘display:none;position:absolute;’,
                            id: ‘tip’
            },Builder.node(‘p’,this.readAttribute(‘alt’)));
    $(‘wrap’).appendChild(tip);
    Element.clonePosition(tip,this,{ offsetTop:20, setHeight: false});
    new Effect.SlideDown(tip,{duration:0.1});
    ev.stop();
}

function hide_tip(ev)
{
    new Effect.SlideUp(‘tip’,{duration:0.1});
    ev.stop();
    Element.remove(‘tip’);
}

Trošku CSS:

#tip { border: 1px solid #B38E5F; background: #FFCB87; }
#tip p { padding: 3px;}

post Scriptaculous - BlindLeft and BlindRight effects

August 11th, 2008

Filed under: javascript — starenka @ 21:20
Tags: , , ,

This is a simple ripoff of standard BlindUp and BlindDown effects known from script.aculo.us javascript framework. To use these effects simply download the source file and link the file after scriptacolous library. Effects are accesible as usual new Effect.BlindLeft(element);. Cheerz.

post Easy image slider with scriptaculous and lightbox

August 11th, 2008

Filed under: javascript — starenka @ 00:07
Tags: , , ,

One lame image slider I made while ago. It just slides images with slight transition effect and shows lightboxed hi-res ones when clicked. See demo here, get example source overe here. Have fun!

ruldrurd
© starenka 2oo7, cute alien monster by noizcut, original theme by Laurentiu Piron - customized by starenka | proudly powered by WordPress