When attempting to run content analysis on any content while TinyMCE 3.4.4 is installed through Wysiwyg 7.x-2.1 the following error is given:

Uncaught TypeError: Cannot call method 'hide' of undefined
$.extend.contentanalysis_analyzecontentanalysis.js:160
$.extend.contentanalysis_full_analysiscontentanalysis.js:104
(anonymous function)edit:1
b.extend.globalEvaljquery.js:33
Oajquery.js:21
b.extend.eachjquery.js:34
c.fn.extend.domManipjquery.js:121
c.fn.extend.appendjquery.js:114
c.fn.extend.htmljquery.js:118
Drupal.CTools.Modal.modal_displaymodal.js:276
Drupal.ajax.successajax.js:400
Drupal.ajax.ajax.options.successajax.js:164
c.extend.handleSuccessjquery.js:143
c.extend.ajax.w.onreadystatechange

Lines in question:

// Turn off TinyMCE if enabled
if(typeof tinyMCE == 'object') {
tinyMCE.get('edit-body-und-0-value').hide(); <<<< This is line 160
}

Turning off the TinyMCE editor for all text formats resolves the issue.

Comments

kingandy’s picture

Title: TinyMCE is causing the contentanalysis.js to break on line 160 » Content Analysis incompatible with TinyMCE/WYSIWYG
Priority: Normal » Major

I'm experiencing the same errors. I guess WYSIWYG changed its methods?

Bumping up to Major priority, since it renders the module unusable from the node form when TinyMCE is in use ("significant repercussions but do[es] not render the whole system unusable").

steveb_uk’s picture

I'm experiencing this exact issue as well. Combined with multiple PHP errors (as noted in this issue: http://drupal.org/node/1416408).

(I actually do get content analysis results on a few nodes but not the majority)

Drupal: 7.12
PHP: 5.3.5
Wysiwyg: 7.x-2.1
TinyMCE: 3.4.8
Content Analysis: 7.x-1.0-beta4 (was about to upgrade to latest version when I came across this issue)

Amazing module, by the way

steveb_uk’s picture

Finally got round to looking at this again and got to the route of the problem on my website, which will hopefully help others:

The Javascript code to hide and show the WYIWYG editor (either TinyMCE or CKeditor) relies on finding it using it's ID.
The file in question is contentanalysis.js (lines 160 and 200)

For example:

if(typeof tinyMCE == 'object') {
tinyMCE.get('edit-body-und-0-value').hide();
}

Multilingual websites will have an ID for their WYSIWYG editor that may be different from this, if a language has been selected.
For example:

id="edit-body-en-0-value"

So we need to find the editor using classes, rather than an ID. I used the following, which allowed Content Analysis to run successfully for all nodes:

if(typeof tinyMCE == 'object') {
$('.form-textarea-wrapper .form-textarea').hide();
}

chefnelone’s picture

@steveb_uk

I have this problem with ckeditor. Should I look at the class of the textarea?

Do I need to just change this lines (162 to 167):

		    // Turn off CKEditor if any.
		    var ckeditor = false;
		    if ($('#cke_edit-body-und-0-value').html()) {
		      $('#wysiwyg-toggle-edit-body-und-0-value').click();
		      ckeditor = true;
		    }

If you already changed the code could you share it please?

asentner’s picture

This should work. Is your body field called something else for the content type? Example, check your content type that you are having problems with. If you created a new body text area field or named it something like text, it will not work. View the source and look at the id tag for your text area.

Always use the existing body type field that already exists when creating a content type.

Hope this helps someone out.

adamsro’s picture

The following bit seems to be working well for me:

-            tinyMCE.get('edit-body-und-0-value').hide();
+            tinyMCE.execCommand('mceRemoveControl', false, 'edit-body-und-0-value');

I understand this many not work for multilingual site though..

Owl Solo’s picture

Issue summary: View changes

I am having the same issue! However, I am in a little over my head...

Using Firebug in Firefox I receive this information when trying to run Content Analysis:

TypeError: tinyMCE.get(...) is undefined
tinyMCE.get('edit-body-und-0-value').hide();
../sites/all/modules/contentanalysis/contentanalysis.js?n0wugq (line 160)

Should I be adding or replacing the above code to contentanalysis.js? If so where? I have attempted replacing line 160 with the above suggested codes. Turning off the WYSIWYG module allows Content Analysis to work. Of course this ruins the entire user experience for the client.

I have just updated all modules and core on this site trying to resolve this issue. This is not a multilingual site.

Any and all advice/guidance would be greatly appreciated.