Exemplo n.º 1
0
 public function run()
 {
     BootstrapPluginAsset::register($this->getView());
     $this->registerClientEvents();
     $buttonDropdown = $this->renderDropdown();
     $items = $this->renderItems($this->items, $this->options);
     $content = $buttonDropdown . $items;
     return Html::tag('div', $content, $this->dropdownContainerOptions);
 }
Exemplo n.º 2
0
 /**
  * Registers a specific Bootstrap plugin and the related events
  * @param string $name the name of the Bootstrap plugin
  */
 protected function registerPlugin($name)
 {
     $view = $this->getView();
     BootstrapPluginAsset::register($view);
     $id = $this->options['id'];
     if ($this->clientOptions !== false) {
         $options = empty($this->clientOptions) ? '' : Json::htmlEncode($this->clientOptions);
         $js = "jQuery('#{$id}').{$name}({$options});";
         $view->registerJs($js);
     }
     $this->registerClientEvents();
 }
Exemplo n.º 3
0
 public function init()
 {
     parent::init();
     if (!in_array($this->toggle, [static::TOGGLE_DROPDOWN, static::TOGGLE_COLLAPSE])) {
         $this->toggle = static::TOGGLE_DROPDOWN;
     }
     foreach ($this->items as $key => $item) {
         $item = static::prepareItem($item);
         if ($item !== null) {
             $this->items[$key] = $item;
         } else {
             unset($this->items[$key]);
         }
     }
     BootstrapPluginAsset::register($this->getView());
 }
Exemplo n.º 4
0
 /**
  * Registers a specific Bootstrap plugin and the related events
  * @param string $name the name of the Bootstrap plugin
  */
 protected function registerPlugin($name)
 {
     $view = $this->getView();
     BootstrapPluginAsset::register($view);
     $id = $this->options['id'];
     if ($this->clientOptions !== false) {
         $options = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions);
         $js = "jQuery('#{$id}').{$name}({$options});";
         $view->registerJs($js);
     }
     if (!empty($this->clientEvents)) {
         $js = [];
         foreach ($this->clientEvents as $event => $handler) {
             $js[] = "jQuery('#{$id}').on('{$event}', {$handler});";
         }
         $view->registerJs(implode("\n", $js));
     }
 }
Exemplo n.º 5
0
 public function render($type)
 {
     // Obviously we need the bootstrap assets for this
     \yii\bootstrap\BootstrapPluginAsset::register($this->desktop->view);
     $glyph = $this->image;
     if (!$glyph) {
         $glyph = 'folder-open';
     }
     $attributes = ['class' => "glyphicon glyphicon-{$glyph}"];
     $styles = [];
     switch ($type) {
         case self::DISPLAY_DOCK:
             $styles = ['position' => 'relative', 'top' => '3px', 'font-size' => '16px', 'padding-right' => '5px'];
             break;
         case self::DISPLAY_TITLEBAR:
             $styles = ['float' => 'left', 'margin' => '4px 8px 0 0', 'font-size' => '20px'];
             break;
         case self::DISPLAY_DESKTOP:
             $styles = ['font-size' => '32px'];
             break;
     }
     Html::addCssStyle($attributes, $styles);
     return Html::tag('span', '', $attributes);
 }
Exemplo n.º 6
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     BootstrapPluginAsset::register($this->getView());
 }
Exemplo n.º 7
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     echo $this->renderItems($this->items, $this->options);
     BootstrapPluginAsset::register($this->getView());
 }
Exemplo n.º 8
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     echo Html::endTag('div');
     if ($this->padded) {
         echo Html::endTag('div');
     }
     echo Html::endTag('div');
     BootstrapPluginAsset::register($this->getView());
 }
