diff --git a/application/modules/admin/controllers/UploadController.php b/application/modules/admin/controllers/UploadController.php index 6db76c96e686a89b72d863c59b1c1c377a5937bd..fbc990512620dd219ca9428247bf4f4271656c92 100644 --- a/application/modules/admin/controllers/UploadController.php +++ b/application/modules/admin/controllers/UploadController.php @@ -86,6 +86,7 @@ $(document).ready(function () { } $this->view->form = $form; + $this->view->url_vignette = Class_Notice::find($this->_getParam('id'))->getUrlVignette(); } } ?> \ No newline at end of file diff --git a/application/modules/admin/views/scripts/upload/vignette-notice.phtml b/application/modules/admin/views/scripts/upload/vignette-notice.phtml index 63d55fd41420e8b49f7fb42f5b731c2e460995db..6282fd6a7987135c8f2579de7536bbd246b0f05c 100644 --- a/application/modules/admin/views/scripts/upload/vignette-notice.phtml +++ b/application/modules/admin/views/scripts/upload/vignette-notice.phtml @@ -9,6 +9,10 @@ echo $this->renderForm($this->form); ?> <img class="patience" style="display:none; margin: 0 auto" src="<?php echo URL_ADMIN_IMG ?>patience.gif" border="0" alt="'.$this->_('Chargement en cours').'" /> +<div style="text-align: center; margin-top: 10px"> + <?php echo $this->_('Aperçu:') ?> + <img class="preview" width="150px" style="display:block; margin: 10px auto" src="<?php echo $this->url_vignette ?>"/> +</div> </div> @@ -16,4 +20,13 @@ echo $this->renderForm($this->form); $('input[type=submit]').click(function() { $('img.patience').css('display', 'block'); }); + +var url_input = $('input[name=url_vignette]'); + +var update_preview = function() { + $('img.preview').attr('src', url_input.attr('value')) +}; + +url_input.keyup(update_preview); +url_input.mouseup(update_preview); </script> \ No newline at end of file diff --git a/application/modules/opac/views/scripts/recherche/viewnotice.phtml b/application/modules/opac/views/scripts/recherche/viewnotice.phtml index a4809c3205de78f66871a25b157c9bfc186327bf..b79f8dd6402f84bf31408315f4730c4bc1c168bb 100644 --- a/application/modules/opac/views/scripts/recherche/viewnotice.phtml +++ b/application/modules/opac/views/scripts/recherche/viewnotice.phtml @@ -55,7 +55,7 @@ $notice_html=new Class_NoticeHtml($this->notice); printf('<img src="%s" width="100" border="0" alt="%s"/>', $this->url_img["vignette"], $this->_('Vignette')); if (Class_Users::isCurrentUserCanAccesBackend()) - echo sprintf('<a href="#" onclick="showPopWin(\'%s\', 700, 200); return false;">%s</a>', + echo sprintf('<a href="#" onclick="showPopWin(\'%s\', 700, 300); return false;">%s</a>', $this->url(['module' => 'admin', 'controller' => 'upload', 'action' => 'vignette-notice', diff --git a/tests/application/modules/admin/controllers/UploadControllerTest.php b/tests/application/modules/admin/controllers/UploadControllerTest.php index 3649dd3de7f724eb6566d7bd441f9e4baf368023..8a971a34da513405642dad4fcd74658c53b92d1d 100644 --- a/tests/application/modules/admin/controllers/UploadControllerTest.php +++ b/tests/application/modules/admin/controllers/UploadControllerTest.php @@ -146,7 +146,7 @@ class UploadControllerMultipleProcessPostAction extends AbstractControllerTestCa class UploadControllerVignetteNoticeActionTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); - + Class_Notice::newInstanceWithId(12345, ['url_vignette' => 'http://harrypotter.com/poster.jpg']); $this->dispatch('/admin/upload/vignette-notice/id/12345', true); } @@ -161,6 +161,12 @@ class UploadControllerVignetteNoticeActionTest extends AbstractControllerTestCas public function formShouldHaveSubmitButtonEnvoyer() { $this->assertXPath('//form//input[@type="submit"][@value="Envoyer"]'); } + + + /** @test */ + public function previewImgSrcShouldBePosterDotJpeg() { + $this->assertXPath('//img[@class="preview"][@src="http://harrypotter.com/poster.jpg"]'); + } }