本文整理汇总了PHP中yii\helpers\Html::jsFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::jsFile方法的具体用法?PHP Html::jsFile怎么用?PHP Html::jsFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::jsFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initialize the widget
* @throws InvalidConfigException
*/
public function init()
{
parent::init();
if (empty(Yii::$app->recaptcha->siteKey)) {
throw new InvalidConfigException('The site key has not been set.');
}
if (empty(Yii::$app->recaptcha->secretKey)) {
throw new InvalidConfigException('The secret key has not been set.');
}
if (!empty(Yii::$app->recaptcha->errorMessage)) {
$this->errorMessage = Yii::$app->recaptcha->errorMessage;
}
if (empty($this->theme)) {
$this->theme = 'light';
} else {
if ($this->theme != 'light' && $this->theme != 'dark') {
throw new InvalidConfigException('The theme has not been set.');
}
}
if ($this->lang) {
echo Html::jsFile('https://www.google.com/recaptcha/api.js?hl=' . $this->lang);
} else {
echo Html::jsFile('https://www.google.com/recaptcha/api.js');
}
if (Yii::$app->recaptcha->hasError) {
echo Html::tag('p', $this->errorMessage, ['class' => 'text-danger']);
}
echo Html::tag('div', '', ['class' => 'g-recaptcha', 'data-sitekey' => Yii::$app->recaptcha->siteKey, 'data-theme' => $this->theme]);
}
示例2: process
/**
* @param integer $position
* @param array $files
*/
protected function process($position, $files)
{
$resultFile = sprintf('%s/%s.js', $this->view->minify_path, $this->_getSummaryFilesHash($files));
if (!file_exists($resultFile)) {
$js = '';
foreach ($files as $file => $html) {
$file = $this->getAbsoluteFilePath($file);
$content = '';
if (!file_exists($file)) {
\Yii::warning(sprintf('Asset file not found `%s`', $file), __METHOD__);
} elseif (!is_readable($file)) {
\Yii::warning(sprintf('Asset file not readable `%s`', $file), __METHOD__);
} else {
$content .= file_get_contents($file) . ';' . "\n";
}
$js .= $content;
}
$this->removeJsComments($js);
if ($this->view->minifyJs) {
$js = (new \JSMin($js))->min();
}
file_put_contents($resultFile, $js);
if (false !== $this->view->file_mode) {
@chmod($resultFile, $this->view->file_mode);
}
}
$file = $this->prepareResultFile($resultFile);
$this->view->jsFiles[$position][$file] = Html::jsFile($file);
}
示例3: addJsFiles
/**
* Registers Js
*/
public function addJsFiles($jsFiles, $options = [])
{
$url = $this->getUrlByFiles($jsFiles);
if (Yii::$app->controller->layout) {
Yii::$app->getView()->registerJsFile($url, $options);
} else {
echo Html::jsFile($url, $options);
}
}
示例4: embed
/**
* This method should be used if you need to embed iframeResizer.contentWindow.min.js
* into an existing iFrame HTML content generated elsewhere.
* @param $html string iFrame HTML code where script needs to be embedded
* @return string iFrame HTML code with embedded script
* @throws InvalidConfigException
*/
public static function embed($html)
{
$config['class'] = IFrameResizer::className();
$widget = Yii::createObject($config);
/* @var $widget IFrameResizer */
$url = $widget->getScriptUrl();
$scriptTag = Html::jsFile($url);
// Using regular expression rather than DOMDocument approach, as the latter may end up messing the code.
// Split the string contained in $html in three parts:
// - everything before the </body> tag
// - the </body> tag with any attributes in it
// - everything following the </body> tag
$matches = preg_split('/(<\\/body.*?>)/i', $html, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
// assemble HTML code back with the script code embedded before </body>
$embeddedHTML = $matches[0] . $scriptTag . $matches[1] . $matches[2];
return $embeddedHTML;
}
示例5: renderJs
/**
* render js in page
* @return string
*/
public function renderJs()
{
$jsLines = "\n";
if ($this->getView()->assetBundles) {
foreach ($this->getView()->assetBundles as $assetBundle) {
if (!$assetBundle->sourcePath) {
foreach ($assetBundle->js as $jsFile) {
$jsLines .= "\n" . Html::jsFile($jsFile, $assetBundle->jsOptions);
}
}
}
}
if ($this->getView()->jsFiles) {
foreach ($this->getView()->jsFiles as $jsFiles) {
$jsLines .= implode("\n", $jsFiles);
}
}
if ($this->getView()->js) {
foreach ($this->getView()->js as $js) {
$jsLines .= implode("\n", $js);
}
}
return $jsLines;
}
示例6: setTimeout
</div>
<br>
<button type="submit" id="submit" class="border0 bgd-787878 c-ffffff p-bottom-10 p-top-10 m-bottom-10" style="width: 100%;">开启免登录</button>
</form>
</div>
<br><br><br><br><br><br><br><br><br>
</div>
<!--content end-->
</div>
<?php
$this->beginBlock('inline_scripts');
echo Html::jsFile('@web/js/bootstrap.js');
echo Html::jsFile('@web/js/bootbox.js');
?>
<script>
$(document).ready(function(){
$(".wapper").css("min-height",$(window).height());
setTimeout(function(){$('#flash').fadeOut(500);},2600);
})
var flag=[0,0];
$('#username').blur(function(){
var username = $('#username').val();
if(username) {
flag[0] = 1;
$('#submit').attr('class','border0 bgd-e44949 c-ffffff p-bottom-10 p-top-10 m-bottom-10');
$('#spanti').hide();
}else{
$('#spanti').html('用户名不能为空');
示例7: renderJsBlockHtml
/**
* Renders the content to be inserted within the default js block
* The content is rendered using the registered JS code blocks and files.
* @param boolean $ajaxMode whether the view is rendering in AJAX mode.
* @return string the rendered content
*/
protected function renderJsBlockHtml($ajaxMode = false)
{
$lines = [];
if (true) {
if (!empty($this->jsFiles[self::POS_JS_BLOCK])) {
$lines[] = implode("\n\t", $this->jsFiles[self::POS_JS_BLOCK]);
$this->jsFiles[self::POS_JS_BLOCK] = [];
}
if ($this->pagePlugin) {
$this->addPagePlugin($this->pagePlugin, true);
$this->pagePlugin = '';
}
if ($this->pagePlugins) {
foreach ($this->pagePlugins as $pagePlugin) {
$lines[] = Html::jsFile($pagePlugin);
}
$this->pagePlugins = [];
}
if (!empty($this->jsFiles[self::POS_END])) {
$lines[] = implode("\n\t", $this->jsFiles[self::POS_END]);
$this->jsFiles[self::POS_END] = [];
}
if (empty($this->js[self::POS_READY])) {
$this->js[self::POS_READY] = [];
}
if ($this->pageReadyJS) {
array_unshift($this->js[self::POS_READY], $this->pageReadyJS);
$this->pageReadyJS = '';
}
if ($this->pageReadyJSs) {
$this->js[self::POS_READY] = array_merge($this->pageReadyJSs, $this->js[self::POS_READY]);
$this->pageReadyJSs = [];
}
if ($this->pageReadyPriorityJSs) {
$this->js[self::POS_READY] = array_merge($this->pageReadyPriorityJSs, $this->js[self::POS_READY]);
$this->pageReadyPriorityJSs = [];
}
if ($this->pageReadyFinalJSs) {
$this->js[self::POS_READY] = array_merge($this->js[self::POS_READY], $this->pageReadyFinalJSs);
$this->pageReadyFinalJSs = [];
}
if (!empty($this->js[self::POS_READY])) {
if ($ajaxMode) {
$js = "\n\t\t" . implode("\n\t\t", $this->js[self::POS_READY]) . "\n\t";
} else {
$js = "\n\t\tjQuery(document).ready(function () {\n\t\t\t" . implode("\n\t\t\t", $this->js[self::POS_READY]) . "\n\t\t});\n\t";
}
$this->js[self::POS_READY] = [];
$lines[] = Html::script($js, ['type' => 'text/javascript']);
}
if (empty($this->js[self::POS_LOAD])) {
$this->js[self::POS_LOAD] = [];
}
if ($this->pageLoadJS) {
array_unshift($this->js[self::POS_LOAD], $this->pageLoadJS);
$this->pageLoadJS = '';
}
if ($this->pageLoadJSs) {
$this->js[self::POS_LOAD] = array_merge($this->pageLoadJSs, $this->js[self::POS_READY]);
$this->pageLoadJSs = [];
}
if ($this->pageLoadPriorityJSs) {
$this->js[self::POS_LOAD] = array_merge($this->pageLoadPriorityJSs, $this->js[self::POS_LOAD]);
$this->pageLoadPriorityJSs = [];
}
if ($this->pageLoadFinalJSs) {
$this->js[self::POS_LOAD] = array_merge($this->js[self::POS_LOAD], $this->pageLoadFinalJSs);
$this->pageLoadFinalJSs = [];
}
if (!empty($this->js[self::POS_LOAD])) {
if ($ajaxMode) {
$js = "\n\t\t" . implode("\n\t\t", $this->js[self::POS_LOAD]) . "\n\t";
} else {
$js = "\n\t\tjQuery(window).load(function () {\n\t\t\t" . implode("\n\t\t\t", $this->js[self::POS_LOAD]) . "\n\t\t});\n\t";
}
$this->js[self::POS_LOAD] = [];
$lines[] = Html::script($js, ['type' => 'text/javascript']);
}
}
return empty($lines) ? '' : "\t" . implode("\n\t", $lines) . "\n";
}
示例8: registerJsFile
/**
* Registers a JS file.
* @param string $url the JS file to be registered.
* @param array $options the HTML attributes for the script tag. The following options are specially handled
* and are not treated as HTML attributes:
*
* - `depends`: array, specifies the names of the asset bundles that this JS file depends on.
* - `position`: specifies where the JS script tag should be inserted in a page. The possible values are:
* * [[POS_HEAD]]: in the head section
* * [[POS_BEGIN]]: at the beginning of the body section
* * [[POS_END]]: at the end of the body section. This is the default value.
*
* Please refer to [[Html::jsFile()]] for other supported options.
*
* @param string $key the key that identifies the JS script file. If null, it will use
* $url as the key. If two JS files are registered with the same key at the same position, the latter
* will overwrite the former. Note that position option takes precedence, thus files registered with the same key,
* but different position option will not override each other.
*/
public function registerJsFile($url, $options = [], $key = null)
{
$url = Yii::getAlias($url);
$key = $key ?: $url;
$depends = ArrayHelper::remove($options, 'depends', []);
if (empty($depends)) {
$position = ArrayHelper::remove($options, 'position', self::POS_END);
$this->jsFiles[$position][$key] = Html::jsFile($url, $options);
} else {
$this->getAssetManager()->bundles[$key] = Yii::createObject(['class' => AssetBundle::className(), 'baseUrl' => '', 'js' => [strncmp($url, '//', 2) === 0 ? $url : ltrim($url, '/')], 'jsOptions' => $options, 'depends' => (array) $depends]);
$this->registerAssetBundle($key);
}
}
示例9:
<tr>
<?php
echo $form->field($preferential, 'preferential_type')->radioList(['1' => '满减', '2' => '折扣']);
?>
</tr>
<tr>
<?php
echo $form->field($preferential, 'preferential_content')->textInput();
?>
满减内容用,隔开(例:满100减80 100,80)
</tr>
<tr>
<?php
echo $form->field($preferential, 'preferential_start', ['inputOptions' => ['placeholder' => '开始日期']])->textInput(['id' => "d11", "onClick" => "WdatePicker()"]);
?>
</tr>
<tr>
<?php
echo $form->field($preferential, 'preferential_end', ['inputOptions' => ['placeholder' => '结束日期']])->textInput(['id' => "d11", "onClick" => "WdatePicker()"]);
?>
</tr>
<tr>
<?php
echo Html::submitButton('添加', ['class' => 'btn btn-micv5 btn-block', 'id' => 'preferential_save', 'style' => 'margin:0px auto;']);
?>
</tr>
</table>
<?php
echo Html::jsFile('public/date/My97DatePicker/WdatePicker.js');
示例10:
?>
">
<head>
<meta charset="<?php
echo Yii::$app->charset;
?>
">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php
echo Html::csrfMetaTags();
?>
<?php
echo Html::cssFile('frontend/web/css/layout.css');
?>
<?php
echo Html::jsFile('frontend/web/js/jquery-1.8.1.min.js');
?>
<title><?php
echo Html::encode('YII2');
?>
</title>
<?php
$this->head();
?>
</head>
<body>
<?php
$this->beginBody();
?>
<div class="container-fluid" id="header">
<div class="row">
示例11:
<p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation »</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum »</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions »</a></p>
</div>
</div>
</div>
</div>
<?php
echo Html::jsFile('@web/js/icomp.js');
示例12:
<?php
echo $form->field($model, 'stage_number')->textInput();
?>
<?php
echo $form->field($model, 'fee_per_stage')->textInput();
?>
<?php
echo $form->field($model, 'start_month')->radioButtonGroup([0 => '当日起', 1 => '下月起']);
?>
<?php
echo $form->field($model, 'description')->textInput();
?>
<?php
echo Html::submitButton('Create', ['class' => 'btn btn-success']);
?>
<?php
$form = ActiveForm::end();
?>
<?php
echo Html::jsFile('/js/fund.js');
?>
<?php
echo Html::a('返回', '/index.php?r=fund/currency/index');
示例13:
<?php
use yii\helpers\Html;
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>消息中心</title>
<?php
echo Html::cssFile('@web/css/bootstrap.min.css');
?>
<?php
echo Html::cssFile('@web/css/style.css');
?>
<?php
echo Html::jsFile('@web/Js/jquery.js');
?>
</head>
<body>
<?php
echo $this->render('_form', ['model' => $model]);
?>
</body>
</html>
示例14: yandexMap
private function yandexMap($model, $field_name, $options)
{
$txt = Html::beginTag("div");
$id_map = 'map' . $this->id;
$id_field = 'field' . $this->id;
$txt .= Html::beginTag('div', ['id' => $id_map, 'style' => 'height: 400px;']);
$txt .= Html::endTag("div");
$options["id"] = $id_field;
$txt .= Html::activeHiddenInput($model, $field_name, $options);
$txt .= Html::endTag("div");
$script = "\n ymaps.ready(init);\n var myMap;\n\n function init(){ \n \n var coord = \$('#" . $id_field . "').val();\n coord = coord.split(',');\n \n\n if (coord.length == 1)\n {\n \n coord = [55.76, 37.64];\n }\n else\n var dPlacemark = new ymaps.Placemark(coord);\n \n\n myMap = new ymaps.Map('" . $id_map . "', {\n center: coord,\n zoom: 7\n });\n\n if (dPlacemark)\n myMap.geoObjects.add(dPlacemark);\n\n myMap.events.add('click', function (e) {\n var coords = e.get('coords');\n \n\n var eMap = e.get('target');\n\n x = coords[0].toPrecision(8);\n y = coords[1].toPrecision(8);\n\n \$('#" . $id_field . "').val(x+', '+y);\n\n var myPlacemark = new ymaps.Placemark([x, y]);\n eMap.geoObjects.removeAll();\n eMap.geoObjects.add(myPlacemark);\n });\n };\n ";
$txt .= Html::script($script);
$txt .= Html::jsFile(Url::to('@web/js/yandex_map.js'));
return $txt;
}
示例15: registerJsFile
/**
* Registers a JS file.
* @param string $url the JS file to be registered.
* @param array $options the HTML attributes for the script tag. The following options are specially handled
* and are not treated as HTML attributes:
*
* - `depends`: array, specifies the names of the asset bundles that this JS file depends on.
* - `position`: specifies where the JS script tag should be inserted in a page. The possible values are:
* * [[POS_HEAD]]: in the head section
* * [[POS_BEGIN]]: at the beginning of the body section
* * [[POS_END]]: at the end of the body section. This is the default value.
*
* Please refer to [[Html::jsFile()]] for other supported options.
*
* @param string $key the key that identifies the JS script file. If null, it will use
* $url as the key. If two JS files are registered with the same key, the latter
* will overwrite the former.
*/
public function registerJsFile($url, $options = [], $key = null)
{
$url = Yii::getAlias($url);
$key = $key ?: $url;
$depends = ArrayHelper::remove($options, 'depends', []);
if (empty($depends)) {
// получим позицию расположения файла
$position = ArrayHelper::remove($options, 'position', self::POS_END);
$this->jsFiles[$position][$key] = Html::jsFile($url, $options);
} else {
$this->getAssetManager()->bundles[$key] = new AssetBundle(['baseUrl' => '', 'js' => [strncmp($url, '//', 2) === 0 ? $url : ltrim($url, '/')], 'jsOptions' => $options, 'depends' => (array) $depends]);
$this->registerAssetBundle($key);
}
}