Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Y
yii2bootstrap
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
yii2bootstrap
Commits
368a4cfe
Commit
368a4cfe
authored
Jul 16, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Asset feature refactoring (WIP)
parent
dc2843a2
Changes
67
Hide whitespace changes
Inline
Side-by-side
Showing
67 changed files
with
820 additions
and
338 deletions
+820
-338
AppAsset.php
apps/advanced/backend/config/AppAsset.php
+28
-0
assets.php
apps/advanced/backend/config/assets.php
+0
-18
main.php
apps/advanced/backend/config/main.php
+0
-3
main.php
apps/advanced/backend/views/layouts/main.php
+2
-1
AppAsset.php
apps/advanced/frontend/config/AppAsset.php
+28
-0
assets.php
apps/advanced/frontend/config/assets.php
+0
-18
main.php
apps/advanced/frontend/config/main.php
+0
-3
main.php
apps/advanced/frontend/views/layouts/main.php
+2
-1
.gitkeep
apps/basic/assets/.gitkeep
+0
-1
AppAsset.php
apps/basic/config/AppAsset.php
+29
-0
assets.php
apps/basic/config/assets.php
+0
-18
web.php
apps/basic/config/web.php
+0
-3
main.php
apps/basic/views/layouts/main.php
+1
-1
upgrade-from-v1.md
docs/guide/upgrade-from-v1.md
+4
-3
CoreAsset.php
extensions/jui/yii/jui/CoreAsset.php
+24
-0
WidgetAsset.php
extensions/jui/yii/jui/WidgetAsset.php
+24
-0
assets.php
extensions/jui/yii/jui/assets.php
+2
-14
YiiBase.php
framework/yii/YiiBase.php
+1
-8
assets.php
framework/yii/assets.php
+7
-57
View.php
framework/yii/base/View.php
+14
-10
AffixAsset.php
framework/yii/bootstrap/AffixAsset.php
+26
-0
AlertAsset.php
framework/yii/bootstrap/AlertAsset.php
+26
-0
BootstrapAsset.php
framework/yii/bootstrap/BootstrapAsset.php
+21
-0
ButtonAsset.php
framework/yii/bootstrap/ButtonAsset.php
+26
-0
CarouselAsset.php
framework/yii/bootstrap/CarouselAsset.php
+26
-0
CollapseAsset.php
framework/yii/bootstrap/CollapseAsset.php
+26
-0
DropdownAsset.php
framework/yii/bootstrap/DropdownAsset.php
+26
-0
ModalAsset.php
framework/yii/bootstrap/ModalAsset.php
+26
-0
Nav.php
framework/yii/bootstrap/Nav.php
+1
-1
NavBar.php
framework/yii/bootstrap/NavBar.php
+6
-2
PopoverAsset.php
framework/yii/bootstrap/PopoverAsset.php
+24
-0
Progress.php
framework/yii/bootstrap/Progress.php
+5
-1
ResponsiveAsset.php
framework/yii/bootstrap/ResponsiveAsset.php
+24
-0
ScrollspyAsset.php
framework/yii/bootstrap/ScrollspyAsset.php
+26
-0
TabAsset.php
framework/yii/bootstrap/TabAsset.php
+26
-0
TooltipAsset.php
framework/yii/bootstrap/TooltipAsset.php
+26
-0
TransitionAsset.php
framework/yii/bootstrap/TransitionAsset.php
+25
-0
Typeahead.php
framework/yii/bootstrap/Typeahead.php
+2
-2
TypeaheadAsset.php
framework/yii/bootstrap/TypeaheadAsset.php
+26
-0
Widget.php
framework/yii/bootstrap/Widget.php
+8
-2
assets.php
framework/yii/bootstrap/assets.php
+15
-104
DebugAsset.php
framework/yii/debug/DebugAsset.php
+25
-0
index.php
framework/yii/debug/views/default/index.php
+0
-1
view.php
framework/yii/debug/views/default/view.php
+1
-1
main.php
framework/yii/debug/views/layouts/main.php
+1
-1
BooleanValidator.php
framework/yii/validators/BooleanValidator.php
+1
-1
CaptchaValidator.php
framework/yii/validators/CaptchaValidator.php
+1
-1
CompareValidator.php
framework/yii/validators/CompareValidator.php
+1
-1
EmailValidator.php
framework/yii/validators/EmailValidator.php
+2
-2
NumberValidator.php
framework/yii/validators/NumberValidator.php
+1
-1
PunycodeAsset.php
framework/yii/validators/PunycodeAsset.php
+21
-0
RangeValidator.php
framework/yii/validators/RangeValidator.php
+1
-1
RegularExpressionValidator.php
framework/yii/validators/RegularExpressionValidator.php
+1
-1
RequiredValidator.php
framework/yii/validators/RequiredValidator.php
+1
-1
StringValidator.php
framework/yii/validators/StringValidator.php
+1
-1
UrlValidator.php
framework/yii/validators/UrlValidator.php
+2
-2
ValidationAsset.php
framework/yii/validators/ValidationAsset.php
+24
-0
AssetBundle.php
framework/yii/web/AssetBundle.php
+11
-1
AssetManager.php
framework/yii/web/AssetManager.php
+18
-45
JqueryAsset.php
framework/yii/web/JqueryAsset.php
+20
-0
YiiAsset.php
framework/yii/web/YiiAsset.php
+23
-0
ActiveForm.php
framework/yii/widgets/ActiveForm.php
+3
-2
ActiveFormAsset.php
framework/yii/widgets/ActiveFormAsset.php
+24
-0
Captcha.php
framework/yii/widgets/Captcha.php
+3
-2
CaptchaAsset.php
framework/yii/widgets/CaptchaAsset.php
+24
-0
MaskedInput.php
framework/yii/widgets/MaskedInput.php
+3
-2
MaskedInputAsset.php
framework/yii/widgets/MaskedInputAsset.php
+24
-0
No files found.
apps/advanced/backend/config/AppAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
backend\config
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
AppAsset
extends
AssetBundle
{
public
$basePath
=
'@wwwroot'
;
public
$baseUrl
=
'@www'
;
public
$css
=
array
(
'css/site.css'
,
);
public
$js
=
array
(
);
public
$depends
=
array
(
'yii\web\YiiAsset'
,
'yii\bootstrap\ResponsiveAsset'
,
);
}
apps/advanced/backend/config/assets.php
deleted
100644 → 0
View file @
dc2843a2
<?php
return
array
(
'app'
=>
array
(
'basePath'
=>
'@wwwroot'
,
'baseUrl'
=>
'@www'
,
'css'
=>
array
(
'css/site.css'
,
),
'js'
=>
array
(
),
'depends'
=>
array
(
'yii'
,
'yii/bootstrap/responsive'
,
),
),
);
apps/advanced/backend/config/main.php
View file @
368a4cfe
...
...
@@ -23,9 +23,6 @@ return array(
'class'
=>
'yii\web\User'
,
'identityClass'
=>
'common\models\User'
,
),
'assetManager'
=>
array
(
'bundles'
=>
require
(
__DIR__
.
'/assets.php'
),
),
'log'
=>
array
(
'targets'
=>
array
(
array
(
...
...
apps/advanced/backend/views/layouts/main.php
View file @
368a4cfe
<?php
use
backend\config\AppAsset
;
use
yii\helpers\Html
;
use
yii\widgets\Menu
;
use
yii\widgets\Breadcrumbs
;
...
...
@@ -7,7 +8,7 @@ use yii\widgets\Breadcrumbs;
* @var $this \yii\base\View
* @var $content string
*/
$this
->
registerAssetBundle
(
'app'
);
AppAsset
::
register
(
$this
);
?>
<?php
$this
->
beginPage
();
?>
<!DOCTYPE html>
...
...
apps/advanced/frontend/config/AppAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
frontend\config
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
AppAsset
extends
AssetBundle
{
public
$basePath
=
'@wwwroot'
;
public
$baseUrl
=
'@www'
;
public
$css
=
array
(
'css/site.css'
,
);
public
$js
=
array
(
);
public
$depends
=
array
(
'yii\web\YiiAsset'
,
'yii\bootstrap\ResponsiveAsset'
,
);
}
apps/advanced/frontend/config/assets.php
deleted
100644 → 0
View file @
dc2843a2
<?php
return
array
(
'app'
=>
array
(
'basePath'
=>
'@wwwroot'
,
'baseUrl'
=>
'@www'
,
'css'
=>
array
(
'css/site.css'
,
),
'js'
=>
array
(
),
'depends'
=>
array
(
'yii'
,
'yii/bootstrap/responsive'
,
),
),
);
apps/advanced/frontend/config/main.php
View file @
368a4cfe
...
...
@@ -22,9 +22,6 @@ return array(
'class'
=>
'yii\web\User'
,
'identityClass'
=>
'common\models\User'
,
),
'assetManager'
=>
array
(
'bundles'
=>
require
(
__DIR__
.
'/assets.php'
),
),
'log'
=>
array
(
'traceLevel'
=>
YII_DEBUG
?
3
:
0
,
'targets'
=>
array
(
...
...
apps/advanced/frontend/views/layouts/main.php
View file @
368a4cfe
<?php
use
frontend\config\AppAsset
;
use
yii\helpers\Html
;
use
yii\widgets\Menu
;
use
yii\widgets\Breadcrumbs
;
...
...
@@ -7,7 +8,7 @@ use yii\widgets\Breadcrumbs;
* @var $this \yii\base\View
* @var $content string
*/
$this
->
registerAssetBundle
(
'app'
);
AppAsset
::
register
(
$this
);
?>
<?php
$this
->
beginPage
();
?>
<!DOCTYPE html>
...
...
apps/basic/assets/.gitkeep
deleted
100644 → 0
View file @
dc2843a2
*
apps/basic/config/AppAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
app\config
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
AppAsset
extends
AssetBundle
{
public
$basePath
=
'@wwwroot'
;
public
$baseUrl
=
'@www'
;
public
$css
=
array
(
'css/site.css'
,
);
public
$js
=
array
(
);
public
$depends
=
array
(
'yii\web\YiiAsset'
,
'yii\bootstrap\ResponsiveAsset'
,
);
}
apps/basic/config/assets.php
deleted
100644 → 0
View file @
dc2843a2
<?php
return
array
(
'app'
=>
array
(
'basePath'
=>
'@wwwroot'
,
'baseUrl'
=>
'@www'
,
'css'
=>
array
(
'css/site.css'
,
),
'js'
=>
array
(
),
'depends'
=>
array
(
'yii'
,
'yii/bootstrap/responsive'
,
),
),
);
apps/basic/config/web.php
View file @
368a4cfe
...
...
@@ -18,9 +18,6 @@ return array(
'class'
=>
'yii\web\User'
,
'identityClass'
=>
'app\models\User'
,
),
'assetManager'
=>
array
(
'bundles'
=>
require
(
__DIR__
.
'/assets.php'
),
),
'log'
=>
array
(
'traceLevel'
=>
YII_DEBUG
?
3
:
0
,
'targets'
=>
array
(
...
...
apps/basic/views/layouts/main.php
View file @
368a4cfe
...
...
@@ -7,7 +7,7 @@ use yii\widgets\Breadcrumbs;
* @var $this \yii\base\View
* @var $content string
*/
$this
->
registerAssetBundle
(
'app'
);
app\config\AppAsset
::
register
(
$this
);
?>
<?php
$this
->
beginPage
();
?>
<!DOCTYPE html>
...
...
docs/guide/upgrade-from-v1.md
View file @
368a4cfe
...
...
@@ -311,9 +311,10 @@ Yii 2.0 introduces a new concept called *asset bundle*. It is similar to script
packages (managed by
`CClientScript`
) in 1.1, but with better support.
An asset bundle is a collection of asset files (e.g. JavaScript files, CSS files, image files, etc.)
under a directory. By registering an asset bundle via
`View::registerAssetBundle()`
, you
will be able to make the assets in that bundle accessible via Web, and the current page
will automatically contain references to the JavaScript and CSS files in that bundle.
under a directory. Each asset bundle is represented as a class extending
`AssetBundle`
.
By registering an asset bundle via
`AssetBundle::register()`
, you will be able to make
the assets in that bundle accessible via Web, and the current page will automatically
contain the references to the JavaScript and CSS files specified in that bundle.
...
...
extensions/jui/yii/jui/CoreAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\jui
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
CoreAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/jui/assets'
;
public
$js
=
array
(
'jquery.ui.core.js'
,
);
public
$depends
=
array
(
'yii\web\JqueryAsset'
,
);
}
extensions/jui/yii/jui/WidgetAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\jui
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
WidgetAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/jui/assets'
;
public
$js
=
array
(
'jquery.ui.widget.js'
,
);
public
$depends
=
array
(
'yii\web\JqueryAsset'
,
);
}
extensions/jui/yii/jui/assets.php
View file @
368a4cfe
<?php
return
array
(
'yii/jui/core'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'jquery.ui.core.js'
,
),
'depends'
=>
array
(
'yii/jquery'
),
),
'yii/jui/widget'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'jquery.ui.widget.js'
,
),
'depends'
=>
array
(
'yii/jquery'
),
),
yii\jui\CoreAsset
::
className
(),
yii\jui\WidgetAsset
::
className
(),
'yii/jui/accordion'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
...
...
framework/yii/YiiBase.php
View file @
368a4cfe
...
...
@@ -69,7 +69,7 @@ class YiiBase
* @see getAlias
* @see setAlias
*/
public
static
$aliases
;
public
static
$aliases
=
array
(
'@yii'
=>
__DIR__
)
;
/**
* @var array initial property values that will be applied to objects newly created via [[createObject]].
* The array keys are class names without leading backslashes "\", and the array values are the corresponding
...
...
@@ -616,10 +616,3 @@ class YiiBase
return
get_object_vars
(
$object
);
}
}
YiiBase
::
$aliases
=
array
(
'@yii'
=>
array
(
'@yii/bootstrap'
=>
__DIR__
.
'/bootstrap'
,
'@yii'
=>
__DIR__
,
),
);
framework/yii/assets.php
View file @
368a4cfe
<?php
return
array
(
'yii'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'yii.js'
,
),
'depends'
=>
array
(
'yii/jquery'
),
),
'yii/jquery'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
YII_DEBUG
?
'jquery.js'
:
'jquery.min.js'
,
),
),
'yii/validation'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'yii.validation.js'
,
),
'depends'
=>
array
(
'yii'
),
),
'yii/form'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'yii.activeForm.js'
,
),
'depends'
=>
array
(
'yii'
),
),
'yii/captcha'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'yii.captcha.js'
,
),
'depends'
=>
array
(
'yii'
),
),
'yii/punycode'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
YII_DEBUG
?
'punycode/punycode.js'
:
'punycode/punycode.min.js'
,
),
),
'yii/maskedinput'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'jquery.maskedinput.js'
,
),
'depends'
=>
array
(
'yii/jquery'
),
),
'yii/debug'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/debug/assets'
,
'css'
=>
array
(
'main.css'
,
),
'depends'
=>
array
(
'yii'
,
'yii/bootstrap/responsive'
,
),
),
yii\web\YiiAsset
::
className
(),
yii\web\JqueryAsset
::
className
(),
yii\validators\PunycodeAsset
::
className
(),
yii\validators\ValidationAsset
::
className
(),
yii\widgets\ActiveFormAsset
::
className
(),
yii\widgets\CaptchaAsset
::
className
(),
yii\widgets\MaskedInputAsset
::
className
(),
);
framework/yii/base/View.php
View file @
368a4cfe
...
...
@@ -10,6 +10,8 @@ namespace yii\base;
use
Yii
;
use
yii\helpers\FileHelper
;
use
yii\helpers\Html
;
use
yii\web\JqueryAsset
;
use
yii\web\AssetBundle
;
use
yii\widgets\Block
;
use
yii\widgets\ContentDecorator
;
use
yii\widgets\FragmentCache
;
...
...
@@ -72,15 +74,15 @@ class View extends Component
/**
* This is internally used as the placeholder for receiving the content registered for the head section.
*/
const
P
L
_HEAD
=
'<![CDATA[YII-BLOCK-HEAD]]>'
;
const
P
H
_HEAD
=
'<![CDATA[YII-BLOCK-HEAD]]>'
;
/**
* This is internally used as the placeholder for receiving the content registered for the beginning of the body section.
*/
const
P
L
_BODY_BEGIN
=
'<![CDATA[YII-BLOCK-BODY-BEGIN]]>'
;
const
P
H
_BODY_BEGIN
=
'<![CDATA[YII-BLOCK-BODY-BEGIN]]>'
;
/**
* This is internally used as the placeholder for receiving the content registered for the end of the body section.
*/
const
P
L
_BODY_END
=
'<![CDATA[YII-BLOCK-BODY-END]]>'
;
const
P
H
_BODY_END
=
'<![CDATA[YII-BLOCK-BODY-END]]>'
;
/**
...
...
@@ -519,9 +521,9 @@ class View extends Component
$content
=
ob_get_clean
();
echo
strtr
(
$content
,
array
(
self
::
P
L
_HEAD
=>
$this
->
renderHeadHtml
(),
self
::
P
L
_BODY_BEGIN
=>
$this
->
renderBodyBeginHtml
(),
self
::
P
L
_BODY_END
=>
$this
->
renderBodyEndHtml
(),
self
::
P
H
_HEAD
=>
$this
->
renderHeadHtml
(),
self
::
P
H
_BODY_BEGIN
=>
$this
->
renderBodyBeginHtml
(),
self
::
P
H
_BODY_END
=>
$this
->
renderBodyEndHtml
(),
));
unset
(
...
...
@@ -540,7 +542,7 @@ class View extends Component
*/
public
function
beginBody
()
{
echo
self
::
P
L
_BODY_BEGIN
;
echo
self
::
P
H
_BODY_BEGIN
;
$this
->
trigger
(
self
::
EVENT_BEGIN_BODY
);
}
...
...
@@ -550,7 +552,7 @@ class View extends Component
public
function
endBody
()
{
$this
->
trigger
(
self
::
EVENT_END_BODY
);
echo
self
::
P
L
_BODY_END
;
echo
self
::
P
H
_BODY_END
;
}
/**
...
...
@@ -558,13 +560,14 @@ class View extends Component
*/
public
function
head
()
{
echo
self
::
P
L
_HEAD
;
echo
self
::
P
H
_HEAD
;
}
/**
* Registers the named asset bundle.
* All dependent asset bundles will be registered.
* @param string $name the name of the asset bundle.
* @return AssetBundle the registered asset bundle instance
* @throws InvalidConfigException if the asset bundle does not exist or a circular dependency is detected
*/
public
function
registerAssetBundle
(
$name
)
...
...
@@ -582,6 +585,7 @@ class View extends Component
}
elseif
(
$this
->
assetBundles
[
$name
]
===
false
)
{
throw
new
InvalidConfigException
(
"A circular dependency is detected for bundle '
$name
'."
);
}
return
$this
->
assetBundles
[
$name
];
}
/**
...
...
@@ -665,7 +669,7 @@ class View extends Component
$key
=
$key
?:
md5
(
$js
);
$this
->
js
[
$position
][
$key
]
=
$js
;
if
(
$position
===
self
::
POS_READY
)
{
$this
->
registerAssetBundle
(
'yii/jquery'
);
JqueryAsset
::
register
(
$this
);
}
}
...
...
framework/yii/bootstrap/AffixAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
AffixAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/bootstrap/assets'
;
public
$js
=
array
(
'js/bootstrap-affix.js'
,
);
public
$depends
=
array
(
'yii\bootstrap\TransitionAsset'
,
'yii\bootstrap\BootstrapAsset'
,
'yii\web\JqueryAsset'
,
);
}
framework/yii/bootstrap/AlertAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
AlertAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/bootstrap/assets'
;
public
$js
=
array
(
'js/bootstrap-alert.js'
,
);
public
$depends
=
array
(
'yii\bootstrap\TransitionAsset'
,
'yii\bootstrap\BootstrapAsset'
,
'yii\web\JqueryAsset'
,
);
}
framework/yii/bootstrap/BootstrapAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
BootstrapAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/bootstrap/assets'
;
public
$css
=
array
(
'css/bootstrap.css'
,
);
}
framework/yii/bootstrap/ButtonAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
ButtonAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/bootstrap/assets'
;
public
$js
=
array
(
'js/bootstrap-button.js'
,
);
public
$depends
=
array
(
'yii\bootstrap\TransitionAsset'
,
'yii\bootstrap\BootstrapAsset'
,
'yii\web\JqueryAsset'
,
);
}
framework/yii/bootstrap/CarouselAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
CarouselAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/bootstrap/assets'
;
public
$js
=
array
(
'js/bootstrap-carousel.js'
,
);
public
$depends
=
array
(
'yii\bootstrap\TransitionAsset'
,
'yii\bootstrap\BootstrapAsset'
,
'yii\web\JqueryAsset'
,
);
}
framework/yii/bootstrap/CollapseAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
CollapseAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/bootstrap/assets'
;
public
$js
=
array
(
'js/bootstrap-collapse.js'
,
);
public
$depends
=
array
(
'yii\bootstrap\TransitionAsset'
,
'yii\bootstrap\BootstrapAsset'
,
'yii\web\JqueryAsset'
,
);
}
framework/yii/bootstrap/DropdownAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
DropdownAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/bootstrap/assets'
;
public
$js
=
array
(
'js/bootstrap-dropdown.js'
,
);
public
$depends
=
array
(
'yii\bootstrap\TransitionAsset'
,
'yii\bootstrap\BootstrapAsset'
,
'yii\web\JqueryAsset'
,
);
}
framework/yii/bootstrap/ModalAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
ModalAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/bootstrap/assets'
;
public
$js
=
array
(
'js/bootstrap-modal.js'
,
);
public
$depends
=
array
(
'yii\bootstrap\TransitionAsset'
,
'yii\bootstrap\BootstrapAsset'
,
'yii\web\JqueryAsset'
,
);
}
framework/yii/bootstrap/Nav.php
View file @
368a4cfe
...
...
@@ -88,7 +88,7 @@ class Nav extends Widget
public
function
run
()
{
echo
$this
->
renderItems
();
$this
->
getView
()
->
registerAssetBundle
(
'yii/bootstrap'
);
BootstrapAsset
::
register
(
$this
->
getView
()
);
}
/**
...
...
framework/yii/bootstrap/NavBar.php
View file @
368a4cfe
...
...
@@ -119,7 +119,11 @@ class NavBar extends Widget
echo
Html
::
beginTag
(
'div'
,
$this
->
options
);
echo
$this
->
renderItems
();
echo
Html
::
endTag
(
'div'
);
$this
->
getView
()
->
registerAssetBundle
(
self
::
$responsive
?
'yii/bootstrap/responsive'
:
'yii/bootstrap'
);
if
(
self
::
$responsive
)
{
ResponsiveAsset
::
register
(
$this
->
getView
());
}
else
{
BootstrapAsset
::
register
(
$this
->
getView
());
}
}
/**
...
...
@@ -136,7 +140,7 @@ class NavBar extends Widget
$brand
=
Html
::
a
(
$this
->
brandLabel
,
$this
->
brandUrl
,
$this
->
brandOptions
);
if
(
self
::
$responsive
)
{
$this
->
getView
()
->
registerAssetBundle
(
'yii/bootstrap/collapse'
);
CollapseAsset
::
register
(
$this
->
getView
()
);
$contents
=
Html
::
tag
(
'div'
,
$this
->
renderToggleButton
()
.
$brand
.
"
\n
"
.
...
...
framework/yii/bootstrap/PopoverAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
PopoverAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/bootstrap/assets'
;
public
$js
=
array
(
'js/bootstrap-popover.js'
,
);
public
$depends
=
array
(
'yii\bootstrap\TooltipAsset'
,
);
}
framework/yii/bootstrap/Progress.php
View file @
368a4cfe
...
...
@@ -105,7 +105,11 @@ class Progress extends Widget
echo
Html
::
beginTag
(
'div'
,
$this
->
options
)
.
"
\n
"
;
echo
$this
->
renderProgress
()
.
"
\n
"
;
echo
Html
::
endTag
(
'div'
)
.
"
\n
"
;
$this
->
getView
()
->
registerAssetBundle
(
static
::
$responsive
?
'yii/bootstrap/responsive'
:
'yii/bootstrap'
);
if
(
self
::
$responsive
)
{
ResponsiveAsset
::
register
(
$this
->
getView
());
}
else
{
BootstrapAsset
::
register
(
$this
->
getView
());
}
}
/**
...
...
framework/yii/bootstrap/ResponsiveAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
ResponsiveAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/bootstrap/assets'
;
public
$css
=
array
(
'css/bootstrap-responsive.css'
,
);
public
$depends
=
array
(
'yii\bootstrap\BootstrapAsset'
,
);
}
framework/yii/bootstrap/ScrollspyAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
ScrollspyAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/bootstrap/assets'
;
public
$js
=
array
(
'js/bootstrap-scrollspy.js'
,
);
public
$depends
=
array
(
'yii\bootstrap\TransitionAsset'
,
'yii\bootstrap\BootstrapAsset'
,
'yii\web\JqueryAsset'
,
);
}
framework/yii/bootstrap/TabAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
TabAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/bootstrap/assets'
;
public
$js
=
array
(
'js/bootstrap-tab.js'
,
);
public
$depends
=
array
(
'yii\bootstrap\TransitionAsset'
,
'yii\bootstrap\BootstrapAsset'
,
'yii\web\JqueryAsset'
,
);
}
framework/yii/bootstrap/TooltipAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
TooltipAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/bootstrap/assets'
;
public
$js
=
array
(
'js/bootstrap-tooltip.js'
,
);
public
$depends
=
array
(
'yii\bootstrap\TransitionAsset'
,
'yii\bootstrap\BootstrapAsset'
,
'yii\web\JqueryAsset'
,
);
}
framework/yii/bootstrap/TransitionAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
TransitionAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/bootstrap/assets'
;
public
$js
=
array
(
'js/bootstrap-transition.js'
,
);
public
$depends
=
array
(
'yii\bootstrap\BootstrapAsset'
,
'yii\web\JqueryAsset'
,
);
}
framework/yii/bootstrap/Type
A
head.php
→
framework/yii/bootstrap/Type
a
head.php
View file @
368a4cfe
...
...
@@ -13,7 +13,7 @@ use yii\base\Model;
use
yii\helpers\Html
;
/**
* Type
A
head renders a typehead bootstrap javascript component.
* Type
a
head renders a typehead bootstrap javascript component.
*
* For example,
*
...
...
@@ -42,7 +42,7 @@ use yii\helpers\Html;
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @since 2.0
*/
class
Type
A
head
extends
Widget
class
Type
a
head
extends
Widget
{
/**
* @var \yii\base\Model the data model that this widget is associated with
...
...
framework/yii/bootstrap/TypeaheadAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
TypeaheadAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/bootstrap/assets'
;
public
$js
=
array
(
'js/bootstrap-typeahead.js'
,
);
public
$depends
=
array
(
'yii\bootstrap\TransitionAsset'
,
'yii\bootstrap\BootstrapAsset'
,
'yii\web\JqueryAsset'
,
);
}
framework/yii/bootstrap/Widget.php
View file @
368a4cfe
...
...
@@ -65,8 +65,14 @@ class Widget extends \yii\base\Widget
{
$id
=
$this
->
options
[
'id'
];
$view
=
$this
->
getView
();
$view
->
registerAssetBundle
(
static
::
$responsive
?
'yii/bootstrap/responsive'
:
'yii/bootstrap'
);
$view
->
registerAssetBundle
(
"yii/bootstrap/
$name
"
);
if
(
self
::
$responsive
)
{
ResponsiveAsset
::
register
(
$view
);
}
else
{
BootstrapAsset
::
register
(
$view
);
}
/** @var \yii\web\AssetBundle $assetClass */
$assetClass
=
'yii\bootstrap\\'
.
ucfirst
(
$name
);
$assetClass
::
register
(
$view
);
if
(
$this
->
clientOptions
!==
false
)
{
$options
=
empty
(
$this
->
clientOptions
)
?
''
:
Json
::
encode
(
$this
->
clientOptions
);
...
...
framework/yii/bootstrap/assets.php
View file @
368a4cfe
...
...
@@ -6,108 +6,19 @@
*/
return
array
(
'yii/bootstrap'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'css'
=>
array
(
YII_DEBUG
?
'css/bootstrap.css'
:
'css/bootstrap.min.css'
,
),
),
'yii/bootstrap/responsive'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'css'
=>
array
(
YII_DEBUG
?
'css/bootstrap-responsive.css'
:
'css/bootstrap-responsive.min.css'
,
),
'depends'
=>
array
(
'yii/bootstrap'
),
),
'yii/bootstrap/affix'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'js/bootstrap-affix.js'
,
),
'depends'
=>
array
(
'yii/jquery'
,
'yii/bootstrap'
,
'yii/bootstrap/transition'
),
),
'yii/bootstrap/alert'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'js/bootstrap-alert.js'
,
),
'depends'
=>
array
(
'yii/jquery'
,
'yii/bootstrap'
,
'yii/bootstrap/transition'
),
),
'yii/bootstrap/button'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'js/bootstrap-button.js'
,
),
'depends'
=>
array
(
'yii/jquery'
,
'yii/bootstrap'
,
'yii/bootstrap/transition'
),
),
'yii/bootstrap/carousel'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'js/bootstrap-carousel.js'
,
),
'depends'
=>
array
(
'yii/jquery'
,
'yii/bootstrap'
,
'yii/bootstrap/transition'
),
),
'yii/bootstrap/collapse'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'js/bootstrap-collapse.js'
,
),
'depends'
=>
array
(
'yii/jquery'
,
'yii/bootstrap'
,
'yii/bootstrap/transition'
),
),
'yii/bootstrap/dropdown'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'js/bootstrap-dropdown.js'
,
),
'depends'
=>
array
(
'yii/jquery'
,
'yii/bootstrap'
,
'yii/bootstrap/transition'
),
),
'yii/bootstrap/modal'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'js/bootstrap-modal.js'
,
),
'depends'
=>
array
(
'yii/jquery'
,
'yii/bootstrap'
,
'yii/bootstrap/transition'
),
),
'yii/bootstrap/popover'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'js/bootstrap-popover.js'
,
),
'depends'
=>
array
(
'yii/bootstrap/tooltip'
),
),
'yii/bootstrap/scrollspy'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'js/bootstrap-scrollspy.js'
,
),
'depends'
=>
array
(
'yii/jquery'
,
'yii/bootstrap'
,
'yii/bootstrap/transition'
),
),
'yii/bootstrap/tab'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'js/bootstrap-tab.js'
,
),
'depends'
=>
array
(
'yii/jquery'
,
'yii/bootstrap'
,
'yii/bootstrap/transition'
),
),
'yii/bootstrap/tooltip'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'js/bootstrap-tooltip.js'
,
),
'depends'
=>
array
(
'yii/jquery'
,
'yii/bootstrap'
,
'yii/bootstrap/transition'
),
),
'yii/bootstrap/transition'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'js/bootstrap-transition.js'
,
),
'depends'
=>
array
(
'yii/jquery'
,
'yii/bootstrap'
),
),
'yii/bootstrap/typeahead'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'js'
=>
array
(
'js/bootstrap-typeahead.js'
,
),
'depends'
=>
array
(
'yii/jquery'
,
'yii/bootstrap'
,
'yii/bootstrap/transition'
),
),
yii\bootstrap\BootstrapAsset
::
className
(),
yii\bootstrap\ResponsiveAsset
::
className
(),
yii\bootstrap\DropdownAsset
::
className
(),
yii\bootstrap\TransitionAsset
::
className
(),
yii\bootstrap\AffixAsset
::
className
(),
yii\bootstrap\AlertAsset
::
className
(),
yii\bootstrap\ButtonAsset
::
className
(),
yii\bootstrap\CarouselAsset
::
className
(),
yii\bootstrap\CollapseAsset
::
className
(),
yii\bootstrap\ModalAsset
::
className
(),
yii\bootstrap\PopoverAsset
::
className
(),
yii\bootstrap\TooltipAsset
::
className
(),
yii\bootstrap\ScrollspyAsset
::
className
(),
yii\bootstrap\TabAsset
::
className
(),
yii\bootstrap\TypeaheadAsset
::
className
(),
);
framework/yii/debug/DebugAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\debug
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
DebugAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/debug/assets'
;
public
$css
=
array
(
'main.css'
,
);
public
$depends
=
array
(
'yii\web\YiiAsset'
,
'yii\bootstrap\ResponsiveAsset'
,
);
}
framework/yii/debug/views/default/index.php
View file @
368a4cfe
...
...
@@ -7,7 +7,6 @@ use yii\helpers\Html;
* @var array $manifest
*/
$this
->
registerAssetBundle
(
'yii/bootstrap/dropdown'
);
$this
->
title
=
'Yii Debugger'
;
?>
<div
class=
"default-index"
>
...
...
framework/yii/debug/views/default/view.php
View file @
368a4cfe
...
...
@@ -11,8 +11,8 @@ use yii\helpers\Html;
* @var \yii\debug\Panel $activePanel
*/
$this
->
registerAssetBundle
(
'yii/bootstrap/dropdown'
);
$this
->
title
=
'Yii Debugger'
;
yii\bootstrap\DropdownAsset
::
register
(
$this
);
?>
<div
class=
"default-view"
>
<div
class=
"navbar"
>
...
...
framework/yii/debug/views/layouts/main.php
View file @
368a4cfe
...
...
@@ -5,7 +5,7 @@
*/
use
yii\helpers\Html
;
Yii
::
$app
->
getView
()
->
registerAssetBundle
(
'yii/debug'
);
yii\debug\DebugAsset
::
register
(
$this
);
?>
<!DOCTYPE html>
<html>
...
...
framework/yii/validators/BooleanValidator.php
View file @
368a4cfe
...
...
@@ -102,7 +102,7 @@ class BooleanValidator extends Validator
$options
[
'strict'
]
=
1
;
}
$view
->
registerAssetBundle
(
'yii/validation'
);
ValidationAsset
::
register
(
$view
);
return
'yii.validation.boolean(value, messages, '
.
json_encode
(
$options
)
.
');'
;
}
}
framework/yii/validators/CaptchaValidator.php
View file @
368a4cfe
...
...
@@ -116,7 +116,7 @@ class CaptchaValidator extends Validator
$options
[
'skipOnEmpty'
]
=
1
;
}
$view
->
registerAssetBundle
(
'yii/validation'
);
ValidationAsset
::
register
(
$view
);
return
'yii.validation.captcha(value, messages, '
.
json_encode
(
$options
)
.
');'
;
}
}
framework/yii/validators/CompareValidator.php
View file @
368a4cfe
...
...
@@ -205,7 +205,7 @@ class CompareValidator extends Validator
'{compareValue}'
=>
$compareValue
,
)));
$view
->
registerAssetBundle
(
'yii/validation'
);
ValidationAsset
::
register
(
$view
);
return
'yii.validation.compare(value, messages, '
.
json_encode
(
$options
)
.
');'
;
}
}
framework/yii/validators/EmailValidator.php
View file @
368a4cfe
...
...
@@ -139,9 +139,9 @@ class EmailValidator extends Validator
$options
[
'skipOnEmpty'
]
=
1
;
}
$view
->
registerAssetBundle
(
'yii/validation'
);
ValidationAsset
::
register
(
$view
);
if
(
$this
->
enableIDN
)
{
$view
->
registerAssetBundle
(
'yii/punycode'
);
PunycodeAsset
::
register
(
$view
);
}
return
'yii.validation.email(value, messages, '
.
Json
::
encode
(
$options
)
.
');'
;
}
...
...
framework/yii/validators/NumberValidator.php
View file @
368a4cfe
...
...
@@ -151,7 +151,7 @@ class NumberValidator extends Validator
$options
[
'skipOnEmpty'
]
=
1
;
}
$view
->
registerAssetBundle
(
'yii/validation'
);
ValidationAsset
::
register
(
$view
);
return
'yii.validation.number(value, messages, '
.
Json
::
encode
(
$options
)
.
');'
;
}
}
framework/yii/validators/PunycodeAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\validators
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
PunycodeAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/assets'
;
public
$js
=
array
(
'punycode/punycode.js'
,
);
}
framework/yii/validators/RangeValidator.php
View file @
368a4cfe
...
...
@@ -103,7 +103,7 @@ class RangeValidator extends Validator
$options
[
'skipOnEmpty'
]
=
1
;
}
$view
->
registerAssetBundle
(
'yii/validation'
);
ValidationAsset
::
register
(
$view
);
return
'yii.validation.range(value, messages, '
.
json_encode
(
$options
)
.
');'
;
}
}
framework/yii/validators/RegularExpressionValidator.php
View file @
368a4cfe
...
...
@@ -112,7 +112,7 @@ class RegularExpressionValidator extends Validator
$options
[
'skipOnEmpty'
]
=
1
;
}
$view
->
registerAssetBundle
(
'yii/validation'
);
ValidationAsset
::
register
(
$view
);
return
'yii.validation.regularExpression(value, messages, '
.
Json
::
encode
(
$options
)
.
');'
;
}
}
framework/yii/validators/RequiredValidator.php
View file @
368a4cfe
...
...
@@ -126,7 +126,7 @@ class RequiredValidator extends Validator
'{value}'
=>
$object
->
$attribute
,
)));
$view
->
registerAssetBundle
(
'yii/validation'
);
ValidationAsset
::
register
(
$view
);
return
'yii.validation.required(value, messages, '
.
json_encode
(
$options
)
.
');'
;
}
}
framework/yii/validators/StringValidator.php
View file @
368a4cfe
...
...
@@ -170,7 +170,7 @@ class StringValidator extends Validator
$options
[
'skipOnEmpty'
]
=
1
;
}
$view
->
registerAssetBundle
(
'yii/validation'
);
ValidationAsset
::
register
(
$view
);
return
'yii.validation.string(value, messages, '
.
json_encode
(
$options
)
.
');'
;
}
}
framework/yii/validators/UrlValidator.php
View file @
368a4cfe
...
...
@@ -143,9 +143,9 @@ class UrlValidator extends Validator
$options
[
'defaultScheme'
]
=
$this
->
defaultScheme
;
}
$view
->
registerAssetBundle
(
'yii/validation'
);
ValidationAsset
::
register
(
$view
);
if
(
$this
->
enableIDN
)
{
$view
->
registerAssetBundle
(
'yii/punycode'
);
PunycodeAsset
::
register
(
$view
);
}
return
'yii.validation.url(value, messages, '
.
Json
::
encode
(
$options
)
.
');'
;
}
...
...
framework/yii/validators/ValidationAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\validators
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
ValidationAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/assets'
;
public
$js
=
array
(
'yii.validation.js'
,
);
public
$depends
=
array
(
'yii\web\YiiAsset'
,
);
}
framework/yii/web/AssetBundle.php
View file @
368a4cfe
...
...
@@ -10,6 +10,7 @@ namespace yii\web;
use
Yii
;
use
yii\base\InvalidConfigException
;
use
yii\base\Object
;
use
yii\base\View
;
/**
* AssetBundle represents a collection of asset files, such as CSS, JS, images.
...
...
@@ -101,6 +102,15 @@ class AssetBundle extends Object
*/
public
$publishOptions
=
array
();
/**
* @param View $view
* @return AssetBundle the registered asset bundle instance
*/
public
static
function
register
(
$view
)
{
return
$view
->
registerAssetBundle
(
get_called_class
());
}
/**
* Initializes the bundle.
*/
...
...
@@ -150,7 +160,7 @@ class AssetBundle extends Object
*/
public
function
publish
(
$am
)
{
if
(
$this
->
sourcePath
!==
null
)
{
if
(
$this
->
sourcePath
!==
null
&&
!
isset
(
$this
->
basePath
,
$this
->
baseUrl
)
)
{
list
(
$this
->
basePath
,
$this
->
baseUrl
)
=
$am
->
publish
(
$this
->
sourcePath
,
$this
->
publishOptions
);
}
$converter
=
$am
->
getConverter
();
...
...
framework/yii/web/AssetManager.php
View file @
368a4cfe
...
...
@@ -22,10 +22,11 @@ use yii\helpers\FileHelper;
class
AssetManager
extends
Component
{
/**
* @var array list of available asset bundles. The keys are the bundle names, and the values are the configuration
* arrays for creating the [[AssetBundle]] objects.
* @var array list of available asset bundles. The keys are the class names of the asset bundles,
* and the values are either the configuration arrays for creating the [[AssetBundle]] objects
* or the corresponding asset bundle instances.
*/
public
$bundles
;
public
$bundles
=
array
()
;
/**
* @return string the root directory storing the published asset files.
*/
...
...
@@ -81,55 +82,29 @@ class AssetManager extends Component
$this
->
basePath
=
realpath
(
$this
->
basePath
);
}
$this
->
baseUrl
=
rtrim
(
Yii
::
getAlias
(
$this
->
baseUrl
),
'/'
);
foreach
(
require
(
YII_PATH
.
'/assets.php'
)
as
$name
=>
$bundle
)
{
if
(
!
isset
(
$this
->
bundles
[
$name
]))
{
$this
->
bundles
[
$name
]
=
$bundle
;
}
}
}
/**
* Returns the named bundle.
* This method will first look for the bundle in [[bundles]]. If not found,
* it will attempt to find the bundle from an installed extension using the following procedure:
*
* 1. Convert the bundle into a path alias;
* 2. Determine the root alias and use it to locate the bundle manifest file "assets.php";
* 3. Look for the bundle in the manifest file.
* Returns the named asset bundle.
*
* For example, given the bundle name "foo/button", the method will first convert it
* into the path alias "@foo/button"; since "@foo" is the root alias, it will look
* for the bundle manifest file "@foo/assets.php". The manifest file should return an array
* that lists the bundles used by the "foo/button" extension. The array format is the same as [[bundles]].
* This method will first look for the bundle in [[bundles]]. If not found,
* it will treat `$name` as the class of the asset bundle and create a new instance of it.
*
* @param string $name the bundle name
* @return AssetBundle the loaded bundle object. Null is returned if the bundle does not exist.
* @param string $name the class name of the asset bundle
* @return AssetBundle the asset bundle instance
* @throws InvalidConfigException if $name does not refer to a valid asset bundle
*/
public
function
getBundle
(
$name
)
{
if
(
!
isset
(
$this
->
bundles
[
$name
]))
{
$rootAlias
=
Yii
::
getRootAlias
(
"@
$name
"
);
if
(
$rootAlias
!==
false
)
{
$manifest
=
Yii
::
getAlias
(
"
$rootAlias
/assets.php"
,
false
);
if
(
$manifest
!==
false
&&
is_file
(
$manifest
))
{
foreach
(
require
(
$manifest
)
as
$bn
=>
$config
)
{
$this
->
bundles
[
$bn
]
=
$config
;
}
}
}
if
(
!
isset
(
$this
->
bundles
[
$name
]))
{
return
null
;
}
}
if
(
is_array
(
$this
->
bundles
[
$name
]))
{
$config
=
$this
->
bundles
[
$name
];
if
(
!
isset
(
$config
[
'class'
]))
{
$config
[
'class'
]
=
'yii\\web\\AssetBundle'
;
if
(
isset
(
$this
->
bundles
[
$name
]))
{
if
(
is_array
(
$this
->
bundles
[
$name
]))
{
$this
->
bundles
[
$name
]
=
Yii
::
createObject
(
array_merge
(
array
(
'class'
=>
$name
),
$this
->
bundles
[
$name
]));
}
elseif
(
!
$this
->
bundles
[
$name
]
instanceof
AssetBundle
)
{
throw
new
InvalidConfigException
(
"Invalid asset bundle:
$name
"
);
}
$this
->
bundles
[
$name
]
=
Yii
::
createObject
(
$config
);
}
else
{
$this
->
bundles
[
$name
]
=
Yii
::
createObject
(
$name
);
}
return
$this
->
bundles
[
$name
];
}
...
...
@@ -142,9 +117,7 @@ class AssetManager extends Component
public
function
getConverter
()
{
if
(
$this
->
_converter
===
null
)
{
$this
->
_converter
=
Yii
::
createObject
(
array
(
'class'
=>
'yii\\web\\AssetConverter'
,
));
$this
->
_converter
=
Yii
::
createObject
(
AssetConverter
::
className
());
}
elseif
(
is_array
(
$this
->
_converter
)
||
is_string
(
$this
->
_converter
))
{
$this
->
_converter
=
Yii
::
createObject
(
$this
->
_converter
);
}
...
...
framework/yii/web/JqueryAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\web
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
JqueryAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/assets'
;
public
$js
=
array
(
'jquery.js'
,
);
}
framework/yii/web/YiiAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\web
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
YiiAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/assets'
;
public
$js
=
array
(
'yii.js'
,
);
public
$depends
=
array
(
'yii\web\JqueryAsset'
,
);
}
framework/yii/widgets/ActiveForm.php
View file @
368a4cfe
...
...
@@ -167,8 +167,9 @@ class ActiveForm extends Widget
$id
=
$this
->
options
[
'id'
];
$options
=
Json
::
encode
(
$this
->
getClientOptions
());
$attributes
=
Json
::
encode
(
$this
->
attributes
);
$this
->
getView
()
->
registerAssetBundle
(
'yii/form'
);
$this
->
getView
()
->
registerJs
(
"jQuery('#
$id
').yiiActiveForm(
$attributes
,
$options
);"
);
$view
=
$this
->
getView
();
ActiveFormAsset
::
register
(
$view
);
$view
->
registerJs
(
"jQuery('#
$id
').yiiActiveForm(
$attributes
,
$options
);"
);
}
echo
Html
::
endForm
();
}
...
...
framework/yii/widgets/ActiveFormAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\widgets
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
ActiveFormAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/assets'
;
public
$js
=
array
(
'yii.activeForm.js'
,
);
public
$depends
=
array
(
'yii\web\YiiAsset'
,
);
}
framework/yii/widgets/Captcha.php
View file @
368a4cfe
...
...
@@ -97,8 +97,9 @@ class Captcha extends InputWidget
$options
=
$this
->
getClientOptions
();
$options
=
empty
(
$options
)
?
''
:
Json
::
encode
(
$options
);
$id
=
$this
->
imageOptions
[
'id'
];
$this
->
getView
()
->
registerAssetBundle
(
'yii/captcha'
);
$this
->
getView
()
->
registerJs
(
"jQuery('#
$id
').yiiCaptcha(
$options
);"
);
$view
=
$this
->
getView
();
CaptchaAsset
::
register
(
$view
);
$view
->
registerJs
(
"jQuery('#
$id
').yiiCaptcha(
$options
);"
);
}
/**
...
...
framework/yii/widgets/CaptchaAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\widgets
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
CaptchaAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/assets'
;
public
$js
=
array
(
'yii.captcha.js'
,
);
public
$depends
=
array
(
'yii\web\YiiAsset'
,
);
}
framework/yii/widgets/MaskedInput.php
View file @
368a4cfe
...
...
@@ -109,8 +109,9 @@ class MaskedInput extends InputWidget
}
$id
=
$this
->
options
[
'id'
];
$js
.=
"jQuery(
\"
#
{
$id
}
\"
).mask(
\"
{
$this
->
mask
}
\"
{
$options
}
);"
;
$this
->
getView
()
->
registerAssetBundle
(
'yii/maskedinput'
);
$this
->
getView
()
->
registerJs
(
$js
);
$view
=
$this
->
getView
();
MaskedInputAsset
::
register
(
$view
);
$view
->
registerJs
(
$js
);
}
/**
...
...
framework/yii/widgets/MaskedInputAsset.php
0 → 100644
View file @
368a4cfe
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\widgets
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
MaskedInputAsset
extends
AssetBundle
{
public
$sourcePath
=
'@yii/assets'
;
public
$js
=
array
(
'jquery.maskedinput.js'
,
);
public
$depends
=
array
(
'yii\web\YiiAsset'
,
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment