php yii-web-JqueryAsset类(方法)实例源码

下面列出了php yii-web-JqueryAsset 类(方法)源码代码实例,从而了解它的用法。

作者:rajanishtime    项目:basicyi   
/**
  * https://github.com/yiisoft/yii2/issues/1755
  */
 public function testLayoutAssets()
 {
     $view = $this->mockView();
     JqueryAsset::register($view);
     $content = $view->renderFile('@yiiunit/extensions/twig/views/layout.twig');
     $this->assertEquals(1, preg_match('#<script src="/assets/[0-9a-z]+/jquery\\.js"></script>\\s*</body>#', $content), 'content does not contain the jquery js:' . $content);
 }

作者:webvimar    项目:ybc-conten   
public function init()
 {
     $this->sourcePath = __DIR__;
     $this->js = ['jquery.sortable.min.js'];
     $this->depends = [JqueryAsset::className()];
     parent::init();
 }

作者:novokshonove    项目:multi-string-widge   
public function init()
 {
     parent::init();
     $this->sourcePath = __DIR__ . DIRECTORY_SEPARATOR . 'source';
     $this->depends[] = JqueryAsset::className();
     $this->depends[] = BootstrapThemeAsset::className();
 }

作者:rajanr    项目:vermilian-tes   
/**
  * Returns form
  * Parameters can be passed to this method via POST method
  *
  * Form could have been generated using Yii::ActiveForm (@see http://www.yiiframework.com/doc-2.0/yii-widgets-activeform.html), however, as this is a test I am coding a custom form and custom javascript
  */
 protected function actionForm()
 {
     $params = Yii::$app->request->post();
     Yii::$app->view->registerJsFile('/js/jquery.validate.js', ['depends' => [JqueryAsset::className()]]);
     Yii::$app->view->registerJsFile('/js/site.js', ['depends' => [JqueryAsset::className()]]);
     return $this->renderPartial('form', ['params' => $params]);
 }

作者:kongoo    项目:yii2-orgchar   
protected function registerAsset()
 {
     $jsData = Json::encode($this->data);
     $setupOptions = Json::encode($this->setupOptions);
     $js = "\n            google.charts.load('current', {packages:[\"orgchart\"]});\n            google.charts.setOnLoadCallback(drawChart);\n\n            function drawChart() {\n                var data = new google.visualization.DataTable();\n                data.addColumn('string', 'Name');\n                data.addColumn('string', 'Manager');\n                data.addColumn('string', 'ToolTip');\n\n                // For each orgchart box, provide the name, manager, and tooltip to show.\n                data.addRows(\n                    " . $jsData . "\n                );\n\n                // Create the chart.\n                var chart = new google.visualization.OrgChart(document.getElementById('" . $this->id . "'));\n                chart.draw(data, {allowHtml:true});\n            }\n        ";
     $this->view->registerJsFile('https://www.gstatic.com/charts/loader.js', ['depends' => [\yii\web\JqueryAsset::className()]]);
     $this->view->registerJs($js, View::POS_READY);
 }

作者:yeesof    项目:yii2-yee-cor   
public function init()
 {
     $this->sourcePath = __DIR__ . '/language';
     $this->js = ['js/language.js'];
     $this->css = ['css/language.css'];
     $this->depends = [JqueryAsset::className()];
     parent::init();
 }

作者:yeesof    项目:yii2-yee-cor   
public function init()
 {
     $this->sourcePath = __DIR__ . '/source/language-selector';
     $this->js = [];
     $this->css = ['css/language-selector.css'];
     $this->depends = [JqueryAsset::className()];
     parent::init();
 }

作者:yeesof    项目:yii2-yee-cor   
public function init()
 {
     $this->sourcePath = __DIR__ . '/admin';
     $this->js = ['js/admin.js'];
     $this->css = ['css/admin.css', 'css/widget.css', 'css/styler.css'];
     $this->depends = [JqueryAsset::className(), 'yii\\web\\YiiAsset', 'yii\\bootstrap\\BootstrapAsset', 'rmrevin\\yii\\fontawesome\\AssetBundle'];
     parent::init();
 }

