protected function render() { $prop = $this->props; if ($prop->disabled) { $this->attr('disabled', 'disabled'); } $this->attrIf($prop->tabIndex, 'tabindex', $prop->tabIndex); $this->attr('type', $prop->type); if (exists($prop->action)) { $this->beginAttr('onclick', null, ';'); if ($prop->confirm) { $msg = str_encodeJavasciptStr($prop->message, "'"); $this->context->getAssetsService()->addInlineScript("function confirm_{$prop->id}()\n{\n swal({\n title: '',\n text: {$msg},\n type: 'warning',\n showCancelButton: true\n },\n function() {\n selenia.doAction('{$prop->action}','{$prop->param}');\n });\n}", "confirm_{$prop->id}"); $this->attrValue("confirm_{$prop->id}()"); } else { $this->attrValue("selenia." . ($prop->type == 'submit' ? 'set' : 'do') . "Action('{$prop->action}','{$prop->param}')"); } $this->endAttr(); } else { if (exists($prop->script)) { $this->attr('onclick', $prop->script); } else { if (exists($prop->url)) { $this->attr('onclick', "selenia.go('{$prop->url}',event);"); } } } if (exists($prop->help)) { $this->attr('title', $prop->help); } $this->beginContent(); if (exists($prop->icon)) { $this->tag('i', ['class' => $prop->icon]); } $txt = trim($prop->label); echo strlen($txt) ? $txt : (exists($prop->icon) ? '' : ' '); }
/** * Generates the interaction script and returns a javascript function call string that you can embed on the page (on * a click handler, for example). * * @return string */ function get() { $msg = str_encodeJavasciptStr($prop->message, "'"); $this->context->getAssetsService()->addInlineScript("function confirm_{$prop->id}()\n{\n swal({\n title: '',\n text: {$msg},\n type: 'warning',\n showCancelButton: true\n },\n function() {\n selenia.doAction('{$action}');\n });\n}"); return "confirm_{$prop->id}()"; }