Skip to content

Commit

Permalink
Create script manager to load assets
Browse files Browse the repository at this point in the history
  • Loading branch information
puleeno committed Nov 19, 2021
1 parent eaaef25 commit 071acb5
Show file tree
Hide file tree
Showing 8 changed files with 7,034 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Nextend\SmartSlider3\Application\Frontend\ApplicationTypeFrontend;
use Nextend\SmartSlider3\Slider\Slider;
use Nextend\SmartSlider3\Widget\SliderWidget;
use Ramphor\SharpSlider\Application\Frontend\ApplicationTypeFrontend as RamphorApplicationTypeFrontend;

abstract class AbstractSliderTypeFrontend {

Expand Down Expand Up @@ -153,8 +154,6 @@ public function setJavaScriptProperty($key, $value) {
}

public function enqueueAssets() {

Js::addStaticGroup(ApplicationTypeFrontend::getAssetsPath() . '/dist/smartslider-frontend.min.js', 'smartslider-frontend');
}

public function handleSliderMinHeight($minHeight) {
Expand Down
4 changes: 3 additions & 1 deletion Nextend/SmartSlider3/SmartSlider3.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Nextend\SmartSlider3\Slider\SliderType\Block\SliderTypeBlock;
use Nextend\SmartSlider3\Slider\SliderType\Simple\SliderTypeSimple;
use Nextend\SmartSlider3\Slider\SliderType\SliderTypeFactory;
use Ramphor\SharpSlider\Application\Frontend\ScriptManager;
use Ramphor\SharpSlider\Slider\ResponsiveTypeLoader;
use Ramphor\SharpSlider\Slider\SliderType\Carousel\SliderTypeCarousel;

Expand Down Expand Up @@ -53,7 +54,8 @@ protected function init() {
'sliderGenerator'
));


$scriptManager = new ScriptManager();
add_action('wp_enqueue_scripts', array($scriptManager, 'init'));
}

public function sliderTypes() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace Ramphor\SharpSlider\Application\Frontend;

class ApplicationTypeFrontend
{
protected static $assetDirUrl;

public static function getAssetPath($path = '') {
if (is_null(static::$assetDirUrl)) {
$rootDir = dirname(SHARP_SLIDER_PLUGIN_FILE);
static::$assetDirUrl = jankx_get_path_url($rootDir);
}
return sprintf('%s/assets/%s', static::$assetDirUrl, $path);
}
}
10 changes: 10 additions & 0 deletions Ramphor/SharpSlider/Application/Frontend/ScriptManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Ramphor\SharpSlider\Application\Frontend;

class ScriptManager
{
public function init() {
js('sharpslider', ApplicationTypeFrontend::getAssetPath('js/sharpslider.js'), array(), '3.5.0.10', true);
js('sharpslider');
}
}
Loading

0 comments on commit 071acb5

Please sign in to comment.