Skip to content

Commit

Permalink
Plugin loader (#2)
Browse files Browse the repository at this point in the history
* Plugin loader

* Codestyle
  • Loading branch information
amelkikh authored and sizeg committed Aug 11, 2016
1 parent 97f342c commit 724ab60
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions JqPlot.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
* 'data' => [[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]
* ]);
* ```
*
*
* The following example will render a bar chart:
*
*
* ```php
* echo sizeg\jqplot\JqPlot::widget([
* 'data' => [
Expand Down Expand Up @@ -48,7 +48,7 @@
* ]
* ]);
* ```
*
*
* @see http://www.jqplot.com/
* @author Dmitry Demin <sizemail@gmail.com>
* @since 1.0.0-a
Expand Down Expand Up @@ -108,7 +108,7 @@ protected function registerJqPlotClientOptions($id)
$js = "jQuery('#" . $id . "')." . static::NAME . "(" . $data . ", " . $options . ")";
$this->getView()->registerJs($js, View::POS_END);
}

/**
* Find renderers and register their JS plugins
* @param array $data
Expand All @@ -119,8 +119,8 @@ public function registerDependenciesRecursively($data)
foreach ($data as $k => $v) {
if ($k == 'renderer' || $k == 'tickRenderer') {
$this->registerRendererJsFile($v);
} elseif ($k == 'pointLabels' && isset($v['show']) && (boolean)$v['show']) {
Yii::$app->assetManager->bundles[JqPlotAsset::className()]->js[] = 'plugins/jqplot.pointLabels.js';
} elseif (is_array($v) && isset($v['show']) && (boolean)$v['show']) {
Yii::$app->assetManager->bundles[JqPlotAsset::className()]->js[] = 'plugins/jqplot.' . $k . '.js';
} elseif (is_array($v)) {
$this->registerDependenciesRecursively($v);
}
Expand All @@ -140,15 +140,15 @@ public function registerRendererJsFile($renderer)
list($jqPrefix, $jqPlot, $name) = explode('.', $renderer);
$url = 'plugins/jqplot.' . lcfirst($name) . '.js';
}

// Additional dependencies
if ($name == 'CanvasAxisLabelRenderer' || $name == 'CanvasAxisTickRenderer') {
$additionalUrl = 'plugins/jqplot.canvasTextRenderer.js';
if (!in_array($additionalUrl, Yii::$app->assetManager->bundles[JqPlotAsset::className()]->js)) {
Yii::$app->assetManager->bundles[JqPlotAsset::className()]->js[] = $additionalUrl;
}
}

if (!in_array($url, Yii::$app->assetManager->bundles[JqPlotAsset::className()]->js)) {
Yii::$app->assetManager->bundles[JqPlotAsset::className()]->js[] = $url;
}
Expand Down

0 comments on commit 724ab60

Please sign in to comment.