diff -r -u yui_editor.orig/plugins/coder.js yui_editor/plugins/coder.js --- yui_editor.orig/plugins/coder.js 2008-11-21 23:54:27.000000000 +0100 +++ yui_editor/plugins/coder.js 2009-08-24 17:21:15.000000000 +0200 @@ -3,11 +3,15 @@ function yui_editor_coder() { for (var e in YAHOO.Drupal.editors) { var myEditor = YAHOO.Drupal.editors[e].editor; + if (typeof myEditor === "undefined") + continue; var config = YAHOO.Drupal.editors[e].config; + var id = YAHOO.Drupal.editors[e].id; + myEditor.config = config; + config.coderState = 'off'; - var coderState = 'off'; if (config.coder == 1) { - myEditor.on('toolbarLoaded', function() { + myEditor.on('toolbarLoaded', function () { var Dom = YAHOO.util.Dom; var codeConfig = { type: 'push', label: 'Edit HTML Code', value: 'editcode' @@ -18,8 +22,8 @@ var ta = this.get('element'), iframe = this.get('iframe').get('element'); - if (coderState == 'on') { - coderState = 'off'; + if (this.config.coderState == 'on') { + this.config.coderState = 'off'; this.toolbar.set('disabled', false); this.setEditorHTML(ta.value); if (!this.browser.ie) { @@ -32,7 +36,6 @@ this._focusWindow(); } else { - coderState = 'on'; this.cleanHTML(); Dom.addClass(iframe, 'editor-hidden'); Dom.removeClass(ta, 'editor-hidden'); @@ -42,13 +45,14 @@ this.dompath.innerHTML = 'Editing HTML Code'; Dom.setStyle(this.get('element'), 'border', '0px'); this.hide(); + this.config.coderState = 'on'; } return false; }, this, true); this.on('cleanHTML', function(ev) { - this.get('element').value = ev.html; + this.get('element').value = ev.html; }, this, true); this.on('afterRender', function() { @@ -63,23 +67,27 @@ this.addClass('editor-hidden'); }, this, true); - }, myEditor, true); + }); } + } - var toggle = 'off'; - $('#toggleEditor-'+id).bind('click', function () { toggle = 'on'; }); - $('form').bind('submit', function (e) { - if (toggle == 'on') { - toggle = 'off'; - return false; - } - else if (coderState == 'on') { - myEditor.setEditorHTML(myEditor.get('textarea').value); - } - else { - myEditor.saveHTML(); - } - }); + // If code is active, make sure contents is saved properly. We need + // to add our own submit handler before the Yahoo one. Not tested what + // happens if handleSubmit is false. + var Event = YAHOO.util.Event; + for (var e in YAHOO.Drupal.editors) { + var myEditor = YAHOO.Drupal.editors[e].editor; + if (typeof myEditor === "undefined") + continue; + var form = myEditor.get('element').form; + Event.removeListener(form, 'submit', myEditor._handleFormSubmit); + Event.addListener(form, 'submit', function (ev) { + if (this.config.coderState == "on") + this.setEditorHTML(this.get('element').value); + }, myEditor, true); + Event.addListener(form, 'submit', myEditor._handleFormSubmit, myEditor, true); } + } + YAHOO.Drupal.yui_editor_load.subscribe(yui_editor_coder); diff -r -u yui_editor.orig/plugins/img_upload.2.6.js yui_editor/plugins/img_upload.2.6.js --- yui_editor.orig/plugins/img_upload.2.6.js 2008-11-22 00:12:43.000000000 +0100 +++ yui_editor/plugins/img_upload.2.6.js 2009-08-20 21:08:10.000000000 +0200 @@ -6,7 +6,7 @@ var config = YAHOO.Drupal.editors[e].config; if (config.img_upload == 1) { - yui_img_uploader(myEditor, config.base_path + '?q=/yui_editor/image_upload', 'files[upload]', config.base_path, YAHOO.Drupal.editors[e].id); + yui_img_uploader(myEditor, config.base_path + '?q=/yui_editor/image_upload', 'files[yui_upload]', config.base_path, YAHOO.Drupal.editors[e].id); } } } diff -r -u yui_editor.orig/plugins/img_upload.inc yui_editor/plugins/img_upload.inc --- yui_editor.orig/plugins/img_upload.inc 2008-11-21 23:54:27.000000000 +0100 +++ yui_editor/plugins/img_upload.inc 2009-08-22 09:36:12.000000000 +0200 @@ -12,16 +12,20 @@ function yui_editor_image_upload() { header('content-type: text/html'); // the return type must be text/html $response = NULL; - $path = file_directory_path(); - // Append trailing slash to path if not there - if (!(substr($path, -1) == '/')) { - $path .= '/'; + $path = file_create_path('images'); + if (!file_check_directory($path, true)) { + $response->status = t('Error creating subdirectory images.'); + print drupal_to_js($response); + exit; } - $path .= 'images'; - $file = file_save_upload('upload', array(), $path, FILE_EXISTS_REPLACE); + $file = file_save_upload('yui_upload', array(), $path, FILE_EXISTS_REPLACE); if (!$file) { - $response->status = t('Error reading uploaded file.'); + $messages = drupal_get_messages('error'); + if ($messages) + $response->status = implode ('; ', $messages['error']); + else + $response->status = t('Error reading uploaded file.'); print drupal_to_js($response); exit; } @@ -42,6 +46,7 @@ 'access callback' => 'user_access', 'access arguments' => array('upload files'), 'type' => MENU_CALLBACK, + 'file' => 'plugins/img_upload.inc', ); return $items; @@ -50,8 +55,8 @@ function yui_editor_img_upload_render(&$profile) { $profile['img_upload'] = (user_access('upload files') ? $profile['img_upload'] : 0); if ($profile['img_upload'] == 1) { - $yui_source = variable_get('yui_source', 'http://yui.yahooapis.com/2.6.0'); - if (preg_match('/2.6.[0-9]$/iU', $yui_source)) { + $is_26_plus = yui_editor_is_26_plus (); + if ($is_26_plus) { drupal_add_js(drupal_get_path('module', 'yui_editor') .'/plugins/img_upload.2.6.js', 'module', 'footer'); } else { diff -r -u yui_editor.orig/plugins/img_upload.js yui_editor/plugins/img_upload.js --- yui_editor.orig/plugins/img_upload.js 2008-11-21 23:54:27.000000000 +0100 +++ yui_editor/plugins/img_upload.js 2009-08-20 21:15:12.000000000 +0200 @@ -6,7 +6,7 @@ var config = YAHOO.Drupal.editors[e].config; if (config.img_upload == 1) { - yui_img_uploader(myEditor, '?q=/yui_editor/image_upload', 'files[upload]', config.base_path); + yui_img_uploader(myEditor, '?q=/yui_editor/image_upload', 'files[yui_upload]', config.base_path); } } } diff -r -u yui_editor.orig/plugins/resize.js yui_editor/plugins/resize.js --- yui_editor.orig/plugins/resize.js 2008-11-21 23:54:27.000000000 +0100 +++ yui_editor/plugins/resize.js 2009-08-24 15:30:36.000000000 +0200 @@ -7,7 +7,7 @@ if (config.resize == 1) { myEditor.on('editorContentLoaded', function() { - resize = new YAHOO.util.Resize(myEditor.get('element_cont').get('element'), { + resize = new YAHOO.util.Resize(this.get('element_cont').get('element'), { handles: ['br'], autoRatio: true, status: true, @@ -16,7 +16,7 @@ resize.on('startResize', function() { this.hide(); this.set('disabled', true); - }, myEditor, true); + }, this, true); resize.on('resize', function(args) { var h = args.height; var th = (this.toolbar.get('element').clientHeight + 2); //It has a 1px border.. @@ -26,7 +26,7 @@ this.set('height', newH + 'px'); this.set('disabled', false); this.show(); - }, myEditor, true); + }, this, true); }); } } diff -r -u yui_editor.orig/plugins/table.js yui_editor/plugins/table.js --- yui_editor.orig/plugins/table.js 2008-11-21 23:54:27.000000000 +0100 +++ yui_editor/plugins/table.js 2009-08-24 17:25:02.000000000 +0200 @@ -11,10 +11,10 @@ var tableConfig = { type: 'push', label: 'Create Table', value: 'table' }; - myEditor.toolbar.addButtonToGroup(tableConfig, 'plugins'); - myEditor.win = null; + this.toolbar.addButtonToGroup(tableConfig, 'plugins'); + this.win = null; - myEditor.createTableHTML = + this.createTableHTML = '
| Rows: | Columns: | ||
| Width: | Height: | ||