-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
18 changed files
with
74 additions
and
33 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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-krajee-base | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 1.8.1 | ||
* @version 1.8.2 | ||
*/ | ||
|
||
namespace kartik\base; | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-krajee-base | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 1.8.1 | ||
* @version 1.8.2 | ||
*/ | ||
|
||
namespace kartik\base; | ||
|
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
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-krajee-base | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 1.8.1 | ||
* @version 1.8.2 | ||
*/ | ||
|
||
namespace kartik\base; | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-krajee-base | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 1.8.1 | ||
* @version 1.8.2 | ||
*/ | ||
|
||
namespace kartik\base; | ||
|
@@ -140,7 +140,7 @@ protected function renderInput() | |
Html::addCssClass($this->options, 'form-control'); | ||
$size = isset($this->size) ? ' input-group-' . $this->size : ''; | ||
Html::addCssClass($this->containerOptions, 'input-group input-group-html5' . $size); | ||
if (isset($this->width) && ((int) $this->width > 0)) { | ||
if (isset($this->width) && ((int)$this->width > 0)) { | ||
Html::addCssStyle($this->html5Container, 'width:' . $this->width); | ||
} | ||
Html::addCssClass($this->html5Container, 'input-group-addon addon-' . $this->type); | ||
|
@@ -192,7 +192,8 @@ protected static function getAddonContent($addon) | |
|
||
/** | ||
* Gets the HTML5 input | ||
* return string | ||
* | ||
* @return string | ||
*/ | ||
protected function getHtml5Input() | ||
{ | ||
|
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
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-krajee-base | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 1.8.1 | ||
* @version 1.8.2 | ||
*/ | ||
|
||
namespace kartik\base; | ||
|
@@ -46,6 +46,11 @@ class InputWidget extends \yii\widgets\InputWidget | |
*/ | ||
public $readonly = false; | ||
|
||
/** | ||
* @var string the javascript that will be used to destroy the jQuery plugin | ||
*/ | ||
public $pluginDestroyJs; | ||
|
||
/** | ||
* @var mixed show loading indicator while plugin loads | ||
*/ | ||
|
@@ -78,7 +83,7 @@ class InputWidget extends \yii\widgets\InputWidget | |
* ~~~ | ||
*/ | ||
public $pluginEvents = []; | ||
|
||
/** | ||
* @var string a pjax container identifier if applicable inside which the widget will be rendered. | ||
* If this is set, the widget will automatically reinitialize on pjax completion. | ||
|
@@ -139,6 +144,7 @@ class InputWidget extends \yii\widgets\InputWidget | |
public function init() | ||
{ | ||
parent::init(); | ||
$this->initDestroyJs(); | ||
$this->initInputWidget(); | ||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-krajee-base | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 1.8.1 | ||
* @version 1.8.2 | ||
*/ | ||
|
||
namespace kartik\base; | ||
|
@@ -13,7 +13,7 @@ | |
* Base module class for Krajee extensions | ||
* | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @since 1.8.1 | ||
* @since 1.8.2 | ||
*/ | ||
class Module extends \yii\base\Module | ||
{ | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-krajee-base | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 1.8.1 | ||
* @version 1.8.2 | ||
*/ | ||
|
||
namespace kartik\base; | ||
|
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
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-krajee-base | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 1.8.1 | ||
* @version 1.8.2 | ||
*/ | ||
|
||
namespace kartik\base; | ||
|
@@ -17,7 +17,7 @@ | |
* @property array $i18n | ||
* | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @since 1.8.1 | ||
* @since 1.8.2 | ||
*/ | ||
trait TranslationTrait | ||
{ | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-krajee-base | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 1.8.1 | ||
* @version 1.8.2 | ||
*/ | ||
|
||
namespace kartik\base; | ||
|
@@ -27,6 +27,11 @@ class Widget extends \yii\base\Widget | |
*/ | ||
public $options = []; | ||
|
||
/** | ||
* @var string the javascript that will be used to destroy the jQuery plugin | ||
*/ | ||
public $pluginDestroyJs; | ||
|
||
/** | ||
* @var array widget plugin options | ||
*/ | ||
|
@@ -43,6 +48,11 @@ class Widget extends \yii\base\Widget | |
*/ | ||
public $pluginEvents = []; | ||
|
||
/** | ||
* @var string the name of the jQuery plugin | ||
*/ | ||
public $pluginName = ''; | ||
|
||
/** | ||
* @var string a pjax container identifier if applicable inside which the widget will be rendered. If this is set, | ||
* the widget will automatically reinitialize on pjax completion. | ||
|
@@ -59,11 +69,6 @@ class Widget extends \yii\base\Widget | |
*/ | ||
protected $_msgCat = ''; | ||
|
||
/** | ||
* @var string the name of the jQuery plugin | ||
*/ | ||
protected $_pluginName; | ||
|
||
/** | ||
* @var string the hashed global variable name storing the pluginOptions | ||
*/ | ||
|
@@ -88,5 +93,6 @@ public function init() | |
if (empty($this->options['id'])) { | ||
$this->options['id'] = $this->getId(); | ||
} | ||
$this->initDestroyJs(); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-krajee-base | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 1.8.1 | ||
* @version 1.8.2 | ||
*/ | ||
|
||
namespace kartik\base; | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package yii2-krajee-base | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 1.8.1 | ||
* @version 1.8.2 | ||
*/ | ||
|
||
namespace kartik\base; | ||
|
@@ -16,6 +16,8 @@ | |
/** | ||
* Trait used for Krajee widgets. | ||
* | ||
* @property string $pluginName | ||
* @property string $pluginDestroyJs | ||
* @property array $options | ||
* @property array $pluginOptions | ||
* @property array $_encOptions | ||
|
@@ -42,6 +44,24 @@ protected function setDataVar($name) | |
$this->_dataVar = "data-krajee-{$name}"; | ||
} | ||
|
||
|
||
/** | ||
* Generates the `pluginDestroyJs` if not set | ||
*/ | ||
protected function initDestroyJs() | ||
{ | ||
if (isset($this->pluginDestroyJs)) { | ||
return; | ||
} | ||
if (empty($this->pluginName)) { | ||
$this->pluginDestroyJs = ''; | ||
return; | ||
} | ||
$id = "jQuery('#" . $this->options['id'] . "')"; | ||
$plugin = $this->pluginName; | ||
$this->pluginDestroyJs = "if ({$id}.data('{$this->pluginName}')) { {$id}.{$plugin}('destroy'); }"; | ||
} | ||
|
||
/** | ||
* Adds an asset to the view | ||
* | ||
|
@@ -127,7 +147,7 @@ protected function getPluginScript($name, $element = null, $callback = null, $ca | |
$script .= "{$id}.on('{$event}', {$function});\n"; | ||
} | ||
} | ||
return $script; | ||
return $this->pluginDestroyJs . "\n" . $script; | ||
} | ||
|
||
/** | ||
|
@@ -148,7 +168,7 @@ protected function registerPlugin($name, $element = null, $callback = null, $cal | |
* Registers a JS code block for the widget. | ||
* | ||
* @param string $js the JS code block to be registered | ||
* @param integer $position the position at which the JS script tag should be inserted in a page. The possible | ||
* @param integer $pos the position at which 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 | ||
|
@@ -160,16 +180,17 @@ protected function registerPlugin($name, $element = null, $callback = null, $cal | |
* @param string $key the key that identifies the JS code block. If null, it will use $js as the key. If two JS | ||
* code blocks are registered with the same key, the latter will overwrite the former. | ||
*/ | ||
public function registerWidgetJs($js, $position = View::POS_READY, $key = null) | ||
public function registerWidgetJs($js, $pos = View::POS_READY, $key = null) | ||
{ | ||
if (empty($js)) { | ||
return; | ||
} | ||
$view = $this->getView(); | ||
$view->registerJs($js, $position, $key); | ||
if (!empty($this->pjaxContainerId) && ($position === View::POS_LOAD || $position === View::POS_READY)) { | ||
$view->registerJs($js, $pos, $key); | ||
if (!empty($this->pjaxContainerId) && ($pos === View::POS_LOAD || $pos === View::POS_READY)) { | ||
$pjax = 'jQuery("#' . $this->pjaxContainerId . '")'; | ||
$view->registerJs("{$pjax}.on('pjax:complete',function(){ {$js} });"); | ||
$evComplete = 'pjax:complete.' . hash('crc32', $js); | ||
$view->registerJs("{$pjax}.off('{$evComplete}').on('{$evComplete}',function(){ {$js} });"); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* @subpackage yii2-widget-activeform | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 1.8.1 | ||
* @version 1.8.2 | ||
* | ||
* HTML 5 input styling for Twitter Bootstrap 3.0 | ||
* Covers color and range inputs | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* @subpackage yii2-widget-activeform | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 1.8.1 | ||
* @version 1.8.2 | ||
* | ||
* Common CSS file for all kartik\widgets. | ||
* | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* @subpackage yii2-widget-activeform | ||
* @author Kartik Visweswaran <[email protected]> | ||
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 | ||
* @version 1.8.1 | ||
* @version 1.8.2 | ||
* | ||
* Common CSS file for all kartik\widgets. | ||
* | ||
|