Exemplo n.º 9
0
 /**
  * Registers the client assets for the widget
  */
 public function registerAssets()
 {
     $view = $this->getView();
     TreeViewAsset::register($view);
     if ($this->_hasBootstrap && $this->autoLoadBsPlugin) {
         BootstrapPluginAsset::register($view);
     }
     $this->pluginOptions += ['treeId' => $this->treeOptions['id'], 'detailId' => $this->detailOptions['id'], 'toolbarId' => $this->toolbarOptions['id'], 'wrapperId' => $this->treeWrapperOptions['id'], 'actions' => $this->nodeActions, 'modelClass' => $this->query->modelClass, 'formAction' => $this->nodeActions[Module::NODE_SAVE], 'formOptions' => $this->nodeFormOptions, 'currUrl' => Yii::$app->request->url, 'messages' => $this->clientMessages, 'alertFadeDuration' => $this->alertFadeDuration, 'enableCache' => ArrayHelper::getValue($this->cacheSettings, 'enableCache', true), 'cacheTimeout' => ArrayHelper::getValue($this->cacheSettings, 'cacheTimeout', 300000), 'showTooltips' => $this->showTooltips, 'isAdmin' => $this->isAdmin, 'showInactive' => $this->showInactive, 'softDelete' => $this->softDelete, 'iconsList' => $this->_iconsList, 'showFormButtons' => $this->showFormButtons, 'showIDAttribute' => $this->showIDAttribute, 'nodeView' => $this->nodeView, 'nodeAddlViews' => $this->nodeAddlViews, 'nodeSelected' => $this->_nodeSelected, 'breadcrumbs' => $this->breadcrumbs, 'multiple' => $this->multiple, 'allowNewRoots' => $this->allowNewRoots];
     $this->registerPlugin('treeview');
 }
Exemplo n.º 10
0
 public function init()
 {
     $model = $this->model;
     $this->id = strtolower(self::FORM_ID_PREF . str_replace("\\", "-", $model::className()));
     BootstrapPluginAsset::register($this->view);
 }
Exemplo n.º 11
0
<?php

use app\components\CategoryModel;
use yii\helpers\Url;
use app\modules\admin\widgets\Button;
\yii\bootstrap\BootstrapPluginAsset::register($this);
$this->title = Yii::$app->getModule('admin')->activeModules[$this->context->module->id]->title;
$baseUrl = '/admin/' . $this->context->moduleName;
$this->params['actions_buttons'] = [['tagName' => 'a', 'label' => Yii::t('admin', 'Create'), 'options' => ['href' => Url::to(['create'])], 'icon' => 'fa fa-plus', 'iconPosition' => Button::ICON_POSITION_LEFT, 'size' => Button::SIZE_SMALL, 'disabled' => false, 'block' => false, 'type' => Button::TYPE_CIRCLE]];
?>

