Skip to content

Commit

Permalink
Merge pull request #188 from joomdev/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
hiteshaggarwal authored Oct 1, 2020
2 parents 2d4e102 + d5d65d4 commit 537b2c2
Show file tree
Hide file tree
Showing 15 changed files with 193 additions and 43 deletions.
14 changes: 13 additions & 1 deletion astroid/astroid-framework/assets/vendor/astroid/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@
return;
}
$('.astroid-mobile-menu').astroidMobileMenu();
$('#astroid-offcanvas').find('ul.menu').astroidMobileMenu();
$('.astroid-mobile-menu').removeClass('d-none');
};
var initOffcanvasMenu = function () {
if (!$('#astroid-offcanvas').length) {
return;
}
$('#astroid-offcanvas').find('ul.menu').astroidMobileMenu();
};
var initSidebarMenu = function () {
if (!$('.astroid-sidebar-menu').length) {
return;
}
$('.astroid-sidebar-menu .nav-item-caret').click(function () {
$(this).parent('li').siblings('li').children('ul').slideUp();
$(this).parent('li').siblings('li').children('.nav-item-caret').removeClass('open');
Expand Down Expand Up @@ -223,6 +233,8 @@
var docReady = function () {
initDisplay();
initMobileMenu();
initOffcanvasMenu();
initSidebarMenu();
//initMegamenu();
//initSubmenu();
initBackToTop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,40 @@ $menu-indicator-width: 60px !default;
padding: 15px;
}

.menu-item.divider.parent {
position: relative;

span.separator~.menu-indicator {
&:before {
position: absolute;
content: '';
width: 100%;
height: 100%;
top: 0;
left: 0;
}

border-left: 0;
}
}

.menu-item.nav-item-divider.nav-item-parent {
position: relative;

a.item-link-separator~.menu-indicator {
&:before {
position: absolute;
content: '';
width: 100%;
height: 100%;
top: 0;
left: 0;
}

border-left: 0;
}
}

.menu-item .menu-indicator {
width: $menu-indicator-width;
text-align: center;
Expand Down
4 changes: 2 additions & 2 deletions astroid/astroid-framework/astroid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<name>Astroid Framework</name>
<libraryname>astroid</libraryname>
<author>JoomDev</author>
<creationDate>Aug 2020</creationDate>
<version>2.4.3</version>
<creationDate>Sept 2020</creationDate>
<version>2.4.4</version>
<url>https://www.astroidframework.com</url>
<copyright>Copyright (C) 2020 Joomdev, Inc. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
Expand Down
26 changes: 26 additions & 0 deletions astroid/astroid-framework/framework/forms/custom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="params">
<fieldset label="ASTROID_CUSTOMCODE_OPTIONS_TITLE_LABEL" id="astroidcustomcode" name="astroidcustomcode">
<field name="astroid_trackingcode" code="html" filter="raw" class="form-control" type="textarea" label="TPL_ASTROID_CUSTOM_TRACKING_CODE" description="TPL_ASTROID_CUSTOM_TRACKING_CODE_DESC">
</field>

<field code="html" filter="raw" name="astroid_beforehead" class="form-control" type="textarea" label="TPL_ASTROID_CUSTOM_SPACE_BEFORE_HEAD_LABEL" description="TPL_ASTROID_CUSTOM_SPACE_BEFORE_HEAD_DESC">
</field>

<field code="html" filter="raw" name="astroid_beforebody" class="form-control" type="textarea" label="TPL_ASTROID_CUSTOM_SPACE_BEFORE_BODY_LABEL" description="TPL_ASTROID_CUSTOM_SPACE_BEFORE_BODY_DESC">
</field>

<field code="css" filter="raw" name="astroid_customcss" class="form-control" type="textarea" label="TPL_ASTROID_CUSTOM_CUSTOM_CSS_LABEL" description="TPL_ASTROID_CUSTOM_CUSTOM_CSS_DESC">
</field>
<field name="astroid_customcssfiles" filter="raw" class="form-control mw-100" type="textarea" label="TPL_ASTROID_CUSTOM_CUSTOM_CSS_FILES_LABEL" hint="https://yourwebsite.com/style.css" description="TPL_ASTROID_CUSTOM_CUSTOM_CSS_FILES_DESC">
</field>

<field code="javascript" filter="raw" name="astroid_customjs" class="form-control" type="textarea" label="TPL_ASTROID_CUSTOM_CUSTOM_SCRIPT_LABEL" description="TPL_ASTROID_CUSTOM_CUSTOM_SCRIPT_DESC">
</field>

<field name="astroid_customjsfiles" filter="raw" class="form-control mw-100" type="textarea" label="TPL_ASTROID_CUSTOM_CUSTOM_SCRIPT_FILES_LABEL" hint="https://yourwebsite.com/script.js" description="TPL_ASTROID_CUSTOM_CUSTOM_SCRIPT_FILE_DESC">
</field>
</fieldset>
</fields>
</form>
6 changes: 5 additions & 1 deletion astroid/astroid-framework/framework/frontend/offcanvas.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@
return;
}

$module_position = 'offcanvas';
$document->addScript('vendor/astroid/js/offcanvas.js', 'body');
$hasMenu = $document->hasModule($module_position, 'mod_menu');
if ($hasMenu) {
$document->addScript('vendor/astroid/js/mobilemenu.js', 'body');
}

$module_position = 'offcanvas';
$togglevisibility = $params->get('offcanvas_togglevisibility', 'd-block');
$effect = $params->get('offcanvas_animation', 'st-effect-1');
$panelwidth = $params->get('offcanvas_panelwidth', '320px');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ public static function run()
Framework::getDebugger()->log('Lazy Load');
$app = \JFactory::getApplication();
$template = Framework::getTemplate();
$document = Framework::getDocument();
$params = $template->getParams();
$run = $params->get('lazyload', 0);
Helper::createDir(ASTROID_CACHE . '/lazy-load/' . $template->id);
if (!$run) {
return;
}

Framework::getDocument()->addScript('vendor/astroid/js/lazyload.min.js');
// Stop Lazy Load for RSSFeeds
if ($document->getType() == 'feed') $run = false;

// Stop Lazy Load
if (!$run) return;

Helper::createDir(ASTROID_CACHE . '/lazy-load/' . $template->id);
$document->addScript('vendor/astroid/js/lazyload.min.js');

if ($params->get('lazyload_components', '')) {
$run = self::selectedComponents($params->get('lazyload_components', ''), $params->get('lazyload_components_action', 'include'));
Expand Down Expand Up @@ -91,7 +95,7 @@ public static function run()
}

if (Framework::getDebugger()->debug) {
Framework::getReporter('Lazy Load Images')->add('<a href="' . $matches[1][$key] . '" target="_blank"><code>' . Framework::getDocument()->beutifyURL($matches[1][$key]) . '</code></a>');
Framework::getReporter('Lazy Load Images')->add('<a href="' . $matches[1][$key] . '" target="_blank"><code>' . $document->beutifyURL($matches[1][$key]) . '</code></a>');
}

if (!isset($imageMap[md5($matches[1][$key])])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

if (ASTROID_JOOMLA_VERSION == 3) {
\JLoader::register('ModMenuHelper', JPATH_SITE . '/modules/mod_menu/helper.php');
\JLoader::registerAlias('MenuHelper', 'ModMenuHelper');
//\JLoader::registerAlias('MenuHelper', 'ModMenuHelper');
} else {
\JLoader::registerAlias('MenuHelper', '\\Joomla\\Module\\Menu\\Site\\Helper\\MenuHelper');
}
Expand Down Expand Up @@ -46,10 +46,10 @@ public static function getMenu($menutype = '', $nav_class = [], $logo = null, $l
$menu_params = new \JRegistry();
$menu_params->loadString($header_menu_params);

$list = \MenuHelper::getList($menu_params);
$base = \MenuHelper::getBase($menu_params);
$active = \MenuHelper::getActive($menu_params);
$default = \MenuHelper::getDefault();
$list = \ModMenuHelper::getList($menu_params);
$base = \ModMenuHelper::getBase($menu_params);
$active = \ModMenuHelper::getActive($menu_params);
$default = \ModMenuHelper::getDefault();

$active_id = $active->id;
$default_id = $default->id;
Expand Down Expand Up @@ -573,10 +573,10 @@ public static function getMobileMenu($menutype = '', $nav_class = [])
$menu_params = new \JRegistry();
$menu_params->loadString($header_menu_params);

$list = \MenuHelper::getList($menu_params);
$base = \MenuHelper::getBase($menu_params);
$active = \MenuHelper::getActive($menu_params);
$default = \MenuHelper::getDefault();
$list = \ModMenuHelper::getList($menu_params);
$base = \ModMenuHelper::getBase($menu_params);
$active = \ModMenuHelper::getActive($menu_params);
$default = \ModMenuHelper::getDefault();

$active_id = $active->id;
$default_id = $default->id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public static function colors()

// Dropdown Menu
$dropdown = Style::addCssBySelector('.megamenu-container', 'background-color', $params->get('dropdown_bg_color', ''));

$submenuDropdown = Style::addCssBySelector('.megamenu-container .nav-submenu .nav-submenu', 'background-color', $params->get('dropdown_bg_color', ''));

Style::addCssBySelector('.has-megamenu.open .arrow', 'border-bottom-color', $params->get('dropdown_bg_color', ''));
Expand Down Expand Up @@ -321,13 +321,46 @@ public static function custom()

$document->addCustomTag($params->get('trackingcode', ''));
$document->addStyleDeclaration($params->get('customcss', ''));
$document->addStyleSheet(explode("\n", $params->get('customcssfiles', '')));

$customcssfiles = explode("\n", $params->get('customcssfiles'));

foreach ($customcssfiles as $customcssfile) {
@list($file, $shift) = \explode('|', $customcssfile);
$shift = $shift ? $shift : 0;
$document->addStyleSheet($file, ['rel' => 'stylesheet', 'type' => 'text/css'], $shift);
}

$document->addScriptdeclaration($params->get('customjs', ''));
$document->addScript(explode("\n", $params->get('customjsfiles', '')));

$document->addCustomTag($params->get('beforehead', ''));
$document->addCustomTag($params->get('beforebody', ''), 'body');

// Page level custom code
$app = \JFactory::getApplication();
$itemid = $app->input->get('Itemid', '', 'INT');
if (empty($itemid)) return false;

$menu = $app->getMenu();
$item = $menu->getItem($itemid);
$params = $item->getParams();

$document->addCustomTag($params->get('astroid_trackingcode', ''));
$document->addStyleDeclaration($params->get('astroid_customcss', ''));

$customcssfiles = explode("\n", $params->get('astroid_customcssfiles'));

foreach ($customcssfiles as $customcssfile) {
@list($file, $shift) = \explode('|', $customcssfile);
$shift = $shift ? $shift : 0;
$document->addStyleSheet($file, ['rel' => 'stylesheet', 'type' => 'text/css'], $shift);
}

$document->addScriptdeclaration($params->get('astroid_customjs', ''));
$document->addScript(explode("\n", $params->get('astroid_customjsfiles', '')));

$document->addCustomTag($params->get('astroid_beforehead', ''));
$document->addCustomTag($params->get('astroid_beforebody', ''), 'body');
}

public static function error()
Expand Down Expand Up @@ -358,4 +391,4 @@ public static function error()
}
$bodyStyle->render();
}
}
}
53 changes: 40 additions & 13 deletions astroid/astroid-framework/framework/library/astroid/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Document
protected $minify_html = false;
protected static $_fontawesome = false;
protected static $_layout_paths = [];
protected $type = null;

