Index: video_filter.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/video_filter/video_filter.module,v
retrieving revision 1.12.2.12
diff -u -r1.12.2.12 video_filter.module
--- video_filter.module	5 Mar 2010 09:32:24 -0000	1.12.2.12
+++ video_filter.module	14 Mar 2010 21:24:18 -0000
@@ -266,6 +266,40 @@
  * Implementation of hook_wysiwyg_plugin().
  */
 function video_filter_wysiwyg_plugin($editor, $version) {
+  static $settings_added = FALSE;
+
+  if (!$settings_added && arg(0) == "node" && is_numeric(arg(1))) {
+    $settings_added = TRUE;
+    
+    $node = node_load(arg(1));
+    $default_settings = array(
+      'width' => variable_get('video_filter_width_' . $node->format, 400),
+      'height' => variable_get('video_filter_height_' . $node->format, 400),
+      'file' =>  url('video_filter/load'),
+      'css' => drupal_get_path('module', 'video_filter') .'/wysiwyg/tinymce/video_filter.css',
+    );
+
+    //Load settings
+    $codecs = module_invoke_all('codec_info');
+    
+    $codec_settings = array();
+
+    foreach($codecs AS $key => $codec) {
+      $codec_settings[$key] = array(
+        'regexp' => $codec['regexp'],
+        'ratio' => $codec['ratio'],
+        'control_bar_height' =>  $codec['control_bar_height'] ? $codec['control_bar_height'] : 0,
+      );
+    }
+
+    $settings = array(
+      'video_filter' => array('default_settings' => $default_settings, 'codec' => $codec_settings),
+    );
+  
+    drupal_add_js($settings, 'setting');
+  }
+ 
+
   switch ($editor) {
     case 'tinymce':
       if ($version > 3) {
@@ -276,6 +310,7 @@
             'buttons' => array('videofilter' => t('Video Filter')),
             'url' => 'http://drupal.org/project/video_filter',
             'load' => TRUE,
+            'css' => drupal_get_path('module', 'video_filter') . '/wysiwyg/tinymce/video_filter.css',
           ),
         );
       }
@@ -283,6 +318,7 @@
   }
 }
 
