nyroFwk  0.2
range/numeric.class.php
Go to the documentation of this file.
1 <?php
11 
12  public function setValue($value, $refill=false, $key=null) {
13  if (is_array($value)) {
14  $value = array_map(create_function('$v', 'return str_replace(",", ".", $v);'), $value);
15  } else {
16  $value = str_replace(',', '.', $value);
17  }
18  parent::setValue($value, $refill, $key);
19  }
20 
21  public function toHtml() {
22  $ret = parent::toHtml();
23 
24  if ($this->cfg->useJs) {
25  $id = $this->makeid($this->name.'-slider');
26 
27  $ret = '<div id="'.$id.'" class="range-slider"></div>'.$ret;
28 
29  $min = $this->cfg->getInarray('allowedRange', 'min');
30  $max = $this->cfg->getInarray('allowedRange', 'max');
31 
32  if (!$min) $min = 0;
33  if (!$max) $max = 100;
34 
35  $minVal = $this->getValue('min');
36  $maxVal = $this->getValue('max');
37  if (!$minVal) $minVal = $min;
38  if (!$maxVal) $maxVal = $max;
39 
40  $resp = response::getInstance();
41  $resp->addJs('jqueryui');
42  $resp->blockJquery('$("#'.$id.'").slider({
43  range: true,
44  min: '.$min.',
45  max: '.$max.',
46  values: ['.$minVal.','.$maxVal.'],
47  slide: function(event, ui) {
48  $("#'.$this->makeId($this->name.'[0]').'").val(ui.values[0]);
49  $("#'.$this->makeId($this->name.'[1]').'").val(ui.values[1]);
50  },
51  change: function() {
52  $("#'.$this->makeId($this->name.'[0]').'").change();
53  $("#'.$this->makeId($this->name.'[1]').'").change();
54  }
55  })'.($this->cfg->disabled?'.next(".range").find("input").attr("disabled", "disabled")' : null).';
56  ;');
57  }
58 
59  return $ret;
60  }
61 
62  public function toXul() {
63  return '<textbox type="number" id="'.$this->name.'" value="'.$this->value.'" min="'.$this->min.'" max="'.$this->max.'" increment="'.$this->step.'" '.utils::htmlAttribute($this->more).'/>';
64  }
65 
66 }
static htmlAttribute(array $prm)
Definition: utils.class.php:90
static getInstance()
setValue($value, $refill=false, $key=null)
Generated on Sun Oct 15 2017 22:25:20 for nyroFwk by doxygen 1.8.13