Skip to content

Commit 537b2c2

Browse files
Merge pull request #188 from joomdev/dev
Dev
2 parents 2d4e102 + d5d65d4 commit 537b2c2

File tree

15 files changed

+193
-43
lines changed

15 files changed

+193
-43
lines changed

astroid/astroid-framework/assets/vendor/astroid/js/script.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@
1515
return;
1616
}
1717
$('.astroid-mobile-menu').astroidMobileMenu();
18-
$('#astroid-offcanvas').find('ul.menu').astroidMobileMenu();
1918
$('.astroid-mobile-menu').removeClass('d-none');
19+
};
20+
var initOffcanvasMenu = function () {
21+
if (!$('#astroid-offcanvas').length) {
22+
return;
23+
}
24+
$('#astroid-offcanvas').find('ul.menu').astroidMobileMenu();
25+
};
26+
var initSidebarMenu = function () {
27+
if (!$('.astroid-sidebar-menu').length) {
28+
return;
29+
}
2030
$('.astroid-sidebar-menu .nav-item-caret').click(function () {
2131
$(this).parent('li').siblings('li').children('ul').slideUp();
2232
$(this).parent('li').siblings('li').children('.nav-item-caret').removeClass('open');
@@ -223,6 +233,8 @@
223233
var docReady = function () {
224234
initDisplay();
225235
initMobileMenu();
236+
initOffcanvasMenu();
237+
initSidebarMenu();
226238
//initMegamenu();
227239
//initSubmenu();
228240
initBackToTop();

astroid/astroid-framework/assets/vendor/astroid/scss/_mobilemenu.scss

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,40 @@ $menu-indicator-width: 60px !default;
8686
padding: 15px;
8787
}
8888

89+
.menu-item.divider.parent {
90+
position: relative;
91+
92+
span.separator~.menu-indicator {
93+
&:before {
94+
position: absolute;
95+
content: '';
96+
width: 100%;
97+
height: 100%;
98+
top: 0;
99+
left: 0;
100+
}
101+
102+
border-left: 0;
103+
}
104+
}
105+
106+
.menu-item.nav-item-divider.nav-item-parent {
107+
position: relative;
108+
109+
a.item-link-separator~.menu-indicator {
110+
&:before {
111+
position: absolute;
112+
content: '';
113+
width: 100%;
114+
height: 100%;
115+
top: 0;
116+
left: 0;
117+
}
118+
119+
border-left: 0;
120+
}
121+
}
122+
89123
.menu-item .menu-indicator {
90124
width: $menu-indicator-width;
91125
text-align: center;

astroid/astroid-framework/astroid.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<name>Astroid Framework</name>
44
<libraryname>astroid</libraryname>
55
<author>JoomDev</author>
6-
<creationDate>Aug 2020</creationDate>
7-
<version>2.4.3</version>
6+
<creationDate>Sept 2020</creationDate>
7+
<version>2.4.4</version>
88
<url>https://www.astroidframework.com</url>
99
<copyright>Copyright (C) 2020 Joomdev, Inc. All rights reserved.</copyright>
1010
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<form>
3+
<fields name="params">
4+
<fieldset label="ASTROID_CUSTOMCODE_OPTIONS_TITLE_LABEL" id="astroidcustomcode" name="astroidcustomcode">
5+
<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">
6+
</field>
7+
8+
<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">
9+
</field>
10+
11+
<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">
12+
</field>
13+
14+
<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">
15+
</field>
16+
<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">
17+
</field>
18+
19+
<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">
20+
</field>
21+
22+
<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">
23+
</field>
24+
</fieldset>
25+
</fields>
26+
</form>

astroid/astroid-framework/framework/frontend/offcanvas.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@
2121
return;
2222
}
2323

24+
$module_position = 'offcanvas';
2425
$document->addScript('vendor/astroid/js/offcanvas.js', 'body');
26+
$hasMenu = $document->hasModule($module_position, 'mod_menu');
27+
if ($hasMenu) {
28+
$document->addScript('vendor/astroid/js/mobilemenu.js', 'body');
29+
}
2530

26-
$module_position = 'offcanvas';
2731
$togglevisibility = $params->get('offcanvas_togglevisibility', 'd-block');
2832
$effect = $params->get('offcanvas_animation', 'st-effect-1');
2933
$panelwidth = $params->get('offcanvas_panelwidth', '320px');

astroid/astroid-framework/framework/library/astroid/Component/LazyLoad.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@ public static function run()
2121
Framework::getDebugger()->log('Lazy Load');
2222
$app = \JFactory::getApplication();
2323
$template = Framework::getTemplate();
24+
$document = Framework::getDocument();
2425
$params = $template->getParams();
2526
$run = $params->get('lazyload', 0);
26-
Helper::createDir(ASTROID_CACHE . '/lazy-load/' . $template->id);
27-
if (!$run) {
28-
return;
29-
}
3027

31-
Framework::getDocument()->addScript('vendor/astroid/js/lazyload.min.js');
28+
// Stop Lazy Load for RSSFeeds
29+
if ($document->getType() == 'feed') $run = false;
30+
31+
// Stop Lazy Load
32+
if (!$run) return;
33+
34+
Helper::createDir(ASTROID_CACHE . '/lazy-load/' . $template->id);
35+
$document->addScript('vendor/astroid/js/lazyload.min.js');
3236

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

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

97101
if (!isset($imageMap[md5($matches[1][$key])])) {

astroid/astroid-framework/framework/library/astroid/Component/Menu.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

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

49-
$list = \MenuHelper::getList($menu_params);
50-
$base = \MenuHelper::getBase($menu_params);
51-
$active = \MenuHelper::getActive($menu_params);
52-
$default = \MenuHelper::getDefault();
49+
$list = \ModMenuHelper::getList($menu_params);
50+
$base = \ModMenuHelper::getBase($menu_params);
51+
$active = \ModMenuHelper::getActive($menu_params);
52+
$default = \ModMenuHelper::getDefault();
5353

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

576-
$list = \MenuHelper::getList($menu_params);
577-
$base = \MenuHelper::getBase($menu_params);
578-
$active = \MenuHelper::getActive($menu_params);
579-
$default = \MenuHelper::getDefault();
576+
$list = \ModMenuHelper::getList($menu_params);
577+
$base = \ModMenuHelper::getBase($menu_params);
578+
$active = \ModMenuHelper::getActive($menu_params);
579+
$default = \ModMenuHelper::getDefault();
580580

581581
$active_id = $active->id;
582582
$default_id = $default->id;

astroid/astroid-framework/framework/library/astroid/Component/Utility.php

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public static function colors()
223223

224224
// Dropdown Menu
225225
$dropdown = Style::addCssBySelector('.megamenu-container', 'background-color', $params->get('dropdown_bg_color', ''));
226-
226+
227227
$submenuDropdown = Style::addCssBySelector('.megamenu-container .nav-submenu .nav-submenu', 'background-color', $params->get('dropdown_bg_color', ''));
228228

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

322322
$document->addCustomTag($params->get('trackingcode', ''));
323323
$document->addStyleDeclaration($params->get('customcss', ''));
324-
$document->addStyleSheet(explode("\n", $params->get('customcssfiles', '')));
324+
325+
$customcssfiles = explode("\n", $params->get('customcssfiles'));
326+
327+
foreach ($customcssfiles as $customcssfile) {
328+
@list($file, $shift) = \explode('|', $customcssfile);
329+
$shift = $shift ? $shift : 0;
330+
$document->addStyleSheet($file, ['rel' => 'stylesheet', 'type' => 'text/css'], $shift);
331+
}
325332

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

329336
$document->addCustomTag($params->get('beforehead', ''));
330337
$document->addCustomTag($params->get('beforebody', ''), 'body');
338+
339+
// Page level custom code
340+
$app = \JFactory::getApplication();
341+
$itemid = $app->input->get('Itemid', '', 'INT');
342+
if (empty($itemid)) return false;
343+
344+
$menu = $app->getMenu();
345+
$item = $menu->getItem($itemid);
346+
$params = $item->getParams();
347+
348+
$document->addCustomTag($params->get('astroid_trackingcode', ''));
349+
$document->addStyleDeclaration($params->get('astroid_customcss', ''));
350+
351+
$customcssfiles = explode("\n", $params->get('astroid_customcssfiles'));
352+
353+
foreach ($customcssfiles as $customcssfile) {
354+
@list($file, $shift) = \explode('|', $customcssfile);
355+
$shift = $shift ? $shift : 0;
356+
$document->addStyleSheet($file, ['rel' => 'stylesheet', 'type' => 'text/css'], $shift);
357+
}
358+
359+
$document->addScriptdeclaration($params->get('astroid_customjs', ''));
360+
$document->addScript(explode("\n", $params->get('astroid_customjsfiles', '')));
361+
362+
$document->addCustomTag($params->get('astroid_beforehead', ''));
363+
$document->addCustomTag($params->get('astroid_beforebody', ''), 'body');
331364
}
332365

333366
public static function error()
@@ -358,4 +391,4 @@ public static function error()
358391
}
359392
$bodyStyle->render();
360393
}
361-
}
394+
}

