- // Look for the previous item in the toolbar.\r
- while ( ( item = item.previous || ( item.toolbar.previous && item.toolbar.previous.items[ item.toolbar.previous.items.length - 1 ] ) ) && !item.focus )\r
- { /*jsl:pass*/ }\r
+ do\r
+ {\r
+ // Look for the previous item in the toolbar.\r
+ next = item.previous;\r
+\r
+ if ( !next )\r
+ {\r
+ nextToolGroup = item.toolbar.previous;\r
+ groupItemsCount = nextToolGroup && nextToolGroup.items.length;\r
+\r
+ // Bypass the empty toolgroups.\r
+ while ( groupItemsCount === 0 )\r
+ {\r
+ nextToolGroup = nextToolGroup.previous;\r
+ groupItemsCount = nextToolGroup && nextToolGroup.items.length;\r
+ }\r
+\r
+ if ( nextToolGroup )\r
+ next = nextToolGroup.items[ groupItemsCount - 1 ];\r
+ }\r
+\r
+ item = next;\r
+ }\r
+ while ( item && !item.focus )\r