diff --git a/jquery_update.module b/jquery_update.module index 9e53f8a..81d9976 100644 --- a/jquery_update.module +++ b/jquery_update.module @@ -78,8 +78,21 @@ function jquery_update_theme_registry_alter(&$theme_registry) { * Replace Drupal core's jquery.js with the new one from jQuery Update module. */ function jquery_update_preprocess_page(&$variables) { + // Make sure this path is not excluded from update. + $current_path = $_GET['q']; + $update_exceptions = variable_get('jquery_update_exception_paths', ''); + $excluded = drupal_match_path($current_path, $update_exceptions); + + // exclusions or inclusions? + $inclusion = intval(variable_get('jquery_update_exception_condition', 0) ); + if ((($inclusion && $excluded) || (!$inclusion && !$excluded)) || (($excluded == '') || ($excluded == NULL))) { + $include = TRUE; + } else { + $include = FALSE; + } + // Only do this for pages that have JavaScript on them. - if (!empty($variables['scripts'])) { + if (!empty($variables['scripts']) && $include) { // Perform the logic if either jQuery Update's jquery.js is newer than core's. if (variable_get('jquery_update_replace', TRUE)) { @@ -175,7 +188,24 @@ function jquery_update_settings() { '#default_value' => variable_get('jquery_update_jquery_version', '1.3'), '#description' => t('Select which jQuery version branch to use.'), ); - + $form['jquery_update_exception_condition'] = array( + '#type' => 'radios', + '#options' => array( + '0' => t('DO NOT update jQuery on these pages'), + '1' => t('ONLY update jQuery on these pages'), + ), + '#default_value' => variable_get('jquery_update_exception_condition', '0'), + ); + $form['jquery_update_exception_paths'] = array( + '#type' => 'textarea', + '#default_value' => variable_get('jquery_update_exception_paths', ''), + '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are blog for the blog page and blog/* for every personal blog. is the front page."), + ); + $form['jquery_update_path'] = array( + '#type' => 'textarea', + '#default_value' => variable_get('jquery_update_path', 'admin/*'."\n". 'node/add'."\n". 'node/*/edit'), + '#description' => t('Specify the path to load jquery 1.3 instead of 1.7. Enter one page per line as Drupal paths. The * caharacter is a wildcard. Example paths are admin for the admin page and node/*/edit for node edit'), + ); return system_settings_form($form); } @@ -192,6 +222,13 @@ function jquery_update_jquery_path() { // Find the jQuery version to use. $version = variable_get('jquery_update_jquery_version', '1.3'); + + // jquery 1.7 won't work on some pages, so we restrict the path + $pattern = variable_get('jquery_update_path', 'admin/*'."\n".'node/add'."\n". 'node/*/edit'); + $limit = drupal_match_path($_REQUEST['q'], $pattern); + if($limit == 1) { + $version = '1.3'; + } $path = drupal_get_path('module', 'jquery_update') .'/replace/jquery/'. $version .'/'; return $path . $jquery_file[$type]; }