* @version $Id$
* @access public
* @license http://opensource.org/licenses/gpl-3.0.html
*/
_debug(__FILE__ . ' loaded');
global $plug;
// we load javascript file
// The file include 4 locales : grunt embedLocales --embedLocales fr,it,es,en
// footerAddJS($plug->getVar('relative_url').'js/moment-2.9.0/min/moment-with-customlocales-min.js');
footerAddJS($plug->getVar('relative_url').'js/moment.min.js');
// We prepare the JS content
$js = 'moment.locale("'.U_L.'");
$( ".published_by" ).each(function( index ) {
var $el = $(this).find("span.published-on");
var $el2 = $(this).find("span.date");
if($($el2).attr("data-published-date")) {
var dateZ = $($el2).attr("data-published-date");
var format = "detailed";
} else {
var dateZ = $el2.text();
var format = "simple";
}
// alert(format + " - " + dateZ);
// if dateZ does not exists we exit
if(!dateZ) return;
var zone = "Europe/Paris";
if (format == "detailed")
var prettyDate = moment(dateZ, "DD-MM-YYYY hh:mm:ss").fromNow();
else
var prettyDate = moment(dateZ, "'.strtoupper(DATE_FORMAT).'").fromNow();
$el.replaceWith("'._t('statut', 'published_on'). '");
$el2.replaceWith("" + prettyDate + "");
// finally we attach the original date as title to the span
$(this).find("span.pretty-date").attr("title", dateZ);
});
';
footerAddInlineJS($js);
?>