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]',
'time' => '[Booleen pour le choix ou non de l heure]',
'manual' => '[Booleen pour l edition manuelle ou non]',
'showNowButton' => '[Booleen]',
'showTodayButton' => '[Booleen]',
'style' => '[Nom du style utilise]'
),]]>
...
@ -176,6 +178,22 @@
</listitem>
</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>
<term>style</term>
<listitem>

View file

@ -165,7 +165,9 @@ class LSformElement_date extends LSformElement {
'format' => $this -> php2js_format($this -> getFormat()),
'style' => $this -> getStyle(),
'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);

View file

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