/** * @return string */ public function run() { \common\widgets\jsoneditor\assets\JsonEditorAsset::register($this->view); $content = '<div id="' . $this->fieldId . '_holder" ></div>'; $content .= '<style>.tab-content > .tab-pane label { padding-top:30px; padding-left:15px;}</style>'; $content .= '<style>.tab-content > .tab-pane input { padding:3px;}</style>'; $content .= '<style>.tab-content > .tab-pane .container-fluid { padding-bottom:30px;}</style>'; $content .= '<style>.sceditor-button div { margin-left: -3px; margin-top: -3px;} .sceditor-button {margin: 2px;} </style>'; $content .= '<style>.select2-container-multi { border: none; padding: 0;} </style>'; $content .= '<style>.select2-container { border: none; padding: 0;} </style>'; $conf = ['fieldId' => $this->fieldId, 'options' => $this->options, 'debug' => YII_DEBUG]; $js = 'var conf = \'' . json_encode($conf) . '\';'; $js .= file_get_contents(Yii::getAlias('@common/widgets/jsoneditor/assets/js/init.js')); $this->view->registerJs($js); return $content; }
/** * @return string */ public function run() { \common\widgets\jsoneditor\assets\JsonEditorAsset::register($this->view); $content = '<div id="' . $this->fieldId . '_holder" ></div>'; $content .= '<style>.tab-content > .tab-pane label { padding-top:30px; padding-left:15px;}</style>'; $content .= '<style>.tab-content > .tab-pane input { padding:3px;}</style>'; $content .= '<style>.tab-content > .tab-pane .container-fluid { padding-bottom:30px;}</style>'; $content .= '<style>.sceditor-button div { margin-left: -3px; margin-top: -3px;} .sceditor-button {margin: 2px;} </style>'; $content .= '<style>.select2-container-multi { border: none; padding: 0;} </style>'; $content .= '<style>.select2-container { border: none; padding: 0;} </style>'; $conf = ['fieldId' => $this->fieldId, 'options' => $this->options, 'debug' => YII_DEBUG]; //$js = 'var conf = \'' . json_encode($conf) . '\';'; //$js .= file_get_contents(Yii::getAlias('@common/widgets/jsoneditor/assets/js/init.js')); $fieldIdForJS = $this->fieldId; $fieldIdForJS = str_replace('_', '__', $fieldIdForJS); $fieldIdForJS = str_replace('-', '_', $fieldIdForJS); $step = intval(str_replace('w', '', $this->id)) * 1000; $js = file_get_contents(Yii::getAlias('@common/widgets/jsoneditor/assets/js/init.js')); $js .= 'window.conf_' . $fieldIdForJS . ' = $.parseJSON(\'' . json_encode($conf) . '\'); dump(conf_' . $fieldIdForJS . '); setTimeout(function() { initialize(conf_' . $fieldIdForJS . ');}, ' . $step . ');'; $this->view->registerJs($js); return $content; }