From e8c21dd68e38d85dcf250fac63336a3fd2588f98 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Sat, 22 Sep 2012 07:24:02 +0000 Subject: [PATCH] =?UTF-8?q?Upload=20vignette:=20aper=C3=A7u=20de=20la=20vi?= =?UTF-8?q?gnette=20dans=20le=20formulaire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/admin/controllers/UploadController.php | 1 + .../views/scripts/upload/vignette-notice.phtml | 13 +++++++++++++ .../opac/views/scripts/recherche/viewnotice.phtml | 2 +- .../admin/controllers/UploadControllerTest.php | 8 +++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/application/modules/admin/controllers/UploadController.php b/application/modules/admin/controllers/UploadController.php index 6db76c96e68..fbc99051262 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 63d55fd4142..6282fd6a798 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 a4809c3205d..b79f8dd6402 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 3649dd3de7f..8a971a34da5 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"]'); + } } -- GitLab