Accueil > > > BOUTON STYLE FLASH
BOUTON STYLE FLASH
Information sur la source
Description
Hello! Ne soyez pas trop severe, je debute en javascript et c'est ma premiere source... Je l'ai un peu commentee mais c'est assez simple a comprendre =) Le principe est simple, des qu'on passe sur une cellule, la fonction change peu a peu le background et le texte de la cellule en donnant un effet comme en flash ^^ Je ne sais pas que dire d'autre... Ce n'est pas tres optimise mais comme je l ai dit je debute ^^ je serai ravi d'ameliorer mon code grace a vos critiques... Pour un exemple live, mon site : http://www.kezako.fr.fm
Source
- <HTML><HEAD>
- <META http-equiv=Content-Type content="text/html; charset=windows-1252">
-
- <SCRIPT language=javascript type=text/javascript>
-
- //Flash button by Goulagman <goulagman@wanadoo.fr>
- //definition des vars
- cod = '#E9EBFF' //couleur de depart du fond
- cof = '#8A96FF' //couleur finale du fond
- tod = '#0000ff' //couleur de depart du texte
- tof = '#F2F3FF' //couleur finale du texte
- step1 = '23' //pas pendant que le bouton fonce
- step2 = '40' //pas pendant que le bouton s'eclaircit ( il s eclaircit plus lentement qu'il ne fonce )
-
-
-
-
- function Hexa(Dec) { //Conversion Hexadecimal > decimal
- var n = Dec.toString(16)
- if (n.length < 2) {n = "0" + n}
- return(n)
- }
-
- function Dec(Hexa) { //Conversion decimal > Hexadecimal
- var n = parseInt(Hexa, 16)
- return(n)
- }
-
- function ToHex(n) { //Conversion couleur RGB > Hexa
- str=n
- var reg = new RegExp("[rgb\\(',\\)]", "i");
- res = str.split(reg);
- m='#'
- for (var i=0;i<str.length;i++) {
- var reg = new RegExp("[0-9]+", "i");
- if (reg.test(res[i])) {
- m=m + Hexa(parseInt(res[i]));
- }
- }
- return(m)
- }
-
- function couleur(id, cd, cf, td, tf, step) {
- if (navigator.appVersion.indexOf("MSIE") == -1){
- if (cd) { cd=ToHex(cd) }
- if (td) { td=ToHex(td) }
- }
- if (!cd ) { cd = cod }
- if (!td ) { td = tod }
-
- //On arrete le timer si le bouton est deja en trian de changer de couleur
- clearTimeout(col[id])
-
- //calcul des RGB de debut et de fin du texte et du fond
- rd=Dec(cd.substring(1,3))
- vd=Dec(cd.substring(3,5))
- bd=Dec(cd.substring(5,7))
- rf=Dec(cf.substring(1,3))
- vf=Dec(cf.substring(3,5))
- bf=Dec(cf.substring(5,7))
- rtd=Dec(td.substring(1,3))
- vtd=Dec(td.substring(3,5))
- btd=Dec(td.substring(5,7))
- rtf=Dec(tf.substring(1,3))
- vtf=Dec(tf.substring(3,5))
- btf=Dec(tf.substring(5,7))
-
- //calcul du step par couleur
- sr=((rf-rd)/step)
- sv=((vf-vd)/step)
- sb=((bf-bd)/step)
- str=((rtf-rtd)/step)
- stv=((vtf-vtd)/step)
- stb=((btf-btd)/step)
-
- //changement de la couleur
- rt = rd;vt = vd;bt = bd
- rtt = rtd;vtt = vtd;btt = btd
- adv = 0
- changecolor(id, rt, vt, bt, sr, sv, sb, rtt, vtt, btt, str, stv, stb, adv, step)
- }
-
- function changecolor(id, rt, vt, bt, sr, sv, sb, rtt, vtt, btt, str, stv, stb, adv, step) {
- document.getElementById(id).style.backgroundColor='#' + Hexa(Math.floor(rt)) + Hexa(Math.floor(vt)) + Hexa(Math.floor(bt))
- document.getElementById(id).style.color='#' + Hexa(Math.floor(rtt)) + Hexa(Math.floor(vtt)) + Hexa(Math.floor(btt))
-
- //on ajoute le pas de chaque couleur
- rt += sr;vt += sv;bt += sb
- rtt += str;vtt += stv;btt += stb
-
- adv++
- if ( adv != step+1 ) { col[id] = setTimeout('changecolor('+id+', '+rt+', '+vt+', '+bt+', '+sr+', '+sv+', '+sb+', '+rtt+', '+vtt+', '+btt+', '+str+', '+stv+', '+stb+', '+adv+', '+step+')',15) }
- else { col[id] = 1 }
- }
- </SCRIPT>
- <STYLE type=text/css>
- .titre {
- FONT-SIZE: 10px; COLOR: #ffffff; FONT-FAMILY: arial; BACKGROUND-COLOR: #7c88ff
- }
- .cell {
- FONT-SIZE: 10px; COLOR: #0000ff; FONT-FAMILY: arial
- }
-
- </STYLE>
-
-
-
- </HEAD>
- <BODY
- onload="col = new Object()">
- <CENTER>
- <TABLE style="BORDER-TOP-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-BOTTOM-STYLE: solid" borderColor=blue cellSpacing=2 cellPadding=3 bgColor=#b2b9ff border=1>
- <TR>
- <TD vAlign=top width=100 bgColor=white>
- <TABLE borderColor=blue cellSpacing=0 cellPadding=1 bgColor=#e9ebff
- border=0>
- <TR>
- <TD class=titre width=100 height=14>
- <CENTER>Site</CENTER></TD></TR>
- <TR>
- <TD class=cell id=1
- style="CURSOR: hand"
- onclick="alert('Bouton Acceuil clické')"
- onmouseover="couleur(1, this.style.backgroundColor, cof, this.style.color, tof, step1)"
- onmouseout="couleur(1, this.style.backgroundColor, cod, this.style.color, tod, step2)">-
- Accueil</TD></TR>
- <TR>
- <TD class=cell id=2
- style="CURSOR: hand"
- onclick="alert('Bouton Liens clické')"
- onmouseover="couleur(2, this.style.backgroundColor, cof, this.style.color, tof, step1)"
- onmouseout="couleur(2, this.style.backgroundColor, cod, this.style.color, tod, step2)">-
- Liens</TD></TR>
- <TR>
- <TD class=cell id=3
- style="CURSOR: hand"
- onclick="alert('Bouton Contact clické')"
- onmouseover="couleur(3, this.style.backgroundColor,cof, this.style.color, tof, step1)"
- onmouseout="couleur(3, this.style.backgroundColor, cod, this.style.color, tod, step2)">-
- Contact
- </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
-
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<SCRIPT language=javascript type=text/javascript>
//Flash button by Goulagman <goulagman@wanadoo.fr>
//definition des vars
cod = '#E9EBFF' //couleur de depart du fond
cof = '#8A96FF' //couleur finale du fond
tod = '#0000ff' //couleur de depart du texte
tof = '#F2F3FF' //couleur finale du texte
step1 = '23' //pas pendant que le bouton fonce
step2 = '40' //pas pendant que le bouton s'eclaircit ( il s eclaircit plus lentement qu'il ne fonce )
function Hexa(Dec) { //Conversion Hexadecimal > decimal
var n = Dec.toString(16)
if (n.length < 2) {n = "0" + n}
return(n)
}
function Dec(Hexa) { //Conversion decimal > Hexadecimal
var n = parseInt(Hexa, 16)
return(n)
}
function ToHex(n) { //Conversion couleur RGB > Hexa
str=n
var reg = new RegExp("[rgb\\(',\\)]", "i");
res = str.split(reg);
m='#'
for (var i=0;i<str.length;i++) {
var reg = new RegExp("[0-9]+", "i");
if (reg.test(res[i])) {
m=m + Hexa(parseInt(res[i]));
}
}
return(m)
}
function couleur(id, cd, cf, td, tf, step) {
if (navigator.appVersion.indexOf("MSIE") == -1){
if (cd) { cd=ToHex(cd) }
if (td) { td=ToHex(td) }
}
if (!cd ) { cd = cod }
if (!td ) { td = tod }
//On arrete le timer si le bouton est deja en trian de changer de couleur
clearTimeout(col[id])
//calcul des RGB de debut et de fin du texte et du fond
rd=Dec(cd.substring(1,3))
vd=Dec(cd.substring(3,5))
bd=Dec(cd.substring(5,7))
rf=Dec(cf.substring(1,3))
vf=Dec(cf.substring(3,5))
bf=Dec(cf.substring(5,7))
rtd=Dec(td.substring(1,3))
vtd=Dec(td.substring(3,5))
btd=Dec(td.substring(5,7))
rtf=Dec(tf.substring(1,3))
vtf=Dec(tf.substring(3,5))
btf=Dec(tf.substring(5,7))
//calcul du step par couleur
sr=((rf-rd)/step)
sv=((vf-vd)/step)
sb=((bf-bd)/step)
str=((rtf-rtd)/step)
stv=((vtf-vtd)/step)
stb=((btf-btd)/step)
//changement de la couleur
rt = rd;vt = vd;bt = bd
rtt = rtd;vtt = vtd;btt = btd
adv = 0
changecolor(id, rt, vt, bt, sr, sv, sb, rtt, vtt, btt, str, stv, stb, adv, step)
}
function changecolor(id, rt, vt, bt, sr, sv, sb, rtt, vtt, btt, str, stv, stb, adv, step) {
document.getElementById(id).style.backgroundColor='#' + Hexa(Math.floor(rt)) + Hexa(Math.floor(vt)) + Hexa(Math.floor(bt))
document.getElementById(id).style.color='#' + Hexa(Math.floor(rtt)) + Hexa(Math.floor(vtt)) + Hexa(Math.floor(btt))
//on ajoute le pas de chaque couleur
rt += sr;vt += sv;bt += sb
rtt += str;vtt += stv;btt += stb
adv++
if ( adv != step+1 ) { col[id] = setTimeout('changecolor('+id+', '+rt+', '+vt+', '+bt+', '+sr+', '+sv+', '+sb+', '+rtt+', '+vtt+', '+btt+', '+str+', '+stv+', '+stb+', '+adv+', '+step+')',15) }
else { col[id] = 1 }
}
</SCRIPT>
<STYLE type=text/css>
.titre {
FONT-SIZE: 10px; COLOR: #ffffff; FONT-FAMILY: arial; BACKGROUND-COLOR: #7c88ff
}
.cell {
FONT-SIZE: 10px; COLOR: #0000ff; FONT-FAMILY: arial
}
</STYLE>
</HEAD>
<BODY
onload="col = new Object()">
<CENTER>
<TABLE style="BORDER-TOP-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-BOTTOM-STYLE: solid" borderColor=blue cellSpacing=2 cellPadding=3 bgColor=#b2b9ff border=1>
<TR>
<TD vAlign=top width=100 bgColor=white>
<TABLE borderColor=blue cellSpacing=0 cellPadding=1 bgColor=#e9ebff
border=0>
<TR>
<TD class=titre width=100 height=14>
<CENTER>Site</CENTER></TD></TR>
<TR>
<TD class=cell id=1
style="CURSOR: hand"
onclick="alert('Bouton Acceuil clické')"
onmouseover="couleur(1, this.style.backgroundColor, cof, this.style.color, tof, step1)"
onmouseout="couleur(1, this.style.backgroundColor, cod, this.style.color, tod, step2)">-
Accueil</TD></TR>
<TR>
<TD class=cell id=2
style="CURSOR: hand"
onclick="alert('Bouton Liens clické')"
onmouseover="couleur(2, this.style.backgroundColor, cof, this.style.color, tof, step1)"
onmouseout="couleur(2, this.style.backgroundColor, cod, this.style.color, tod, step2)">-
Liens</TD></TR>
<TR>
<TD class=cell id=3
style="CURSOR: hand"
onclick="alert('Bouton Contact clické')"
onmouseover="couleur(3, this.style.backgroundColor,cof, this.style.color, tof, step1)"
onmouseout="couleur(3, this.style.backgroundColor, cod, this.style.color, tod, step2)">-
Contact
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
Conclusion
Pas de bugs connus ^^
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|