<?php 
if (sizeof($cats) > 0) {
    ?>
    <table class="table table-hover">
        <tbody>
            <?php 
    foreach ($cats as $cat) {
        ?>
                <tr>
                    <td width="50"><?php 
        echo $cat->id;
        ?>
</td>
                    <td style="padding-left:  <?php 
        echo $cat->depth * 20;
        ?>
px;">
                        <?php 
        if (count($cat->children)) {
            ?>
Exemplo n.º 12
0
 public function run()
 {
     BootstrapPluginAsset::register($this->getView());
     BsRemoteModalAssets::register($this->getView());
     $this->_beginModal();
     $this->_beginContent();
     $this->_header();
     $this->_body();
     $this->_footer();
     $this->_endContent();
     $this->_endModal();
     $this->_scripts();
 }
Exemplo n.º 13
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     $attribute = $this->attribute;
     $buttons = [];
     foreach ($this->buttons as $button) {
         if (is_array($button)) {
             $name = $this->name ?: $this->model->{$this->attribute};
             $value = isset($button['value']) ? $button['value'] : $this->value;
             $checked = $value == $this->value;
             $options = isset($button['options']) ? $button['options'] : [];
             if (!isset($options['class'])) {
                 Html::addCssClass($options, 'btn btn-primary');
             }
             if ($checked) {
                 Html::addCssClass($options, 'active');
             }
             $buttons[] = Html::radio($name, $checked, ['label' => $button['label'], 'value' => $value, 'uncheck' => null, 'labelOptions' => $options]);
         } else {
             $buttons[] = $button;
         }
     }
     $view = $this->getView();
     BootstrapPluginAsset::register($view);
     $view->registerJs('
         $(".button-group-wrapper .btn").button();
     ');
     return Html::tag('div', ButtonGroup::widget(['options' => ['class' => 'btn-group btn-toggle', ' data-toggle' => 'buttons'], 'buttons' => $buttons]), ['class' => 'button-group-wrapper']);
 }
Exemplo n.º 14
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     Html::addCssClass($footerOptions, 'box-footer');
     echo Html::endTag('div');
     if (!empty($this->footer)) {
         echo Html::beginTag('div', $footerOptions);
         echo $this->footer;
         echo Html::endTag('div');
     }
     echo Html::endTag('div');
     BootstrapPluginAsset::register($this->getView());
 }
Exemplo n.º 15
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     echo Html::endTag('div');
     if ($this->type == 'small') {
         echo Html::beginTag('div', ['class' => 'icon']);
         echo '<i class="' . $this->icon . '"></i>';
         echo Html::endTag('div');
         Html::addCssClass($this->footerOptions, 'small-box-footer');
         echo Html::a($this->footer, $this->link, $this->footerOptions);
     } else {
         if ($this->type == 'tiles') {
         } else {
             Html::addCssClass($this->footerOptions, 'box-footer');
             echo Html::beginTag('div', $this->footerOptions);
             echo $this->footer;
             echo Html::endTag('div');
         }
     }
     echo Html::endTag('div');
     BootstrapPluginAsset::register($this->getView());
 }
Exemplo n.º 16
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     $tag = ArrayHelper::remove($this->containerOptions, 'tag', 'div');
     echo Html::endTag($tag);
     if ($this->renderInnerContainer) {
         echo Html::endTag('div');
     }
     $tag = ArrayHelper::remove($this->options, 'tag', 'nav');
     echo Html::endTag($tag, $this->options);
     BootstrapPluginAsset::register($this->getView());
 }
Exemplo n.º 17
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     BootstrapPluginAsset::register($this->getView());
     $this->registerClientEvents();
     return $this->renderItems($this->items, $this->options);
 }
