diff --git a/sources/application/WebPage/AjaxPage.php b/sources/application/WebPage/AjaxPage.php index db42dcd8e..6b2517fb3 100644 --- a/sources/application/WebPage/AjaxPage.php +++ b/sources/application/WebPage/AjaxPage.php @@ -179,7 +179,7 @@ EOF 'aCssInline' => $this->a_styles, 'aJsFiles' => $this->a_linked_scripts, 'aJsInlineLive' => $this->a_scripts, - 'aJsInlineOnDomReady' => $this->a_ready_scripts, + 'aJsInlineOnDomReady' => $this->GetReadyScripts(), 'aJsInlineOnInit' => $this->a_init_scripts, 'bEscapeContent' => ($this->sContentType == 'text/html') && ($this->sContentDisposition == 'inline'), // TODO 3.0.0: TEMP, used while developping, remove it. diff --git a/sources/application/WebPage/NiceWebPage.php b/sources/application/WebPage/NiceWebPage.php index 602bd2df1..4afea7c8a 100644 --- a/sources/application/WebPage/NiceWebPage.php +++ b/sources/application/WebPage/NiceWebPage.php @@ -235,4 +235,18 @@ EOF ) ); } + + protected function GetReadyScriptsStartedTrigger(): ?string + { + return <<a_ready_scripts; + + $sReadyStartedTriggerScript = $this->GetReadyScriptsStartedTrigger(); + if (!empty($sReadyStartedTriggerScript)) { + array_unshift($aReadyScripts, $sReadyStartedTriggerScript); + } + + $sReadyFinishedTriggerScript = $this->GetReadyScriptsFinishedTrigger(); + if (!empty($sReadyFinishedTriggerScript)) { + $aReadyScripts[] = $sReadyFinishedTriggerScript; + } + + return $aReadyScripts; + } + + /** + * @return ?string script to execute before all ready scripts + * @since 3.0.0 N°3750 method creation + */ + protected function GetReadyScriptsStartedTrigger(): ?string + { + return null; + } + + /** + * @return ?string script to execute after all ready scripts are done processing + * @since 3.0.0 N°3750 method creation + */ + protected function GetReadyScriptsFinishedTrigger(): ?string + { + return null; + } + /** * Empty all base linked scripts for the page * - * @uses \WebPage::$a_linked_scripts * @return void + * @uses \WebPage::$a_linked_scripts * @since 3.0.0 */ protected function EmptyLinkedScripts(): void @@ -1041,7 +1086,7 @@ class WebPage implements Page 'aCssInline' => $this->a_styles, 'aJsFiles' => $this->a_linked_scripts, 'aJsInlineLive' => $this->a_scripts, - 'aJsInlineOnDomReady' => $this->a_ready_scripts, + 'aJsInlineOnDomReady' => $this->GetReadyScripts(), 'aJsInlineOnInit' => $this->a_init_scripts, // TODO 3.0.0: TEMP, used while developing, remove it. diff --git a/sources/application/WebPage/iTopWebPage.php b/sources/application/WebPage/iTopWebPage.php index aa7839c66..37ced3fd0 100644 --- a/sources/application/WebPage/iTopWebPage.php +++ b/sources/application/WebPage/iTopWebPage.php @@ -925,7 +925,7 @@ HTML; 'aCssInline' => $this->a_styles, 'aJsFiles' => $this->a_linked_scripts, 'aJsInlineOnInit' => $this->a_init_scripts, - 'aJsInlineOnDomReady' => $this->a_ready_scripts, + 'aJsInlineOnDomReady' => $this->GetReadyScripts(), 'aJsInlineLive' => $this->a_scripts, // TODO 3.0.0: TEMP, used while developping, remove it. 'sSanitizedContent' => utils::FilterXSS($this->s_content), @@ -1244,9 +1244,8 @@ EOF */ protected function OutputPrintable(): BlockPrintHeader { - $oBlock= new BlockPrintHeader(); + $oBlock = new BlockPrintHeader(); + return $oBlock; } - - }