I recently upgraded from 1.x to 2.x and am having an issue with the toolbar not opening in Safari or Chrome. I can see the toolbar wedge but when clicked on, it does not open. I receive the following JS error:

Uncaught TypeError: Object function (D,E){var C=E||window;for(var B=0,A=this.length;B<A;++B){D.call(C,this[B],B,this)}} has no method 'split'

/sites/all/modules/admin/includes/admin.toolbar.js?i:144

The toolbar works fine in Firefox.

I tried deleting the module, re-uploading the module, running update.php and clearing cache all with no luck.

A side note: I find the UI of 1.x to be more intuitive for non-tech savvy content authors. But I needed to upgrade to 2.x because 1.x was incompatible with Ubercart.

Comments

bibo’s picture

I'm having the same problem (using Chrome on Mac OS, same on Linux). Same JS error.

Having tested this a bit, it seems the issue is somehow related to views ajax. The toolbar actually works on pages other than the frontpage (which are not views). The difference in loaded js files is these two:

So I'm guessing the problem is related to views. I'm using these module versions:

admin 6.x-2.0-beta3
views 6.x-2.10
ctools 6.x-dev (2010-May-27), also tested 6.x-1.4

bibo’s picture

Category: bug » support

Some testing:

- Disabling Ajax on views had no effect for better or worse (so it's not caused by /views/js/ajax_view.js file )
- Disabling/enabling JS aggregation has no effect
- Disabling panels (or panels_node, to be more specific) => FIXED
--> It hides all the panels on the frontpage, which is a lot of content, so hard to say. But it might have something to do with invidual id:s.

More info:

On the frontpage there is a panel with several views/blocks. Some nodes are connected via node_relationship (dunno if that matters). The theme is a customized subtheme of zen. Admin theme is a custom subtheme of rubik (basically just rubik). Only the frontpage seems to bug, and only with Chrome :S

In other words, I still haven't found what exactly causes this. It's not critical at the moment, since our clients don't generally use Chrome.. but I do.

EDIT: I just found out the problem is related to the active theme (customized zen subtheme)! Or to be more specific, theming panels/views. When I switched to some of the basic drupal themes, all worked just fine. So this is not really a bug with the module, but a feature request to support some module/theming combination. (I'm still not sure which exactly though).

yhahn’s picture

Thank you for taking the time to debug this. Keep me posted if you learn any more.

bibo’s picture

I had finally some time to debug this more. I think I found the culprit: widget.js, which belongs to a custom made twitter window (which was in one of the CCK templates added by a fellow developer).

This is a snippet of the template:

...
           <script src="http://widgets.twimg.com/j/2/widget.js"></script>
            <script>
            new TWTR.Widget({
              version: 2,
              type: 'search',
              search: '<?php echo addslashes($tag) ?>',
              interval: 6000,
              width: 250,
              height: 300,
              theme: {
                shell: {
                  background: '#8ec1da',
                  color: '#ffffff'
                },
                tweets: {
                  background: '#ffffff',
                  color: '#444444',
                  links: '#1985b5'
                }
              },
              features: {
                scrollbar: false,
                loop: false,
                live: true,
                hashtags: true,
                timestamp: true,
                avatars: true,
                behavior: 'all'
              }
            }).render().start();
            </script>
...

Commenting or removing this line clears the JS error:

<script src="http://widgets.twimg.com/j/2/widget.js"></script>

....and all is fine. Except the Twitter window, which naturally don't work anymore :(

@rootdownmedia: are you also using a twitter block or something like that?

@yhahn: any chance you could take a look at the twitter code :)?

bibo’s picture

Status: Active » Needs work

More testing: it's not just chrome failing, but Safari and IE aswell (Firefox and Opera seem unaffected).

Luckily I finally found another Drupal issue about the same widget.js incompatibility, for views: #798764: base.js line 67 chrome, variable pairs[i] sometimes contain functions and not only stings.

Their recent solution was some changes to base.js, to fix the same "split" error like this:

if(typeof(pairs[i]) == 'string'){
var pair = pairs[i].split('=');
// Ignore the 'q' path argument, if present.
if (pair[0] != 'q' && pair[1]) {
args[pair[0]] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
}
} else if (typeof(pairs[i]) == 'function') {
eval(pairs[i]);
}

@yhahn, could this code be adapted for admin.toolbar.js?

bibo’s picture

Status: Needs work » Needs review
StatusFileSize
new706 bytes

Ok, I figured it out. Not that much to change in the end:

I changed:

			var values = query[i].split('=');

to:

	    if(typeof(query[i]) == 'string'){
			var values = query[i].split('=');
		}    

JavaScript works fine again. Hooray.

I added this small change (+comments) as a patch. Hoping it gets committed soon. Or reviewed and committed, luckily there's not that much to review :)

andermt’s picture

StatusFileSize
new605 bytes

The patch fixed the issue only partially. In some cases in IE8 it gives errors like:


Message: 'length' is null or not an object
Line: 150
Char: 9
Code: 0
URI: http://www.mysite.com/sites/mysite.com/modules/admin/includes/admin.tool...

I've slightly changed the patch.

bibo’s picture

Status: Needs review » Reviewed & tested by the community

@AnderMT thanks for noticing that. values of course cant stay undefined, and the last line needed to be moved to the additional if.

With this patch JavaScript works fine in Chrome also. Marking this "as reviewed as tested", and hoping for some attention from yhahn :)

