diff --git a/VERSIONS_HOTLINE/140071 b/VERSIONS_HOTLINE/140071 new file mode 100644 index 0000000000000000000000000000000000000000..692f4fc28b2d2bd5a54a940341bb3d98fe57bf40 --- /dev/null +++ b/VERSIONS_HOTLINE/140071 @@ -0,0 +1 @@ + - ticket #140071 : Magasin de thèmes : correction des liens de consultation et d'emprunt des prêts numériques en bibliothèque. \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php b/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php index f67c28889b00fcaf607330cc4def3be5f26960ed..b82a6d4b2d2cbac17403ed249d338ee71e7d3d2c 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php +++ b/library/templates/Intonation/Library/View/Wrapper/RichContent/Section.php @@ -185,8 +185,8 @@ abstract class Intonation_Library_View_Wrapper_RichContent_Section { if ($class = $this->getClass()) $js = sprintf('$(\'.loading_icon\').parent().remove(); - if ($(\'.%1$s [data-ajax-content] > *\').length) - return $(\'.%1$s\').removeClass(\'d-none text-black-50 disabled\');', + if ($(\'.%1$s [data-ajax-content] > *\').length) { + return $(\'.%1$s\').removeClass(\'d-none text-black-50 disabled\');}', $class); if ($html) diff --git a/library/templates/Intonation/View/RenderAjax.php b/library/templates/Intonation/View/RenderAjax.php index aa00ff7a024a2ca9bd706a5f8787afbe4e58b635..8dc2469e082e553787ed39566f6d8c14ef4d818d 100644 --- a/library/templates/Intonation/View/RenderAjax.php +++ b/library/templates/Intonation/View/RenderAjax.php @@ -28,7 +28,11 @@ class Intonation_View_RenderAjax extends ZendAfi_View_Helper_BaseHelper { 'action' => $action], $params); - $js_callback .= 'initializePopups();setupAnchorsTarget();'.Class_AdminVar_Cookies::manager()->triggers(); + $js_callback = 'initializePopups();setupAnchorsTarget();' + . Class_AdminVar_Cookies::manager()->triggers() + . ';' + . $js_callback; + if (($ig = Zend_Controller_Front::getInstance() ->getPlugin('ZendAfi_Controller_Plugin_InspectorGadget')) && ($ig->isEnabled())) diff --git a/tests/scenarios/Templates/TemplatesDigitalResourcesTest.php b/tests/scenarios/Templates/TemplatesDigitalResourcesTest.php index 808327b6a99891d25620af8b366caa66019944f1..afbe25fbc0dadb8f990f6222f5741c5f1729b705 100644 --- a/tests/scenarios/Templates/TemplatesDigitalResourcesTest.php +++ b/tests/scenarios/Templates/TemplatesDigitalResourcesTest.php @@ -240,10 +240,17 @@ class TemplatesDigitalResourcesDilicomItemTest extends TemplatesDigitalResources public function consultLinkShouldBeDisabled() { $this->assertXPathContentContains('//a[@data-disabled]', 'Consulter le livre en ligne'); } + + + /** @test */ + public function initializePopupsScriptsAndSetupAnchorsTargetShouldBePresent() { + $this->assertXPathContentContains('//script', 'setTimeout(function(){initializePopups();setupAnchorsTarget();}, 5);'); + } } + /** @see http://forge.afi-sa.fr/issues/115415 */ class TemplatesDigitalResourcesWrongIndexationTest extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true; @@ -515,3 +522,35 @@ class TemplatesDigitalResourcesAudioRecordTest extends AbstractControllerTestCas $this->assertXPathContentContains('//div[@class="list-group-item bg-transparent px-0 mb-3"]//a[@class="audio_track card-title text-secondary"][contains(@data-track-url,"bib-numerique/play-ressource/id/4.mp3")]/span[@class="track_title"]', 'The prophecy'); } } + + + + +class TemplatesDigitalResourcesDilicomRecordItemTest extends TemplatesDigitalResourcesDilicomTestCase { + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_Notice', + ['id' => 123, + 'type_doc' => Class_TypeDoc::LIVRE_NUM]); + + $this->fixture('Class_Exemplaire', + ['id' => 8, + 'id_origine' => 3, + 'id_notice' => 123]); + + (new DilicomFixtures())->albumTotemThora(); + RessourcesNumeriquesFixtures::activateDilicom(); + + $this->dispatch('record/items/id/123'); + } + + + /** @test */ + public function initializePopupsScriptsShouldBeDoneBeforeReturn() { + $this->assertXPathContentContains('//script', '.load("/noticeajax/resources/id/123", function() {initializePopups();setupAnchorsTarget();;$(\'.loading_icon\').parent().remove(); + if ($(\'.document_items [data-ajax-content] > *\').length) { + return $(\'.document_items\').removeClass(\'d-none text-black-50 disabled\');}});}'); + } +} \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesJumbotronTest.php b/tests/scenarios/Templates/TemplatesJumbotronTest.php index 49b4036dbd240a157a125ff15fbe9458d406be02..dd66352116350cc4c6347e0efae8397e09515edd 100644 --- a/tests/scenarios/Templates/TemplatesJumbotronTest.php +++ b/tests/scenarios/Templates/TemplatesJumbotronTest.php @@ -40,9 +40,9 @@ class TemplatesRecordsDispatchItemsTest extends AbstractControllerTestCase { /** @test */ public function shouldJsLoadItemsWithInitializePopupAndSetupAnchorTarget() { $this->dispatch('/record/items/id/1'); - $this->assertXPathContentContains('//script', '.load("/noticeajax/resources/id/1", function() {$(\'.loading_icon\').parent().remove(); - if ($(\'.document_items [data-ajax-content] > *\').length) - return $(\'.document_items\').removeClass(\'d-none text-black-50 disabled\');initializePopups();setupAnchorsTarget();});}, 5);'); + $this->assertXPathContentContains('//script', '.load("/noticeajax/resources/id/1", function() {initializePopups();setupAnchorsTarget();;$(\'.loading_icon\').parent().remove(); + if ($(\'.document_items [data-ajax-content] > *\').length) { + return $(\'.document_items\').removeClass(\'d-none text-black-50 disabled\');}});}, 5);'); } @@ -50,8 +50,8 @@ class TemplatesRecordsDispatchItemsTest extends AbstractControllerTestCase { public function shouldJsLoadHasAuthor() { $this->dispatch('/record/items/id/1'); $this->assertXPathContentContains('//script', '.load("/noticeajax/has-author/id/1", function() {$(\'.loading_icon\').parent().remove(); - if ($(\'.document_author [data-ajax-content] > *\').length) - return $(\'.document_author\').removeClass(\'d-none text-black-50 disabled\');});}, 5);'); + if ($(\'.document_author [data-ajax-content] > *\').length) { + return $(\'.document_author\').removeClass(\'d-none text-black-50 disabled\');}});}, 5);'); } @@ -59,8 +59,8 @@ class TemplatesRecordsDispatchItemsTest extends AbstractControllerTestCase { public function shouldJsLoadHasMedia() { $this->dispatch('/record/items/id/1'); $this->assertXPathContentContains('//script', '.load("/noticeajax/has-media/id/1", function() {$(\'.loading_icon\').parent().remove(); - if ($(\'.document_media [data-ajax-content] > *\').length) - return $(\'.document_media\').removeClass(\'d-none text-black-50 disabled\');});}, 5);'); + if ($(\'.document_media [data-ajax-content] > *\').length) { + return $(\'.document_media\').removeClass(\'d-none text-black-50 disabled\');}});}, 5);'); } @@ -118,8 +118,8 @@ class TemplatesRecordsDispatchItemsTest extends AbstractControllerTestCase { $this->dispatch('/abonne/selections/id/2'); $this->assertXPathContentContains('//script', 'load("/abonne/has-loan/id/2", function() {$(\'.loading_icon\').parent().remove(); - if ($(\'.user_loans [data-ajax-content] > *\').length) - return $(\'.user_loans\').removeClass(\'d-none text-black-50 disabled\');});});'); + if ($(\'.user_loans [data-ajax-content] > *\').length) { + return $(\'.user_loans\').removeClass(\'d-none text-black-50 disabled\');}});});'); }