作者:erclin    项目:yii2-loadingindicato   
public function run()
 {
     $asset = \Yii::$app->assetManager->publish("@ercling/loadingindicator/assets", ['forceCopy' => YII_DEBUG]);
     $this->getView()->registerCssFile($asset[1] . '/themes/' . $this->color . '/pace-theme-' . $this->theme . '.css');
     $this->getView()->registerJs('
         var yii2LoadingIndicator=' . json_encode($this->options) . ';
         ', \yii\web\View::POS_BEGIN);
     $this->getView()->registerJsFile($asset[1] . '/indicator.js', ['depends' => [JqueryAsset::className()]]);
 }

作者:aweb    项目:web_xb   
public function init()
 {
     parent::init();
     $this->isFollow = Tag::isFollow($this->tagId);
     if ($this->isFollow) {
         $this->label = "已关注";
     }
     $this->getView()->registerJsFile('/js/jquery.toggle.js', ['depends' => [JqueryAsset::className()]]);
     $this->getView()->registerJs("\$('.tagFollowToggle').toggle();");
 }

作者:istrange    项目:yii2-resource-smart-loa   
/**
  * @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()]]);
 }

作者:host3    项目:yii2-multilevel-horizontal-men   
/**
     * Registers the clientside widget files (css & js)
     */
    public function registerClientScripts()
    {
        $resources = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'resources';
        $this->_baseUrl = Yii::$app->getAssetManager()->publish($resources);
        $this->getView()->registerJsFile($this->_baseUrl[1] . '/menu.js', ['depends' => [\yii\web\JqueryAsset::className()]]);
        $this->getView()->registerJsFile($this->_baseUrl[1] . '/selectnav.js', ['depends' => [\yii\web\JqueryAsset::className()]]);
        $this->getView()->registerJs('
			selectnav(\'myslidemenu\',\'insertHere\');
		', View::POS_END, 'selectnavstart');
        $this->getView()->registerCssFile($this->_baseUrl[1] . '/style.css', [], 'horizontal-menu-css');
    }

作者:highestgoodlikewate    项目:yii2-toolbo   
/**
  * Registers the js code if necessary
  */
 protected function registerJs()
 {
     if (static::$JS_REGISTERED) {
         return;
     }
     JqueryAsset::register($this->getView());
     BootstrapAsset::register($this->getView());
     $js = new JsExpression("\n\t\t\tvar widgetClass = 'widget-memory-tabs';\n\t\t\tvar storageName = 'widget-memory-tabs';\n\n\t\t\tvar hasStorage = function() {\n\t\t\t\tvar test = 'test';\n\t\t\t\ttry {\n\t\t\t\t\tsessionStorage.setItem(test, test);\n\t\t\t\t\tsessionStorage.removeItem(test);\n\t\t\t\t\treturn true;\n\t\t\t\t} catch(e) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (hasStorage) {\n\n\t\t\t\tvar loadData = function() {\n\t\t\t\t\tvar dataStr = sessionStorage.getItem(storageName);\n\t\t\t\t\tif (dataStr == null) return {};\n\t\t\t\t\treturn JSON.parse(dataStr);\n\t\t\t\t};\n\n\t\t\t\tvar saveData = function(dataObj) {\n\t\t\t\t\tdataStr = JSON.stringify(dataObj);\n\t\t\t\t\tsessionStorage.setItem(storageName, dataStr);\n\t\t\t\t};\n\n\t\t\t\tvar activateIndex = function(tabId, index) {\n\t\t\t\t\tvar tab = \$('#' + tabId);\n\t\t\t\t\tvar items = tab.children('li');\n\t\t\t\t\tif (items.length <= index) return;\n\n\t\t\t\t\t\$('#' + tabId + ' li:eq(' + index + ') a').tab('show');\n\t\t\t\t};\n\n\t\t\t\tvar initIndexes = function() {\n\t\t\t\t\tvar data = loadData();\n\t\t\t\t\tvar curUrl = window.location.href;\n\t\t\t\t\tif (data[curUrl] == null) return;\n\n\t\t\t\t\tvar tabs = \$('.' + widgetClass);\n\t\t\t\t\ttabs.each(function(i, el) {\n\t\t\t\t\t\tvar tabId = \$(this).attr('id');\n\t\t\t\t\t\tif (tabId != null) {\n\t\t\t\t\t\t\tvar index = data[curUrl][tabId];\n\t\t\t\t\t\t\tactivateIndex(tabId, index);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\tvar setIndex = function(tabId, index) {\n\t\t\t\t\tvar curUrl = window.location.href;\n\t\t\t\t\tvar data = loadData();\n\t\t\t\t\tif (data[curUrl] == null) data[curUrl] = {};\n\t\t\t\t\tdata[curUrl][tabId] = index;\n\n\t\t\t\t\tsaveData(data);\n\t\t\t\t};\n\n\t\t\t\t\$('.widget-memory-tabs > li > a').mouseup(function(event) {\n\t\t\t\t\tvar tabs = \$(this).closest('.' + widgetClass);\n\t\t\t\t\tvar selectedIndex = \$(this).parent().prevAll().length;\n\n\t\t\t\t\tsetIndex(tabs.attr('id'), selectedIndex);\n\t\t\t\t});\n\n\t\t\t\tinitIndexes();\n\t\t\t}\n\t\t");
     $this->view->registerJs($js);
     static::$JS_REGISTERED = true;
 }

作者:host3    项目:yii2-multilevel-vertical-men   
/**
     * Registers the clientside widget files (css & js)
     */
    public function registerClientScripts()
    {
        $resources = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
        $this->_baseUrl = Yii::$app->getAssetManager()->publish($resources);
        $this->getView()->registerJsFile($this->_baseUrl[1] . '/jquery.dlmenu.js', ['depends' => [\yii\web\JqueryAsset::className()]]);
        $this->getView()->registerJsFile($this->_baseUrl[1] . '/modernizr.custom.js', ['position' => View::POS_HEAD]);
        $this->getView()->registerJs('
	    $(\'#dl-menu\').dlmenu({
	        animationClasses : { classin : \'dl-animate-in-' . $this->transition . '\', classout : \'dl-animate-out-' . $this->transition . '\' }
	    });
		', View::POS_END, 'menuscript');
        $this->getView()->registerCssFile($this->_baseUrl[1] . '/component.css', [], 'vertical-menu-css');
    }

作者:urbanind    项目:yii2-core-widget   
/**
     * @return void
     */
    private function registerJs()
    {
        $url = \yii\helpers\Url::to($this->url);
        \yii\web\JqueryAsset::register($this->getView());
        $this->getView()->registerJs(<<<JS
\$('#{$this->options['id']}').load('{$url}', function (response, textStatus, xhr) {
    if (textStatus == "error") {
        \$(this).html('{$this->errorContent}');
        \$(this).addCssClass('{$this->errorCssClass}');
    }
});
JS
);
    }

作者:aweb    项目:web_xb   
public function init()
 {
     parent::init();
     $assets = \Yii::$app->assetManager->publish('@app/modules/comment/assets/', ['forceCopy' => YII_DEBUG]);
     $this->getView()->registerJsFile($assets['1'] . '/comment.js', ['depends' => [JqueryAsset::className()]]);
     if ($this->needForm) {
         $this->model = new Comment();
         $this->model->obj_id = $this->obj_id;
         $this->model->obj_type = $this->obj_type;
         $this->model->parent_id = $this->parent_id;
     }
     $this->comments = Comment::find()->with('author')->where(['obj_type' => $this->obj_type, 'obj_id' => $this->obj_id])->limit(20)->orderBy('id desc')->offset($this->offset)->all();
     $this->number = Comment::find()->where(['obj_type' => $this->obj_type, 'obj_id' => $this->obj_id])->count();
 }

作者:Zlato    项目:yii2tes   
public function run()
 {
     $this->view->registerCssFile('css/treeList.css');
     $this->view->registerJsFile('js/treeList.js', ['depends' => [\yii\web\JqueryAsset::className()]]);
     $result = '<ul class="ul-tree ul-drop">';
     foreach ($this->treeList as $key => $val) {
         $result .= $this->render('treeListLi', ['val' => $val, 'enableDel' => isset($this->treeList[$key + 1]) && $this->treeList[$key + 1]['level'] > $val['level'] ? false : true]);
         if (isset($this->treeList[$key + 1]) && $this->treeList[$key + 1]['level'] > $val['level']) {
             $result .= '<ul>';
         }
         if (isset($this->treeList[$key + 1]) && $this->treeList[$key + 1]['level'] == $val['level']) {
             $result .= '</li>';
         }
         if (isset($this->treeList[$key + 1]) && $this->treeList[$key + 1]['level'] < $val['level']) {
             $result .= str_repeat('</li>' . '</ul>', $val['level'] - $this->treeList[$key + 1]['level']);
         }
         if (!isset($this->treeList[$key + 1])) {
             $result .= '</li>' . str_repeat('</ul>' . '</li>', $val['level']);
         }
     }
     $result .= '</ul>';
     return $result;
 }

作者:alfarioekaputr    项目:yii2_cm   
}*/
/*$root = Category::findOne(['name' => 'Provinsi']);

// We need to find our children. We don't do this lazily because it can be
// advantageous to control when it happens. You may wish to provide a
// $depth limit to speed up queries even more.
$depth = 2; // This will limit to countries & states only for example
$root->children($depth)->all();

// We can now loop through our children
foreach ($root->children()->all() as $category)
{
    echo "<h3>{$category->name}</h3>";

    if (count($category->children()->all()))
    {
        echo "<p>{$category->name} has the following states registered with our system:</p>";

        echo "<ul>";

        foreach ($category->children()->all() as $state)
        {
            echo "<li>{$state->name}</li>";
        }

        echo "</ul>";
    }
}*/
$this->registerCssFile('../jstree/themes/default/style.min.css');
$this->registerJsFile('../admin/jstree/jstree.min.js', ['depends' => [\yii\web\JqueryAsset::className()]]);
$this->registerJs("\n\$('#jstree_demo_div')\n.on('changed.jstree', function (e, data) {\n    var i, j, r = [];\n    for(i = 0, j = data.selected.length; i < j; i++) {\n      r.push(data.instance.get_node(data.selected[i]).text);\n    }\n    \$('#category-parent').val(r.join(', '));\n  })\n.jstree();\n");

作者:chaimvai    项目:linet   
</tfoot>
                            <tbody id="det">

                            </tbody>

                        </table>

                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
<?php 
$this->registerJs("var baseAddress='" . yii\helpers\BaseUrl::base() . "';" . "var accountSelect='" . str_replace("\n", "", $form->field($model, 'ops', ['template' => '{input}'])->dropDownList(\yii\helpers\ArrayHelper::map(Accounts::find()->All(), 'id', 'name'))) . "';" . "var msg='" . Yii::t('app', 'sum is not 0') . "';", \yii\web\View::POS_HEAD);
$this->registerJsFile(yii\helpers\BaseUrl::base() . '/assets/transaction.js', ['depends' => [\yii\web\JqueryAsset::className()]]);
?>


<div class="form-actions">
    <?php 
echo \yii\helpers\Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-success']);
?>
</div>

<?php 
kartik\form\ActiveForm::end();
?>

<?php 
echo \app\widgets\RefnumModal::widget(['model' => $model, 'attribute' => 'refnum1']);

作者:nirantarno    项目:paperles   
<p>
        <?php 
//echo Html::a('Create Roles', ['create'], ['class' => 'btn btn-success'])
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'layout' => "{summary}\n{items}\n{pager}", 'panel' => ['type' => GridView::TYPE_SUCCESS, 'heading' => $this->render('_search', ['model' => $searchModel])], 'toolbar' => [['content' => Html::a('สร้างใหม่', ['create'], ['class' => 'btn btn-primary'])], '{toggleData}', '{export}'], 'columns' => [['class' => 'yii\\grid\\SerialColumn', 'header' => 'ลำดับ', 'headerOptions' => ['style' => 'text-align: center'], 'contentOptions' => ['style' => 'text-align: center']], 'rolename', 'description:ntext', 'createdate', ['header' => 'Action', 'headerOptions' => ['style' => 'width: 160px;text-align:center;', 'class' => 'activity-view-link'], 'class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'text-align: center'], 'buttons' => ['view' => function ($url, $data, $index) {
    $options = ['title' => Yii::t('yii', 'View'), 'aria-label' => Yii::t('yii', 'View'), 'data-pjax' => '0'];
    return Html::a('<span class="glyphicon glyphicon-eye-open btn btn-default"></span>', $url, $options);
}, 'update' => function ($url, $data, $index) {
    $options = array_merge(['title' => Yii::t('yii', 'Update'), 'aria-label' => Yii::t('yii', 'Update'), 'data-pjax' => '0', 'id' => 'modaledit']);
    return Html::a('<span class="glyphicon glyphicon-pencil btn btn-default"></span>', $url, ['id' => 'activity-view-link', 'data-id' => $index, 'data-pjax' => '0']);
}, 'delete' => function ($url, $data, $index) {
    $options = array_merge(['title' => Yii::t('yii', 'Delete'), 'aria-label' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0']);
    return Html::a('<span class="glyphicon glyphicon-trash btn btn-default"></span>', $url, $options);
}]]]]);
?>

</div>
<div class="pagename"  <?php 
echo "id={$pagename}";
?>
></div>
<?php 
$this->registerJsFile(Yii::$app->request->baseUrl . '/js/leftmenu.js', ['depends' => [\yii\web\JqueryAsset::className()]]);
$this->registerJs('
    var path = location.pathname;
    //console.log(path);
        ');


问题


面经


文章

微信
公众号

扫码关注公众号