Skip to content

Commit

Permalink
add params
Browse files Browse the repository at this point in the history
  • Loading branch information
cui-liang committed Aug 27, 2017
1 parent 053c60f commit 64aa320
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion MdEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,38 @@
namespace yiichina\mdeditor;

use yii\Helpers\Html;
use yii\helpers\Json;

/**
* This is just an example.
*/
class MdEditor extends \yii\widgets\InputWidget
{
public $debug = false;
public $codeMirror;
public $buttons;
public $disabledButtons;

public function init()
{
parent::init();
$view = $this->getView();
MdEditorAsset::register($view);
$view->registerJs("$(\"#{$this->options['id']}\").mdEditor()");
$optionsArray = [];
if($this->debug)) {
$optionsArray['debug'] = true;
}
if(empty($this->codeMirror)) {
$optionsArray['codeMirror'] = $this->codeMirror;
}
if(empty($this->buttons)) {
$optionsArray['buttons'] = $this->buttons;
}
if(empty($this->codeMirror)) {
$optionsArray['disabledButtons'] = $this->disabledButtons;
}
$options = Json::encode($optionsArray);
$view->registerJs("$(\"#{$this->options['id']}\").mdEditor($options)");
}

public function run()
Expand Down

0 comments on commit 64aa320

Please sign in to comment.