Пример #1
1
    function run()
    {
        parent::run();
        $wid = $this->options['id'];
        echo Html::activeHiddenInput($this->model, $this->attribute);
        echo Html::beginTag('div', ['id' => $wid . '-buttons', 'class' => 'input-group btn-group']);
        $items = PublishBehavior::getPublishedOptions();
        $colors = PublishBehavior::getPublishedColors();
        foreach ($items as $key => $item) {
            echo Html::button($item, ['data' => ['value' => $key], 'class' => $key == $this->model->{$this->attribute} ? 'btn btn-' . $colors[$key] . ' active' : 'btn btn-default']);
        }
        echo Html::endTag('div');
        $js_colors = Json::encode($colors);
        $js = <<<JS
 \$('#{$wid}-buttons').find('button').each(function(){
   \$(this).on('click',function(){
     \$('#{$wid}-buttons').find('button').each(function(){
        \$(this).removeClass('btn-danger btn-warning btn-success btn-info active');
        \$(this).addClass('btn-default');
     });
     var color={$js_colors};
     \$(this).removeClass('btn-default');
     \$(this).addClass('btn-'+color[\$(this).data('value')]+' active');
     \$('#{$wid}').val(\$(this).data('value'))
   });  
});               
JS;
        $this->view->registerJs($js);
    }
 /**
  * @inheritdoc
  */
 public function run()
 {
     parent::run();
     if ($this->hasModel()) {
         echo Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         echo Html::textInput($this->name, $this->value, $this->options);
     }
     $this->registerPlugin();
 }
Пример #3
0
 /**
  * {@inheritDoc}
  * @see \yii\base\Widget::run()
  */
 public function run()
 {
     if (isset($this->options['disabled'])) {
         $this->disabled = true;
     }
     $this->applyPluginSettings();
     parent::run();
     if (method_exists($this, 'renderWidget')) {
         $this->renderWidget();
     }
 }
Пример #4
0
 public function run()
 {
     //        echo '<table class="table table-bordered">';
     //        foreach ($this->view->params[$this->name] as $item) {
     //            echo '<tr>';
     //            foreach($item as $value) {
     //                echo '<td>';
     //                echo $value;
     //                echo '</td>';
     //            }
     //            echo '</tr>';
     //        }
     //        echo '</table>';
     parent::run();
 }
