protected function renderXEditable() { return \hipanel\widgets\XEditable::widget(['model' => $this->model, 'attribute' => 'level', 'scenario' => $this->scenario, 'linkOptions' => ['id' => $this->getId(), 'data-attribute' => $this->type], 'pluginOptions' => ['selector' => '#' . $this->getId(), 'type' => 'select', 'title' => Yii::t('hipanel:client', 'Verification level'), 'source' => $this->model->getAvailableLevels(), 'params' => new JsExpression("function (params) {\n params.type = \$(this).attr('data-attribute');\n return params;\n }"), 'display' => new JsExpression("function (value, sourceData) {\n var elem = \$.grep(sourceData, function (o) { return o.value == value; });\n var classes = {\n unconfirmed: 'text-warning',\n confirmed: '',\n fullverified: 'text-success',\n };\n\n \$.map(classes, function(val) {\n return \$(this).removeClass(val);\n }.bind(this));\n\n if (value instanceof String) {\n var newClass = classes[value[0]];\n } else {\n newClass = classes[value];\n }\n\n \$(this).text(elem[0].text).addClass(newClass);\n }")]]); }