Пример #1
0
 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 = ['bajadev.ckEditor.registerOnChange(' . Json::encode($this->options['id']) . ');'];
     if (isset($this->editorOptions['filebrowserUploadUrl'])) {
         $js[] = "bajadev.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);
     }
 }
Пример #2
0
    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);
    }
Пример #3
0
 /**
  * @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);
 }
Пример #4
0
    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;
    }
Пример #5
0
 public function run()
 {
     $this->autoSavePath .= $this->parentType . '/' . $this->parentId;
     $this->options['id'] .= $this->parentId;
     $this->widgetOptions['id'] .= $this->parentId;
     switch ($this->_enableRevisions) {
         case true:
             $this->revisionsModel->setScenario('validateNew');
             $revisionOptions = ['role' => $this->options['role'], 'id' => $this->options['id'] . $this->parentId, 'data-dave-path' => $this->autoSavePath, 'data-use-redactor' => $this->enableRedactor];
             Asset::register($this->getView());
             break;
         default:
             $revisionOptions = [];
             break;
     }
     switch ($this->enableRedactor) {
         case true:
             $this->editorOptions['id'] = 'message' . uniqid();
             $this->editorOptions['model'] = $this->model;
             $this->editorOptions['attribute'] = $this->name;
             $this->editorOptions['options']['value'] = $this->value;
             $input = Editor::widget($this->editorOptions);
             break;
         default:
             $input = Html::activeTextarea($this->model, $this->name, $revisionOption);
             break;
     }
     $result = Html::tag('div', '', ['role' => 'revisionStatus']);
     echo Html::tag('div', $input . $result, $this->widgetOptions);
 }
 /**
  * @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 . ');');
 }
Пример #7
0
 /**
  * @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 . ');');
 }
Пример #8
0
 public function run()
 {
     $this->tagOptions['data-input'] = '#' . $this->options['id'];
     $this->options['style'] = 'display: none;';
     $this->registerClientScripts();
     echo Html::tag('div', Html::getAttributeValue($this->model, $this->attribute), $this->tagOptions);
     echo Html::activeTextarea($this->model, $this->attribute, $this->options);
 }
Пример #9
0
 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);
     }
 }
 /**
  * @param string $attribute
  *
  * @return string
  */
 public function getInputField($attribute)
 {
     if ($this->inputType == 'textArea') {
         return Html::activeTextarea($this->model, $attribute, $this->inputOptions);
     } else {
         return Html::activeTextInput($this->model, $attribute, $this->inputOptions);
     }
 }
 /**
  * Renders the widget.
  */
 public function renderInput()
 {
     Html::addCssClass($this->_displayOptions, 'element-' . $this->options['id']);
     Html::addCssClass($this->_displayOptions, 'form-control');
     $this->_displayOptions['rows'] = 1;
     $input = Html::activeTextarea($this->model, $this->attribute, $this->_displayOptions);
     echo $input;
 }
Пример #12
0
    public function run()
    {
        BootstrapMarkdownAsset::register($this->view);
        $this->view->registerJs('
            var markdown=$("#markdown-textarea").markdown({autofocus:true});

        ');
        return Html::activeTextarea($this->model, $this->attribute, $this->options);
    }
Пример #13
0
 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]);
     }
 }
 /**
  * @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;
 }
Пример #15
0
 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);
     }
 }
Пример #16
0
 public function run()
 {
     $view = $this->getView();
     MiniAssets::register($view);
     $initScript = $this->getInitScript();
     $view->registerJs($initScript);
     unset($this->options['clientOptions']);
     return Html::activeTextarea($this->model, $this->attribute, $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()
 {
     $this->registerClientScript();
     if ($this->hasModel()) {
         echo Html::activeTextarea($this->model, $this->attribute, $this->options);
     } else {
         echo Html::textarea($this->name, $this->value, $this->options);
     }
 }
Пример #19
0
 /**
  * @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();
 }
Пример #20
0
 /**
  * @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;
 }
Пример #21
0
 /**
  * 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 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();
 }
Пример #23
0
 /**
  * @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);
 }
Пример #24
0
 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();
 }
Пример #25
0
 /**
  * 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();
 }
 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();
 }
Пример #27
0
 /**
  * @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);
         }
     }
 }
Пример #28
0
 /**
  * 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();
 }
Пример #29
0
 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();
 }
Пример #30
0
 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();
 }