Skip to content

Instantly share code, notes, and snippets.

@evaldeslacasa
Last active November 23, 2015 23:19
Show Gist options
  • Select an option

  • Save evaldeslacasa/c19cfef283fd6de922a9 to your computer and use it in GitHub Desktop.

Select an option

Save evaldeslacasa/c19cfef283fd6de922a9 to your computer and use it in GitHub Desktop.
aui script to use in button
the main.js:
AUI().ready(
/*
This function gets loaded when all the HTML, not including the portlets, is
loaded.
*/
function() {
alert("hola");
A=AUI();
A.one('#toggle-controls').on('click', function(e) {
e.preventDefault();
if (A.one('body').hasClass('controls-visible')) {
A.one('body').removeClass('controls-visible')
.addClass('controls-hidden');
} else {
A.one('body').removeClass('controls-hidden')
.addClass('controls-visible');
}
});
}
);
Liferay.Portlet.ready(
/*
This function gets loaded after each and every portlet on the page.
portletId: the current portlet's id
node: the Alloy Node object of the current portlet
*/
function(portletId, node) {
}
);
Liferay.on(
'allPortletsReady',
/*
This function gets loaded when everything, including the portlets, is on
the page.
*/
function() {
}
);
And the button is:
<script type="text/javascript" src="$javascript_folder/main.js"></script>
<a id="toggle-controls" href="#">Toggle Controls</a><br/>
@evaldeslacasa

Copy link
Copy Markdown
Author

Solution in JQuery: script in portal_normal.vm

$(window).load(function(){
    tempM=$("#banner").height();
    $(".desktop-menu").css({marginTop:tempM});

    $("#show-hide-controls").bind("click",function(event){
        event.preventDefault();
        $("body").toggleClass("controls-hidden");
    })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment