Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
new global message in template.xhtml
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Mar 24, 2014
1 parent 4186053 commit 8b1a798
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 129 deletions.
65 changes: 0 additions & 65 deletions zanata-war/src/main/webapp/WEB-INF/layout/statsbar.xhtml

This file was deleted.

45 changes: 12 additions & 33 deletions zanata-war/src/main/webapp/WEB-INF/template/template.xhtml
Expand Up @@ -6,6 +6,7 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:zanata="http://java.sun.com/jsf/composite/zanata"
xmlns:s="http://jboss.org/schema/seam/taglib">
<!--[if lt IE 7]> <html class="no-js new-zanata lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js new-zanata lt-ie9 lt-ie8"> <![endif]-->
Expand Down Expand Up @@ -47,40 +48,18 @@

<h:body styleClass="new-zanata">
<ui:include src="banner.xhtml"/>
<a4j:outputPanel layout="block" ajaxRendered="true" styleClass="l__wrapper">
<s:div styleClass="l--push-top-1"
rendered="#{not facesContext.validationFailed and not empty facesContext.messageList}">
<h:messages id="messages" globalOnly="true"
styleClass="list--no-bullets"
errorClass="message--danger l--push-bottom-half"
infoClass="message--highlight l--push-bottom-half"
warnClass="message--warning l--push-bottom-half"
rendered="#{showGlobalMessages != 'false'}"/>
</s:div>

<s:fragment rendered="#{flashScopeMessage.hasMessages()}">
<ul class="list--no-bullets l--push-top-1" id="pageMessages">
<ui:repeat value="#{flashScopeMessage.messages}" var="message">
<s:fragment
rendered="#{message.severity.toString().startsWith('INFO')}">
<li class="message--highlight l--push-bottom-half">
#{message.summary}
</li>
</s:fragment>
<s:fragment
rendered="#{message.severity.toString().startsWith('WARN')}">
<li class="message--warning l--push-bottom-half">
#{message.summary}
</li>
</s:fragment>
<s:fragment
rendered="#{message.severity.toString().startsWith('ERROR') or message.severity.toString().startsWith('FATAL')}">
<li class="message--danger l--push-bottom-half">
#{message.summary}
</li>
</s:fragment>
</ui:repeat>
<a4j:outputPanel layout="block" ajaxRendered="true" id="messages">
<s:fragment rendered="#{showGlobalMessages != 'false'}">
<ul
class="list--no-bullets message--global #{(flashScopeMessage.hasMessages() or (not facesContext.validationFailed and not empty facesContext.messageList)) ? 'is-active' : ''}">
<zanata:global-messages value="#{facesContext.messageList}"
rendered="#{not facesContext.validationFailed and not empty facesContext.messageList}"/>
<zanata:global-messages value="#{flashScopeMessage.messages}"
rendered="#{flashScopeMessage.hasMessages()}"/>
</ul>
<script type="text/javascript">
startGlobalMessageTimer();
</script>
</s:fragment>
</a4j:outputPanel>

Expand Down
9 changes: 4 additions & 5 deletions zanata-war/src/main/webapp/error.xhtml
Expand Up @@ -3,7 +3,6 @@
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.org/schema/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
template="WEB-INF/template/template.xhtml">

Expand All @@ -23,10 +22,10 @@
<h2 class="alert__heading">#{messages['jsf.ErrorTitle']}</h2>

<div class="alert__content">
<h:messages id="errorMessage" styleClass="message"
infoClass="infomsg icon-info-circle-2"
warnClass="warnmsg icon-attention"
errorClass="errormsg icon-info-circle-2 alert__highlight"/>
<h:messages id="errorMessage"
infoClass="message--highlight l--push-bottom-half"
warnClass="message--warning l--push-bottom-half"
errorClass="message--danger l--push-bottom-half"/>

<p>#{messages['jsf.YouCanHelpUs']}</p>

Expand Down
60 changes: 34 additions & 26 deletions zanata-war/src/main/webapp/resources/script/components-script.js
Expand Up @@ -7,9 +7,15 @@ jQuery(document).ready(function() {
registerJsTab();
});

// automatically clear global message after 10 seconds
function startGlobalMessageTimer() {
setTimeout(function() {
jQuery('#messages').find('.message--global').removeClass("is-active");
}, 10000);
}

