Commit 5bc64ee3 by Alto

Добавил форматирование суммы

1 parent 8a995070
...@@ -105,11 +105,11 @@ $(document).ready( ...@@ -105,11 +105,11 @@ $(document).ready(
function fenix_check(el_input) function fenix_check(el_input)
{ {
if ($(el_input).length==0) if ($(el_input).length==0)
el_input = $('.fenix_calc input[type="number"][min][max]'); el_input = $('.fenix_calc input[type="number"][min][max], .fenix_calc input[type="text"][min][max]');
$(el_input).each( $(el_input).each(
function () function ()
{ {
var inp_val = $(this).val(); var inp_val = ($(this).val()).split(' ').join('');
var inp_val_int = inp_val|0; var inp_val_int = inp_val|0;
var inp_min = $(this).attr('min')|0; var inp_min = $(this).attr('min')|0;
var inp_max = $(this).attr('max')|0; var inp_max = $(this).attr('max')|0;
...@@ -119,13 +119,20 @@ $(document).ready( ...@@ -119,13 +119,20 @@ $(document).ready(
inp_val_int=inp_min; inp_val_int=inp_min;
if (inp_val_int>inp_max) if (inp_val_int>inp_max)
inp_val_int=inp_max; inp_val_int=inp_max;
if ((inp_val).toString() != (inp_val_int).toString())
$(this).val(inp_val_int); if ($(this).attr('type')==='number')
{
if ((inp_val).toString() != (inp_val_int).toString())
$(this).val(inp_val_int);
}
else if ((inp_val).toString() != (inp_val_int).toLocaleString())
$(this).val((inp_val_int).toLocaleString());
if ((inp_range).toString() != (inp_val_int).toString()) if ((inp_range).toString() != (inp_val_int).toString())
$(inp_range).val(inp_val_int); $(inp_range).val(inp_val_int);
} }
); );
$('.fenix_calc .calc_btn').toggleClass('disabled', $('.fenix_calc input[type="number"][min][max]:invalid').length>0); $('.fenix_calc .calc_btn').toggleClass('disabled', $('.fenix_calc input[type="number"][min][max]:invalid, .fenix_calc input[type="text"][min][max]:invalid').length>0);
} }
function fenix_calc (el_wrap) function fenix_calc (el_wrap)
...@@ -247,7 +254,7 @@ $(document).ready( ...@@ -247,7 +254,7 @@ $(document).ready(
'change.fenix', 'change.fenix',
'blur.fenix' 'blur.fenix'
].join(' '), ].join(' '),
'.fenix_calc input[type="number"][min][max]', '.fenix_calc input[type="number"][min][max], .fenix_calc input[type="text"][min][max]',
function () function ()
{ {
fenix_check(this); fenix_check(this);
...@@ -257,7 +264,7 @@ $(document).ready( ...@@ -257,7 +264,7 @@ $(document).ready(
'.fenix_calc input[type="range"][min][max]', '.fenix_calc input[type="range"][min][max]',
function () function ()
{ {
$(this).prev('input[type="number"][min][max]').val($(this).val()); $(this).prev('input[type="number"][min][max], input[type="text"][min][max]').val($(this).val());
} }
); );
} }
......
...@@ -19,12 +19,12 @@ function fenix_calc ($atts, $content) ...@@ -19,12 +19,12 @@ function fenix_calc ($atts, $content)
'<div class="col-12 col-md-3">'. '<div class="col-12 col-md-3">'.
'<div class="mb-3 d-none">'. '<div class="mb-3 d-none">'.
'<label for="calc_inv_'.$atts['id'].'" class="form-label mb-3">Поступление кредита, руб</label>'. '<label for="calc_inv_'.$atts['id'].'" class="form-label mb-3">Поступление кредита, руб</label>'.
'<input type="number" class="form-control rounded-pill p-2 px-4" id="calc_credit_'.$atts['id'].'" name="calc_credit" required="required" value="0" min="0" max="10000000" />'. '<input type="text" class="form-control rounded-pill p-2 px-4" id="calc_credit_'.$atts['id'].'" name="calc_credit" required="required" value="0" min="0" max="10000000" oninput="this.value = this.value.replace(/[^0-9.]/g, \'\').replace(/(\..*?)\..*/g, \'$1\').replace(/^0[^.]/, \'0\');" />'.
'<input type="range" class="form-range d-md-none" min="0" max="10000000" step="1000" id="calc_credit_range_'.$atts['id'].'" />'. '<input type="range" class="form-range d-md-none" min="0" max="10000000" step="1000" id="calc_credit_range_'.$atts['id'].'" />'.
'</div>'. '</div>'.
'<div class="mb-3">'. '<div class="mb-3">'.
'<label for="calc_inv_'.$atts['id'].'" class="form-label mb-3">Инвестиции в проект, тыс. руб</label>'. '<label for="calc_inv_'.$atts['id'].'" class="form-label mb-3">Инвестиции в проект, тыс. руб</label>'.
'<input type="number" class="form-control rounded-pill p-2 px-4" id="calc_inv_'.$atts['id'].'" name="calc_inv" required="required" value="" min="10000000" max="250000000" />'. '<input type="text" class="form-control rounded-pill p-2 px-4" id="calc_inv_'.$atts['id'].'" name="calc_inv" required="required" value="" min="10000000" max="250000000" oninput="this.value = this.value.replace(/[^0-9.]/g, \'\').replace(/(\..*?)\..*/g, \'$1\').replace(/^0[^.]/, \'0\');" />'.
'<input type="range" class="form-range d-md-none" min="10000000" max="250000000" step="1000" id="calc_inv_range_'.$atts['id'].'" />'. '<input type="range" class="form-range d-md-none" min="10000000" max="250000000" step="1000" id="calc_inv_range_'.$atts['id'].'" />'.
'</div>'. '</div>'.
'<div class="mb-3">'. '<div class="mb-3">'.
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!