diff --git a/src/KekRozsak/FrontBundle/Controller/NewsController.php b/src/KekRozsak/FrontBundle/Controller/NewsController.php new file mode 100644 index 0000000..e40bd19 --- /dev/null +++ b/src/KekRozsak/FrontBundle/Controller/NewsController.php @@ -0,0 +1,38 @@ +getDoctrine()->getRepository('KekRozsakFrontBundle:News'); + $searchCriteria = array(); + if ( + !is_object($this->get('security.context')->getToken()) + || !is_object($this->get('security.context')->getToken()->getUser()) + ) { + $searchCriteria['public'] = true; + } + + $news = $newsRepo->findBy($searchCriteria, array('createdAt' => 'DESC'), 4); + + return array( + 'news' => $news, + ); + } +} diff --git a/src/KekRozsak/FrontBundle/Resources/config/services.xml b/src/KekRozsak/FrontBundle/Resources/config/services.xml index 8658366..0318904 100644 --- a/src/KekRozsak/FrontBundle/Resources/config/services.xml +++ b/src/KekRozsak/FrontBundle/Resources/config/services.xml @@ -2,11 +2,6 @@ - - - - - diff --git a/src/KekRozsak/FrontBundle/Resources/public/css/main.css b/src/KekRozsak/FrontBundle/Resources/public/css/main.css index f0d71b7..e0b168b 100644 --- a/src/KekRozsak/FrontBundle/Resources/public/css/main.css +++ b/src/KekRozsak/FrontBundle/Resources/public/css/main.css @@ -34,6 +34,7 @@ a { color: #c4d3ff; height: 32px; border-bottom: 1px solid #1b3586; + z-index: 200; } #top-line-padding { @@ -69,6 +70,7 @@ a { color: #c4d3ff; height: 32px; border-top: 1px solid #1b3586; + z-index: 200; } #wrapper { @@ -94,7 +96,7 @@ a { #content-outline { color: #3366ff; text-align: justify; - width: 740px; + width: 955px; float: left; background-color: #c6ecfe; } @@ -103,10 +105,30 @@ a { padding: 5px; } +#news-button { + position: relative; + top: 7px; + background-image: url('../images/news-button.png'); + width: 20px; + height: 57px; + left: 955px; + z-index: 150; + cursor: pointer; +} + +#news-close-button { + background-image: url('../images/no.png'); + width: 16px; + height: 16px; + float: right; + cursor: pointer; +} + #hirek { float: right; color: #aaaacc; width: 215px; + display: none; } #hirek h3 { @@ -173,3 +195,8 @@ h3 a { .gomb a { color: inherit !important; } + +.clear { + clear: both; + float: none; +} \ No newline at end of file diff --git a/src/KekRozsak/FrontBundle/Resources/public/images/news-button.png b/src/KekRozsak/FrontBundle/Resources/public/images/news-button.png new file mode 100644 index 0000000..51c711b Binary files /dev/null and b/src/KekRozsak/FrontBundle/Resources/public/images/news-button.png differ diff --git a/src/KekRozsak/FrontBundle/Resources/views/Default/main_template.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Default/main_template.html.twig index 9d8fd37..8590c59 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Default/main_template.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Default/main_template.html.twig @@ -77,18 +77,11 @@
+

Hírek

-{% for news in recentNews %} -
-

{{ news.title }}

-

{{ news.text|raw }}

-{% if app.user %} -

{{ news.createdBy|userdataspan }}

-{% endif %} -

{{ news.createdAt|date('Y-m-d H:i') }}

-
-{% endfor %} +
Betöltés...
+
{# div#content-wrapper #} {# div#wrapper #}
@@ -178,20 +171,53 @@ }); } - $(document).ready(function() { + function resizeBoxes() + { bottomLineTop = $('#bottom-line').position().top; contentOutlineTop = $('#content-outline').position().top; contentHeight = $('#content-outline').outerHeight(); newsHeight = $('#hirek').outerHeight(); minHeight = bottomLineTop - contentOutlineTop; + // TODO: Resize content to its original small size if news is + // hidden height = Math.max(contentHeight, newsHeight, minHeight); if ($('#content-outline').outerHeight() < height) { $('#content-outline').css('height', height + 'px'); } - if ($('#hirek').outerHeight() < height) { + if ($('#hirek').is(':visible') && ($('#hirek').outerHeight() < height)) { $('#hirek').css('height', height + 'px'); } + } + + $(document).ready(function() { + resizeBoxes(); + + $('#news-button').click(function() { + $('#news-button').hide(); + $('#content-outline').css('width', '740px'); + $('#hirek').show(); + $('#news-list').html('Betöltés...'); + + $.ajax({ + method: 'GET', + url: Routing.generate('KekRozsakFrontBundle_newsSideList') + }).done(function(data) { + $('#news-list').html(data); + resizeBoxes(); + }).error(function() { + $('#news-list').html('Nem sikerült betölteni a híreket!'); + resizeBoxes(); + }); + }); + + $('#news-close-button').click(function() { + $('#hirek').html(''); + $('#hirek').hide(); + $('#content-outline').css('width', '955px'); + $('#news-button').show(); + resizeBoxes(); + }); }); {% block bottomscripts %}{% endblock %} diff --git a/src/KekRozsak/FrontBundle/Resources/views/News/sideList.html.twig b/src/KekRozsak/FrontBundle/Resources/views/News/sideList.html.twig new file mode 100644 index 0000000..504a32d --- /dev/null +++ b/src/KekRozsak/FrontBundle/Resources/views/News/sideList.html.twig @@ -0,0 +1,10 @@ +{% for news in recentNews %} +
+

{{ news.title }}

+

{{ news.text|raw }}

+{% if app.user %} +

{{ news.createdBy|userdataspan }}

+{% endif %} +

{{ news.createdAt|date('Y-m-d H:i') }}

+
+{% endfor %} \ No newline at end of file diff --git a/src/KekRozsak/FrontBundle/Twig/NewsExtension.php b/src/KekRozsak/FrontBundle/Twig/NewsExtension.php deleted file mode 100644 index 8e4d071..0000000 --- a/src/KekRozsak/FrontBundle/Twig/NewsExtension.php +++ /dev/null @@ -1,38 +0,0 @@ -_doctrine = $doctrine; - $this->_securityContext = $securityContext; - } - - public function getGlobals() - { - $newsRepo = $this->_doctrine->getRepository('KekRozsakFrontBundle:News'); - $searchCriteria = array(); - if (!is_object($this->_securityContext->getToken()) || !is_object($this->_securityContext->getToken()->getUser())) - $searchCriteria['public'] = true; - - $news = $newsRepo->findBy($searchCriteria, array('createdAt' => 'DESC'), 4); - - return array( - 'recentNews' => $news, - ); - } - - public function getName() - { - return 'News'; - } -} -