function refreshTooltip(wrapperId) {
jQuery('#' + wrapperId).find('[title]').each(function () {
jQuery('#' + wrapperId).find('[title]').each(function() {
zanata.tooltip.init(this);
});
}
Expand All @@ -26,7 +32,7 @@ function onTabClick(tab) {
jQuery(tab).parent().siblings("li").children("a").removeClass('is-active');
jQuery(tab).addClass("is-active");
jQuery(tab).parents('.tabs--lined').children('.tabs__content')
.children('div').addClass('is-hidden');
.children('div').addClass('is-hidden');
jQuery('#' + jQuery(tab).attr('id') + '_content').removeClass('is-hidden');
}

Expand All @@ -37,16 +43,18 @@ function updateStateFromUrl() {
function updateUrl(urlPrefix, suffixToUpdate) {
var newUrl = window.location.pathname;
newUrl = newUrl.substring(0, newUrl.indexOf(urlPrefix) + urlPrefix.length)
+ suffixToUpdate;
var status = {path: newUrl}
+ suffixToUpdate;
var status = {
path : newUrl
}
window.history.pushState(status, document.title, newUrl)
updateStateFromUrl();
}

jQuery(function() {
jQuery(window).on("popstate", function(event) {
var state = event.originalEvent.state
if(state)
if (state)
crossroads.parse(state.path)
})
})
Expand Down Expand Up @@ -132,9 +140,9 @@ jQuery(document).ready(function() {
});

function onResultKeyPressed(autocomplete, event, selectItemAction,
selectItemFunction) {
selectItemFunction) {
var currentSelected = jQuery(autocomplete).find('.autocomplete__results')
.children('.is-selected');
.children('.is-selected');

if (isEnterKey(event)) {
event.preventDefault();
Expand All @@ -145,9 +153,9 @@ function onResultKeyPressed(autocomplete, event, selectItemAction,
// key: down
deselectRow(currentSelected);
if (currentSelected.length == 0
|| jQuery(currentSelected).next().length == 0) {
|| jQuery(currentSelected).next().length == 0) {
selectRow(jQuery(autocomplete).find('.autocomplete__results').children(
'li').first());
'li').first());
} else {
selectRow(jQuery(currentSelected).next("li"));
}
Expand All @@ -156,7 +164,7 @@ function onResultKeyPressed(autocomplete, event, selectItemAction,
deselectRow(currentSelected);
if (currentSelected.length == 0) {
selectRow(jQuery(autocomplete).find('.autocomplete__results').children(
'li').last());
'li').last());
} else {
selectRow(jQuery(currentSelected).prev("li"));
}
Expand Down Expand Up @@ -204,24 +212,24 @@ function onValueChange(inputField, event, renderResultFn) {
}

function registerMouseEvent(autocompleteId, selectItemAction,
selectItemFunction) {
selectItemFunction) {
jQuery("[id='" + autocompleteId + "']").find('.autocomplete__results')
.children('.autocomplete__result').each(function() {
jQuery(this).mouseover(function() {
selectRow(this);
});

jQuery(this).mouseout(function() {
deselectRow(this);
.children('.autocomplete__result').each(function() {
jQuery(this).mouseover(function() {
selectRow(this);
});

jQuery(this).mouseout(function() {
deselectRow(this);
});

jQuery(this).click(function() {
onSelectItem(this, selectItemAction, selectItemFunction);
});
});

jQuery(this).click(function() {
onSelectItem(this, selectItemAction, selectItemFunction);
});
});

var firstResult = jQuery("[id='" + autocompleteId + "']").find(
'.autocomplete__results').children('.autocomplete__result').first();
'.autocomplete__results').children('.autocomplete__result').first();
if (firstResult.length != 0) {
selectRow(firstResult);
}
Expand All @@ -236,8 +244,8 @@ function filterList(input, filterFn) {
/* ----------------------------------------------------------- */

function onCheckboxValueChanged(checkbox, jsFunction) {
var isChecked = !jQuery(checkbox).children(".js-form__checkbox__input")
.is(':checked');
var isChecked = !jQuery(checkbox).children(".js-form__checkbox__input").is(
':checked');
var key = jQuery(checkbox).children("input").first().val();
jsFunction(key, isChecked);
}
47 changes: 47 additions & 0 deletions zanata-war/src/main/webapp/resources/zanata/global-messages.xhtml
@@ -0,0 +1,47 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:s="http://jboss.org/schema/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets">

<composite:interface>
<composite:attribute name="value" type="java.util.List"
shortDescription="list of messages (javax.faces.application.FacesMessage)"
required="true"/>
</composite:interface>

<composite:implementation>
<ui:repeat value="#{cc.attrs.value}" var="message">
<s:fragment
rendered="#{message.severity.toString().startsWith('INFO')}">
<li
class="message--highlight message--removable js-message-removable">
#{message.summary}
<a href="#" class="message__remove js-message-remove">
<i class="i i--remove"></i>
</a>
</li>
</s:fragment>
<s:fragment
rendered="#{message.severity.toString().startsWith('WARN')}">
<li
class="message--warning message--removable js-message-removable">
#{message.summary}
<a href="#" class="message__remove js-message-remove">
<i class="i i--remove"></i>
</a>
</li>
</s:fragment>
<s:fragment
rendered="#{message.severity.toString().startsWith('ERROR') or message.severity.toString().startsWith('FATAL')}">
<li class="message--danger message--removable js-message-removable">
#{message.summary}
<a href="#" class="message__remove js-message-remove">
<i class="i i--remove"></i>
</a>
</li>
</s:fragment>
</ui:repeat>
</composite:implementation>
</html>

0 comments on commit 8b1a798

Please sign in to comment.