Skip to content

Commit 1c4b301

Browse files
Add option noIncludeCssFilesOnPjax
1 parent 531cdf7 commit 1c4b301

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
==============
33

4+
1.4.3.2
5+
-----------------
6+
* Fixed option noIncludeJsFilesOnPjax = true
7+
* Add option noIncludeCssFilesOnPjax = true — Do not connect the css files when all pjax requests when enabled cssFileCompile
8+
49
1.4.3.1
510
-----------------
611
* Fixed: https://github.com/skeeks-semenov/yii2-assets-auto-compress/pull/60

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ How to use
8080
'jsFileCompress' => true, //Enable compression and processing js before saving a file
8181
'jsFileCompressFlaggedComments' => true, //Cut comments during processing js
8282

83-
'noIncludeJsFilesOnPjax' => true, //Do not connect the js files when all pjax requests
83+
'noIncludeJsFilesOnPjax' => true, //Do not connect the js files when all pjax requests when all pjax requests when enabled jsFileCompile
84+
'noIncludeCssFilesOnPjax' => true, //Do not connect the css files when all pjax requests when all pjax requests when enabled cssFileCompile
8485

8586
'htmlFormatter' => [
8687
//Enable compression html

src/AssetsAutoCompressComponent.php

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class AssetsAutoCompressComponent extends Component implements BootstrapInterfac
7474

7575
/**
7676
* Enables the compilation of files in groups rather than in a single file. Works only when the $cssFileCompile option is enabled
77-
* @var bool
77+
* @var bool
7878
*/
7979
public $cssFileCompileByGroups = false;
8080

@@ -139,10 +139,16 @@ class AssetsAutoCompressComponent extends Component implements BootstrapInterfac
139139
public $jsFileCompressFlaggedComments = true;
140140

141141
/**
142-
* Do not connect the js files when all pjax requests.
142+
* Do not connect the js files when all pjax requests when enabled jsFileCompile
143143
* @var bool
144144
*/
145145
public $noIncludeJsFilesOnPjax = true;
146+
147+
/**
148+
* Do not connect the css files when all pjax requests when enabled cssFileCompile
149+
* @var bool
150+
*/
151+
public $noIncludeCssFilesOnPjax = true;
146152
/**
147153
* @var bool|array|string|IFormatter
148154
*/
@@ -220,8 +226,15 @@ public function bootstrap($app)
220226
}
221227

222228
//TODO:: Think about it
223-
if ($this->enabled && $app->request->isPjax && $this->noIncludeJsFilesOnPjax) {
224-
\Yii::$app->view->jsFiles = null;
229+
if ($this->enabled && $app->request->isPjax) {
230+
231+
if ($this->noIncludeJsFilesOnPjax && $this->jsFileCompile) {
232+
\Yii::$app->view->jsFiles = null;
233+
}
234+
235+
if ($this->noIncludeCssFilesOnPjax && $this->cssFileCompile) {
236+
\Yii::$app->view->cssFiles = null;
237+
}
225238
}
226239
});
227240

@@ -233,10 +246,6 @@ public function bootstrap($app)
233246
if (!empty($response->data)) {
234247
$response->data = $this->_processingHtml($response->data);
235248
}
236-
237-
/*if (!empty($response->content)) {
238-
$response->content = $this->_processingHtml($response->content);
239-
}*/
240249
}
241250
});
242251
}
@@ -345,14 +354,14 @@ protected function _processAndGroupJsFiles($files = [])
345354

346355
$result = [];
347356
$groupedFiles = $this->_getGroupedFiles($files);
348-
foreach ($groupedFiles as $files)
349-
{
357+
foreach ($groupedFiles as $files) {
350358
$resultGroup = $this->_processingJsFiles($files);
351359
$result = ArrayHelper::merge($result, $resultGroup);
352360
}
353-
361+
354362
return $result;
355-
echo "<pre><code>" . print_r($result, true); die;
363+
echo "<pre><code>".print_r($result, true);
364+
die;
356365

357366
}
358367

@@ -366,7 +375,7 @@ public function _getGroupedFiles($files)
366375
foreach ($files as $fileCode => $fileTag) {
367376
list($one, $two, $key) = explode("/", $fileCode);
368377

369-
$counter ++;
378+
$counter++;
370379

371380
if ($key != $lastKey && $counter > 1) {
372381
$result[] = $tmpData;
@@ -550,7 +559,7 @@ protected function _processingJs($parts)
550559

551560
return $result;
552561
}
553-
562+
554563
/**
555564
* @param array $files
556565
*/
@@ -562,16 +571,15 @@ protected function _processAndGroupCssFiles($files = [])
562571

563572
$result = [];
564573
$groupedFiles = $this->_getGroupedFiles($files);
565-
foreach ($groupedFiles as $files)
566-
{
574+
foreach ($groupedFiles as $files) {
567575
$resultGroup = $this->_processingCssFiles($files);
568576
$result = ArrayHelper::merge($result, $resultGroup);
569577
}
570-
578+
571579
return $result;
572580

573581
}
574-
582+
575583
/**
576584
* @param array $files
577585
* @return array

0 commit comments

Comments
 (0)