diff -u b/misc/ajax_facets.js b/misc/ajax_facets.js --- b/misc/ajax_facets.js +++ b/misc/ajax_facets.js @@ -357,7 +357,7 @@ var ajax = new Drupal.ajax(false, false, settings); ajax.success = function(response, status) { // Push new state only on successful ajax response. - if (typeof history.pushState != "undefined" && pushStateNeeded) { + if (pushStateNeeded) { var stateUrl = Drupal.settings.basePath + Drupal.settings.pathPrefix + Drupal.settings.facetapi.searchPath + '?' + Drupal.ajax_facets.getFacetsQuery(), state = { current_id: Drupal.ajax_facets.current_id, @@ -365,7 +365,7 @@ facets: Drupal.ajax_facets.queryState['f'] }; - history.pushState(state, document.title, stateUrl); + History.pushState(state, document.title, stateUrl); } //Pass back to original method. @@ -531,7 +531,7 @@ Drupal.ajax_facets.initHistoryState = function ($facet) { // Set the initial state only initial page load. if (typeof history.replaceState != "undefined" && Drupal.ajax_facets.firstLoad) { - history.replaceState({ + History.replaceState({ current_id: $facet.attr('id'), current_facet_name: $facet.data('facet'), facets: Drupal.ajax_facets.queryState['f'] @@ -545,8 +545,8 @@ */ - window.onpopstate = function (event) { - if (event.state != null) { - Drupal.ajax_facets.queryState['f'] = event.state.facets; - Drupal.ajax_facets.sendAjaxQuery($('#' + event.state.current_id), false); - } - }; + History.Adapter.bind(window, 'statechange', function() { + var state = History.getState(); + + Drupal.ajax_facets.queryState['f'] = state.data.facets; + Drupal.ajax_facets.sendAjaxQuery($('#' + state.data.current_id), false); + }); })(jQuery); only in patch2: unchanged: --- a/ajax_facets.info +++ b/ajax_facets.info @@ -3,6 +3,7 @@ description = Ajax facet filters. dependencies[] = facetapi dependencies[] = search_api dependencies[] = views +dependencies[] = libraries package = Search Toolkit core = 7.x only in patch2: unchanged: --- a/ajax_facets.install +++ b/ajax_facets.install @@ -0,0 +1,33 @@ + $t('Ajax Facets'), + 'description' => $t('Please download and unpack "history.js" library to libraries directory.'), + 'value' => l($t('Download'), 'https://github.com/browserstate/history.js/', array( + 'attributes' => array( + 'target' => '_blank', + ), + )), + 'severity' => REQUIREMENT_ERROR, + ); + } + break; + } + + return $requirements; +} only in patch2: unchanged: --- a/ajax_facets.module +++ b/ajax_facets.module @@ -95,6 +95,7 @@ function ajax_facets_add_ajax_js($facet) { $included = TRUE; $module_path = drupal_get_path('module', 'ajax_facets'); drupal_add_js($module_path . '/misc/ajax_facets.js'); + drupal_add_js(libraries_get_path('history.js') . '/scripts/bundled/html4+html5/jquery.history.js', array('group' => JS_LIBRARY)); drupal_add_css($module_path . '/misc/ajax_facets.css'); $search_path = $facet->getAdapter()->getSearchPath(); $filter_key = $facet->getAdapter()->getUrlProcessor()->getFilterKey();