Commit 3747a100 authored by Patrick Barroca's avatar Patrick Barroca 😁
Browse files

hotline #68652 : fix filters / osm interaction in jquery 3

parent 62463092
- ticket #68652 : Boite bibliothèque : correction de la disparition de la carte lorsque les filtres sont utilisés
\ No newline at end of file
......@@ -421,9 +421,13 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac
return $this;
}
$opts = ($onLoadComplete = $filter_settings->getOnLoadComplete())
? '{onLoadComplete: function(widget){ '. $onLoadComplete .' }}'
: '{}';
$instance
->addOPACScript('renderFilters/ajaxifyFilters.js')
->addJQueryReady('$("#boite_' . $this->getIdModule() . '").ajaxifyFilters();');
->addJQueryReady('$("#boite_' . $this->getIdModule() . '").ajaxifyFilters('. $opts .');');
$filter_settings->isDisplayModeList()
? $instance->addStyleSheet(Class_Url::baseUrl() . '/public/opac/js/renderFilters/list.css')
......
......@@ -243,6 +243,10 @@ class ZendAfi_View_Helper_Accueil_Library extends ZendAfi_View_Helper_Accueil_Ba
->setFiltersPosition($this->preferences['filters_position'])
->setIdModule($this->id_module);
if ($this->preferences['osm_map'])
$this->_filter_settings
->setOnLoadComplete('if (0 < $(widget).find(".leaflet_osm").length) widget.openStreetMap();');
return $this->view->filters_Render($this->_filter_settings);
}
......
......@@ -18,8 +18,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
(function ( $ ) {
$.fn.ajaxifyFilters = function () {
$.fn.ajaxifyFilters = function (opts) {
var widget = $(this);
var options= undefined != opts ? opts : {};
var refresh = function(node, event, url_attr) {
var url = node.attr(url_attr);
......@@ -36,7 +38,10 @@
var onLoadComplete = function() {
widget.ajaxifyFilters();
if ('onLoadComplete' in options)
options.onLoadComplete(widget);
widget.ajaxifyFilters(options);
};
......
......@@ -318,7 +318,9 @@ class ZendAfi_View_Helper_Accueil_LibraryCustomFieldsDisplayTest extends ZendAfi
$this->_generateLibrary(['titre' => 'My library',
'libraries' => '1',
'fields' => 'custom_field_5;custom_field_7;custom_field_9']);
'fields' => 'custom_field_5;custom_field_7;custom_field_9',
'filters' => 'custom_field_5',
'osm_map' => '1']);
}
......@@ -351,5 +353,12 @@ class ZendAfi_View_Helper_Accueil_LibraryCustomFieldsDisplayTest extends ZendAfi
$this->assertNotXPath($this->html,
'//div["fields"]//div[3][@class="field-custom"]');
}
/** @test */
public function jQueryReadyShouldContainsAjaxifyFilters() {
$js = Class_ScriptLoader::getInstance()->javaScriptsHTML();
$this->assertContains('$("#boite_2").ajaxifyFilters({onLoadComplete: function(widget){ if (0 < $(widget).find(".leaflet_osm").length) widget.openStreetMap(); }});',
$js);
}
}
?>
\ No newline at end of file
......@@ -20,7 +20,7 @@
*/
class ZendAfi_View_Helper_Accueil_LibraryTestCase extends ViewHelperTestCase {
class ZendAfi_View_Helper_Accueil_LibrariesMapTest extends ViewHelperTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment