Accueil/modules/clockAdvanced/ClockAdvanced.php

36 lines
1.2 KiB
PHP

<?php
class clockAdvanced extends Module {
protected $moduleTitle = 'Horloge Avancée';
protected $paramsList = array(
'visibility',
'x',
'y',
'fontFamily',
'fontSize',
'format',
'color'
);
public function __construct($params){
parent::__construct(__CLASS__, $params);
}
public function build(){
echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
<link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />';
echo '<div class="jclockAdvanced" id="clockAdvanced" style="left:'.$this->getParam('x').'; top:'.$this->getParam('y').';"></div>';
$options = '';
foreach (self::$paramsList as $paramName){
if($this->getParam($paramName) != null)
$options .= $paramName.' : "'.$this->getParam($paramName).'",';
}
echo '<script>$(document).ready(function(){
$(\'#fontFamily\').val("'.$this->getParam('fontFamily').'");
$(\'#fontSize\').val("'.$this->getParam('fontSize').'");
$(\'#format\').val("'.$this->getParam('format').'");
$(\'#color\').val("'.$this->getParam('color').'");
$(\'.jclockAdvanced\').jclock({'.substr($options,0,-1).'});
});
</script>';
}
}