24 $this->_template =
'<%tagName% id="%identifier%" %properties%>%wrapContentBefore%%content%%wrapContentAfter%</%tagName%>';
37 if (! \is_array($this->content)) {
38 if (isset($this->content))
39 $this->content = array(
43 $this->content = array();
46 \array_unshift($this->content,
$content);
59 $this->content->run($js);
60 }
else if (\is_array($this->content)) {
61 foreach ($this->content as $itemContent) {
63 $itemContent->run($js);
72 $this->wrapContentBefore .= $before;
96 $instances = \array_merge($instances,
$content->getContentInstances($class));
110 public function asLink($href = NULL, $target = NULL) {
119 if (\is_array($this->content)) {
120 return \strip_tags(implode(
"", $this->content));
122 return \strip_tags($this->content);
130 $frm->setProperty(
"onsubmit",
"return false;");
131 $fields = $frm->addFields();
132 $idE = $frm->getIdentifier();
133 $fields->addItem($field);
134 $fields->addButtonIcon(
"bt-okay",
"check",
"green mini",
"\$('#" . $idE .
"').trigger('validate',{value: $('#'+idF+' input').val()});");
135 $fields->addButtonIcon(
"bt-cancel",
"close",
"mini",
"\$('#" . $idE .
"').trigger('endEdit');");
136 $this->_editableContent = $frm;
140 $focusOut =
"if(e.relatedTarget==null)elm.trigger('endEdit');";
141 $this->_editableContent = $field;
142 $keypress =
"$('#" . $idF .
"').keyup(function(e){if(e.which == 13) {\$('#" . $idE .
"').trigger('validate',{value: $('#'+idF+' input').val()});}if(e.keyCode===27) {\$('#" . $idE .
"').trigger('endEdit');}});";
144 $this->_editableContent->
setProperty(
"style",
"display:none;");
145 $this->
onCreate(
"let idF='" . $idF .
"';let idE='" . $idE .
"';let elm=$('#'+idE);let self=$('#" . $this->
getIdentifier() .
"');" . $keypress .
"elm.on('validate',function(){self.html($('#'+idE+' input')." . $setValueProperty .
");elm.trigger('endEdit');});elm.on('endEdit',function(){self.show();$(this).hide();});elm.focusout(function(e){" . $focusOut .
"});");
146 $this->
onClick(
"let self=$(this);self.hide();" . $field->
setJsContent(
"self.html()") .
";$('#" . $idF .
" input').trigger('change');elm.show();$('#'+idE+' input').focus();");
155 if (! $this->_compiled && isset($this->_editableContent)) {
156 $this->
wrap(
"", $this->_editableContent);
158 parent::compile_once($js, $view);
wrapWith(HtmlDoubleElement $container)
Wraps the element with a container.
run(JsUtils $js)
SimpleExtComponent\Ajax\common\html\BaseHtmlrun()
compile_once(\Ajax\JsUtils $js=NULL, &$view=NULL)
{}
asEditable(HtmlFormField $field, $asForm=false, $setValueProperty="val()")
asLink($href=NULL, $target=NULL)
Transforms the element into a link.
__construct($identifier, $tagName="p")
wrapContent($before, $after="")
_getContentInstances($class, $content)
getContentInstances($class)
addContent($content, $before=false)
onClick($jsCode, $stopPropagation=false, $preventDefault=true)
setProperty($name, $value)
setProperty($name, $value)