protected function editable() { $id = $this->id; $autocompletion = $this->autocompletion ? 'true' : 'false'; if ($this->autocompletion) { $this->aceOptions['enableBasicAutocompletion'] = true; $this->aceOptions['enableSnippets'] = true; $this->aceOptions['enableLiveAutocompletion'] = false; } $aceOptions = Json::encode($this->aceOptions); $this->view->registerJs(<<<JS (function(){ if({$autocompletion}) { ace.require("ace/ext/language_tools"); } var _editor = ace.edit("{$id}"); _editor.setTheme("ace/theme/{$this->theme}"); _editor.getSession().setMode("ace/mode/{$this->mode}"); _editor.setOptions({$aceOptions}); })(); JS ); if ($this->hasModel()) { $html = Html::activeTextarea($this->model, $this->attribute, $this->options); } else { $html = Html::textarea($this->name, $this->value, $this->options); } return $html; }
public function run() { Assets::register($this->getView()); echo Html::beginTag('div', $this->containerOptions); if ($this->hasModel()) { echo Html::activeTextarea($this->model, $this->attribute, $this->options); } else { echo Html::textarea($this->name, $this->value, $this->options); } echo Html::endTag('div'); $js = ['mihaildev.ckEditor.registerOnChange(' . Json::encode($this->options['id']) . ');']; if (isset($this->editorOptions['filebrowserUploadUrl'])) { $js[] = "mihaildev.ckEditor.registerCsrf();"; } if (!isset($this->editorOptions['on']['instanceReady'])) { $this->editorOptions['on']['instanceReady'] = new JsExpression("function( ev ){" . implode(' ', $js) . "}"); } if ($this->_inline) { $JavaScript = "CKEDITOR.inline("; $JavaScript .= Json::encode($this->options['id']); $JavaScript .= empty($this->editorOptions) ? '' : ', ' . Json::encode($this->editorOptions); $JavaScript .= ");"; $this->getView()->registerJs($JavaScript, View::POS_END); $this->getView()->registerCss('#' . $this->containerOptions['id'] . ', #' . $this->containerOptions['id'] . ' .cke_textarea_inline{height: ' . $this->editorOptions['height'] . 'px;}'); } else { $JavaScript = "CKEDITOR.replace("; $JavaScript .= Json::encode($this->options['id']); $JavaScript .= empty($this->editorOptions) ? '' : ', ' . Json::encode($this->editorOptions); $JavaScript .= ");"; $this->getView()->registerJs($JavaScript, View::POS_END); } }
/** * @inheritdoc */ public function run() { $this->registerAssets(); echo $this->hasModel() ? Html::activeTextarea($this->model, $this->attribute, $this->options) : Html::textarea($this->name, $this->value, $this->options); $clientOptions = empty($this->clientOptions) ? null : Json::encode($this->clientOptions); $this->getView()->registerJs('jQuery( "#' . $this->options['id'] . '" ).summernote(' . $clientOptions . ');'); }
/** * рисует виджет */ public function run() { $this->registerClientScript(); $attribute = $this->attribute; $value = $this->model->{$attribute}; return Html::textarea($this->fieldName, $value, ['id' => $this->fieldId]); }
private function renderFields() { $rows = ''; if (count($this->_config['fieldName'])) { foreach ($this->_config['fieldName'] as $ind => $n) { $search = []; $replace = []; $t = $this->_config['fieldType'][$ind]; $r = $this->_config['fieldRequired'][$ind]; //$opt = $r ? ['required'=>true] : []; $name = 'f' . $ind; $label = Html::label($n) . ($r ? $this->_config['tplMarker'] : ''); $search[] = '{*label*}'; $replace[] = $label; if ($t == 'input') { $opt['maxlength'] = 50; $tpl = 'tplInput'; $field = Html::textInput($name, null, $opt); } elseif ($t == 'textarea') { $opt['rows'] = 4; $opt['maxlength'] = 500; $tpl = 'tplArea'; $field = Html::textarea($name, '', $opt); } if (strpos($this->_config[$tpl], '{*label*}') === false && $r) { $field .= $this->_config['tplMarker']; } $search[] = '{*field*}'; $replace[] = $field; $rows .= str_replace($search, $replace, $this->_config[$tpl]) . "\n"; } } return $rows; }
/** * @inheritdoc */ public function run() { echo $this->hasModel() ? Html::activeTextarea($this->model, $this->attribute, $this->options) : Html::textarea($this->name, $this->value, $this->options); $this->clientOptions['onImageUpload'] = new JsExpression("function(files){summerNoteImgUpload(files[0], '" . $this->options['id'] . "','" . $this->imgServer . "')}"); $clientOptions = empty($this->clientOptions) ? null : Json::encode($this->clientOptions); $this->getView()->registerJs('jQuery( "#' . $this->options['id'] . '" ).summernote(' . $clientOptions . ');'); }
protected function set_input_type($type, $name, $value) { if (isset($type) && isset($name) && isset($value)) { $input = NULL; $input_name = $name . '[value]'; switch ($type) { case 'string': $input = Html::input('text', $input_name, $value, ['class' => 'form-control', 'placeholder' => 'Значение пустое...']); break; case 'integer': $input = Html::input('number', $input_name, $value, ['class' => 'form-control', 'placeholder' => 'Значение пустое...']); break; case 'text': $input = Html::textarea($input_name, $value, ['class' => 'form-control', 'placeholder' => 'Значение пустое...']); break; case 'boolean': $input = Switchery::widget(['name' => $input_name, 'clientOptions' => ['color' => '#64bd63', 'secondaryColor' => '#dfdfdf', 'jackColor' => '#fff', 'jackSecondaryColor' => null, 'className' => 'switchery', 'disabled' => FALSE, 'disabledOpacity' => 0.5, 'speed' => '0.1s', 'size' => 'default'], 'options' => array_merge(['value' => '1'], $this->has_checked($value))]); break; default: $input = Html::input('text', $input_name, $value, ['class' => 'form-control', 'placeholder' => 'Значение пустое...']); break; } return $input; } return FALSE; }
/** * @inheritdoc */ public function init() { parent::init(); switch ($this->thema) { case 'mini': $this->getMiniSetting(); break; case 'full': $this->getFullSetting(); break; default: $this->getDefaultSetting(); break; } //Додаємо поле для редактору та визначаємо ідентифікатор if (!isset($this->settings['selector'])) { $this->settings['selector'] = '#' . $this->options['id']; $this->_textarea = $this->hasModel() ? Html::activeTextarea($this->model, $this->attribute, $this->options) : Html::textarea($this->name, $this->value, $this->options); } /* Якщо [[options['selector']]] false видаляємо з налаштувань. */ if (isset($this->settings['selector']) && $this->settings['selector'] === false) { unset($this->settings['selector']); } if (empty($this->language)) { $this->language = Yii::$app->language; } $this->settings = ArrayHelper::merge($this->_defaultSettings, $this->settings); }
public function init() { parent::init(); Html::addCssClass($this->htmlOptions, 'custom-dz'); /** @var Image[] $files */ $files = Image::find()->where(['and', 'object_id = :objectId', 'object_model_id = :modelId'], [':objectId' => $this->objectId, ':modelId' => $this->modelId])->orderBy(['sort_order' => SORT_ASC])->all(); /** Image $file */ foreach ($files as $file) { $thumbnail_src = $file->getThumbnail('80x80'); $this->storedFiles[] = ['id' => $file->id, 'name' => $file->filename, 'file' => $file->file, 'thumbnail' => $thumbnail_src, 'description' => $file->image_description]; } $params = ArrayHelper::merge(isset($this->options['params']) ? $this->options['params'] : [], ['objectId' => $this->objectId, 'modelId' => $this->modelId]); $this->sortable = true; $this->options = ArrayHelper::merge($this->options, ['acceptedFiles' => 'image/*', 'params' => $params, 'previewTemplate' => '<div class="file-row"> ' . Html::input('hidden', 'id[]') . Html::input('hidden', 'file[]') . ' <!-- This is used as the file preview template --> <div> <span class="preview"><img style="width: 80px; height: 80px;" data-dz-thumbnail /></span> </div> <div> <p class="name" data-dz-name></p> <div class="dz-error-message"><span data-dz-errormessage></span></div> </div> <div class="description"> ' . Html::textarea('description', '', ['style' => 'width: 100%; min-width: 80px; height: 80px;']) . ' </div> <div> <p class="size" data-dz-size></p> <div class="dz-progress progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"> <div class="progress-bar progress-bar-success" style="width:0%;" data-dz-uploadprogress></div> </div> <div class="dz-success-mark"><span>✔</span> OK</div> <div class="dz-error-mark"><span>✘</span> ERROR</div> </div> <div> <button data-dz-remove class="btn btn-danger delete"> <i class="fa fa-trash-o"></i> <span>' . Yii::t('app', 'Delete') . '</span> </button> </div> </div>', 'thumbnailWidth' => '80', 'thumbnailHeight' => '80', 'previewsContainer' => "#{$this->id}"]); $this->eventHandlers = ['removedfile' => 'function(file) { jQuery.get( "' . Url::toRoute($this->removeUrl) . '", { "id" : jQuery(file.previewElement).find("[name=\\"id[]\\"]").val(), "filename" : jQuery(file.previewElement).data("filename") } ).done(function (data) { return data }); }', 'success' => 'function(file, response) { response = jQuery.parseJSON(response); jQuery(file.previewElement).find("[data-dz-name]").text(response.filename); jQuery(file.previewElement).data("filename", response.filename); jQuery(file.previewElement).find("[name=\\"id[]\\"]").val(response.afterUpload.id); jQuery(file.previewElement).find("[name=\\"file[]\\"]").val(response.afterUpload.file); jQuery(file.previewElement).find(".description textarea").attr("name", "description["+response.afterUpload.id+"]"); }', 'complete' => 'function(file) { jQuery(file.previewElement).removeClass("dz-processing"); }']; }
protected function editable() { $id = $this->id; $autocompletion = $this->autocompletion ? 'true' : 'false'; if ($this->autocompletion) { $this->aceOptions['enableBasicAutocompletion'] = true; $this->aceOptions['enableSnippets'] = true; $this->aceOptions['enableLiveAutocompletion'] = false; } $aceOptions = Json::encode($this->aceOptions); $js = <<<JS (function(){ var aceEditorAutocompletion = {$autocompletion}; if (aceEditorAutocompletion) { ace.require("ace/ext/language_tools"); } {$this->varNameAceEditor} = ace.edit("{$id}"); {$this->varNameAceEditor}.setTheme("ace/theme/{$this->theme}"); {$this->varNameAceEditor}.getSession().setMode("ace/mode/{$this->mode}"); {$this->varNameAceEditor}.setOptions({$aceOptions}); })(); JS; $view = $this->getView(); $view->registerJs("\nvar {$this->varNameAceEditor} = {};\n", $view::POS_HEAD); $view->registerJs($js); if ($this->hasModel()) { return Html::activeTextarea($this->model, $this->attribute, $this->options); } return Html::textarea($this->name, $this->value, $this->options); }
public function run() { if ($this->hasModel()) { echo Html::activeTextarea($this->model, $this->attribute, $this->options); } else { echo Html::textarea($this->name, $this->value, $this->options); } }
public function run() { $this->registerClientScript(); if ($this->hasModel()) { return Html::activeTextarea($this->model, $this->attribute, ['id' => $this->id]); } else { return Html::textarea($this->id, $this->value, ['id' => $this->id]); } }
public function run() { Autogrow::widget(['selector' => '#' . $this->options['id']]); if ($this->hasModel()) { return Html::activeTextarea($this->model, $this->attribute, $this->options); } else { return Html::textarea($this->name, $this->value, $this->options); } }
/** * @inheritdoc */ public function run() { if ($this->hasModel()) { $content = Html::activeTextarea($this->model, $this->attribute, $this->options); } else { $content = Html::textarea($this->name, $this->value, $this->options); } return $content; }
/** * @inheritdoc */ public function run() { $this->registerClientScript(); if ($this->hasModel()) { echo Html::activeTextarea($this->model, $this->attribute, $this->options); } else { echo Html::textarea($this->name, $this->value, $this->options); } }
public function run() { JSMarkdownEditorAsset::register($this->getView()); $class = 'mdeditor_' . $this->id; $jsOptions = ArrayHelper::merge($this->jsOptions, ['uploader' => $this->uploader, 'preview' => $this->preview, 'images' => $this->images, 'uploaderData' => ['_csrf' => \Yii::$app->request->getCsrfToken()]]); $this->view->registerJs('var md_' . $class . ' = new MdEditor(".' . $class . '", ' . Json::encode($jsOptions) . ' )'); $this->options = ArrayHelper::merge($this->options, ['class' => $class]); return $this->hasModel() ? Html::activeTextarea($this->model, $this->attribute, $this->options) : Html::textarea($this->name, $this->value, $this->options); }
/** * @inheritdoc */ public function run() { if ($this->hasModel()) { echo Html::activeTextarea($this->model, $this->attribute, $this->options); } else { echo Html::textarea($this->name, $this->value, $this->options); } $this->registerAssets(); $this->_registerPlugin(); }
/** * @inheritdoc */ public function run() { $this->options = array_merge($this->inputOptions, $this->options, ['id' => $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->id]); if ($this->hasModel()) { echo Html::activeTextarea($this->model, $this->attribute, $this->options); } else { echo Html::textarea($this->name, $this->value, $this->options); } $this->registerUEditor(); }
/** * @inheritdoc */ public function run() { if ($this->hasModel()) { $output = Html::activeTextarea($this->model, $this->attribute, $this->options); } else { $output = Html::textarea($this->name, $this->value, $this->options); } $this->registerClientScript(); return $output; }
public function run() { if ($this->hasModel()) { echo Html::activeTextarea($this->model, $this->attribute, $this->htmlOptions); } else { $this->htmlOptions['id'] = $this->getId(); echo Html::textarea($this->name, $this->value, $this->htmlOptions); } $this->registerScripts(); }
/** * Renders the widget. */ public function run() { if (!is_null($this->model)) { echo Html::activeTextarea($this->model, $this->attribute, $this->htmlOptions); } else { echo Html::textarea($this->attribute, $this->value, $this->htmlOptions); } TinyMceAsset::register($this->getView())->language = $this->options['language']; $this->registerClientScript(); }
/** * @inheritdoc */ public function renderHtml() { if ($this->form !== null && $this->model !== null) { return $this->form->field($this->model, $this->attribute)->hint($this->hint)->textarea($this->options); } if ($this->model !== null) { return Html::activeTextarea($this->model, $this->attribute, $this->options); } return Html::textarea($this->name, $this->value, $this->options); }
public function run() { $view = $this->getView(); SummernoteAsset::register($view); if (ArrayHelper::getValue($this->clientOptions, 'lang', null)) { LanguageAsset::register($view)->language = $this->clientOptions['lang']; } echo $this->hasModel() ? Html::activeTextarea($this->model, $this->attribute, $this->options) : Html::textarea($this->name, $this->value, $this->options); $clientOptions = empty($this->clientOptions) ? null : Json::encode($this->clientOptions); $view->registerJs('jQuery( "#' . $this->options['id'] . '" ).summernote(' . $clientOptions . ');'); }
public function run() { $this->selector = '#' . $this->getId(); if (!is_null($this->model)) { echo Html::activeTextarea($this->model, $this->attribute, $this->htmlOptions); } else { echo Html::textarea($this->attribute, $this->value, $this->htmlOptions); } SummernoteAsset::register($this->getView()); $this->registerClientScript(); }
public function run() { if ($this->hasModel() && $this->form !== null) { echo $this->form->field($this->model, $this->attribute)->textarea($this->options); } elseif ($this->hasModel() && $this->form === null) { echo Html::activeTextarea($this->model, $this->attribute, $this->options); } else { echo Html::textarea($this->name, $this->value, $this->options); } $this->registerClientScript(); }
/** * Renders the widget. */ public function run() { $this->selector = '#' . $this->htmlOptions['id']; if (!is_null($this->model)) { echo Html::activeTextarea($this->model, $this->attribute, $this->htmlOptions); } else { echo Html::textarea($this->attribute, $this->value, $this->htmlOptions); } ImperaviRedactorAsset::register($this->getView())->setLang($this->options['lang']); $this->registerClientScript(); }
/** * Renders the widget. */ public function run() { $this->selector = '#' . $this->htmlOptions['id']; if (!is_null($this->model)) { echo Html::activeTextarea($this->model, $this->attribute, $this->htmlOptions); } else { echo Html::textarea($this->attribute, $this->value, $this->htmlOptions); } $this->registerRedactorAsset(); $this->registerClientScript(); }
/** * @inheritdoc */ public function run() { $this->registerClientScript(); if ($this->_renderTextarea === true) { if ($this->hasModel()) { return Html::activeTextarea($this->model, $this->attribute, $this->options); } else { return Html::textarea($this->name, $this->value, $this->options); } } }
public function run() { $this->options['id'] = $this->textAreaId; if ($this->hasModel()) { echo Html::activeTextarea($this->model, $this->attribute, $this->options); } else { echo Html::textarea($this->name, $this->value, $this->options); } $this->renderTokens(); $this->registerClientScript(); }
public function run() { MarkdownAsset::register($this->view)->js[] = 'js/locale/bootstrap-markdown.' . $this->language . '.js'; $options = ['autofocus' => false, 'language' => $this->language, 'footer' => "本站编辑器使用了 GFM (GitHub Flavored Markdown) 语法,关于此语法的说明,请 <a href=\"https://help.github.com/articles/github-flavored-markdown\" target=\"_blank\">点击此处</a> 获得更多帮助。"]; $clientOptions = yii\helpers\Json::htmlEncode($options); if (!$this->useUploadImage) { $js = "\$(\"[data-provide=markdown-textarea]\").markdown({$clientOptions})"; } else { $js = <<<JS \$("[data-provide=markdown-textarea]").markdown({ autofocus:false, language:'{$this->language}', footer:"本站编辑器使用了 GFM (GitHub Flavored Markdown) 语法,关于此语法的说明,请 <a href=\\"https://help.github.com/articles/github-flavored-markdown\\" target=\\"_blank\\">点击此处</a> 获得更多帮助。", buttons: [ [{},{ name: "groupLink", data: [{},{ name: "cmdImage", callback: function(e) { \$('#imageModal').modal(); var chunk, cursor, selected = e.getSelection(), content = e.getContent(), link; \$('#imageModal .btn-success').on('click', function(){ link = \$('#imageModal img').attr('src'); chunk = '图片描述'; var images = ''; if(link !== null && link !== '' && link !== 'http://') { var sanitizedLink = \$('<div>'+link+'</div>').text(); images = '!['+chunk+']('+sanitizedLink+' "'+chunk+'")\\n\\n'; } e.replaceSelection(images); cursor = selected.start+2; e.setSelection(cursor,cursor+chunk.length); \$(this).off('click'); }) } }] }] ], }); JS; } $this->view->registerJs($js); $html = ''; if ($this->hasModel()) { $html = Html::activeTextarea($this->model, $this->attribute, $this->options); } else { $html = Html::textarea($this->name, $this->value, $this->options); } if ($this->useUploadImage) { $html .= $this->render('modal'); } return $html; }