Esempio n. 1
0
 /**
  * Register widget scripts
  */
 public function registerClientScript()
 {
     $view = $this->getView();
     YiiAsset::register($view);
     if ($this->items['batch-delete']['visible'] === true) {
         $view->registerJs("jQuery(document).on('click', '#batch-delete', function (evt) {\n                evt.preventDefault();\n                var keys = jQuery('#" . $this->gridId . "').yiiGridView('getSelectedRows');\n                if (keys == '') {\n                    alert('" . Yii::t('control', 'BATCH_DELETE_NOT_SELECTED') . "');\n                } else {\n                    if (confirm('" . Yii::t('control', 'BATCH_DELETE_CONFIRMATION') . "')) {\n                        jQuery.ajax({\n                            type: 'POST',\n                            url: jQuery(this).attr('href'),\n                            data: { ids: keys}\n                        });\n                    }\n                }\n            });");
     }
 }
 public function init()
 {
     parent::init();
     $jsFile = '@app/views/' . $this->id . '/ajax.js';
     // Publish and register the required JS file
     Yii::$app->assetManager->publish($jsFile);
     $this->getView()->registerJsFile(Yii::$app->assetManager->getPublishedUrl($jsFile), ['depends' => [\yii\web\YiiAsset::className()]]);
 }
 /**
  * @inheritdoc
  */
 protected function publishExtensionResources()
 {
     /** @var View $resourceManager */
     $resourceManager = $this->getResourceManager();
     // Initialization of extension resources
     $assetsExt = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . 'assets';
     $assetsPaths = \Yii::$app->getAssetManager()->publish($assetsExt);
     // [0] - path, [1] - URL
     $resourceManager->registerJsFile($assetsPaths[1] . '/resource-smart-load.js', ['depends' => [\yii\web\JqueryAsset::className(), \yii\web\YiiAsset::className()]]);
 }
Esempio n. 4
0
 private function registerClientScripts()
 {
     $view = $this->getView();
     YiiAsset::register($view);
     $view->registerJs("jQuery(document).on('click', '#batch-delete', function (evt) {" . "evt.preventDefault();" . "var keys = jQuery('#" . $this->id . "').yiiGridView('getSelectedRows');" . "if (keys == '') {" . "alert('" . \Yii::t('theme/widgets/box', 'You need to select at least one item.') . "');" . "} else {" . "if (confirm('" . \Yii::t('theme/widgets/box', 'Are you sure you want to delete selected items?') . "')) {" . "jQuery.ajax({" . "type: 'POST'," . "url: jQuery(this).attr('href')," . "data: { " . $this->batchParam . ": keys}" . "});" . "}" . "}" . "});" . "\$('#table-{$this->id}').on('click', 'a', function(e) {" . "if (\$(this).attr('ajax')) { return true; }" . "e.preventDefault();" . "var self = this;" . "\$.ajax({" . "url: \$(self).attr('href')," . "dataType: 'html'," . "cache: false," . "type: 'post'," . "data: {ajax: true}," . "success: function(html) {" . "\$('#table-{$this->id}').html(html);" . "\$('#box-{$this->id}').find('a#button-up').attr('href', \$('#{$this->id}').attr('buttonup'));" . "history.pushState(null, null, \$(self).attr('href'));" . "var parent = location.search.replace('?','').split('&').reduce(function(s,c){var t=c.split('=');s[t[0]]=t[1];return s;},{})['parent'];" . "if (\$('#box-{$this->id}').find('input[name=\\'parent\\']').length) {" . "\$('#box-{$this->id}').find('input[name=\\'parent\\']').attr('value', parent);" . "} else {" . "\$('#box-{$this->id}').find('form').append('<input type=\"hidden\" name=\"parent\" value=\"'+ parent +'\">');" . "}" . "}," . "});" . "});" . "\$('#box-{$this->id}').on('click', 'a#button-up', function(e) {" . "e.preventDefault();" . "var self = this;" . "\$.ajax({" . "url: \$(self).attr('href')," . "dataType: 'html'," . "cache: false," . "type: 'post'," . "data: {ajax: true}," . "success: function(html) {" . "\$('#table-{$this->id}').html(html);" . "history.pushState(null, null, \$(self).attr('href'));" . "\$('#box-{$this->id}').find('a#button-up').attr('href', \$('#{$this->id}').attr('buttonup'));" . "var parent = location.search.replace('?','').split('&').reduce(function(s,c){var t=c.split('=');s[t[0]]=t[1];return s;},{})['parent'];" . "if (\$('#box-{$this->id}').find('input[name=\\'parent\\']').length) {" . "\$('#box-{$this->id}').find('input[name=\\'parent\\']').attr('value', parent);" . "} else {" . "\$('#box-{$this->id}').find('form').append('<input type=\"hidden\" name=\"parent\" value=\"'+ parent +'\">');" . "}" . "}," . "});" . "});");
     /*        $view->registerJs(''
               . '$(function () {'
               . "$('#{$this->id}').dataTable({"
               . '"bPaginate": true,'
               . '"bLengthChange": false,'
               . '"bFilter": false,'
               . '"bSort": true,'
               . '"bAutoWidth": false,'
               . '"bInfo": true,'
               . '});'
               . '});'); */
 }
