Index: javascript_aggregator.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/javascript_aggregator/javascript_aggregator.module,v
retrieving revision 1.10
diff -u -r1.10 javascript_aggregator.module
--- javascript_aggregator.module	19 Jan 2008 20:15:48 -0000	1.10
+++ javascript_aggregator.module	3 Feb 2008 17:58:34 -0000
@@ -20,7 +20,19 @@
   preg_match_all($pattern, $scripts, $matches);
   // $matches[2] is where paths and filenames are stored
   $scripts_js_files = $matches[2];
-
+  
+  // this excludes listed files by unsetting the array element
+  if ($javascript_aggregator_exclude_js = variable_get('javascript_aggregator_exclude_js', FALSE)) {
+    $exclude_list = preg_split('/\r?\n/', $javascript_aggregator_exclude_js, -1, PREG_SPLIT_NO_EMPTY);
+   
+    foreach ($scripts_js_files as $key => $value) {
+      if (in_array($value, $exclude_list)) {
+        unset($scripts_js_files[$key]); // unsets the array element containing listed file 
+        $add_list[] = $value; // prepares it to add it later after aggregation
+      }
+    }
+  }
+  
   // Generate a unique filename for any set of js files
   $filename = md5(implode('', $scripts_js_files)) . '.js';
 
@@ -29,7 +41,7 @@
   file_check_directory($jspath, FILE_CREATE_DIRECTORY);
   $jsfile = $jspath .'/'. $filename;
 
-  if (!file_exists($jsfile) && variable_get('aggregate_js', 0)) {
+  if (!file_exists($jsfile) && variable_get('javascript_aggregator_aggregate_js', 0)) {
     $contents = '';
 
     foreach ($scripts_js_files as $scripts_js_file) {
@@ -45,7 +57,7 @@
       }
       $data = file_get_contents($scripts_js_file);
 
-      if (variable_get('optimize_js', 0)) {
+      if (variable_get('javascript_aggregator_optimize_js', 0)) {
         // Perform some safe JS optimizations.
         $data = preg_replace('<
           /\*([^*\\\\]|\*(?!/))+\*/    # Remove comments
@@ -58,14 +70,22 @@
     file_save_data($contents, $jsfile, FILE_EXISTS_REPLACE);
   }
 
-  if (variable_get('aggregate_js', 0)) {
+  if (variable_get('javascript_aggregator_aggregate_js', 0)) {
     // remove aggregated js files from $scripts using the same $pattern
     $scripts  = preg_replace($pattern, "",$scripts);
     // $newscripts = '<script type="text/javascript" src="/'. $jspath .'/'. $filename.'"></script>';
     $newscripts = '<script type="text/javascript" src="'. base_path() .$jspath .'/'. $filename.'"></script>';
   }
+  
+  // adds excluded files again to the $scripts variable
+  if (variable_get('javascript_aggregator_exclude_js', FALSE) && isset($add_list)) {
+    foreach ($add_list as $add_to_scripts) {
+      $newscripts .= "\n<script type=\"text/javascript\" src=\"$add_to_scripts\"></script>";
+    }
+  }
+  
   $newscripts .= $scripts;
-
+  
   return $newscripts;
 }
 
@@ -102,23 +122,32 @@
       '#weight' => 0
     );
 
-    $form['javascript_aggregation']['aggregate_js'] = array(
+    $form['javascript_aggregation']['javascript_aggregator_aggregate_js'] = array(
       '#type' => 'radios',
       '#title' => t('Aggregate JavaScript files'),
-      '#default_value' => variable_get('aggregate_js', 0),
+      '#default_value' => variable_get('javascript_aggregator_aggregate_js', 0),
       '#disabled' => !$is_writable,
       '#options' => array(t('Disabled'), t('Enabled')),
       '#description' => t("This option can interfere with module development. It is recommended to only turn this on when your site is complete."),
     );
 
-    $form['javascript_aggregation']['optimize_js'] = array(
+    $form['javascript_aggregation']['javascript_aggregator_optimize_js'] = array(
       '#type' => 'radios',
       '#title' => t('Optimize JavaScript files'),
-      '#default_value' => variable_get('optimize_js', 0),
+      '#default_value' => variable_get('javascript_aggregator_optimize_js', 0),
       '#disabled' => !$is_writable,
       '#options' => array(t('Disabled'), t('Enabled')),
       '#description' => t("This option removes /* */ comments to reduce file size."),
     );
+    
+    $form['javascript_aggregation']['javascript_aggregator_exclude_js'] = array(
+      '#type' => 'textarea',
+      '#title' => t('Exclude from js aggregation'),
+      '#default_value' => variable_get('javascript_aggregator_exclude_js', ''),
+      '#disabled' => !$is_writable,
+      '#description' => t('Enter one js file per line that should be excluded from js aggregation. Check your HTML source for paths. TinyMCE Example: <em>/sites/all/modules/tinymce/tinymce/jscripts/tiny_mce/tiny_mce.js</em>'),
+      
+    );
 
   }
 }