public function __construct()
{
Expand All @@ -38,11 +39,18 @@ public function __construct()
$this->minify_js = $params->get('minify_js', false);
$this->minify_html = $params->get('minify_html', false);

$doc = \JFactory::getDocument();
$this->type = $doc->getType();

$template = Framework::getTemplate();
$this->addLayoutPath(JPATH_SITE . '/templates/' . $template->template . '/html/frontend/');
}

public function getType()
{
return $this->type;
}

public function addLayoutPath($path)
{
self::$_layout_paths[] = $path;
Expand Down Expand Up @@ -104,17 +112,15 @@ public function compress()
$app = \JFactory::getApplication();
$body = $app->getBody();

if ($this->minify_css) {
$body = $this->minifyCSS($body);
}
// Stop Minification for RSSFeeds and other doc types.
if ($this->type == 'feed') $this->minify_css = $this->minify_js = $this->minify_html = false;

if ($this->minify_js && !$this->isFrontendEditing()) {
$body = $this->minifyJS($body);
}
if ($this->minify_css) $body = $this->minifyCSS($body);

if ($this->minify_html) {
$body = $this->minifyHTML($body);
}
if ($this->minify_js && !$this->isFrontendEditing()) $body = $this->minifyJS($body);

if ($this->minify_html) $body = $this->minifyHTML($body);

$app->setBody($body);
}

