Skip to content

Commit 79c35ec

Browse files
committed
treeview
1 parent 9a3e85a commit 79c35ec

File tree

8 files changed

+148
-74
lines changed

8 files changed

+148
-74
lines changed

.gitattributes

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +0,0 @@
1-
# Auto detect text files and perform LF normalization
2-
* text=auto
3-
4-
# Custom for Visual Studio
5-
*.cs diff=csharp
6-
7-
# Standard to msysgit
8-
*.doc diff=astextplain
9-
*.DOC diff=astextplain
10-
*.docx diff=astextplain
11-
*.DOCX diff=astextplain
12-
*.dot diff=astextplain
13-
*.DOT diff=astextplain
14-
*.pdf diff=astextplain
15-
*.PDF diff=astextplain
16-
*.rtf diff=astextplain
17-
*.RTF diff=astextplain

.gitignore

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +0,0 @@
1-
assets/*
2-
!assets/.gitignore
3-
protected/runtime/*
4-
!protected/runtime/.gitignore
5-
protected/data/*.db
6-
themes/classic/views/
7-
8-
# =========================
9-
# Operating System Files
10-
# =========================
11-
12-
# OSX
13-
# =========================
14-
15-
.DS_Store
16-
.AppleDouble
17-
.LSOverride
18-
19-
# Thumbnails
20-
._*
21-
22-
# Files that might appear in the root of a volume
23-
.DocumentRevisions-V100
24-
.fseventsd
25-
.Spotlight-V100
26-
.TemporaryItems
27-
.Trashes
28-
.VolumeIcon.icns
29-
30-
# Directories potentially created on remote AFP share
31-
.AppleDB
32-
.AppleDesktop
33-
Network Trash Folder
34-
Temporary Items
35-
.apdisk
36-
37-
# Windows
38-
# =========================
39-
40-
# Windows image file caches
41-
Thumbs.db
42-
ehthumbs.db
43-
44-
# Folder config file
45-
Desktop.ini
46-
47-
# Recycle Bin used on file shares
48-
$RECYCLE.BIN/
49-
50-
# Windows Installer files
51-
*.cab
52-
*.msi
53-
*.msm
54-
*.msp
55-
56-
# Windows shortcuts
57-
*.lnk

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
yii2-bootstrap-tree
2+
===================
3+
Виджет основыный на [bootstrap-treeview](https://github.com/lesha724/yii2-tree-view)
4+
5+
Installation
6+
------------
7+
8+
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
9+
10+
Either run
11+
12+
```
13+
php composer.phar require --prefer-dist lesha724/yii2-bootstrap-tree "*"
14+
```
15+
16+
or add
17+
18+
```
19+
"lesha724/yii2-bootstrap-tree": "*"
20+
```
21+
22+
to the require section of your `composer.json` file.
23+
24+
25+
Usage
26+
-----
27+
28+
Once the extension is installed, simply use it in your code by :
29+
30+
```php
31+
<?= \lesha724\bootstraptree\AutoloadExample::widget(); ?>```

TreeView.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace lesha724\bootstraptree;
4+
use yii\helpers\Html;
5+
use yii\helpers\Json;
6+
use yii\web\View;
7+
8+
/**
9+
* This is just an example.
10+
*/
11+
class TreeView extends \yii\base\Widget
12+
{
13+
public static $autoIdPrefix = 'wbtreeview_';
14+
/**
15+
* @var array additional HTML attributes that will be rendered in the div tag.
16+
*/
17+
public $htmlOptions=[];
18+
/**
19+
* @var array additional options that can be passed to the constructor of the treeview js object.
20+
*/
21+
public $options=[];
22+
23+
protected $_id;
24+
25+
public function init(){
26+
parent::init();
27+
28+
if(isset($this->htmlOptions['id']))
29+
$this->_id=$this->htmlOptions['id'];
30+
else
31+
$this->_id=$this->htmlOptions['id']=$this->getId();
32+
}
33+
34+
public function run()
35+
{
36+
parent::run(); // TODO: Change the autogenerated stub
37+
38+
$view = $this->getView();
39+
TreeViewAsset::register($view);
40+
41+
$options=$this->options===[]?'{}' : Json::encode($this->options);
42+
$view->registerJs('$("#' . $this->_id . '").treeview( ' .$options .')', View::POS_READY);
43+
44+
return $this->_runWidget();
45+
}
46+
47+
/**
48+
* Вывод виджета
49+
* @return string html widget
50+
*/
51+
protected function _runWidget()
52+
{
53+
$html = Html::beginTag('div',$this->htmlOptions);
54+
$html .= Html::endTag('div');
55+
56+
return $html;
57+
}
58+
}

TreeViewAsset.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Neff
5+
* Date: 06.02.2017
6+
* Time: 22:10
7+
*/
8+
9+
namespace lesha724\bootstraptree;
10+
11+
12+
use yii\web\AssetBundle;
13+
14+
class TreeViewAsset extends AssetBundle
15+
{
16+
public static $customCss = null;
17+
public $sourcePath = '@vendor/lesha724/yii2-bootstrap-tree/assets/bootstrap-treeview';
18+
19+
public $css = [
20+
'bootstrap-treeview.min.css'
21+
];
22+
23+
public $js = [
24+
'bootstrap-treeview.min.js'
25+
];
26+
27+
public $depends = [
28+
'yii\web\JqueryAsset',
29+
'yii\bootstrap\BootstrapPluginAsset',
30+
];
31+
32+
public function init()
33+
{
34+
parent::init(); // TODO: Change the autogenerated stub
35+
}
36+
}

assets/bootstrap-treeview/bootstrap-treeview.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/bootstrap-treeview/bootstrap-treeview.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "lesha724/yii2-bootstrap-tree",
3+
"description": "Виджет основыный на [bootstrap-treeview](https://github.com/lesha724/yii2-tree-view)",
4+
"type": "yii2-extension",
5+
"keywords": ["yii2","extension","bootstrap","tree"],
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "lesha724",
10+
"email": "neff.alexey@gmail.com"
11+
}
12+
],
13+
"require": {
14+
"yiisoft/yii2": "*"
15+
},
16+
"autoload": {
17+
"psr-4": {
18+
"lesha724\\bootstraptree\\": ""
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)