Left menu open

GK User
Mon Mar 09, 2015 5:13 pm
Hi,
is it possible to start the page with an open side menu?
Would be great, thank you
Monika!
User avatar
Fresh Boarder

GK User
Mon Mar 09, 2015 5:23 pm
It can be done - you need to modify gk.scripts.js and add this code:
Code: Select all
jQuery('#gk-menu-button').click();

within first jQuery document ready statement, just before it ends.
User avatar
Moderator

GK User
Mon Mar 09, 2015 5:23 pm
Could you please post an url to your site - I'll provide you info with exactly what and where to change?
User avatar
Moderator

GK User
Mon Mar 09, 2015 6:50 pm
Thank you, I've tried to put it in gk.menu.js

jQuery(document).ready(function() {
jQuery('#gk-menu-button').sidr({
name: 'aside-menu',
onOpen: function() {
jQuery('#gk-bg').addClass('menu-open');
jQuery('#gk-menu-button').addClass('menu-clicked');

setTimeout(function() {
jQuery('#gk-menu-button').addClass('menu-open');
}, 450);
},
onClose: function() {
jQuery('#gk-bg').removeClass('menu-open');
jQuery('#gk-menu-button').removeClass('menu-clicked');
jQuery('#gk-menu-button').removeClass('menu-open');
jQuery('#gk-menu-button').click();

}
});

but it doesn#t work, and I don't know exactly where to put it

http://www.organic-revolution.de/superjuice/
User avatar
Fresh Boarder

GK User
Mon Mar 09, 2015 6:54 pm
oh sorry, I've just seen that I have to put it in gk.scripts.js, but i can't find the right place to put it....
User avatar
Fresh Boarder

GK User
Mon Mar 09, 2015 7:05 pm
Code: Select all
window.addEvent('domready', function() {
   // smooth anchor scrolling
    jQuery('a[href*="#"]').on('click', function (e) {
        e.preventDefault();
        if(this.hash !== '') {
            if(this.hash !== '' && this.href.replace(this.hash, '') == window.location.href.replace(window.location.hash, '')) {
                var target = jQuery(this.hash);
                if(target.length && this.hash !== '#') {
                    jQuery('html, body').stop().animate({
                        'scrollTop': target.offset().top
                    }, 1000, 'swing', function () {
                        if(this.hash !== '#') {
                            window.location.hash = target.selector;
                        }
                    });
                } else {
                    if(this.hash !== '#') {
                        window.location = jQuery(this).attr('href');
                    }
                }
            } else {
                if(this.hash !== '#') {
                    window.location = jQuery(this).attr('href');
                }
            }
        }
    });
   // style area
   if(jQuery('#gkStyleArea').length > 0){
      jQuery('#gkStyleArea').find('a').each(function(i, element){
         jQuery(element).click(function(e){
            e.preventDefault();
            e.stopPropagation();
            changeStyle(i+1);
         });
      });
   }
   // K2 font-size switcher fix
   if(jQuery('#fontIncrease').length > 0 && jQuery('.itemIntroText').length > 0) {
      jQuery('#fontIncrease').click(function() {
         jQuery('.itemIntroText').attr('class', 'itemIntroText largerFontSize');
      });
      
      jQuery('#fontDecrease').click( function() {
         jQuery('.itemIntroText').attr('class', 'itemIntroText smallerFontSize');
      });
   }
   // Equal columns
   gkEqualColumns();
   // Floating sidebar
   if(jQuery('#gk-right-top')) {
      var top_area = jQuery('#gk-right-top');
      var top_area_bg = jQuery('#gk-right-top-bg');
      var win = jQuery(window);
      var body = jQuery(document.body);
      
      jQuery(window).scroll(function() {
         if(win.width() >= body.attr('data-tablet-width')) {
            var scrolled = win.scrollTop();
            top_area.css('top', scrolled + 'px');
            top_area_bg.css('top', scrolled + 'px');
         } else {
            top_area.css('top', '0px');
         }
      });
   }
   // Login popup
   if(jQuery('#gk-login-btn')) {
      var login_btn = jQuery('#gk-login-btn');
      var sidebar = jQuery('#gk-right');
      var popup = jQuery('#gkPopupLogin');
      
      login_btn.click(function(e) {
         e.preventDefault();
         
         if(login_btn.hasClass('popup-open')) {
            sidebar.removeClass('popup-open')
            login_btn.removeClass('popup-open');
            
            setTimeout(function() {
               popup.css('display', 'none');
            }, 350);
         } else {
            popup.css('display', 'block');
            
            if(jQuery(window).width() <= jQuery(document.body).attr('data-tablet-width')) {
               popup.css('top', '100px');
            } else {
               popup.css('top', (jQuery(window).scrollTop() + 100) + "px");
            }
            
            setTimeout(function() {
               sidebar.addClass('popup-open');
               login_btn.addClass('popup-open');
            }, 50);
         }
      });
   }
   // search
   var searchbox = jQuery('#gk-search .inputbox');
   if(searchbox.length) {
      jQuery('#gk-search').click(function() {
         searchbox.trigger('focus');
      });
      
      searchbox.focus(function() {
         var input = jQuery('#gk-search');
         input.addClass('search-active');
      });
      
      searchbox.blur(function() {
         var input = jQuery('#gk-search');
         input.removeClass('search-active');
      });
   }
});

above is a standard jQuery dom ready script - you need to place the code just before last:
Code: Select all
});
User avatar
Moderator

