After spending too much time on this I realized that #1127530: Use of a reserved word and this issue are for 6.x-3.x-dev and issue #1221668: Breaks a lot of functionality when Aggregate JavaScript is on is for 7.x-3.x

This issue came from #1127530: Use of a reserved word, which turned out to be two parts.
Apparently, even after that patch, AMH still does not work with Safari.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Josh The Geek’s picture

The problem is the defer attribute: I use the defer attribute of the script tag to delay the running of amh's scripts until the config variable is set up. According to http://www.w3schools.com/tags/att_script_defer.asp , IE is the only browser that supports this tag. (Apparently, it works in Firefox and Chrome, too.)

Safari does not know what the attribute means, so it gets skipped. The scripts are run before the config variable is loaded, causing a 'TypeError: Result of expression 'Drupal.settings.admin_menu_dropdown' [undefined] is not an object.'

The solution is to wrap the code in jQuery(document).ready(function(){}). Patch coming shortly.

Screenshot of Safari debugger: https://skitch.com/joshthegeek/r4q94/defer-attribute-used-by-admin-menu-...

Josh The Geek’s picture

Status: Active » Needs review
FileSize
1.68 KB

Patch.

ejohnson’s picture

Patch seems to fix it now in Safari.

Testing in Firefox 3 and IE8 as well.

Thanks.

distinctgrey’s picture

After having applied the patches from both issues, Firebug still showed errors.

What you want is to execute the JS only after the config variable has been set up.
To do this correctly in Drupal, do not use document.ready(), but wrap the JS code as follows:

Drupal.behaviors.admin_menu_dropdown = function(context) {
	if (Drupal.settings.admin_menu_dropdown.onload) {
		$('#admin-menu').hide();
		$('body').addClass('adm_menu_hidden');
	}
	$(document).keypress(function(e) {
	  var unicode=e.keyCode ? e.keyCode : e.charCode;
	  if (String.fromCharCode(unicode) == Drupal.settings.admin_menu_dropdown.key) {
		$('#admin-menu').slideToggle('fast');
		$('body').toggleClass('adm_menu_hidden');
	  }
	});
}

This works for me, without any more errors showing up in Firebug.

izmeez’s picture

Priority: Critical » Normal
Issue summary: View changes
FileSize
1.38 KB

As a followup to @distinctgrey attached is the suggestion in comment #4 as a patch for review.

Ignore this patch, it is confusing 7.x-3.x with 6.x-3.x which is what this issue is about.

izmeez’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev

The patch I uploaded in #5 is actually for admin_menu_dropdown 7.x-3.x so I am changing the version.
I hope the suggestion in comment #4 was for 7.x-3.x but I have not tested with safari, not my usual environment.
1 will have to do some tests to see if this is even needed.

Removing comments as not relevant.

izmeez’s picture

Title: Incompatible with Safari » Fix javascript for Safari
FileSize
1.2 KB

As mentioned in the opening of the issue summary the problem has been twofold, the module code and the javascript.

The patch in #2 again combines changes to the module code and the javascript and should be abandoned in favor of

Issue #1221668: Breaks a lot of functionality when Aggregate JavaScript is on

with this issue focusing on the javascript.

Attached is an update to patch in #5 incorporating suggestions in #4 for review and testing.

Removed comments as not relevant.

izmeez’s picture

Title: Fix javascript for Safari » Incompatible with Safari
Version: 7.x-3.x-dev » 6.x-3.x-dev
Issue summary: View changes

After spending too much time on this I realized that #1127530: Use of a reserved word and this issue are for 6.x-3.x-dev and issue #1221668: Breaks a lot of functionality when Aggregate JavaScript is on is for 7.x-3.x

izmeez’s picture