Skip to content

Instantly share code, notes, and snippets.

@waerp

waerp/growl.js Secret

Created Feb 8, 2016
Embed
What would you like to do?
PrimeFaces.widget.Growl = PrimeFaces.widget.Growl.extend({
renderMessage: function (msg) {
var growlId = msg.id;
var markup = '<div class="ui-growl-item-container ui-state-highlight ui-corner-all ui-helper-hidden ui-shadow" onclick="onGrowlDivClicked(\'' + growlId + '\')" style="cursor:pointer;">';
markup += '<div class="ui-growl-item">';
markup += '<div class="ui-growl-icon-close ui-icon ui-icon-closethick" style="display:none"></div>';
markup += '<span class="ui-growl-image ui-growl-image-' + msg.severity + '" />';
markup += '<div class="ui-growl-message">';
markup += '<span class="ui-growl-title"></span>';
markup += '<p></p>';
markup += '</div><div style="clear: both;"></div></div></div>';
var message = $(markup),
summaryEL = message.find('span.ui-growl-title'),
detailEL = summaryEL.next();
if (this.cfg.escape) {
summaryEL.text(msg.summary);
detailEL.text(msg.detail);
} else {
summaryEL.html(msg.summary);
detailEL.html(msg.detail);
}
this.bindEvents(message);
message.appendTo(this.jq).fadeIn();
}
});
function onGrowlDivClicked(clientId) {
var clientId = PrimeFaces.escapeClientId(clientId);
if ($(clientId).is("div")) {
$('html, body').animate({
scrollTop: $(clientId).offset().top
}, 2000);
} else {
$('html, body').animate({
scrollTop: $(clientId).offset().top
}, 2000);
$(clientId).focus();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment