Author: fdesbois Date: 2010-06-15 17:59:24 +0000 (Tue, 15 Jun 2010) New Revision: 534 Log: Evo #2333 : use max char to hide too large news, not working because of style inside news content... Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java trunk/wao-ui/src/main/webapp/Index.tml trunk/wao-ui/src/main/webapp/css/news.css trunk/wao-ui/src/main/webapp/js/wao.js Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java 2010-06-15 16:16:52 UTC (rev 533) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java 2010-06-15 17:59:24 UTC (rev 534) @@ -147,6 +147,26 @@ return dateFormat; } + private static final int NEWS_CONTENT_MAX_CHARS = 500; + + public boolean isMoreContentNeeded() { + return news.getContent().length() > NEWS_CONTENT_MAX_CHARS; + } + + public String getNewsContent() { + String result = news.getContent(); + if (isMoreContentNeeded()) { + result = result.substring(0, NEWS_CONTENT_MAX_CHARS); + } + return result; + } + + public String getNewsMoreContent() { + String content = news.getContent(); + String result = content.substring(NEWS_CONTENT_MAX_CHARS, content.length()); + return result; + } + void onActionFromAddNews() throws WaoException { news = serviceNews.getNewNews(user); // Create a new list with the new news in first position Modified: trunk/wao-ui/src/main/webapp/Index.tml =================================================================== --- trunk/wao-ui/src/main/webapp/Index.tml 2010-06-15 16:16:52 UTC (rev 533) +++ trunk/wao-ui/src/main/webapp/Index.tml 2010-06-15 17:59:24 UTC (rev 534) @@ -39,7 +39,7 @@ </p> </t:if> <t:loop t:source="newsList" value="news" t:index="rowIndex" t:volatile="true"> - <div class="item" > + <div class="news-item" > <p class="date"> <t:unless t:test="createMode"> Publiée par @@ -82,18 +82,27 @@ </t:if> </p> </t:if> - <div class="content"> + <div class="news-content"> <t:if t:test="editionMode"> <t:label t:for="content" /><br /> <!--<input t:type="textarea" t:id="content" value="news.content" t:validate="required" />--> <textarea t:type="easyfck/fckeditor" t:id="content" width="800px" height="200px" value="news.content" t:configuration="fckconf" t:validate="required" /> <p:else> <t:outputraw t:value="news.content"/> + <!--${newsContent}--> + <!--<t:if t:test="moreContentNeeded">--> + <!--...--> + <!--<a onClick="toggleNewsMoreContent(this)">lire la suite</a>--> + <!--<span class="news-more hidden">--> + <!--<!–<t:outputraw t:value="newsMoreContent"/>–>--> + <!--${newsMoreContent}--> + <!--</span>--> + <!--</t:if>--> </p:else> </t:if> </div> </div> - <div class="sep"><hr /></div> + <div class="news-sep"><hr /></div> </t:loop> </form> Modified: trunk/wao-ui/src/main/webapp/css/news.css =================================================================== --- trunk/wao-ui/src/main/webapp/css/news.css 2010-06-15 16:16:52 UTC (rev 533) +++ trunk/wao-ui/src/main/webapp/css/news.css 2010-06-15 17:59:24 UTC (rev 534) @@ -40,22 +40,22 @@ } -div#so-news div.item { +div#so-news div.news-item { padding: 15px; /*background-color: #DEE7EC;*/ } -div#so-news div.item h2 { +div#so-news div.news-item h2 { margin: 5px; padding: 5px; color: #007CC2; } -div#so-news div.item h2.company { +div#so-news div.news-item h2.company { color: #19A28D !important; } -div#so-news div.item div.content { +div#so-news div.news-item div.news-content { margin: 5px; text-align: justify; border-left: 3px solid #133852; @@ -65,7 +65,7 @@ text-indent: 30px; } -div#so-news div.item p.date { +div#so-news div.news-item p.date { font-style: italic; font-size: 0.8em; padding-right: 10px; @@ -73,7 +73,7 @@ font-weight: bold; } -div#so-news div.sep { +div#so-news div.news-sep { width: 60%; margin-left: auto; margin-right: auto; Modified: trunk/wao-ui/src/main/webapp/js/wao.js =================================================================== --- trunk/wao-ui/src/main/webapp/js/wao.js 2010-06-15 16:16:52 UTC (rev 533) +++ trunk/wao-ui/src/main/webapp/js/wao.js 2010-06-15 17:59:24 UTC (rev 534) @@ -101,3 +101,16 @@ } } } + +function toggleNewsMoreContent(element) { + // Get the 'div' parent of the 'a' element + var newsContent = element.ancestors()[0]; + + if (newsContent.match('div.news-content')) { + // Retrieve elements with select 'span.news-more', so the hidden block + var array = newsContent.select('span.news-more'); + // toggle the block + array[0].toggleClassName('hidden'); + } + +}