When activating the (sub)module "Image Browser Plugin - WYSIWYG API" the browser drop the folowing error:
IE V8.0.6: Drupal.wysiwyg.plugins is null or not an object.
Mozilla/5.0 (Firefox/3.5.4): Drupal.wysiwyg is undefined.
I went deep into the code and it appears to be that the file wysiwyg.init.js is not being included or the Drupal object is being overwritten, that's why when the IB module load the code "Drupal.wysiwyg.plugins.imagebrowser = {

/**
* Return whether the passed node belongs to this plugin.
*/
isNode: function(node) {
return ($(node).is('img.ibimage'));
},"
the browser dosent find a valid object.
I must say that when the module IB is enable but the (sub)module "Image Browser Plugin - WYSIWYG API" is disable the error is not present but i'm reporting this issue here becouse i think this module has more responsability for this error although i will let know to the developers of IB module.

Comments

neoglez’s picture

StatusFileSize
new84.44 KB

This situation can be seen in the same demo page of the IB module http://ib2.coredesigns.co.uk/

jdelaune’s picture

Project: Wysiwyg » Image Browser

I imagine it's more my problem. I'll take a peak when I can.

neoglez’s picture

Thanks!

milos.kroulik’s picture

Priority: Normal » Critical
StatusFileSize
new24.95 KB

I also experience this problem. Additionally i get:

$("#ib_dialog").dialog is not a function

when I click on the Imagebrowser button. I enclose screenshot made with Firebug.

ihanick’s picture

Quick and dirty fix:
add several js lines at the begining of plugins/ib_wysiwyg/ib_wysiwyg_init.js file.
Drupal.wysiwyg = Drupal.wysiwyg || { 'instances': {} };
Drupal.wysiwyg.editor = Drupal.wysiwyg.editor || { 'init': {}, 'attach': {}, 'detach': {}, 'instance': {} };
Drupal.wysiwyg.plugins = Drupal.wysiwyg.plugins || {};

ñull’s picture

Title: Change how init files are loaded » JavaScript error: Drupal.wysiwyg.plugins is null or not an object
Assigned: peter törnstrand » Unassigned
Priority: Normal » Critical
Status: Closed (fixed) » Active

That did not do it for me. Without the dirty fix I get the error:

Drupal.wysiwyg.plugins.imagebrowser = { drupal.wysiwyg is undefined on line 30

With the fix I get:

uncaught exception: [Exception... "Could not convert JavaScript argument arg 0" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: https://mydomain.com/misc/jquery.js?t :: anonymous :: line 13" data: no]

Line 0

Note: The wysiwyg_init.js is inserted, but it is in head of the page, but it is missing in the head of the editor's iframe! Shouldn't it be inserted there? And when I think of it, may be both should be inserted there?

jdelaune’s picture

Hey everyone. Sorry for the lack of response. Had an unexpected spell in hospital, but I'm back now.

Is this JS error only seen in IE8 or earlier? I'm not seeing it in Safari or Firefox.

Please let me know your browser, version and operating system. Cheers

thsutton’s picture

I see this error in Safari 4.0.4 and Firefox 3.5.5 both on Mac OS X.

Modifying the ib_wysiwyg_init() function in imagebrowser/plugins/ib_wysiwyg/ib_wysiwyg.module so that the ib_wysiwyg_init.js JavaScript file is included in the footer rather than the head as per default makes the error go away:

function ib_wysiwyg_init() {
  drupal_add_js(drupal_get_path('module', 'ib_wysiwyg') . "/ib_wysiwyg_init.js", 'module', 'footer');
  drupal_add_css(drupal_get_path('module', 'ib_wysiwyg') . "/ib_wysiwyg_init.css");
  if(module_exists('jquery_ui')){ jquery_ui_add('ui.dialog'); };
}

This suggests that this is due to the JavaScript being loaded before something it depends on.

jdelaune’s picture

Title: JavaScript error: Drupal.wysiwyg.plugins is null or not an object » Change how init files are loaded
Priority: Critical » Normal

Ah I thought the error was causing something not to work. It still works fine, you just get that JS error. It's due to the fact that those files shouldn't even be loaded in the imagebrowser window.

The quickfix is to change this function in ib_wysiwyg.module

function ib_wysiwyg_init() {
  if (arg(0) != 'imagebrowser') {
    drupal_add_js(drupal_get_path('module', 'ib_wysiwyg') . "/ib_wysiwyg_init.js");
    drupal_add_css(drupal_get_path('module', 'ib_wysiwyg') . "/ib_wysiwyg_init.css");
    if(module_exists('jquery_ui')){ jquery_ui_add('ui.dialog'); };
  }
}

A better fix is needed however to intelligently load the ib_wysiwyg_init.js file on any page which has a wysiwyg editor loaded.

thsutton’s picture

Neither my modification in comment 8 above, not that in comment 9 fixes this issue in all cases. I still get the ib_wysiwyg_init.js included incorrectly (on the front page, for example).

wysiwyg.module contains the following comment:

// Collect native plugins for this editor provided via hook_wysiwyg_plugin()
// and Drupal plugins provided via hook_wysiwyg_include_directory().

This suggests that both these hooks are only called when the WYSIWYG module is actually being used in a form. I've traced through the code and this seems to be the case.

I moved the three lines in ib_wysiwyg_init() into ib_wysiwyg_wysiwyg_include_directory() instead, and this seems to have fixed the issue: ib_wysiwyg_init.js is included on only those pages that use the WYSIWYG module and the JavaScript error is no more.

jdelaune’s picture

awesome work. I'll roll that in :)

perandre’s picture

sub +1 (feel ashamed everytime I do this)

cvedovini’s picture

StatusFileSize
new1.16 KB

Hi just stumbled upon this bug as well, it appears in every browsers and is due to the fact that the javascript for the wysiwyg plugin is included in each and every page whereas the wysiwyg javascript (upon which it depends) is only included when necessary.
To correct this I moved the drupal_add_js calls from the ib_wysiwyg_init() to the ib_wysiwyg_imagebrowser_plugin(), it looked more logical than other proposed solutions :)

ckng’s picture

Status: Active » Needs review

It was due to the sequence of the js files, ib_wysiwyg_init.js is loaded before ckeditor.js.
#13 should fix it just fine.

peter törnstrand’s picture

Assigned: Unassigned » peter törnstrand
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Status: Active » Closed (fixed)