Johnny vd Laar’s picture

+1 subscribe

rootdownmedia’s picture

Yes it ended up being a Twitter widget (default one from twitter.com) screwing up the toolbar. JS conflict.

sampeckham’s picture

I've been looking at this from an IE 8 perspective, (never had any problems with Safari). When i first read this post I thought it was an unrelated issue, but it seems we have both come to the same line of code causing the problem.

I've tried all three patches (the two here and one on the other thread) and still get very mixed results with IE. I don't have the twitter widget but do have other JS, one that seems to break with this module is jqgalscroll.js for sliding panes (it works fine usually), but also have problems on clean installs with views and cck the only additions.

Had problems getting AnderMT's patch to take though. Can someone post the final function so I can get a clear idea of what it should look like?

Been trying admin beta4 as well with the same results.

andermt’s picture

For beta4 it will be like this:

Drupal.adminToolbar.getState = function(key) {
  if (!Drupal.adminToolbar.state) {
    Drupal.adminToolbar.state = {};
    var cookie = $.cookie('DrupalAdminToolbar');
    var query = cookie ? cookie.split('&') : [];
    if (query) {
      for (var i in query) {
        if(typeof(query[i]) == 'string'){
          var values = query[i].split('=');
          if (values.length === 2) {
            Drupal.adminToolbar.state[values[0]] = values[1];
          }
        }
      }
    }
  }
  return Drupal.adminToolbar.state[key] ? Drupal.adminToolbar.state[key] : false;
};
shark’s picture

I also had this issue and am using the Twitter widget. The patch from #7 worked for me. Using Chrome 5.0.375.99 beta on Linux.

yhahn’s picture

Status: Reviewed & tested by the community » Fixed

Thank you, and I apologize for the delay: http://drupal.org/cvs?commit=400594

TheInspector’s picture

Version: 6.x-2.0-beta3 » 6.x-2.0-rc1

I have the same issue when I'm using Chrome and the Twitter widget. The console says:

jquery.drilldown.js:89 Uncaught TypeError: Cannot call method 'attr' of undefined

Status: Fixed » Closed (fixed)

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

askibinski’s picture

@TheInspector:
I had that issue too with twitter/jquery widgets (for example jquery_slideshow)

Adding an extra check in jquery.drilldown.js to see if it's an object fixed it for me:

...
if (breadcrumb[key] && typeof breadcrumb[key] === "object") {
...
harking’s picture

Category: support » bug
Status: Closed (fixed) » Reviewed & tested by the community

Tested #17's patch and it corrected the issue of #15

HylkeVDS’s picture

I just ran into the same problem, and some searching resulted in this:
https://developer.mozilla.org/en/JavaScript/Reference/Statements/For...in

Although it may be tempting to use this as a way to iterate over an Array, this is a bad idea. The for...in statement iterates over user-defined properties in addition to the array elements, so if you modify the array's non-integer or non-positive properties (e.g. by adding a "foo" property to it or even by adding a method or property to Array.prototype), the for...in statement will return the name of your user-defined properties in addition to the numeric indexes.

So better is to change jquery.drilldown.js line 83 to

var numberOfCrumbs=breadcrumb.length;
for (var key=0; key<numberOfCrumbs;key++) {
tanc’s picture

Also had this problem but this time a clash with a 3rd party library. #19 fixed my issue.

altrugon’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new568 bytes

Both #17 and #19 solve the issue jquery.drilldown.js:89 Uncaught TypeError: Cannot call method 'attr' of undefined, but since breadcrumb is actually an array I would say the solution in #19 is more appropriated.

Here is a patch that worked for me using the solution in #19.

agileware’s picture

Version: 6.x-2.0-rc1 » 6.x-2.0-beta3
Status: Needs review » Closed (fixed)

The issue from the original post was fixed in #14, the error you are now reporting is a different issue.
Putting settings back to what they were.

There is already another issue for what you are now reporting anyway, which is here - #969916: jquery.drilldown.js Breadcrumb error

bnewtonius’s picture

#17 is right, but overall you shouldn't be using a for in loop here. Webkit browsers behave differently, and they will return all methods of that object as well as the indexes for an array, where FireFox will not.

        if (breadcrumb.length > 0) {
          var trail = $(settings.trail);
          trail.empty();
          for (var key in breadcrumb) {
            if (breadcrumb[key]) {

Should be changed to something like:

        if (breadcrumb.length > 0) {
          var trail = $(settings.trail);
          trail.empty();
          <b>for (var key = 0; key < breadcrumb.length; ++key) {</b>
            if (breadcrumb[key]) {

This will keep it from trying to run the code with a key of something like "filter" or "push", which are methods on that object, not indexes in the array.

Ogg says "for in loops bad. Ogg smash for in loops"

bnewtonius’s picture

Ogg, er, I mean, I just saw the comment #22, seems like someone smarter (and possibly better looking) has already solved this.