Exemplo n.º 18
0
    /**
     * Register client side
     */
    public function registerAssets($view)
    {
        BootstrapPluginAsset::register($view);
        $queue = ArrayHelper::remove($this->clientOptions, 'queue');
        $strollToPopover = ArrayHelper::remove($this->clientOptions, 'strollToPopover');
        $strollToFirstPopover = ArrayHelper::remove($this->clientOptions, 'strollToFirstPopover');
        $showBg = ArrayHelper::remove($this->clientOptions, 'showBg');
        $scrollOptions = ArrayHelper::remove($this->clientOptions, 'scrollOptions', []);
        $scrollOptions = ArrayHelper::merge(['duration' => 500], $scrollOptions);
        $id = $this->options['id'];
        $script = '$("#' . $id . '").popover(' . Json::encode($this->clientOptions) . ')
                        .on("hidden.bs.popover", function () {
                                if(disposableHintQueue.length && ' . ($queue ? 1 : 0) . '){
                                    var $next       = $(disposableHintQueue.shift()).popover("show");
                                    ' . ($strollToPopover ? 'disposableHintScrollTo($next);' : '') . '
                                }else{
                                    $(".bg-disposable-hint").removeClass("show").hide();
                                }
                        });';
        foreach ($this->clientEvents as $event => $handler) {
            $script .= '$("#' . $id . '").on("' . $event . '" ,' . new JsExpression($handler) . ');';
        }
        if ($queue) {
            $script .= '
                disposableHintQueue.push("#' . $id . '");
            ';
        } else {
            $script .= '
                $("#' . $id . '").popover("show");
            ';
        }
        $view->registerJs($script);
        if (self::$showBg === false && $showBg) {
            $view->on($view::EVENT_END_BODY, function ($event) {
                echo Html::tag('div', '', ['class' => 'bg-disposable-hint modal-backdrop fade in show']);
            });
            self::$showBg = true;
        }
        if (self::$loaded === false) {
            $script = '';
            if ($strollToFirstPopover) {
                $script .= '
                    if(disposableHintQueue.length){
                        disposableHintScrollTo($(disposableHintQueue.shift()).popover("show"));
                    }
                ';
            } else {
                $script .= '
                    if(disposableHintQueue.length){
                        $(disposableHintQueue.shift()).popover("show");
                    }
                ';
            }
            $script .= '
                $(document).on("click",".disposable-hint-btn",function(){
                        var $cont = $($(this).attr("data-trigger"));
                        var id    = parseInt($cont.attr("data-id"));
                        if(!id){
                            return false;
                        }
                        $.ajax({
                            url: "' . Url::to(['/' . $this->moduleId]) . '",
                            type: "POST",
                            dataType: "json",
                            data: {id:id},
                            beforeSend: function(){
                                $cont.popover("hide");
                                $("#' . $id . '").trigger("dhint.ajaxBeforeSend",[$cont,id]);
                            },
                            success: function(d){
                               $("#' . $id . '").trigger("dhint.ajaxSuccess",[$cont,id,d]);
                            },
                            complete:function(jqXHR,textStatus){
                                $("#' . $id . '").trigger("dhint.ajaxComplete",[$cont,id,jqXHR,textStatus]);
                            },
                            error:function(jqXHR,textStatus,message){
                                 $("#' . $id . '").trigger("dhint.ajaxError",[$cont,id,jqXHR,textStatus,message]);
                            },
                        });

                        return false;
                });

            ';
            $view->registerJs($script);
            $view->registerJs('
                var disposableHintQueue = [];
                var disposableHintScrollTo = function($next){
                    var settings    = $next.data("bs.popover");
                    var $tip        = settings.$tip;
                    var top         = $tip.offset().top - ($(window).height() - $tip.outerHeight(true))/2;
                    $("html").animate({scrollTop : top},' . Json::encode($scrollOptions) . ');
                }
            ', $view::POS_HEAD);
            self::$loaded = true;
        }
    }
Exemplo n.º 19
0
 /**
  * Register slider-specific assets(js, css, etc.)
  * @return void
  */
 public function registerAssets()
 {
     \yii\bootstrap\BootstrapPluginAsset::register($this->getView());
 }
Exemplo n.º 20
0
<?php

use hipanel\modules\domain\models\Domain;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\web\View;
/**
 * @var Domain $model
 */
$getPasswordUrl = Url::toRoute('get-password');
$changePasswordUrl = Url::toRoute('regen-password');
$errorMessage = Yii::t('hipanel', 'An error occurred. Try again please.');
$successMessage = Yii::t('hipanel:domain', 'The password has been changed');
\yii\bootstrap\BootstrapPluginAsset::register($view);
$view->registerJs(<<<JS

jQuery('#pincode-modal').on('shown.bs.modal', function () {
  \$('#pincode').focus();
});

jQuery('#pincode-modal').on('show.bs.modal', function (e) {
    jQuery('#pincode').val('');
    jQuery('#pincode-modal .form-group').removeClass('has-error');
    jQuery('#pincode-modal .help-block').text('');
});

jQuery('#get-authcode-button').on('click', function() {
    jQuery('#pincode-modal .form-group').removeClass('has-error');
    jQuery('#pincode-modal .help-block').text('');

    var btn = jQuery(this);