Index: img_assist.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/img_assist/img_assist.module,v
retrieving revision 1.95
diff -u -p -r1.95 img_assist.module
--- img_assist.module	18 Jan 2009 21:51:07 -0000	1.95
+++ img_assist.module	27 Jan 2009 05:58:04 -0000
@@ -1855,22 +1855,12 @@ function theme_img_assist_page($content,
  */
 
 /**
- * Implementation of hook_wysiwyg_plugin().
+ * Implementation of hook_wysiwyg_include_directory().
  */
-function img_assist_wysiwyg_plugin($editor, $version) {
-  switch ($editor) {
-    case 'tinymce':
-      if ($version > 3) {
-        return array(
-          'img_assist' => array(
-            'path' => drupal_get_path('module', 'img_assist') .'/drupalimage/editor_plugin.js',
-            'buttons' => array('img_assist' => t('Image Assist')),
-            'url' => 'http://drupal.org/project/img_assist',
-            'extended_valid_elements' => array('img[class|src|border=0|alt|title|width|height|align|name|style]'),
-          ),
-        );
-      }
-      break;
+function img_assist_wysiwyg_include_directory($type) {
+  switch ($type) {
+    case 'plugins':
+      return $type;
   }
 }
 
Index: img_assist_tinymce.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/img_assist/img_assist_tinymce.js,v
retrieving revision 1.6
diff -u -p -r1.6 img_assist_tinymce.js
--- img_assist_tinymce.js	18 Jan 2009 04:10:25 -0000	1.6
+++ img_assist_tinymce.js	27 Jan 2009 00:42:06 -0000
@@ -106,7 +106,7 @@ function getFilterTag(formObj) {
   var content = '<img src="' + Drupal.settings.basePath + 'index.php?q=image/view/' + nid + '"'
               + ' width="' + width + '" height="' + height + '" align="' + align + '"'
               + ' alt="' + miscAttribs + '" title="' + miscAttribs + '"'
-              + ' name="mceItemDrupalImage" class="mceItemDrupalImage" />';
+              + ' name="mceItemDrupalImage" class="img-assist" />';
   
   return content;
 }
Index: plugins/img_assist.inc
===================================================================
RCS file: plugins/img_assist.inc
diff -N plugins/img_assist.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/img_assist.inc	25 Jan 2009 04:16:02 -0000
@@ -0,0 +1,27 @@
+<?php
+// $Id: wysiwyg_editor.plugins.inc,v 1.1.2.7 2008/10/05 04:05:04 sun Exp $
+
+
+/**
+ * Implementation of hook_wysiwyg_plugin().
+ */
+function img_assist_img_assist_plugin() {
+  $plugins = array();
+  $plugins['img_assist'] = array(
+    'title' => t('Image Assist'),
+    'vendor url' => 'http://drupal.org/project/img_assist',
+    'icon file' => 'img_assist.gif',
+    'icon title' => t('Insert or update an embedded image'),
+    'settings' => array(
+      'dialog' => array(
+        'url' => base_path() . 'index.php?q=img_assist/load/tinymce',
+        'width' => 700,
+        'height' => 500,
+      ),
+    ),
+    // @todo Use a more granular way to validate contents for input formats.
+    'extended_valid_elements' => array('img[class|src|border=0|alt|title|width|height|align|name|style]'),
+  );
+  return $plugins;
+}
+
Index: plugins/img_assist/img_assist.css
===================================================================
RCS file: plugins/img_assist/img_assist.css
diff -N plugins/img_assist/img_assist.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/img_assist/img_assist.css	14 Oct 2008 02:04:27 -0000
@@ -0,0 +1,10 @@
+/* $Id: drupalimage.css,v 1.1.4.1.2.1 2008/07/18 00:14:51 sun Exp $ */
+
+.mceItemDrupalImage {
+  border: 1px dotted #cc0000;
+  background-image: url('images/img_assist.gif');
+  background-position: center;
+  background-repeat: no-repeat;
+  background-color: #ffffcc;
+}
+
Index: plugins/img_assist/img_assist.js
===================================================================
RCS file: plugins/img_assist/img_assist.js
diff -N plugins/img_assist/img_assist.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/img_assist/img_assist.js	27 Jan 2009 00:45:10 -0000
@@ -0,0 +1,94 @@
+// $Id: editor_plugin.js 201 2008-02-12 15:56:56Z sun $
+
+Drupal.wysiwyg.plugins.img_assist = {
+
+  // Return whether the passed node belongs to this plugin.
+  isNode: function (node) {
+    return ($(node).is('img.img-assist'));
+  },
+
+  // Execute the button.
+  invoke: function (data, settings, instanceId) {
+    if (data.format == 'html') {
+      // captionTitle and captionDesc for backwards compatibility.
+      var options = {nid: '', title: '', captionTitle: '', desc: '', captionDesc: '', link: '', url: '', align: '', width: '', height: '', id: instanceId, action: 'insert'};
+      if ($(data.node).is('img.img-assist')) {
+        options.width = data.node.width;
+        options.height = data.node.height;
+        options.align = data.node.align;
+        // Expand inline tag in alt attribute
+        data.node.alt = decodeURIComponent(data.node.alt);
+        var chunks = data.node.alt.split('|');
+        for (var i in chunks) {
+          chunks[i].replace(/([^=]+)=(.*)/g, function(o, property, value) {
+            options[property] = value;
+          });
+        }
+        options.captionTitle = options.title;
+        options.captionDesc = options.desc;
+        options.action = 'update';
+      }
+    }
+    else {
+      // @todo Plain text support.
+      /*
+    	if (data.content.match(/<!--break-->/)) {
+        return;
+    	}
+    	var content = '<!--break-->';
+      */
+    }
+    if (typeof options != 'undefined') {
+      Drupal.wysiwyg.instances[instanceId].openDialog(settings.dialog, options);
+    }
+  },
+
+  // Replace inline tags in data.content with images.
+  attach: function (content, settings, instanceId) {
+    content = content.replace(/\[img_assist\|([^\[\]]+)\]/g, function(orig, match) {
+      var node = {}, chunks = match.split('|');
+      for (var i in chunks) {
+        chunks[i].replace(/([^=]+)=(.*)/g, function(o, property, value) {
+          node[property] = value;
+        });
+      }
+      node.name = 'mceItemDrupalImage';
+      node.class = 'img-assist';
+      node.src = Drupal.settings.basePath + 'index.php?q=image/view/' + node.nid;
+      node.alt = 'nid=' + node.nid + '|title=' + node.title + '|desc=' + node.desc;
+      if (node.link.indexOf(',') != -1) {
+        var link = node.link.split(',', 2);
+        node.alt += '|link=' + link[0] + '|url=' + link[1];
+      }
+      else {
+        node.alt += '|link=' + node.link;
+      }
+      if (typeof node.url != 'undefined') {
+        node.alt += '|url=' + node.url;
+      }
+      node.alt = encodeURIComponent(node.alt);
+      var element = '<img ';
+      for (var property in node) {
+        element += property + '="' + node[property] + '" ';
+      }
+      element += '/>';
+      return element;
+    });
+    return content;
+  },
+
+  // Replace images with inline tags in editor contents upon data.save.
+  detach: function (content, settings, instanceId) {
+    $content = $('<div>' + content + '</div>'); // No .outerHTML() in jQuery :(
+    console.log($content);
+    $('img', $content).each(function(node) {
+      if (this.className != 'img-assist') {
+        return;
+      }
+      var inlineTag = '[img_assist|' + decodeURIComponent(this.alt) + '|align=' + this.align + '|width=' + this.width + '|height=' + this.height + ']';
+      $(this).replaceWith(inlineTag);
+    });
+    console.log($content);
+    return $content.html();
+  }
+};
Index: plugins/img_assist/images/img_assist.gif
===================================================================
RCS file: plugins/img_assist/images/img_assist.gif
diff -N plugins/img_assist/images/img_assist.gif
Binary files /dev/null and img_assist.gif differ
