TypeError: Drupal.CTools is undefined

Drupal.CTools.Modal.show = function(choice) {

http://mysite/profiles/openatrium/themes/oa_radix/assets/javascripts/oa-...

I get this on views edit and panels edit pages.

I am not sure why Drupal.Ctools would not be included prior.

how can I add an include statement to ensure that tat ctools is added before this point?

i can then better troubleshoot from there.

Comments

mpotter’s picture

Status: Active » Closed (cannot reproduce)

I cannot reproduce this on any system. CTools should definitely already be defined first.

socialnicheguru’s picture

Status: Closed (cannot reproduce) » Active
Issue tags: +advagg

it happens when advagg module is used and gz compression

socialnicheguru’s picture

Project: Open Atrium Radix » Advanced CSS/JS Aggregation
Version: 7.x-3.x-dev » 7.x-2.x-dev
Issue tags: -advagg +oa_radix

This problem only happens when advagg is enabled. For some reason ctools is not loaded correctly.

mikeytown2’s picture

woodzie’s picture

StatusFileSize
new582 bytes

I get the same error when advagg is enabled - Drupal.Ctools is not defined when it's accessed in oa-radix-modal.js.

I don't have either defer or .gz compression enabled.

If the "Move JS to the footer" options in the Modifications tab is set to:

- Disabled: Works
- All but Javascript Libraries: Error

For some reason even though the 'oa-radix-modal.js' group is set to JS_THEME and not JS_LIBRARY, it's getting added to the header, while ctools modal.js ends up aggregated into the footer, causing the undefined error.

The attached patch fixes it for me, and I haven't noticed any side effects yet. Not sure if this is the best way to do it, or it should be done in one of the avgagg hooks instead...

.

socialnicheguru’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 5: move_oa_radix_modal_to_footer-2369343.patch, failed testing.

The last submitted patch, 5: move_oa_radix_modal_to_footer-2369343.patch, failed testing.

The last submitted patch, 5: move_oa_radix_modal_to_footer-2369343.patch, failed testing.

The last submitted patch, 5: move_oa_radix_modal_to_footer-2369343.patch, failed testing.

The last submitted patch, 5: move_oa_radix_modal_to_footer-2369343.patch, failed testing.

socialnicheguru’s picture

I don't know where to apply the patch? advagg? I think it is in oa_radix

woodzie’s picture

Yes, sorry, the patch was for oa_radix. I realized that this issue is in the advagg project after I submitted it.

Im not sure if it makes sense to move this isssue to oa_radix, or is that considered bad practice?

mikeytown2’s picture

Thanks for the patch! I'll see if this should be re-worked as an advagg patch once I test this out.

nitin.k’s picture

I have faced the same problem but in my case I used the following code and got the pop up on page load.
It can help till some extent , hoping so.

Note: Include your JS in the callback where you need to put the below code.

JS code:
********

(function($) {
Drupal.behaviors.module_name = {
attach: function (context, settings) {
     var content = 'my content';
     var title = 'my title';
     Drupal.CTools.Modal.show(); // This was producing error in my case.
     $('#modal-title').html(title); // Adding title to popup;
     $('#modal-content').html(content); // Adding content to popup;
   }
};
})(jQuery);

Callback code:
**************

function _foo_callback() {
  drupal_add_js(drupal_get_path('module', 'mymodule') . '/js/some_javascript.js');
  ctools_include('modal'); // Addition of this resolved JS error.
  ctools_modal_add_js();  // Addition of this resolved JS error.
} 

Note: Please include the required files by using ctools_include function, normally we face this error when some inc and js file is not included in the page.

Cheers !!

mikeytown2’s picture

Installing the theme by it's self and I get a WSOD in regards to variable_get_value() being undefined.

( ! ) Fatal error: Call to undefined function variable_get_value() in sites/all/themes/oa_radix/template.php on line 111
Call Stack
# Time Memory Function Location
1 0.0000 136280 {main}( ) ../index.php:0
2 0.1000 1787944 menu_execute_active_handler( ) ../index.php:21
3 0.5920 2983560 drupal_deliver_page( ) ../menu.inc:534
4 0.5920 2984016 drupal_deliver_html_page( ) ../common.inc:2605
5 0.5920 2984840 drupal_render_page( ) ../common.inc:2723
6 0.6270 3170768 drupal_render( ) ../common.inc:5850
7 0.6270 3172176 theme( ) ../common.inc:5988
8 0.8981 3523280 oa_radix_preprocess_page( ) ../theme.inc:1125

Looks like I need the https://www.drupal.org/project/variable module

Also the panels module
Call to undefined function panels_mini_block_view() in sites/all/themes/oa_radix/template.php on line 112

Also https://www.drupal.org/project/oa_core which means I need to get the distribution in order to test this theme.

mikeytown2’s picture

OK fresh install of OA with advagg updated to the latest dev. How do I trigger this error; so far the only thing I see is "You must install the Colorbox library."

mikeytown2’s picture

Status: Needs work » Postponed (maintainer needs more info)
mikeytown2’s picture

Any news?

mikeytown2’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Re-open if you have more info