Пример #5
0
 public function run()
 {
     echo '<table class="table table-bordered">';
     foreach ($this->view->params[$this->name] as $item) {
         echo '<tr>';
         if (is_array($item)) {
             foreach ($item as $value) {
                 echo '<td>';
                 echo $value;
                 echo '</td>';
             }
         } else {
             echo $item;
         }
         echo '</tr>';
     }
     echo '</table>';
     parent::run();
 }
    public function run()
    {
        parent::run();
        DateTimePickerAsset::register($this->view);
        echo $this->renderInput();
        if ($this->renderIcon) {
            echo $this->renderIcon;
        }
        $js = 'jQuery(\'#' . $this->getId() . '\').datetimepicker(' . Json::encode($this->getClientOptions()) . ');';
        if ($this->renderIcon) {
            $js .= 'jQuery(\'#' . $this->getId() . '\').next().on(\'click\', function(){
    var $input = jQuery(\'#' . $this->getId() . '\');
    if(!$input.attr(\'disabled\') && !$input.attr(\'readonly\')){
        $input.datetimepicker(\'show\');
    }
    return false;
});';
        }
        $this->view->registerJs($js);
    }
 public function run()
 {
     parent::run();
     echo Html::beginTag($tag = ArrayHelper::remove($this->options, 'tag', 'div'), $this->options);
     echo Html::beginTag($listTag = ArrayHelper::remove($this->listOptions, 'tag', 'div'), $this->listOptions);
     if ($values = $this->hasModel() ? $this->model->{$this->attribute} : $this->value) {
         foreach ($values as $key => $value) {
             echo $this->renderItem($key, $value);
         }
     } else {
         echo $this->renderItem(null, null);
     }
     echo Html::endTag($listTag);
     if (is_callable($this->addLinkOptions)) {
         echo call_user_func($this->addLinkOptions, $this->renderItem(null, null), $this);
     } else {
         Html::addCssClass($this->addLinkOptions, $this->addLinkClass());
         $this->addLinkOptions['data-sample-item'] = $this->renderItem(null, null);
         echo Html::a(Html::tag('span', '', ['class' => 'glyphicon glyphicon-plus']) . self::t('multistring', 'Add...'), '#', $this->addLinkOptions);
     }
     echo Html::endTag($tag);
     $this->view->registerJs('jQuery(\'#' . $this->getId() . '\').multiString(' . Json::encode($this->clientOptions) . ')');
 }
 /**
  * Run widget
  */
 public function run()
 {
     parent::run();
     if (!isset($this->wrapperOptions)) {
         $this->wrapperOptions = [];
     }
     if (!isset($this->wrapperOptions['id'])) {
         $this->wrapperOptions['id'] = $this->id;
     }
     if (!isset($this->wrapperOptions['style'])) {
         $this->wrapperOptions['style'] = 'width: 100%; height: 500px;';
     }
     SelectMapLocationAssets::$googleMapApiKey = $this->googleMapApiKey;
     SelectMapLocationAssets::register($this->view);
     // getting inputs ids
     $address = Html::getInputId($this->model, $this->attribute);
     $latitude = Html::getInputId($this->model, $this->attributeLatitude);
     $longitude = Html::getInputId($this->model, $this->attributeLongitude);
     $jsOptions = ArrayHelper::merge($this->jsOptions, ['address' => '#' . $address, 'latitude' => '#' . $latitude, 'longitude' => '#' . $longitude, 'draggable' => $this->draggable]);
     // message about not founded addess
     if (!isset($jsOptions['addressNotFound'])) {
         $hasMainCategory = isset(Yii::$app->i18n->translations['*']) || isset(Yii::$app->i18n->translations['main']);
         $jsOptions['addressNotFound'] = $hasMainCategory ? Yii::t('main', 'Address not found') : 'Address not found';
     }
     $this->view->registerJs(new JsExpression('
         $(document).ready(function() {
             $(\'#' . $this->wrapperOptions['id'] . '\').selectLocation(' . Json::encode($jsOptions) . ');
         });
     '));
     $mapHtml = Html::tag('div', '', $this->wrapperOptions);
     $mapHtml .= Html::activeHiddenInput($this->model, $this->attributeLatitude);
     $mapHtml .= Html::activeHiddenInput($this->model, $this->attributeLongitude);
     if (is_callable($this->renderWidgetMap)) {
         return call_user_func_array($this->renderWidgetMap, [$mapHtml]);
     }
     return Html::activeInput('text', $this->model, $this->attribute, $this->textOptions) . $mapHtml;
 }
 /**
  * @inheritdoc
  */
 public function run()
 {
     parent::run();
     $view = $this->getView();
     if (is_array($this->maskOptions)) {
         if ($this->hasModel()) {
             $this->maskOptions = ArrayHelper::merge($this->maskOptions, ['options' => $this->options, 'model' => $this->model, 'attribute' => $this->attribute]);
         } else {
             $this->maskOptions = ArrayHelper::merge($this->maskOptions, ['options' => $this->options, 'name' => $this->name, 'value' => $this->value]);
         }
         $input = MaskedInput::widget($this->maskOptions);
     } else {
         $input = $this->hasModel() ? Html::activeTextInput($this->model, $this->attribute, $this->options) : Html::textInput($this->name, $this->value, $this->options);
     }
     $options = Json::encode($this->pluginOptions);
     $callback = isset($this->callback) ? ", {$this->callback}" : '';
     $script = "moment.locale('{$this->locale}');";
     $script .= "\$('#{$this->options['id']}').daterangepicker({$options}{$callback});";
     $view->registerJs($script);
     echo strtr($this->template, ['{input}' => $input]);
     MomentAsset::$locale = $this->locale;
     MomentAsset::register($view);
     DateRangePickerAsset::register($view);
 }
Пример #10
0
    public function run()
    {
        //prepare data
        $view = $this->getView();
        //render input for results
        if ($this->_renderInput) {
            if ($this->hasModel()) {
                echo Html::activeHiddenInput($this->model, $this->attribute, $this->options);
            } else {
                echo Html::hiddenInput($this->name, $this->value, $this->options);
            }
        }
        //render editor container
        $containerOptions = $this->containerOptions;
        $tag = ArrayHelper::remove($containerOptions, 'tag', 'div');
        echo Html::tag($tag, '', $containerOptions);
        //prepare client options
        $clientOptions = $this->clientOptions;
        $clientOptions['schema'] = $this->schema;
        ArrayHelper::remove($clientOptions, 'startval');
        $clientOptions = Json::encode($clientOptions);
        //prepare element IDs
        $widgetId = $this->id;
        $inputId = $this->inputId;
        $containerId = $this->containerOptions['id'];
        //register js code
        $view->registerJs(<<<JS
var {$widgetId} = new JSONEditor(document.getElementById('{$containerId}'), {$clientOptions});
try {
    var initialValue = JSON.parse(document.getElementById('{$inputId}').value);
    {$widgetId}.setValue(initialValue);
} catch (e) {
    console.log('Could not parse initial value for {$widgetId}');
}
{$widgetId}.on('change', function() {
    document.getElementById('{$inputId}').value = JSON.stringify({$widgetId}.getValue());
});
JS
, $view::POS_READY);
        parent::run();
    }
Пример #11
0
 /**
  * @return string
  */
 public function run()
 {
     parent::run();
     $this->registerJs();
     return $this->hasModel() ? Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options) : Html::dropDownList($this->name, $this->value, $this->items, $this->options);
 }
Пример #12
0
 public function run()
 {
     parent::run();
     $this->renderWidget();
 }
Пример #13
0
 /**
  * Run the widget
  */
 public function run()
 {
     parent::run();
     if ($this->showExport) {
         echo $this->renderExportForm();
     }
     echo Html::endTag('div');
     echo Html::endTag('div');
 }
Пример #14
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     parent::run();
     $this->registerAssets();
     echo $this->renderInput();
 }
Пример #15
0
 public function run()
 {
     \yii\jui\AutoComplete::widget();
     parent::run();
 }
Пример #16
0
 public function run()
 {
     parent::run();
     $this->registerAssets();
     $this->initLayout();
     $template = preg_replace_callback("/{\\w+}/", function ($matches) {
         $template = $this->renderSection($matches[0]);
         return $template === false ? $matches[0] : $template;
     }, $this->layouts);
     $this->renderLayout($template);
 }
 public function run()
 {
     //prepare data
     $view = $this->getView();
     //render input for results
     if ($this->_renderInput) {
         if ($this->hasModel()) {
             echo Html::activeHiddenInput($this->model, $this->attribute, $this->options);
         } else {
             echo Html::hiddenInput($this->name, $this->value, $this->options);
         }
     }
     //render editor container
     $containerOptions = $this->containerOptions;
     $tag = ArrayHelper::remove($containerOptions, 'tag', 'div');
     echo Html::tag($tag, '', $containerOptions);
     //prepare client options
     $clientOptions = $this->clientOptions;
     $clientOptions['schema'] = $this->schema;
     ArrayHelper::remove($clientOptions, 'startval');
     $clientOptions = Json::encode($clientOptions);
     //prepare element IDs
     $widgetId = $this->id;
     $inputId = $this->inputId;
     $containerId = $this->containerOptions['id'];
     if ($this->enableSelectize) {
         $view->registerJs("JSONEditor.plugins.selectize.enable = true;\n", $view::POS_READY, 'JSONEditorEnableSelectize');
     }
     $widgetJs = "var {$widgetId} = new JSONEditor(document.getElementById('{$containerId}'), {$clientOptions});\n";
     $readyFunction = '';
     try {
         $parsedValue = Json::decode($this->value);
     } catch (\Exception $e) {
         $parsedValue = null;
     }
     if (!empty($parsedValue)) {
         $encodedValue = Json::encode($parsedValue);
         $readyFunction .= "try { {$widgetId}.setValue({$encodedValue}); } catch (e) { console.warn('Could not parse initial value for {$widgetId}, error: '+e); }\n";
     }
     $readyFunction .= "{$widgetId}.on('change', function() { document.getElementById('{$inputId}').value = JSON.stringify({$widgetId}.getValue()); });\n";
     $widgetJs .= "{$widgetId}.on('ready', function() {\n{$readyFunction}\n});";
     //register js code
     $view->registerJs($widgetJs, $view::POS_READY);
     parent::run();
 }
Пример #18
0
 public function run()
 {
     $this->params = ArrayHelper::merge($this->params, ['decimals' => $this->decimals, 'percent' => $this->percent, self::THOUSANDS_SEPARATOR => $this->thousandsSeparator, self::DECIMAL_SEPARATOR => $this->decimalSeparator]);
     return parent::run();
 }
Пример #19
0
 public function run()
 {
     parent::run();
     echo $this->attribute;
 }
Пример #20
0
 public function run()
 {
     $this->registerWidget();
     echo $this->renderWidget();
     parent::run();
 }