Expand Down Expand Up @@ -499,6 +505,11 @@ public function position($position, $style = 'none')
return $return;
}

public function hasModule($position, $module)
{
return in_array($module, array_column(\JModuleHelper::getModules($position), 'module'));
}

public function loadModule($content)
{
// Expression to search for(module Position)
Expand Down Expand Up @@ -779,7 +790,7 @@ public function addStyleDeclaration($content, $device = 'desktop')
$this->_styles[$device][] = trim($content);
}

public function addStyleSheet($url, $attribs = ['rel' => 'stylesheet', 'type' => 'text/css'])
public function addStyleSheet($url, $attribs = ['rel' => 'stylesheet', 'type' => 'text/css'], $shifted = 0)
{
if (!is_array($url)) {
$url = [$url];
Expand All @@ -792,7 +803,7 @@ public function addStyleSheet($url, $attribs = ['rel' => 'stylesheet', 'type' =>
}
foreach ($url as $u) {
if (!empty(trim($u))) {
$stylesheet = ['url' => $u, 'attribs' => $attribs];
$stylesheet = ['url' => $u, 'attribs' => $attribs, 'shifted' => $shifted];
$this->_stylesheets[md5($u)] = $stylesheet;
}
}
Expand All @@ -814,15 +825,31 @@ public function loadFontAwesome()
Helper\Font::loadFontAwesome();
}

public function moveFile(&$array, $a, $b)
{
$out = array_splice($array, $a, 1);
array_splice($array, $b, 0, $out);
}

public function getStylesheets()
{
$keys = array_keys($this->_stylesheets);

foreach ($keys as $index => $key) {
if ($this->_stylesheets[$key]['shifted']) {
$newindex = $index + $this->_stylesheets[$key]['shifted'];
$this->moveFile($keys, $index, $newindex);
}
}

$content = '';
foreach ($this->_stylesheets as $stylesheet) {
foreach ($keys as $key) {
$stylesheet = $this->_stylesheets[$key];
$content .= '<link href="' . $this->_systemUrl($stylesheet['url']) . '"';
foreach ($stylesheet['attribs'] as $prop => $value) {
$content .= ' ' . $prop . '="' . $value . '"';
}
$content .= ' />';
$content .= ' />' . "\n";
}
return $content;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public function onContentPrepareForm($form, $data)
$form->loadFile('menu', false);
$form->loadFile('banner', false);
$form->loadFile('og', false);
$form->loadFile('custom', false);
$loaded = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class Constants
{
public static $astroid_version = '2.4.3';
public static $astroid_version = '2.4.4';
public static $fontawesome_version = '5.14.0';
public static $animatecss_version = '3.7.0';
public static $forum_link = 'https://www.joomdev.com/forum/astroid-framework';
Expand Down
Loading

0 comments on commit 537b2c2

Please sign in to comment.