[Aggiornato] LightBox Helper per Ruby on Rails

Logo Rails Volevo informare i nostri gentilissimi lettori che ho creato un plugin (corredato di installer) molto utile (a me.. dato che lo uso spesso nei miei siti) basato su LightBox (ver 2.0.) e che permette in pochi e semplici passi di:

  • Installare copiare tutti i css, immagini, javascripts di lightbox nella public directory
  • Associare ad un immagine o un link il lightbox

Per installare il plugin basta digitare da console:

script/plugin install http://lipsiasoft.googlecode.com/svn/trunk/lightbox_helper
Questo plugin (come sopra accennato) copierà nella vostra directory pubblica tutti i file necessari al corretto funzionamento di lightbox.

Il javascript lightbox.js verrà aggiunto di default nell'AssetTagHelper pertanto (se già non lo avete) aggiungete nell'head questo:

<%= javascript_include_tag :defaults %>

Ora dovete inserire nell'head del vostro sito il link allo stylesheet pertanto:

<%= stylesheet_link_tag 'lightbox' %>

Infine per aggiungere a un link ad un immagine in lightbox:

<%= lightbox_link_to "Nome del Link",  "/path/of/your/image.png" %>

Ho anche creato un'helper per aggiungere lightbox alle immagini:

<%= lightbox_image_tag("/path/of/your/image-thumb.png", "/path/of/your/image.png") %>

Nota: L'helper lightbox_link_to e lightbox_image_tag si basano rispettivamente su link_to e image_tag pertanto si comportano di conseguenza e quindi potete fare:

<%= lightbox_image_tag("/path/of/your/image-thumb.png", "/path/of/your/image.png", {:class=>"images"}, :title => "This is a test!") %>

Potete trovare su AgileWebDevelopment il mio plugin. Datemi un bel voto!

Technorati Tags: , ,

Questo post è stato inviato il June 05, 2007 11:12 e Posted in , . Puoi seguire tutte le risposte tramite il Atom feed. You can leave a comments, Or a trackback from your own site.
Tags , , , ,


Trackbacks

Utilizza il link seguente per fare trackback dal tuo sito
http://blog.lipsiasoft.com/trackbacks?article_id=lightbox-helper-per-ruby-on-rails&day=05&month=06&year=2007

Commenti

Lascia una risposta

  1. Exon il June 05, 2007 11:12:
    Hello, somthing is wrong with method lightbox_image_tag, it doesn't work :(
  2. Davide D'Agostino il June 05, 2007 11:12:
    mmm, strange, I'll use it in this site and much other without problem. I do some check, if u whant please provide me your code. Thanks so much for your feedback!
  3. Davide D'Agostino il June 05, 2007 11:12:
    Exon Try to redownload them! I Fixed the problem! See the readme! Thanks for your feedback
  4. vince il June 05, 2007 11:12:
    It seems to work fine under FF and Safari, but I'm having trouble getting it to work with IE6 or IE7. Is there a secret to that? I have a simple link that I used to test with in a new application: <%= lightbox_link_to "Link Name", "http://www.piepalace.ca/blog/wp-content/uploads/2006/09/sw-awesome.jpg" %> Like, I said.. it works great in FF and Safari, but in IE it just opens the image on a new page. Thx.
  5. Davide D'Agostino il June 05, 2007 11:12:
    Can you give me url of the page that give this problem? Thanks
  6. zammer il June 05, 2007 11:12:
    I keep getting an undefined method for lightbox_image_tag. What have I missed?
  7. Davide D'Agostino il June 05, 2007 11:12:
    zammer u have restarted webrich or mongrel?
  8. Samuel il June 05, 2007 11:12:
    I would like to use this plug-in... but i also got the undefined method for lightbox_image_tag. From your last reply to Zammer, dose this plug-in need webrich or mongrel??
  9. zammer il June 05, 2007 11:12:
    No. Overlooked that. thanx
  10. Davide D'Agostino il June 05, 2007 11:12:
    @Zammer
    You have resolved the problem?

    @Samuel
    work with all server, the only thing is that once u download and install the plugin u need to restart your server.
    Say me if there is any future problem.
  11. Thom Cherryhomes il June 05, 2007 11:12:
    Hello, I love your lightbox helper, and it's exactly what I need..however, I am having a bit of a problem..... I have a page here: http://articles/snoogsnewpage/ that when you click on the :+: opens a file repository.. If I click on the View under actions, the image does not display properly at all.... I am loading the individual file items in via AJAX, and thus the lightbox javascript doesn't know of the changed DOM tree since the window first loaded. I was able to get the lightbox to appear by injecting an initLightbox() call at the bottom of the call that renders the collection partials..however there seems to be a problem, i think the object has moved from its expected place in the DOM tree so it can't deal with the problem.. is there a work around to fix this so that AJAX generated partials can also render lightboxes? -Thom
  12. Thom Cherryhomes il June 05, 2007 11:12:
    oops, sorry, the URL is http://65.96.165.138/articles/snoogsnewpage/ :-)
  13. nira il June 05, 2007 11:12:
    the plugin is great and easy to use:)
    can i send acollection of images as in lightbox2?
  14. Davide D'Agostino il June 05, 2007 11:12:
    @nira,

    you can simply override the REL, so for a collection of image you can do:

    <%= lightbox_link_to "My Album",  "/path/of/your/image.png",  :rel => "lightbox[myalbum]" %>

  15. Pat il June 05, 2007 11:12:
    i got the same problem like vince
    here's my code


  16. lightbox_image_tag(photo.public_filename(:thumb),
    photo.public_filename,
    {
    :class=>'images'
    }, :title => "This is a test!")


  17. Rudi il June 05, 2007 11:12:
    Innazittutto ottimo helper Davide. Per le immagini tutto perfetto ma per lightbox_link_to non mi funziona, carica la modal window la wheel gira all'infinito ma non mi renderizza la pagine. Mongrel conferma il caricamento corretto di quella action. Idea? Stesso codice con RedBox funziona
  18. Parbroops il June 05, 2007 11:12:
    Hi people As a fresh blog.lipsiasoft.com user i only want to say hi to everyone else who uses this site <:-)

Lascia un commento