Skip to content
Permalink
Browse files

Visibility: Move getJsComparator to Widget class

  • Loading branch information...
protich committed Oct 3, 2019
1 parent 36b44f7 commit d3f46bfd67a526e760bf5953d888a84710e642ee
Showing with 18 additions and 16 deletions.
  1. +18 −16 include/class.forms.php
@@ -4079,6 +4079,24 @@ function getValue() {
function getJsValueGetter($id='%s') {
return sprintf('%s.val()', $id);
}
/**
* getJsComparator
*
* Used with the dependent fields to get comparison expression
*
*/
function getJsComparator($value, $id) {
if (strpos($value, '|') !== false)
return sprintf('$.inArray(%s, %s) !== -1',
$this->getJsValueGetter($id),
JsonDataEncoder::encode(explode('|', $value)));
return sprintf('%s == %s',
$this->getJsValueGetter($id),
JsonDataEncoder::encode($value));
}
}
class TextboxWidget extends Widget {
@@ -4401,17 +4419,6 @@ function getJsValueGetter($id='%s') {
return sprintf('%s.find(":selected").val()', $id);
}
function getJsComparator($value, $id) {
if (strpos($value, '|') !== false)
return sprintf('$.inArray(%s, %s) !== -1',
$this->getJsValueGetter($id),
JsonDataEncoder::encode(explode('|', $value)));
return sprintf('%s == %s',
$this->getJsValueGetter($id),
JsonDataEncoder::encode($value));
}
}
/**
@@ -4615,11 +4622,6 @@ function getJsValueGetter($id='%s') {
return sprintf('%s.is(":checked")', $id);
}
function getJsComparator($value, $id) {
return sprintf('%s == %s',
$this->getJsValueGetter($id),
JsonDataEncoder::encode($value));
}
}
class DatetimePickerWidget extends Widget {

0 comments on commit d3f46bf

Please sign in to comment.
You can’t perform that action at this time.