65 lines
1.6 KiB
PHP
65 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* @link https://github.com/wbraganca/yii2-fancytree-widget
|
|
* @copyright Copyright (c) 2014 Wanderson Bragança
|
|
* @license https://github.com/wbraganca/yii2-fancytree-widget/blob/master/LICENSE
|
|
*/
|
|
|
|
namespace wbraganca\fancytree;
|
|
|
|
/**
|
|
* Asset bundle for fancytree Widget
|
|
*
|
|
* @author Wanderson Bragança <wanderson.wbc@gmail.com>
|
|
*/
|
|
class FancytreeAsset extends \yii\web\AssetBundle
|
|
{
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public $depends = [
|
|
'yii\web\JqueryAsset',
|
|
'yii\jui\JuiAsset'
|
|
];
|
|
|
|
/**
|
|
* Set up CSS and JS asset arrays based on the base-file names
|
|
* @param string $type whether 'css' or 'js'
|
|
* @param array $files the list of 'css' or 'js' basefile names
|
|
*/
|
|
protected function setupAssets($type, $files = [])
|
|
{
|
|
$srcFiles = [];
|
|
$minFiles = [];
|
|
foreach ($files as $file) {
|
|
$srcFiles[] = "{$file}.{$type}";
|
|
$minFiles[] = "{$file}.min.{$type}";
|
|
}
|
|
if (empty($this->$type)) {
|
|
$this->$type = YII_DEBUG ? $srcFiles : $minFiles;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function init()
|
|
{
|
|
$this->setSourcePath(__DIR__ . '/assets');
|
|
$this->setupAssets('css', ['skin-lion/ui.fancytree']);
|
|
$this->setupAssets('js', ['jquery.fancytree']);
|
|
parent::init();
|
|
}
|
|
|
|
/**
|
|
* Sets the source path if empty
|
|
* @param string $path the path to be set
|
|
*/
|
|
protected function setSourcePath($path)
|
|
{
|
|
if (empty($this->sourcePath)) {
|
|
$this->sourcePath = $path;
|
|
}
|
|
}
|
|
}
|