-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Igor Chepurnoy
committed
Dec 31, 2016
1 parent
1009328
commit 4df21da
Showing
7 changed files
with
122 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Ignore all test and documentation for archive | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.scrutinizer.yml export-ignore | ||
/.travis.yml export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/tests export-ignore | ||
/docs export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# phpstorm project files | ||
.idea | ||
|
||
# netbeans project files | ||
nbproject | ||
|
||
# zend studio for eclipse project files | ||
.buildpath | ||
.project | ||
.settings | ||
|
||
# windows thumbnail cache | ||
Thumbs.db | ||
|
||
# composer vendor dir | ||
/vendor | ||
|
||
/composer.lock | ||
|
||
# composer itself is not needed | ||
composer.phar | ||
|
||
# Mac DS_Store Files | ||
.DS_Store | ||
|
||
# phpunit itself is not needed | ||
phpunit.phar | ||
# local phpunit config | ||
/phpunit.xml | ||
|
||
# local tests configuration | ||
/tests/data/config.local.php | ||
|
||
# runtime cache | ||
/tests/runtime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->exclude('vendor') | ||
->in([__DIR__]); | ||
|
||
$config = PhpCsFixer\Config::create() | ||
->setUsingCache(false) | ||
->setRules([ | ||
'@Symfony' => true, | ||
'phpdoc_align' => false, | ||
'phpdoc_summary' => false, | ||
'phpdoc_inline_tag' => false, | ||
'pre_increment' => false, | ||
'heredoc_to_nowdoc' => false, | ||
'cast_spaces' => false, | ||
'include' => false, | ||
'phpdoc_no_package' => false, | ||
'concat_space' => ['spacing' => 'one'], | ||
'ordered_imports' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
]) | ||
->setFinder($finder); | ||
|
||
return $config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
language: php | ||
|
||
php: | ||
- 5.6 | ||
|
||
# faster builds on new travis setup not using sudo | ||
sudo: false | ||
|
||
# cache vendor dirs | ||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
- vendor | ||
|
||
install: | ||
- travis_retry composer self-update && composer --version | ||
- travis_retry composer global require "fxp/composer-asset-plugin:~1.1.1" | ||
- export PATH="$HOME/.composer/vendor/bin:$PATH" | ||
- travis_retry composer install --prefer-dist --no-interaction | ||
|
||
script: | ||
- vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --dry-run --diff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,52 +7,46 @@ | |
use yii\widgets\InputWidget; | ||
|
||
/** | ||
* Chosen Select Widget based on Chosen jQuery plugin {@link http://harvesthq.github.io/chosen) | ||
* @package yii2mod\chosen | ||
* Yii2 wrapper for Chosen plugin {@link http://harvesthq.github.io/chosen) | ||
* | ||
* @author Igor Chepurnoy | ||
* @author Igor Chepurnoy <[email protected]> | ||
* | ||
* @since 1.0 | ||
*/ | ||
class ChosenSelect extends InputWidget | ||
{ | ||
/** | ||
* @var array the HTML attributes for the input tag. In default it contains ['data-placeholder' => 'Please select...', 'multiple' => false] | ||
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. | ||
*/ | ||
public $options = []; | ||
|
||
/** | ||
* @var array select items | ||
*/ | ||
public $items = []; | ||
|
||
/** | ||
* @var array Plugin options. In default it contains ['width' => '100%'] | ||
* @var array plugin options. By default it contains ['width' => '100%'] | ||
*/ | ||
public $pluginOptions = []; | ||
|
||
/** | ||
* Initializes the object. | ||
* This method is invoked at the end of the constructor after the object is initialized with the | ||
* given configuration. | ||
* @inheritdoc | ||
*/ | ||
public function init() | ||
{ | ||
parent::init(); | ||
|
||
if(empty($this->options['data-placeholder'])) { | ||
if (empty($this->options['data-placeholder'])) { | ||
$this->options['data-placeholder'] = 'Please select...'; | ||
} | ||
if(empty($this->options['multiple'])) { | ||
|
||
if (empty($this->options['multiple'])) { | ||
$this->options['multiple'] = false; | ||
} | ||
if(empty($this->pluginOptions['width'])) { | ||
|
||
if (empty($this->pluginOptions['width'])) { | ||
$this->pluginOptions['width'] = '100%'; | ||
} | ||
} | ||
|
||
/** | ||
* Render chosen select | ||
* @return string|void | ||
* @inheritdoc | ||
*/ | ||
public function run() | ||
{ | ||
|
@@ -71,24 +65,17 @@ protected function registerAssets() | |
{ | ||
$view = $this->getView(); | ||
ChosenSelectAsset::register($view); | ||
$js = '$("#' . $this->getInputId() . '").chosen(' . $this->getPluginOptions() . ');'; | ||
$js = '$("#' . $this->options['id'] . '").chosen(' . $this->getPluginOptions() . ');'; | ||
$view->registerJs($js, $view::POS_END); | ||
} | ||
|
||
/** | ||
* Return plugin options in json format | ||
* | ||
* @return string | ||
*/ | ||
public function getPluginOptions() | ||
{ | ||
return Json::encode($this->pluginOptions); | ||
} | ||
|
||
/** | ||
* Return input id | ||
*/ | ||
public function getInputId() | ||
{ | ||
return $this->options['id']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,36 +5,38 @@ | |
use yii\web\AssetBundle; | ||
|
||
/** | ||
* Class ChosenSelectAsset | ||
* @package yii2mod\chosen | ||
* ChosenSelectAsset bundle | ||
* | ||
* @author Igor Chepurnoy <[email protected]> | ||
* | ||
* @since 1.0 | ||
*/ | ||
class ChosenSelectAsset extends AssetBundle | ||
{ | ||
/** | ||
* @var string | ||
* @var string the directory that contains the source asset files for this asset bundle | ||
*/ | ||
public $sourcePath = '@bower/drmonty-chosen'; | ||
|
||
/** | ||
* @var array | ||
* @var array list of JavaScript files that this bundle contains | ||
*/ | ||
public $js = [ | ||
'js/chosen.jquery.js', | ||
'js/chosen.proto.js', | ||
]; | ||
|
||
/** | ||
* @var array | ||
* @var array list of CSS files that this bundle contains | ||
*/ | ||
public $css = [ | ||
'css/chosen.css', | ||
]; | ||
|
||
/** | ||
* Depends | ||
* @var array | ||
* @var array list of JavaScript files that this bundle contains | ||
*/ | ||
public $depends = [ | ||
'yii\web\YiiAsset' | ||
'yii\web\YiiAsset', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters