diff --git a/advagg.module b/advagg.module index b7281e8..7337872 100644 --- a/advagg.module +++ b/advagg.module @@ -1152,7 +1152,7 @@ function advagg_form_system_performance_settings_alter(&$form, &$form_state) { * Implements hook_js_alter(). */ function advagg_js_alter(&$js) { - if (module_exists('admin_menu') && !module_exists('adminimal_admin_menu')) { + if (module_exists('admin_menu')) { // Fix for admin menu; put JS in footer. $path = drupal_get_path('module', 'admin_menu'); $filename = $path . '/admin_menu.js'; diff --git a/advagg_mod/advagg_mod.advagg.inc b/advagg_mod/advagg_mod.advagg.inc index 74c6909..e7514e5 100644 --- a/advagg_mod/advagg_mod.advagg.inc +++ b/advagg_mod/advagg_mod.advagg.inc @@ -33,6 +33,54 @@ function advagg_mod_advagg_get_info_on_files_alter(&$return, $cached_data, $bypa } /** + * Implements hook_advagg_get_js_file_contents_alter(). + */ +function advagg_mod_advagg_get_js_file_contents_alter(&$contents, $filename, $aggregate_settings) { + // Fix adminimal_admin_menu js issues with admin menu. + if (!module_exists('adminimal_admin_menu')) { + return; + } + $adminimal_admin_menu_path = drupal_get_path('module', 'adminimal_admin_menu'); + if ($filename === "$adminimal_admin_menu_path/js/slicknav/jquery.slicknav.js" + || $filename === "$adminimal_admin_menu_path/js/slicknav/jquery-no-conflict.slicknav.js" + ) { + $inserted_string = "Drupal.admin = Drupal.admin || {};\n + Drupal.admin.behaviors = Drupal.admin.behaviors || {};\n"; + if (strpos($contents, $inserted_string) !== FALSE) { + return; + } + + $strlen = strlen($contents); + // Get the first occurance of the problem string. + $end = strpos($contents, 'Drupal.admin.behaviors.responsivemenu'); + if ($end === FALSE) { + return; + } + // Get the start of this code block. + $start = strrpos($contents, '(function($)', $end - $strlen); + if ($start === FALSE) { + return; + } + // Get the lcoation of { + $middle = strpos($contents, "{\n", $start); + if ($middle === FALSE) { + $middle = strpos($contents, "{", $start); + if ($middle === FALSE) { + return; + } + else { + $middle += 1; + } + } + else { + $middle += 2; + } + + $contents = substr_replace($contents, $inserted_string, $middle, 0); + } +} + +/** * Implements hook_advagg_get_css_file_contents_alter(). * * Used to run strings inside of quotes of the content attribute through the t