Blogbonzo: Matteo Magni

Consulente Informatico, Web Developer & System Administrator

Archive for the ‘Javascript’ tag

Bug di IE con le gif animate

leave a comment

Purtroppo su IE ogni volta che inviamo un form le gif animate vengono fermate.

Ecco uno scenario tipico per questo errore: una form per inviare una foto dove si vuole fare attendere l’utente che finisca l’upload dandogli la sensazione, tramite una gif animata, che la pagina web stia lavorando.

<form onSubmit="gif()" name="myform" action="#" method="post" enctype="multipart/form-data">
<p id="wait">
<img id="WaitImage" src="images/loadingAnimation.gif"/><br />
<strong>È in corso l'invio ...<br />
L'operazione potrebbe richiedere qualche minuto, attendi senza chiudere questa finestra.
</strong>
</p>
</form>

Visto che su IE la gif che era nascosta, quando invio la form smette di essere animata, bisogna trovare un modo per farla ripartire.

Tutto si può fare dando l’impressione ad IE di aver modificato l’immagine con Javascript un tempo successivo all’invio della form, tramite questa istruzione:

setTimeout('document.getElementById("WaitImage").src = "images/loadingAnimation.gif"', 200);


<script type="text/javascript">
function gif()
{
if (document.forms["myform"]["file"].value != "")
{
document.getElementById(\'bottone_carica\').style.display = \'none\';
document.getElementById(\'wait\').style.display = \'block\';
setTimeout(\'document.getElementById("WaitImage").src = "images/loadingAnimation.gif"\', 200);
}
}
</script>

Così la gif bloccata ripartirà a eseguire la sua animazione.

Written by Bonzo

settembre 1st, 2009 at 7:02 am

Posted in Javascript

Tagged with

Aggiungi a preferiti

leave a comment

Funzione javascript per aggiungere una pagina ai preferiti


function BookmarkPage(){
if (window.sidebar)
window.sidebar.addPanel(document.title, window.location,"");
else if(document.all)
window.external.AddFavorite(window.location, document.title);
else if(window.opera && window.print)
alert("Utenti Opera: per aggiungere questo sito ai preferiti, cliccare su 'OK' poi premere CTRL-D");
else
alert("Utenti: per aggiungere questo sito ai preferiti, cliccare su 'OK' poi premere CTRL-D");}

Written by Bonzo

maggio 18th, 2009 at 2:23 pm

Posted in Senza categoria

Tagged with

Plugin shadowbox per wordpress

14 comments

Ho letto di questo componente Shadowbox che è una specie di Lightbox, slimbox che consente di inserire molti tipi di contenuti: non solo foto ma video da youtube, animazioni flash, pagine html, ecc..

Ho quindi pensato di provare a creare il mio primo plugin per wordpress integrando questo componente.

Qui intanto gli esempi di come funziona Shadowbox:

Demos

Images

Single Image (Flickr)
Image Gallery


Large Image

You may have to shrink your browser window to view the effect here. See the handleLgImages option for more information.

Clipped (no resizing) Resized Draggable

Thumb Gallery

Unlike the previous image gallery, this one is triggered by thumbnail links. It also uses a skip counter and is continuous.

Red Red Red

Flash

Single SWF
SWF Gallery
Flash Video

Movies

Single Movie (mov)
Single Movie (mpeg-4, controller disabled)
Single Movie (avi, autoplay disabled)

Single Movie (wmv)
Apple.com Trailer
YouTube
Google Video
Movie Gallery



External Website
This page
Mixed Content Gallery


Il Plugin è molto semplice, basta caricare la cartella che si ottiene scompattando l’archivio compresso nelal cartella /wp-content/plugins, andare nella parte di amministrazione e attivare il plugin.

Per utilizzarlo basta aggiungere rel=”shadowbox” ai link che volete aprire in questo modo.

ecco un po’ di esempi presi dal sito di shadowbox

Markup

The simplest way to use Shadowbox is through your HTML markup. At the very least, you must add a rel="shadowbox" attribute to your links. For example, say you have this link to an image on your page:

<a href="myimage.jpg">My Image</a>

In order to set up this link for use with Shadowbox, simply change it to this:

<a href="myimage.jpg" rel="shadowbox">My Image</a>

If you would like to display a title for your image, simply add a title attribute to the link.

<a href="myimage.jpg" rel="shadowbox" title="My Image">My Image</a>

You must explicitly tell Shadowbox the dimensions to use to display content other than images. This is done by adding a few parameters to the end of the rel attribute, separated by semi-colons (like a CSS style declaration). To specify a movie's height and width, use the height and width parameters. Note: unlike in CSS, these values must always be specified in pixels.

<a href="mymovie.swf" rel="shadowbox;height=140;width=120">My Movie</a>

Additionally, you may set Shadowbox options on a per-link basis. To do this, you must include a JSON-formatted parameter called options. An example could be:

<a href="myimage.jpg" rel="shadowbox;options={overlayOpacity: 0.5, resize: false}">My Image</a>

In addition to displaying single images and movies, Shadowbox is also capable of displaying galleries of content. In order to designate a link as part of a gallery, you must add the gallery name to the rel attribute between square brackets immediately following the word "shadowbox". For example, the following markup creates a gallery called "Vacation" with two pictures:

<a href="beach.jpg" rel="shadowbox[Vacation]">The Beach</a>
<a href="pier.jpg" rel="shadowbox[Vacation]">The Pier</a>

Galleries may be composed of content of many different types. The following markup is a compressed version of the last demo above. It demonstrates how various media can be combined into a single gallery.

<a rel="shadowbox[Mixed];options={counterType:'skip',continuous:true}" href="vanquish.jpg">jpg</a>
<a rel="shadowbox[Mixed];width=520;height=390" href="caveman.swf">swf</a>
<a rel="shadowbox[Mixed];width=292;height=218" href="kayak.mp4">movie</a>
<a rel="shadowbox[Mixed]" href="index.html">iframe</a>

Per ora il plugin funziona con mootools, ma è facilmente adattabile ad altre librerie javascript, visto che shqdowbox include i vari adapter per queste librerie.

Scarica il plugin versione 0.1
Ovviamente spero che se ci sono reeori qualcuno me lo segnali.

Gabba Gabba Hey
Bonzo

Written by Bonzo

gennaio 31st, 2008 at 9:55 am