Browse Source

fix menu open/close

feature/home
Carmine De Rosa 5 years ago
parent
commit
b89df0c021
  1. 4
      components/header/header.html
  2. 31
      components/header/header.js
  3. 4
      components/home/home.js
  4. 4
      pages/home.ejs
  5. 19
      pages/index.ejs
  6. 3
      webpack.config.js

4
components/header/header.html

@ -13,7 +13,7 @@
</div>
<ul class="menu">
<li class="item <?php if($_GET['q'] == 'iolovolio') { echo "active";}?>">
<li class="item <?php if(!$_GET['q'] || $_GET['q'] == 'iolovolio') { echo "active";}?>">
<a href="/iolovolio" class="label"><b>io</b>lov<b>olio ...</b></a>
</li>
<li class="item <?php if($_GET['q'] == 'buy') { echo "active";}?>">
@ -28,7 +28,7 @@
</ul>
<ul class="sidebar-menu">
<li class="item <?php if($_GET['q'] == 'iolovolio') { echo "active";}?>">
<li class="item <?php if(!$_GET['q'] || $_GET['q'] == 'iolovolio') { echo "active";}?>">
<a href="/iolovolio" class="label"><b>io</b>lov<b>olio ...</b></a>
</li>
<li class="item <?php if($_GET['q'] == 'buy') { echo "active";}?>">

31
components/header/header.js

@ -2,27 +2,22 @@
$(document).ready( () => {
console.log('Load component - header')
const components = $('.component-header')
const component = $('.component-header')
components.each( (i, e) => {
const component = $(e)
const hamburger = component.find('.hamburger')
const menu = component.find('.sidebar-menu')
const hamburger = component.find('.hamburger')
const menu = component.find('.sidebar-menu')
hamburger.on('click', (e) => {
const hamburger = $(e.currentTarget)
hamburger.toggleClass('is-active')
hamburger.off('.click').on('click.click', (e) => {
const ham = $(e.currentTarget)
if(hamburger.hasClass('is-active')){
menu.addClass('active')
//items.slideDown()
//$('html, body').css({overflow: 'hidden'})
} else {
menu.removeClass('active')
//items.slideUp()
//$('html, body').css({overflow: 'auto'})
}
})
ham.toggleClass('is-active')
console.log(ham, menu)
if(ham.hasClass('is-active')){
menu.addClass('active')
} else {
menu.removeClass('active')
}
})
})

4
components/home/home.js

@ -1,5 +1,5 @@
/*
$(document).ready( () => {
console.log('Load component - home')
})
})*/

4
pages/home.ejs

@ -1,7 +1,5 @@
${require('../components/home/home.html')}
${require('../components/home/home.html')}

19
pages/index.ejs

@ -13,21 +13,18 @@
<?php
if(!$_GET['q'] || $_GET['q'] == 'home') {
if(!$_GET['q'] || $_GET['q'] == 'home' || $_GET['q'] == 'iolovolio') {
@include 'home.php';
} else {
?>
<main class="main-content">
<?php
?>
<main class="main-content">
<?php
@include $_GET['q'].'.php';
?>
</main>
<?php
?>
</main>
<?php
}
?>
?>
${require('../components/footer/footer.html')}

3
webpack.config.js

@ -75,7 +75,8 @@ module.exports = (env) => {
plugins.push(
new HtmlWebpackPlugin({
template: path.resolve(pagesPath, page),
filename: path.resolve(distPath, page.substr(0, page.lastIndexOf(".")) + ".php")
filename: path.resolve(distPath, page.substr(0, page.lastIndexOf(".")) + ".php"),
inject: page == 'index.ejs'
})
)
}

Loading…
Cancel
Save