2015-12-02 19:12:34 +00:00
|
|
|
// on définit le "indexOf" pour <HTMLCollection> et <NodeList>
|
|
|
|
NodeList.prototype.indexOf = HTMLCollection.prototype.indexOf = function(searchedElement){
|
|
|
|
for( var i = 0 ; i < this.length ; i++ ) // on parcours la collection
|
|
|
|
// si on trouve l'élement, on retourne son rang
|
|
|
|
if( this[i] == searchedElement ) return i;
|
|
|
|
|
|
|
|
// si on a rien trouvé, on retourne -1
|
|
|
|
return -1;
|
2016-01-08 17:00:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* GESTION DE L'AJOUT/SUPPRESSION D'UNE CLASSE */
|
|
|
|
function addClass(el, pClass){
|
|
|
|
if( el.className.length > 0 && el.className != pClass ) el.className = el.className + ' ' + pClass;
|
|
|
|
else el.className = pClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
function remClass(el, pClass){
|
|
|
|
if( el.className.indexOf(pClass) > -1 ) // si la class de l'élement contient la classe à enlever
|
|
|
|
el.className = el.className.substr(0, el.className.indexOf(pClass)) + '' + el.className.substr(el.className.indexOf(pClass)+pClass.length);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ANIMATION DE BOUNCE PENDANT 1 SEC */
|
|
|
|
function makeBounce(buttonElement){
|
|
|
|
// ajout de la classe
|
|
|
|
remClass(buttonElement, 'loading');
|
|
|
|
addClass(buttonElement, 'bounce_error');
|
|
|
|
addClass(buttonElement, 'pamp');
|
|
|
|
|
|
|
|
// suppression de la classe après 1 sec
|
|
|
|
setTimeout(function(){
|
|
|
|
remClass(buttonElement, 'bounce_error');
|
|
|
|
remClass(buttonElement, 'pamp');
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
}
|