LSattr_html :: date : Add showNowButton and showTodayButton parameters

This commit is contained in:
Benjamin Renard 2017-10-12 14:58:31 +02:00
parent a935828a83
commit 835dccb5f6
3 changed files with 48 additions and 14 deletions

View file

@ -12,6 +12,8 @@
'format' => '[Format d'affichage de la date]', 'format' => '[Format d'affichage de la date]',
'time' => '[Booleen pour le choix ou non de l heure]', 'time' => '[Booleen pour le choix ou non de l heure]',
'manual' => '[Booleen pour l edition manuelle ou non]', 'manual' => '[Booleen pour l edition manuelle ou non]',
'showNowButton' => '[Booleen]',
'showTodayButton' => '[Booleen]',
'style' => '[Nom du style utilise]' 'style' => '[Nom du style utilise]'
),]]> ),]]>
... ...
@ -176,6 +178,22 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>showNowButton</term>
<listitem>
<simpara>Booléen définissant si le bouton <emphasis>Maintenant</emphasis> est
affiché ou non. Par défaut, il est affiché.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>showTodayButton</term>
<listitem>
<simpara>Booléen définissant si le bouton <emphasis>Aujourd'hui</emphasis> est
affiché ou non. Par défaut, il est affiché.</simpara>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term>style</term> <term>style</term>
<listitem> <listitem>

View file

@ -165,7 +165,9 @@ class LSformElement_date extends LSformElement {
'format' => $this -> php2js_format($this -> getFormat()), 'format' => $this -> php2js_format($this -> getFormat()),
'style' => $this -> getStyle(), 'style' => $this -> getStyle(),
'time' => (isset($this -> params['html_options']['time'])?$this -> params['html_options']['time']:true), 'time' => (isset($this -> params['html_options']['time'])?$this -> params['html_options']['time']:true),
'manual' => (isset($this -> params['html_options']['manual'])?$this -> params['html_options']['manual']:true) 'manual' => (isset($this -> params['html_options']['manual'])?$this -> params['html_options']['manual']:true),
'showNowButton' => (isset($this -> params['html_options']['showNowButton'])?$this -> params['html_options']['showNowButton']:true),
'showTodayButton' => (isset($this -> params['html_options']['showTodayButton'])?$this -> params['html_options']['showTodayButton']:true),
); );
LSsession :: addJSconfigParam($this -> name,$params); LSsession :: addJSconfigParam($this -> name,$params);

View file

@ -13,7 +13,12 @@ var LSformElement_date_field = new Class({
if (!$type(this.params.manual)) { if (!$type(this.params.manual)) {
this.params.manual = true; this.params.manual = true;
} }
if (!$type(this.params.showNowButton)) {
this.params.showNowButton = true;
}
if (!$type(this.params.showTodayButton)) {
this.params.showNowButton = true;
}
if (!$type(this.params.style)) { if (!$type(this.params.style)) {
this.params.style = 'dashboard'; this.params.style = 'dashboard';
} }
@ -37,19 +42,28 @@ var LSformElement_date_field = new Class({
} }
); );
if (this.params.showNowButton) {
this.nowBtn = new Element('img'); this.nowBtn = new Element('img');
this.nowBtn.src = varLSdefault.imagePath('now'); this.nowBtn.src = varLSdefault.imagePath('now');
this.nowBtn.addClass('btn'); this.nowBtn.addClass('btn');
this.nowBtn.addEvent('click',this.onNowBtnClick.bind(this)); this.nowBtn.addEvent('click',this.onNowBtnClick.bind(this));
this.nowBtn.injectAfter(this.input); this.nowBtn.injectAfter(this.input);
varLSdefault.addHelpInfo(this.nowBtn,'LSformElement_date','now'); varLSdefault.addHelpInfo(this.nowBtn,'LSformElement_date','now');
}
if (this.params.showTodayButton) {
this.todayBtn = new Element('img'); this.todayBtn = new Element('img');
this.todayBtn.src = varLSdefault.imagePath('calendar'); this.todayBtn.src = varLSdefault.imagePath('calendar');
this.todayBtn.addClass('btn'); this.todayBtn.addClass('btn');
this.todayBtn.addEvent('click',this.onTodayBtnClick.bind(this)); this.todayBtn.addEvent('click',this.onTodayBtnClick.bind(this));
if (!$type(this.nowBtn)) {
this.todayBtn.injectAfter(this.input);
}
else {
this.todayBtn.injectAfter(this.nowBtn); this.todayBtn.injectAfter(this.nowBtn);
}
varLSdefault.addHelpInfo(this.todayBtn,'LSformElement_date','today'); varLSdefault.addHelpInfo(this.todayBtn,'LSformElement_date','today');
}
}, },
onNowBtnClick: function() { onNowBtnClick: function() {