astroid/astroid-framework/framework/library/astroid/Document.php

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Document
3030
protected $minify_html = false;
3131
protected static $_fontawesome = false;
3232
protected static $_layout_paths = [];
33+
protected $type = null;
3334

3435
public function __construct()
3536
{
@@ -38,11 +39,18 @@ public function __construct()
3839
$this->minify_js = $params->get('minify_js', false);
3940
$this->minify_html = $params->get('minify_html', false);
4041

42+
$doc = \JFactory::getDocument();
43+
$this->type = $doc->getType();
4144

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

49+
public function getType()
50+
{
51+
return $this->type;
52+
}
53+
4654
public function addLayoutPath($path)
4755
{
4856
self::$_layout_paths[] = $path;
@@ -104,17 +112,15 @@ public function compress()
104112
$app = \JFactory::getApplication();
105113
$body = $app->getBody();
106114

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

111-
if ($this->minify_js && !$this->isFrontendEditing()) {
112-
$body = $this->minifyJS($body);
113-
}
118+
if ($this->minify_css) $body = $this->minifyCSS($body);
114119

115-
if ($this->minify_html) {
116-
$body = $this->minifyHTML($body);
117-
}
120+
if ($this->minify_js && !$this->isFrontendEditing()) $body = $this->minifyJS($body);
121+
122+
if ($this->minify_html) $body = $this->minifyHTML($body);
123+
118124
$app->setBody($body);
119125
}
120126

@@ -499,6 +505,11 @@ public function position($position, $style = 'none')
499505
return $return;
500506
}
501507

