本文整理汇总了PHP中yii\web\JqueryAsset类的典型用法代码示例。如果您正苦于以下问题:PHP JqueryAsset类的具体用法?PHP JqueryAsset怎么用?PHP JqueryAsset使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JqueryAsset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLayoutAssets
/**
* 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);
}
示例2: init
public function init()
{
$this->sourcePath = __DIR__;
$this->js = ['jquery.sortable.min.js'];
$this->depends = [JqueryAsset::className()];
parent::init();
}
示例3: init
public function init()
{
parent::init();
$this->sourcePath = __DIR__ . DIRECTORY_SEPARATOR . 'source';
$this->depends[] = JqueryAsset::className();
$this->depends[] = BootstrapThemeAsset::className();
}
示例4: actionForm
/**
* 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]);
}
示例5: registerAsset
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);
}
示例6: init
public function init()
{
$this->sourcePath = __DIR__ . '/language';
$this->js = ['js/language.js'];
$this->css = ['css/language.css'];
$this->depends = [JqueryAsset::className()];
parent::init();
}
示例7: init
public function init()
{
$this->sourcePath = __DIR__ . '/source/language-selector';
$this->js = [];
$this->css = ['css/language-selector.css'];
$this->depends = [JqueryAsset::className()];
parent::init();
}
示例8: init
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();
}
示例9: run
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()]]);
}
示例10: init
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();");
}
示例11: publishExtensionResources
/**
* @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()]]);
}
示例12: registerClientScripts
/**
* 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');
}
示例13: registerJs
/**
* 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;
}
示例14: registerClientScripts
/**
* 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');
}
示例15: registerJs
/**
* @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
);
}