Index: img_assist.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/img_assist/img_assist.module,v
retrieving revision 1.75.2.18
diff -u -p -r1.75.2.18 img_assist.module
--- img_assist.module	27 Oct 2008 19:15:16 -0000	1.75.2.18
+++ img_assist.module	3 Nov 2008 20:27:37 -0000
@@ -1806,7 +1806,7 @@ function theme_img_assist_page($content,
   $output .= drupal_get_js();
   $output .= "\n<script type=\"text/javascript\"><!-- \n";
   $output .= "  if (parent.tinyMCE) {\n";
-  $output .= "    document.write('<link href=\"' + parent.tinyMCE.getParam(\"popups_css\") + '\" rel=\"stylesheet\" type=\"text/css\">');\n";
+  $output .= "    document.write('<link href=\"' + parent.tinyMCEPopup.getParam(\"popups_css\") + '\" rel=\"stylesheet\" type=\"text/css\">');\n";
   $output .= "  } else {\n";
   foreach (drupal_add_css() as $media => $type) {
     $paths = array_merge($type['module'], $type['theme']);
@@ -1843,17 +1843,29 @@ function theme_img_assist_page($content,
 /**
  * Implementation of hook_wysiwyg_plugin().
  */
-function img_assist_wysiwyg_plugin($editor) {
+function img_assist_wysiwyg_plugin($editor, $version) {
   switch ($editor) {
     case 'tinymce':
-      return array(
-        'drupalimage' => array(
-          'path' => drupal_get_path('module', 'img_assist') .'/drupalimage',
-          'buttons' => array('drupalimage' => 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]'),
-        ),
-      );
+      if ($version > 3) {
+        return array(
+          'img_assist' => array(
+            'path' => drupal_get_path('module', 'img_assist') .'/plugins/tinymce/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]'),
+          ),
+        );
+      }
+      else {
+        return array(
+          'drupalimage' => array(
+            'path' => drupal_get_path('module', 'img_assist') .'/drupalimage',
+            'buttons' => array('drupalimage' => 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]'),
+          ),
+        );
+      }
   }
 }
 
Index: img_assist_popup.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/img_assist/img_assist_popup.js,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 img_assist_popup.js
--- img_assist_popup.js	22 Jul 2008 23:08:13 -0000	1.1.2.2
+++ img_assist_popup.js	3 Nov 2008 20:19:51 -0000
@@ -113,7 +113,7 @@ function hideElement(id) {
 }
 
 function insertImage() {
-  if (window.opener) {
+  if (window.opener || !tinyMCEPopup.isWindow) {
     // Get variables from the fields on the properties frame
     var formObj = frames['img_assist_main'].document.forms[0];
     // Get mode  (see img_assist.module for detailed comments)
Index: img_assist_tinymce.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/img_assist/img_assist_tinymce.js,v
retrieving revision 1.3.4.1
diff -u -p -r1.3.4.1 img_assist_tinymce.js
--- img_assist_tinymce.js	18 Jul 2008 22:54:36 -0000	1.3.4.1
+++ img_assist_tinymce.js	3 Nov 2008 20:21:54 -0000
@@ -18,20 +18,15 @@
 // get variables that were passed to this window from the tinyMCE editor
 var nid, captionTitle, captionDesc, link, url, align, width, height;
 
-function preinit() {
-  tinyMCE.setWindowArg('mce_windowresize', false);
-  tinyMCE.setWindowArg('mce_replacevariables', false);
-}
-
 function initLoader() {
-  nid          =      tinyMCE.getWindowArg('nid');
-  captionTitle = '' + tinyMCE.getWindowArg('captionTitle');
-  captionDesc  = '' + tinyMCE.getWindowArg('captionDesc');
-  link         = '' + tinyMCE.getWindowArg('link');
-  url          = '' + tinyMCE.getWindowArg('url');
-  align        = '' + tinyMCE.getWindowArg('align');
-  width        = '' + tinyMCE.getWindowArg('width');
-  height       = '' + tinyMCE.getWindowArg('height');
+  nid          =      tinyMCEPopup.getWindowArg('nid');
+  captionTitle = '' + tinyMCEPopup.getWindowArg('captionTitle');
+  captionDesc  = '' + tinyMCEPopup.getWindowArg('captionDesc');
+  link         = '' + tinyMCEPopup.getWindowArg('link');
+  url          = '' + tinyMCEPopup.getWindowArg('url');
+  align        = '' + tinyMCEPopup.getWindowArg('align');
+  width        = '' + tinyMCEPopup.getWindowArg('width');
+  height       = '' + tinyMCEPopup.getWindowArg('height');
 
   if (nid > 0) {
     frames['img_assist_main'].window.location.href = BASE_URL + 'index.php?q=img_assist/properties/' + nid + '/update';
@@ -98,6 +93,7 @@ function getFilterTag(formObj) {
   align        = formObj['edit-align'].value;
   width        = formObj['edit-width'].value;
   height       = formObj['edit-height'].value;
+  var size     = formObj['edit-size-label'].value;
   
   // Create the image placeholder tag
   // @see TinyMCE_drupalimage_cleanup() in drupalimage plugin.
@@ -107,7 +103,7 @@ function getFilterTag(formObj) {
     miscAttribs += '|url=' + url;
   }
   miscAttribs = encodeURIComponent(miscAttribs);
-  var content = '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '"'
+  var content = '<img src="' + Drupal.settings.basePath + 'image/view/' + nid + '"'
               + ' width="' + width + '" height="' + height + '" align="' + align + '"'
               + ' alt="' + miscAttribs + '" title="' + miscAttribs + '"'
               + ' name="mceItemDrupalImage" class="mceItemDrupalImage" />';
@@ -117,8 +113,7 @@ function getFilterTag(formObj) {
 
 function insertToEditor(content) {
   // Insert the image
-  tinyMCE.execCommand("mceInsertContent", true, content);
-  tinyMCE.selectedInstance.repaint();
+  tinyMCEPopup.editor.execCommand('mceInsertContent', false, content);
   
   // Close the dialog
   tinyMCEPopup.close();
@@ -130,5 +125,3 @@ function cancelAction() {
   tinyMCEPopup.close();
 }
 
-// While loading
-preinit();
Index: plugins/tinymce/editor_plugin.js
===================================================================
RCS file: plugins/tinymce/editor_plugin.js
diff -N plugins/tinymce/editor_plugin.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/tinymce/editor_plugin.js	3 Nov 2008 20:30:14 -0000
@@ -0,0 +1,130 @@
+// $Id: editor_plugin.js 201 2008-02-12 15:56:56Z sun $
+
+(function() {
+  // Load plugin specific language pack.
+  tinymce.PluginManager.requireLangPack('img_assist');
+
+  tinymce.create('tinymce.plugins.ImageAssistPlugin', {
+    /**
+     * Initialize the plugin, executed after the plugin has been created.
+     *
+     * This call is done before the editor instance has finished it's
+     * initialization so use the onInit event of the editor instance to
+     * intercept that event.
+     *
+     * @param ed
+     *   The tinymce.Editor instance the plugin is initialized in.
+     * @param url
+     *   The absolute URL of the plugin location.
+     */
+    init : function(ed, url) {
+      // Register the ImageAssist execCommand.
+      ed.addCommand('ImageAssist', function() {
+        // captionTitle and captionDesc for backwards compatibility.
+        var data = {nid: '', title: '', captionTitle: '', desc: '', captionDesc: '', link: '', url: '', align: '', width: '', height: '', id: ed.id, action: 'insert'};
+        var node = ed.selection.getNode();
+        if (node.name == 'mceItemDrupalImage') {
+          data.width = node.width;
+          data.height = node.height;
+          data.align = node.align;
+          // Expand inline tag in alt attribute
+          node.alt = decodeURIComponent(node.alt);
+          var chunks = node.alt.split('|');
+          for (var i in chunks) {
+            chunks[i].replace(/([^=]+)=(.*)/g, function(o, property, value) {
+              data[property] = value;
+            });
+          }
+          data.captionTitle = data.title;
+          data.captionDesc = data.desc;
+          data.action = 'update';
+        }
+        
+        ed.windowManager.open({
+          file : Drupal.settings.basePath + 'index.php?q=img_assist/load/tinymce&textarea=' + ed.id,
+          width : 700 + parseInt(ed.getLang('img_assist.delta_width', 0)),
+          height : 500 + parseInt(ed.getLang('img_assist.delta_height', 0)),
+          inline : 1
+        }, data);
+      });
+
+      // Register Image Assist button.
+      ed.addButton('img_assist', {
+        title : 'img_assist.desc',
+        cmd : 'ImageAssist',
+        image : url + '/img/img_assist.gif'
+      });
+
+      // Load Image Assist's CSS for editor contents on startup.
+      ed.onInit.add(function() {
+        if (!ed.settings.drupalimage_skip_plugin_css) {
+          ed.dom.loadCSS(url + "/css/img_assist.css");
+        }
+      });
+
+      // Replace images with inline tags in editor contents upon data.save.
+      // @todo Escape regular | pipes.
+      ed.onBeforeGetContent.add(function(ed, data) {
+        if (!data.save) {
+          return;
+        }
+        each(ed.dom.select('img', data.content), function(node) {
+          if (node.name != 'mceItemDrupalImage') {
+            return;
+          }
+          var inlineTag = '[img_assist|' + decodeURIComponent(node.alt) + '|align=' + node.align + '|width=' + node.width + '|height=' + node.height + ']';
+          ed.dom.setOuterHTML(node, inlineTag);
+        });
+      });
+
+      // Replace inline tags in data.content with images.
+      ed.onBeforeSetContent.add(function(ed, data) {
+        data.content = data.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.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);
+          return ed.dom.createHTML('img', node);
+        });
+        return;
+      });
+
+      // Add a node change handler, selects the button in the UI when an image is selected.
+      ed.onNodeChange.add(function(ed, command, node) {
+        command.setActive('img_assist', node.nodeName == 'IMG' && ed.dom.getAttrib(node, 'name').indexOf('mceItemDrupalImage') != -1);
+      });
+    },
+
+    /**
+     * Return information about the plugin as a name/value array.
+     */
+    getInfo : function() {
+      return {
+        longname : 'Image Assist',
+        author : 'Daniel F. Kudwien',
+        authorurl : 'http://www.unleashedmind.com',
+        infourl : 'http://drupal.org/project/img_assist',
+        version : "2.0"
+      };
+    }
+  });
+
+  // Register plugin.
+  tinymce.PluginManager.add('img_assist', tinymce.plugins.ImageAssistPlugin);
+})();
Index: plugins/tinymce/css/img_assist.css
===================================================================
RCS file: plugins/tinymce/css/img_assist.css
diff -N plugins/tinymce/css/img_assist.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/tinymce/css/img_assist.css	8 Oct 2008 04:53:44 -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/drupalimage.gif');
+  background-position: center;
+  background-repeat: no-repeat;
+  background-color: #ffffcc;
+}
+
Index: plugins/tinymce/img/img_assist.gif
===================================================================
RCS file: plugins/tinymce/img/img_assist.gif
diff -N plugins/tinymce/img/img_assist.gif
Binary files /dev/null and img_assist.gif differ
Index: plugins/tinymce/langs/en.js
===================================================================
RCS file: plugins/tinymce/langs/en.js
diff -N plugins/tinymce/langs/en.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/tinymce/langs/en.js	8 Oct 2008 04:54:03 -0000
@@ -0,0 +1,3 @@
+tinyMCE.addI18n('en.img_assist',{
+  desc : 'Insert or update an embedded image.'
+});
