/** * Initialisation de la barre de progression du courriel action * * @author Benjamin MENANT job-contact@menant-benjamin.fr * */ Drupal.behaviors.ape_faireundonBarreDeProgression = function (context) { var $wrapper = $('#conteneur_barre'), $progressBar = $wrapper.children('div.barreDeProgression'), $curseur = $progressBar.children('div.curseur'), $barre = $progressBar.children('div.barre'), _nbAttendu = parseInt($('#conteneur_barre span.nbAttendu').text().replace(/\D/gi, ''), 10), _nbAtteint = parseInt($('#conteneur_barre span.nbAtteint').text().replace(/\D/gi, ''), 10); // Redéfinition des positions des éléments mobiles de la barre (cross-browser compatibility) $curseur.css('backgroundPosition', '1px 0px'); $barre.css('backgroundPosition', '-275px 0px'); window.setTimeout(function () { // Ajout du pourcentage en filigrane var _pourcentage = Math.round(100 * _nbAtteint / _nbAttendu), transitionHandler = function (evt) { $barre.text(_pourcentage + ' %'); }; // Init le filigrane if ($('html').hasClass('csstransitions')) { $wrapper.addClass('enable-csstransitions'); $barre.text('...'); $progressBar.bind('webkitTransitionEnd oTransitionEnd transitionend', transitionHandler); } else{ $barre.text(_pourcentage + ' %'); } // Initialisation du plugin barreDeProgression $progressBar.barreDeProgression({ 'nombreAttendu' : _nbAttendu, 'nombreAtteint' : _nbAtteint, 'elementsMobiles' : $curseur.add($barre), 'size' : 275, 'axe' : 'x' }); }, 100); };