當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Html::jsFile方法代碼示例

本文整理匯總了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]);
 }
開發者ID:richweber,項目名稱:yii2-recaptcha,代碼行數:33,代碼來源:Captcha.php

示例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);
 }
開發者ID:rmrevin,項目名稱:yii2-minify-view,代碼行數:33,代碼來源:JS.php

示例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);
     }
 }
開發者ID:aiddroid,項目名稱:yii2-assets-combine,代碼行數:12,代碼來源:AssetsCombine.php

示例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;
 }
開發者ID:loveorigami,項目名稱:yii2-iframe-resizer,代碼行數:24,代碼來源:IFrameResizer.php

示例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;
 }
開發者ID:ASDAFF,項目名稱:yincart2-framework,代碼行數:28,代碼來源:Widget.php

示例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('用戶名不能為空');
開發者ID:wuwenhan,項目名稱:huoqiwang,代碼行數:31,代碼來源:login.php

示例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";
 }
開發者ID:fangface,項目名稱:yii2-concord,代碼行數:87,代碼來源:View.php

示例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);
     }
 }
開發者ID:Abbas-Hashemian,項目名稱:yii2,代碼行數:32,代碼來源:View.php

示例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');
開發者ID:welcomedcoffee,項目名稱:dcoffee,代碼行數:29,代碼來源:preferential.php

示例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">
開發者ID:jia253,項目名稱:centosYii2,代碼行數:31,代碼來源:main.php

示例11:

                <p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation &raquo;</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 &raquo;</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 &raquo;</a></p>
            </div>
        </div>

    </div>
</div>

<?php 
echo Html::jsFile('@web/js/icomp.js');
開發者ID:kalleycorrea,項目名稱:progweb,代碼行數:29,代碼來源:index.php

示例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');
開發者ID:jh27408079,項目名稱:magenet,代碼行數:30,代碼來源:insterStage.php

示例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>
開發者ID:realphp,項目名稱:yii2-admin,代碼行數:26,代碼來源:update.php

示例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;
 }
開發者ID:a7000q,項目名稱:yasvoboden,代碼行數:15,代碼來源:FFields.php

示例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);
     }
 }
開發者ID:Rid65,項目名稱:purpure,代碼行數:32,代碼來源:View.php


注:本文中的yii\helpers\Html::jsFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。