Skip to content

Commit

Permalink
Dev: update Pjax and added position postscript
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Nov 14, 2017
1 parent 7385eaa commit d1bddef
Show file tree
Hide file tree
Showing 4 changed files with 1,849 additions and 876 deletions.
13 changes: 12 additions & 1 deletion application/core/LSYii_ClientScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

class LSYii_ClientScript extends CClientScript {


const POS_POSTSCRIPT=5;

/**
* cssFiles is protected on CClientScript. It can be useful to access it for debugin purpose
* @return array
Expand Down Expand Up @@ -478,7 +481,7 @@ public function renderBodyBegin(&$output)
public function renderBodyEnd(&$output)
{
if(!isset($this->scriptFiles[self::POS_END]) && !isset($this->scripts[self::POS_END])
&& !isset($this->scripts[self::POS_READY]) && !isset($this->scripts[self::POS_LOAD]))
&& !isset($this->scripts[self::POS_READY]) && !isset($this->scripts[self::POS_LOAD]) && !isset($this->scripts[self::POS_POSTSCRIPT]))
{
str_replace('<###end###>','',$output);
return;
Expand Down Expand Up @@ -518,6 +521,14 @@ public function renderBodyEnd(&$output)
$scripts[]=implode("\n",$this->scripts[self::POS_LOAD]);
}

if(isset($this->scripts[self::POS_POSTSCRIPT]))
{
if($fullPage) //This part is different to reflect the changes needed in the backend by the pjax loading of pages
$scripts[]="jQuery(document).on('load pjax:scriptcomplete',function() {\nconsole.log('loading on scriptcomplete');\n".implode("\n",$this->scripts[self::POS_POSTSCRIPT])."\n});";
else
$scripts[]=implode("\n",$this->scripts[self::POS_POSTSCRIPT]);
}

//All scripts are wrapped into a section to be able to reload them accordingly
if(!empty($scripts))
{
Expand Down

0 comments on commit d1bddef

Please sign in to comment.