From 80420baa5b6c42f016c041bc13264382cc50d698 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Sat, 7 Oct 2017 11:10:25 +0200 Subject: The shorthand methods "addCSS" and "addJS" have been removed. If you need shorthand syntax, you can abstract the Pagelet class and use your own extended class which is more flexible and will keep the BigPipe main classes as small as possible. --- include/classes/BigPipe/Pagelet.php | 14 -------------- include/pagelets.php | 14 ++++++-------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/include/classes/BigPipe/Pagelet.php b/include/classes/BigPipe/Pagelet.php index f052b71..664883a 100755 --- a/include/classes/BigPipe/Pagelet.php +++ b/include/classes/BigPipe/Pagelet.php @@ -95,20 +95,6 @@ class Pagelet extends Item { return $this->resources[$Resource->getType()][] = $Resource; } - #=============================================================================== - # Short: Add stylesheet resource by URL - #=============================================================================== - public function addCSS($resourceURL): Resource { - return $this->addResource(new Resource\Stylesheet(NULL, $resourceURL)); - } - - #=============================================================================== - # Short: Add javascript resource by URL - #=============================================================================== - public function addJS($resourceURL): Resource { - return $this->addResource(new Resource\Javascript(NULL, $resourceURL)); - } - #=============================================================================== # Attach a main JS code part #=============================================================================== diff --git a/include/pagelets.php b/include/pagelets.php index 4a86d49..cdb1a14 100644 --- a/include/pagelets.php +++ b/include/pagelets.php @@ -9,9 +9,8 @@ BigPipe\BigPipe::debugging(TRUE); #=============================================================================== $PageletRed = new BigPipe\Pagelet('redPL'); $PageletRed->addHTML('
I AM A PAGELET WITH RED BACKGROUND
'); -$PageletRed->addCSS('static/red.php'); -$PageletRed->addCSS('static/red.php'); -$PageletRed->addJS('static/delayJS.php'); +$PageletRed->addResource(new BigPipe\Resource\Stylesheet(NULL, 'static/red.php')); +$PageletRed->addResource(new BigPipe\Resource\Javascript(NULL, 'static/delayJS.php')); $PageletRed->addJSCode("document.getElementById('red').innerHTML += ' [JS executed]';document.getElementById('red').style.borderRadius = '30px';"); #=============================================================================== @@ -19,9 +18,8 @@ $PageletRed->addJSCode("document.getElementById('red').innerHTML += ' [JS execut #=============================================================================== $PageletBlue = new BigPipe\Pagelet('bluePL', BigPipe\Pagelet::PRIORITY_HIGH); $PageletBlue->addHTML('
I AM A PAGELET WITH BLUE BACKGROUND
'); -$PageletBlue->addCSS('static/blue.php'); -$PageletRed->addCSS('static/red.php'); -$PageletBlue->addJS('static/delayJS.php'); +$PageletBlue->addResource(new BigPipe\Resource\Stylesheet(NULL, 'static/blue.php')); +$PageletBlue->addResource(new BigPipe\Resource\Javascript(NULL, 'static/delayJS.php')); $PageletBlue->addJSCode("document.getElementById('blue').innerHTML += ' [JS executed]';document.getElementById('blue').style.borderRadius = '30px';"); #=============================================================================== @@ -54,7 +52,7 @@ $PageletGreen = new BigPipe\Pagelet('greenPL'); } $PageletGreen->addHTML('
I AM A PAGELET WITH GREEN BACKGROUND'.$InnerPagelet.'
'); -$PageletGreen->addCSS('static/green.php'); -$PageletGreen->addJS('static/delayJS.php'); +$PageletGreen->addResource(new BigPipe\Resource\Stylesheet(NULL, 'static/green.php')); +$PageletGreen->addResource(new BigPipe\Resource\Javascript(NULL, 'static/delayJS.php')); $PageletGreen->addJSCode("document.getElementById('green').innerHTML += ' [JS executed]';document.getElementById('green').style.borderRadius = '30px';"); ?> \ No newline at end of file -- cgit v1.2.3