MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mfloatfield.class
Ir para a documentação deste ficheiro.
1
<?php
2
3
$MIOLO
=
MIOLO::getInstance
();
4
$MIOLO
->page->addScript(
'm_floatfield.js'
);
5
28
class
MFloatField
extends
MTextField
29
{
33
private
$userField;
34
38
private
$fixed = 2;
39
43
private
$separator =
','
;
44
56
public
function
__construct
(
$name
=
''
,
$value
=
''
,
$label
=
''
,
$size
=10,
$hint
=
''
,
$validator
=NULL, $isReadOnly=
false
, $fixed=2, $separator=
','
)
57
{
58
$userFieldId =
"{$name}user"
;
59
$this->userField =
new
MTextField
($userFieldId,
$value
,
$label
,
$size
,
$hint
);
60
61
62
parent::__construct(
$name
,
$value
,
$label
,
$size
,
$hint
,
$validator
, $isReadOnly);
63
64
$this->fixed = $fixed;
65
$this->separator = $separator;
66
$this->hint =
null
;
67
}
68
72
public
function
setValue
(
$value
)
73
{
74
if
( isset(
$value
) &&
$value
!=
''
)
75
{
76
if
( $this->separator ==
','
)
77
{
78
$userValue = str_replace(
'.'
,
','
,
$value
);
79
}
80
}
81
82
$this->userField->setValue($userValue);
83
$this->value =
$value
;
84
}
85
89
public
function
setFixed
($fixed)
90
{
91
$this->fixed = $fixed;
92
}
93
97
public
function
getFixed
()
98
{
99
return
$this->fixed;
100
}
101
105
public
function
setSeparator
($separator)
106
{
107
$this->separator = $separator;
108
}
109
113
public
function
getSeparator
()
114
{
115
return
$this->separator;
116
}
117
124
public
function
addAttribute
(
$name
,
$value
=
''
, $userField =
true
)
125
{
126
if
( $userField )
127
{
128
$this->userField->addAttribute(
$name
,
$value
);
129
}
130
else
131
{
132
parent::addAttribute(
$name
,
$value
);
133
}
134
}
135
142
public
function
addBoxStyle
(
$name
,
$value
)
143
{
144
parent::addBoxStyle(
$name
,
$value
);
145
$this->userField->addBoxStyle(
$name
,
$value
);
146
}
147
153
public
function
setReadOnly
($readOnly)
154
{
155
parent::setReadOnly($readOnly);
156
$this->userField->setReadOnly($readOnly);
157
}
158
162
public
function
generate
()
163
{
164
$this->
setValue
($this->value);
165
$this->userField->setValue($this->value);
166
167
$jsValidate =
"MIOLO_FloatField.validate(this, $this->fixed, '$this->separator');"
;
168
$jsUpdate =
"MIOLO_FloatField.update(this, '$this->name', $this->fixed, '$this->separator');"
;
169
170
// Remove non float
171
$this->userField->addAttribute(
'onkeyup'
,
"$jsValidate $jsUpdate"
);
172
173
// Update real field
174
$this->userField->addAttribute(
'onkeypress'
, $jsUpdate);
175
176
// Do everything when changing the value other way (like pasting)
177
$this->userField->addAttribute(
'onchange'
,
"$jsValidate $jsUpdate"
);
178
179
$this->
addAttribute
(
"style"
,
"display: none"
,
false
);
180
return
$this->userField->generate() . parent::generate();
181
}
182
183
public
function
setJsHint
(
$hint
)
184
{
185
$this->userField->setJsHint(
$hint
);
186
}
187
}
188
189
?>
MComponent\$name
$name
Definição
mcomponent.class:17
MFloatField
Definição
mfloatfield.class:29
MFloatField\getFixed
getFixed()
Definição
mfloatfield.class:97
MFloatField\setSeparator
setSeparator($separator)
Definição
mfloatfield.class:105
MFloatField\__construct
__construct($name='', $value='', $label='', $size=10, $hint='', $validator=NULL, $isReadOnly=false, $fixed=2, $separator=',')
Definição
mfloatfield.class:56
MFloatField\addAttribute
addAttribute($name, $value='', $userField=true)
Definição
mfloatfield.class:124
MFloatField\setValue
setValue($value)
Definição
mfloatfield.class:72
MFloatField\getSeparator
getSeparator()
Definição
mfloatfield.class:113
MFloatField\generate
generate()
Definição
mfloatfield.class:162
MFloatField\setFixed
setFixed($fixed)
Definição
mfloatfield.class:89
MFloatField\setJsHint
setJsHint( $hint)
Definição
mfloatfield.class:183
MFloatField\addBoxStyle
addBoxStyle($name, $value)
Definição
mfloatfield.class:142
MFloatField\setReadOnly
setReadOnly($readOnly)
Definição
mfloatfield.class:153
MFormControl\$value
$value
Definição
mformcontrol.class:6
MFormControl\$label
$label
Definição
mformcontrol.class:5
MFormControl\$hint
$hint
Definição
mformcontrol.class:7
MIOLO\getInstance
static getInstance()
Definição
miolo.class:134
MTextField
Definição
inputcontrols.class:4
MTextField\$validator
$validator
Definição
inputcontrols.class:7
MTextField\$size
$size
Definição
inputcontrols.class:5
$MIOLO
$MIOLO
Definição
mfloatfield.class:3
classes
ui
controls
mfloatfield.class
Gerado por
1.10.0