+
 /**
  * Output tinymce popup html.
  * 
Index: wysiwyg/tinymce/editor_plugin_src.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/video_filter/wysiwyg/tinymce/Attic/editor_plugin_src.js,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 editor_plugin_src.js
--- wysiwyg/tinymce/editor_plugin_src.js	15 Jan 2010 16:04:00 -0000	1.1.2.2
+++ wysiwyg/tinymce/editor_plugin_src.js	14 Mar 2010 21:23:42 -0000
@@ -1,10 +1,86 @@
 (function() {
   tinymce.create('tinymce.plugins.VideoFilterPlugin', {
     init : function(ed, url) {
+      
+      function isVideofilter(n) {
+				return /^(videoFitler)$/.test(n.className);
+			};
+
+      /**
+      * Helper function to return a HTML placeholder.
+      */
+      function _getPlaceholder(settings) {
+        var style = '';
+        if(settings.width) { style += 'width:'+settings.width + 'px; '; }
+        if(settings.height) { style += 'height:'+settings.height + 'px; '; }
+        var str = '<img src="' + ed.baseURI.path + '/plugins/media/img/trans.gif" class="videoFitler"';
+        if(style) { str += ' style="'+style+'"'; }
+        str += ' title="' + settings.fullmatch.substring(1,(settings.fullmatch.length-1)) + '"/>';
+        return str;
+      };
+
+      function _getRegExp(codec) {
+        var exp = null;
+        if(typeof codec.regexp == 'string') {          
+          var old_reg = codec.regexp;
+          var pattern = old_reg.replace(/^\//, '').replace(/\/i*$/, '');
+          pattern = new RegExp(pattern, 'ig');
+          exp = pattern;
+        } 
+        // codecs[service].regexp is an array of regexps
+        else {
+          var pattern = [];
+          for(i in codec.regexp) {
+            pattern.push(new RegExp(codec.regexp[i].replace(/^\//, '').replace(/\/i*$/, ''),'ig'));
+          }
+          exp = pattern;
+        }
+        
+        return exp;
+      };
+
+      function _getSettings(content, codecs) {
+        for(service in codecs) {
+           var exp = _getRegExp(codecs[service]);
+           var match = false;
+           var settings = {};
+           
+           if(exp != null && exp.constructor.toString().indexOf("Array") == -1  && exp.test(content)) {
+              settings.fullmatch = content;
+              match = true;
+           } 
+           // Array exp
+           else if(exp.constructor.toString().indexOf("Array") != -1) {
+             for(i in exp) {
+              if(exp[i].test(content)) {
+                settings.fullmatch = content;
+                match = true;
+              }
+             }
+           }
+            
+           if(match) {
+              settings.height = Drupal.settings.video_filter.default_settings.height;
+              settings.width = Drupal.settings.video_filter.default_settings.width;
+              if (settings.fullmatch.length > 0) {
+                if(/height:\s*(\d+)/i.test(settings.fullmatch)) {
+                  settings.height = RegExp.$1;
+                }
+                if(/width:\s*(\d+)/i.test(settings.fullmatch)) {
+                  settings.width = RegExp.$1;
+                }
+              }
+            return settings;
+           }
+        }
+        
+        return null;
+      };
+
       // Register commands
       ed.addCommand('mceVideoFilter', function() {
         ed.windowManager.open({
-          file : Drupal.settings.basePath + '?q=video_filter/load',
+          file : Drupal.settings.video_filter.default_settings.file,
           width : 480,
           height : 480,
           inline : 1,
@@ -12,11 +88,52 @@
         });
       });
 
+      ed.onInit.add(function() {
+        //Load videofilter css.
+        ed.dom.loadCSS(Drupal.settings.video_filter.default_settings.css);
+      });
+
       // Register buttons
       ed.addButton('videofilter', {
         title : 'Video Filter',
         cmd : 'mceVideoFilter'
       });
+
+      ed.onNodeChange.add(function(ed, cm, n) {
+				cm.setActive('videofilter', n.nodeName == 'IMG' && isVideofilter(n));
+        /*
+        // @todo: Fix so Image button doesnt get active
+        if(n.nodeName == 'IMG' && isVideofilter(n)) {
+          console.log('set false');
+          cm.setDisabled('image', false, true);
+        }
+        */
+			});
+
+         // Attach: Replace plain text with HTML representations.
+      ed.onBeforeSetContent.add(function(ed, data) {
+          var codecs = Drupal.settings.video_filter.codec;
+          var content = $('<div>' + data.content + '</div>'); 
+          $("*:contains('[video:')", content).each(function(i) {
+            var settings = null;
+            settings = _getSettings($(this).html(), codecs);
+            if(settings != null) {
+              data.content = data.content.replace($(this).html(), _getPlaceholder(settings));
+            }
+          });
+      });
+
+      // Detach: Replace HTML representations with plain text.
+      ed.onGetContent.add(function(ed, data) {
+        var $content = $('<div>' + data.content + '</div>'); 
+        $.each($('img.videoFitler', $content), function (i, elem) {
+          $(this).before('[' + $(this).attr('title') + ']');
+          $(this).remove();
+        });
+        
+        data.content =  $content.html();
+      });
+
     },
 
     getInfo : function() {
Index: wysiwyg/tinymce/video_filter.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/video_filter/wysiwyg/tinymce/Attic/video_filter.css,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 video_filter.css
--- wysiwyg/tinymce/video_filter.css	22 Oct 2009 19:40:44 -0000	1.1.2.1
+++ wysiwyg/tinymce/video_filter.css	10 Mar 2010 22:10:51 -0000
@@ -12,4 +12,12 @@
 #mceVideoPopup ul {
   margin:0;
   padding-left:13px;
-}
\ No newline at end of file
+}
+
+img.videoFitler {
+  background-color:#FFFFCC;
+  background: #FFFFCC url('images/movie_track.png') no-repeat 50% 50%;
+  border:1px dotted #CC0000;
+  color:#f96f6f;
+  padding:10px;
+}