Esempio n. 5
0
<style>
    form > div.row > div.col-lg-8 {
        width: 100%;
    }
</style>
<?php 
$addition = isset($addition) ? $addition : '';
$notVisible = isset($notVisible) && is_array($notVisible) ? $notVisible : [];
$titleBox = isset($titleBox) ? $titleBox : 'Origin table';
/* @var $this yii\web\View */
/* @var $form yii\widgets\ActiveForm */
/* @var $generator \infinitydevphp\gii\table\Generator */
use insolita\wgadminlte\Box;
\yii\web\YiiAsset::register($this);
\insolita\wgadminlte\JCookieAsset::register($this);
insolita\wgadminlte\ExtAdminlteAsset::register($this);
\dmstr\web\AdminLteAsset::register($this);
if (!in_array('db', $notVisible)) {
    echo $form->field($generator, $addition . 'db');
}
if (!in_array('migrationPath', $notVisible)) {
    echo $form->field($generator, $addition . 'migrationPath');
}
if (!in_array('useTablePrefix', $notVisible)) {
    echo $form->field($generator, $addition . 'useTablePrefix')->checkbox();
}
Box::begin(['type' => Box::TYPE_PRIMARY, 'withBorder' => true, 'title' => $titleBox, 'collapse' => true]);
if (!in_array('migrationName', $notVisible)) {
    echo $form->field($generator, $addition . 'migrationName')->hiddenInput()->label(false);
}
if (!in_array('tableName', $notVisible)) {
Esempio n. 6
0
<?php

use yii\helpers\Html;
use yii\helpers\Json;
use mdm\admin\AnimateAsset;
use yii\web\YiiAsset;
/* @var $this yii\web\View */
/* @var $routes [] */
$this->title = Yii::t('rbac-admin', 'Routes');
$this->params['breadcrumbs'][] = $this->title;
AnimateAsset::register($this);
YiiAsset::register($this);
$opts = Json::htmlEncode(['routes' => $routes]);
$this->registerJs("var _opts = {$opts};");
$this->registerJs($this->render('_script.js'));
$animateIcon = ' <i class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></i>';
?>
<h1><?php 
echo Html::encode($this->title);
?>
</h1>
<div class="row">
    <div class="col-sm-11">
        <div class="input-group">
            <input id="inp-route" type="text" class="form-control"
                   placeholder="<?php 
echo Yii::t('rbac-admin', 'New route(s)');
?>
">
            <span class="input-group-btn">
                <?php 
Esempio n. 7
0
 /**
  * Register widgets assets bundles.
  */
 protected function registerClientScripts()
 {
     if (strpos($this->buttonsTemplate, '{delete}') !== false && isset($this->buttons['delete'])) {
         YiiAsset::register($this->getView());
     }
     if (strpos($this->buttonsTemplate, '{batch-delete}') !== false && $this->grid !== null && isset($this->buttons['batch-delete'])) {
         $view = $this->getView();
         YiiAsset::register($view);
         $view->registerJs("jQuery(document).on('click', '#batch-delete', function (evt) {" . "evt.preventDefault();" . "var keys = jQuery('#" . $this->grid . "').yiiGridView('getSelectedRows');" . "if (keys == '') {" . "alert('" . Yii::t('theme/widgets/box', 'You need to select at least one item.') . "');" . "} else {" . "if (confirm('" . Yii::t('theme/widgets/box', 'Are you sure you want to delete selected items?') . "')) {" . "jQuery.ajax({" . "type: 'POST'," . "url: jQuery(this).attr('href')," . "data: { " . $this->batchParam . ": keys}" . "});" . "}" . "}" . "});");
     }
 }
Esempio n. 8
0
 public function renderTableFooter()
 {
     $html = "var html = '';\n";
     foreach ($this->columns as $column) {
         $html .= "html += '" . str_replace("\n", "';\nhtml += '", $column->renderFooterCellJS($this->createModel)) . "';\n";
     }
     $view = $this->getView();
     YiiAsset::register($view);
     $view->registerJs("\$('#{$this->id}').on('click', 'a#button-create', function(e) {" . "var self = this;" . "var str = {};" . "str = \$('#{$this->id}').children('table').data('defaultvalue');" . "str.ajax = true;" . "\$.ajax({" . "url: \$(self).attr('href')," . "dataType: 'html'," . "cache: false," . "type: 'post'," . "data: str," . "success: function(data) {" . "var data = \$.parseJSON(data);" . $html . "var tbody = \$('#{$this->id}').find('tbody');" . "tbody.append('<tr data-key='+ data.id +'>'+html+'</tr>');" . "}," . "});" . "return false;" . "});");
     $cells = [];
     foreach ($this->columns as $column) {
         $cells[] = $column->renderFooterCell();
     }
     $content = Html::tag('tr', implode('', $cells), $this->footerRowOptions);
     return "<tfoot>\n" . $content . "\n</tfoot>";
 }
Esempio n. 9
0
 /**
  * Register widgets assets bundles.
  */
 protected function registerClientScripts()
 {
     if (strpos($this->buttonsTemplate, '{delete}') !== false && isset($this->buttons['delete'])) {
         YiiAsset::register($this->getView());
     }
     if (strpos($this->buttonsTemplate, '{mass-delete}') !== false && $this->grid !== null && isset($this->buttons['mass-delete'])) {
         $view = $this->getView();
         YiiAsset::register($view);
         $view->registerJs("jQuery(document).on('click', '#mass-delete', function (evt) {" . "evt.preventDefault();" . "var keys = jQuery('#" . $this->grid . "').yiiGridView('getSelectedRows');" . "if (keys == '') {" . "\$('#mass_delete_alert_no_sel').modal('show');" . "} else {" . "\$('#mass_delete_alert').modal('show');" . "}" . "});" . " " . "jQuery(document).on('click', '#btn_delete_confirm', function (evt) {" . "evt.preventDefault();" . "var keys = jQuery('#" . $this->grid . "').yiiGridView('getSelectedRows');" . "jQuery.ajax({" . "type: 'POST'," . "url: jQuery(this).attr('href')," . "data: { " . $this->massParam . ": keys}" . "});" . "});");
         //Confirm Modal buttons configuration
         $boxButtons[] = '{cancel}{delete}';
         $boxButtons = !empty($boxButtons) ? implode(' ', $boxButtons) : null;
         $buttons['delete'] = ['url' => ['mass-delete'], 'label' => Yii::t('admincube', 'BUTTON_DELETE'), 'options' => ['id' => 'btn_delete_confirm', 'class' => 'btn btn-sm btn-danger', 'title' => Yii::t('admincube', 'BUTTON_DELETE')]];
         //Confirm Modal
         Modal::begin(['modal' => 'mass_delete_alert', 'title' => Yii::t('admincube', 'MSG_DELETE_CONFIRM'), 'options' => ['class' => 'fade'], 'buttonsTemplate' => $boxButtons, 'buttons' => $buttons]);
         echo '<p>' . Yii::t('admincube', 'MSG_DELETE_CONFIRM_DESCRIPTION') . '</p>';
         Modal::end();
         //No selection alert modal
         Modal::begin(['modal' => 'mass_delete_alert_no_sel', 'title' => Yii::t('admincube', 'MSG_NO_SELECTION'), 'options' => ['class' => 'fade'], 'buttonsTemplate' => '{close}']);
         echo '<p>' . Yii::t('admincube', 'MSG_NO_SELECTION_DESCRIPTION') . '</p>';
         Modal::end();
     }
 }
 public function init()
 {
     $this->depends = array_merge([JqueryAsset::className(), YiiAsset::className()], $this->depends);
     $this->css = array_merge([YII_DEBUG ? 'vendor/materialize/css/materialize.css' : 'vendor/materialize/css/materialize.min.css'], $this->css);
     $this->js = array_merge([YII_DEBUG ? 'vendor/materialize/js/materialize.js' : 'vendor/materialize/js/materialize.min.js'], $this->js);
 }
Esempio n. 11
-1
<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets;
$this->registerAssetBundle(\yii\web\YiiAsset::className(), \yii\web\View::POS_HEAD);
$this->registerAssetBundle(\yii\bootstrap\BootstrapAsset::className(), \yii\web\View::POS_HEAD);
$this->registerAssetBundle(\app\assets\AppAsset::className(), \yii\web\View::POS_HEAD);
$this->beginPage();
?>
<!DOCTYPE html>
<html lang="<?php 
echo Yii::$app->language;
?>
">
<head>
    <meta charset="<?php 
echo Yii::$app->charset;
?>
"/>
    <link rel="icon" type="image/png" href="/img/fav.png" />
    <title><?php 
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
    <?php 
echo Html::csrfMetaTags();
?>