GK User
Mon Mar 09, 2015 7:15 pm
That works!! Thank you so much!!!!
User avatar
Fresh Boarder

GK User
Mon Mar 09, 2015 7:16 pm
Is there anything else I can help you with regarding this topic?
User avatar
Moderator

GK User
Tue Mar 10, 2015 12:37 pm
Hi, I have the same problem but I can not make it work,
is this the right place? Thank you!

......
input.addClass('search-active');
});

searchbox.blur(function() {
var input = jQuery('#gk-search');
input.removeClass('search-active');

});
}

jQuery('#gk-menu-button').click();
});
User avatar
Fresh Boarder

GK User
Tue Mar 10, 2015 3:18 pm
If you ask so nice, yes there is something ;-)
Is there a possibility that the menu closes automatically after a few seconds?
But it is too complex, right?
User avatar
Fresh Boarder

GK User
Tue Mar 10, 2015 3:46 pm
Hi, it's gk.scripts.js line 122

// IE checker
function gkIsIE() {
var myNav = navigator.userAgent.toLowerCase();
return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;
}
//
window.addEvent('domready', function() {
// smooth anchor scrolling
jQuery('a[href*="#"]').on('click', function (e) {
e.preventDefault();
if(this.hash !== '') {
if(this.hash !== '' && this.href.replace(this.hash, '') == window.location.href.replace(window.location.hash, '')) {
var target = jQuery(this.hash);
if(target.length && this.hash !== '#') {
jQuery('html, body').stop().animate({
'scrollTop': target.offset().top
}, 1000, 'swing', function () {
if(this.hash !== '#') {
window.location.hash = target.selector;
}
});
} else {
if(this.hash !== '#') {
window.location = jQuery(this).attr('href');
}
}
} else {
if(this.hash !== '#') {
window.location = jQuery(this).attr('href');
}
}
}
});
// style area
if(jQuery('#gkStyleArea').length > 0){
jQuery('#gkStyleArea').find('a').each(function(i, element){
jQuery(element).click(function(e){
e.preventDefault();
e.stopPropagation();
changeStyle(i+1);
});
});
}
// K2 font-size switcher fix
if(jQuery('#fontIncrease').length > 0 && jQuery('.itemIntroText').length > 0) {
jQuery('#fontIncrease').click(function() {
jQuery('.itemIntroText').attr('class', 'itemIntroText largerFontSize');
});

jQuery('#fontDecrease').click( function() {
jQuery('.itemIntroText').attr('class', 'itemIntroText smallerFontSize');
});
}
// Equal columns
gkEqualColumns();
// Floating sidebar
if(jQuery('#gk-right-top')) {
var top_area = jQuery('#gk-right-top');
var top_area_bg = jQuery('#gk-right-top-bg');
var win = jQuery(window);
var body = jQuery(document.body);

jQuery(window).scroll(function() {
if(win.width() >= body.attr('data-tablet-width')) {
var scrolled = win.scrollTop();
top_area.css('top', scrolled + 'px');
top_area_bg.css('top', scrolled + 'px');
} else {
top_area.css('top', '0px');
}
});
}
// Login popup
if(jQuery('#gk-login-btn')) {
var login_btn = jQuery('#gk-login-btn');
var sidebar = jQuery('#gk-right');
var popup = jQuery('#gkPopupLogin');

login_btn.click(function(e) {
e.preventDefault();

if(login_btn.hasClass('popup-open')) {
sidebar.removeClass('popup-open')
login_btn.removeClass('popup-open');

setTimeout(function() {
popup.css('display', 'none');
}, 350);
} else {
popup.css('display', 'block');

if(jQuery(window).width() <= jQuery(document.body).attr('data-tablet-width')) {
popup.css('top', '100px');
} else {
popup.css('top', (jQuery(window).scrollTop() + 100) + "px");
}

setTimeout(function() {
sidebar.addClass('popup-open');
login_btn.addClass('popup-open');
}, 50);
}
});
}
// search
var searchbox = jQuery('#gk-search .inputbox');
if(searchbox.length) {
jQuery('#gk-search').click(function() {
searchbox.trigger('focus');
});

searchbox.focus(function() {
var input = jQuery('#gk-search');
input.addClass('search-active');
});

searchbox.blur(function() {
var input = jQuery('#gk-search');
input.removeClass('search-active');
});
}
jQuery('#gk-menu-button').click();
});
User avatar
Fresh Boarder

GK User
Wed Mar 11, 2015 5:42 pm
Cyberek wrote:Is there anything else I can help you with regarding this topic?


Hi, sorry for bothering you again, but do you think there is an easy way to close the open menu automatically after a few seconds or ist it too complex?
Thank you
Monika
User avatar
Fresh Boarder

GK User
Thu Mar 12, 2015 5:56 pm
It is possible - you could implement javascript timeout and add another click in it. Please read about javascript timeouts.
User avatar
Moderator


cron