From feda5d7d5715da9d941471bf5e06f174d930b2e8 Mon Sep 17 00:00:00 2001 From: Gergely POLONKAI Date: Wed, 15 Aug 2012 14:11:05 +0200 Subject: [PATCH] News sidebar is now ajax-based, and hidden by default Signed-off-by: Gergely Polonkai --- .../FrontBundle/Controller/NewsController.php | 38 +++++++++++++ .../FrontBundle/Resources/config/services.xml | 5 -- .../FrontBundle/Resources/public/css/main.css | 29 +++++++++- .../Resources/public/images/news-button.png | Bin 0 -> 888 bytes .../views/Default/main_template.html.twig | 50 +++++++++++++----- .../Resources/views/News/sideList.html.twig | 10 ++++ .../FrontBundle/Twig/NewsExtension.php | 38 ------------- 7 files changed, 114 insertions(+), 56 deletions(-) create mode 100644 src/KekRozsak/FrontBundle/Controller/NewsController.php create mode 100644 src/KekRozsak/FrontBundle/Resources/public/images/news-button.png create mode 100644 src/KekRozsak/FrontBundle/Resources/views/News/sideList.html.twig delete mode 100644 src/KekRozsak/FrontBundle/Twig/NewsExtension.php 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 0000000000000000000000000000000000000000..51c711b079a712ec3dd3a777af73d24d880388ff GIT binary patch literal 888 zcmV-;1Bd*HP)WFU8GbZ8()Nlj2>E@cM*00P`eL_t(o!|j+^NEJ~S z$A4$8=1t8dY}KqR)XGpOMFSPI0>cF^lm@0CnviBx52;ZgQ5L-vLHLqNW~TKJq+~7? zXoX5rnM-D6nnt!rWl3G(_F#(FrQ|f%6#Sls?=Zjl&VRn;%m_#C69!bYuDWzFbS%%Q!=>_k zy!Gjw=d;-|Y0JtfL9ZWBzbh7Ir}3$`kE5A+9N42{frG8OkssQ(9mgdOq-Nx(pDh}V zLQ;Gvmx^wi=7kC&*cBN(1ImB0@=cHO@B7wIQ%eWg`DM7SawIt+Ob$MtSzFD;XM-DN z<{D0&xr&{wHF42f)sYCLrf30>70AKt1)ssc0$o>ewQ}vj#JN0ySeLx6s zc3MbKfG0uzo(Li2;W_zblvX}8^0mF}rtM`njm@t~NsN%wyrHR`(#nU}+E{V?NbImb zBQ=`&_Vc(`(?r$%r*iP}yY+*WstaKC%B918ch_aaL=EpV3>H!K6Qgmqc%ePv zA-)_t9D}8$_U{vF_G@muhW3BQ+|BYjatkUD0+Qmx@b~jj=d4&#R!eR{1saWlR%^le z3&qsdxBff4_*M-UuT&z0ASE$^^!+<9H#6gG)^(mVzLJOED6Ju{@b+&hLh;?`j_YbC z4kqg`7z~^~ca4_kZ{*-Z=e~rP5F?E}JzUtkI~=`!fRks6XE zhS1;tLoQpQbb)N!;yvL_!2w?MO=9}b-11jU6?Io#x=>671`wwFulNhbkoYV59aZiC O0000
+

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'; - } -} -