508+
public function hasModule($position, $module)
509+
{
510+
return in_array($module, array_column(\JModuleHelper::getModules($position), 'module'));
511+
}
512+
502513
public function loadModule($content)
503514
{
504515
// Expression to search for(module Position)
@@ -779,7 +790,7 @@ public function addStyleDeclaration($content, $device = 'desktop')
779790
$this->_styles[$device][] = trim($content);
780791
}
781792

782-
public function addStyleSheet($url, $attribs = ['rel' => 'stylesheet', 'type' => 'text/css'])
793+
public function addStyleSheet($url, $attribs = ['rel' => 'stylesheet', 'type' => 'text/css'], $shifted = 0)
783794
{
784795
if (!is_array($url)) {
785796
$url = [$url];
@@ -792,7 +803,7 @@ public function addStyleSheet($url, $attribs = ['rel' => 'stylesheet', 'type' =>
792803
}
793804
foreach ($url as $u) {
794805
if (!empty(trim($u))) {
795-
$stylesheet = ['url' => $u, 'attribs' => $attribs];
806+
$stylesheet = ['url' => $u, 'attribs' => $attribs, 'shifted' => $shifted];
796807
$this->_stylesheets[md5($u)] = $stylesheet;
797808
}
798809
}
@@ -814,15 +825,31 @@ public function loadFontAwesome()
814825
Helper\Font::loadFontAwesome();
815826
}
816827

828+
public function moveFile(&$array, $a, $b)
829+
{
830+
$out = array_splice($array, $a, 1);
831+
array_splice($array, $b, 0, $out);
832+
}
833+
817834
public function getStylesheets()
818835
{
836+
$keys = array_keys($this->_stylesheets);
837+
838+
foreach ($keys as $index => $key) {
839+
if ($this->_stylesheets[$key]['shifted']) {
840+
$newindex = $index + $this->_stylesheets[$key]['shifted'];
841+
$this->moveFile($keys, $index, $newindex);
842+
}
843+
}
844+
819845
$content = '';
820-
foreach ($this->_stylesheets as $stylesheet) {
846+
foreach ($keys as $key) {
847+
$stylesheet = $this->_stylesheets[$key];
821848
$content .= '<link href="' . $this->_systemUrl($stylesheet['url']) . '"';
822849
foreach ($stylesheet['attribs'] as $prop => $value) {
823850
$content .= ' ' . $prop . '="' . $value . '"';
824851
}
825-
$content .= ' />';
852+
$content .= ' />' . "\n";
826853
}
827854
return $content;
828855
}

astroid/astroid-framework/framework/library/astroid/Helper/Client.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public function onContentPrepareForm($form, $data)
169169
$form->loadFile('menu', false);
170170
$form->loadFile('banner', false);
171171
$form->loadFile('og', false);
172+
$form->loadFile('custom', false);
172173
$loaded = true;
173174
}
174175

0 commit comments

Comments
 (0)