Skip to content

Commit

Permalink
Refs #950; fix the moving of views when zooming:
Browse files Browse the repository at this point in the history
- jQuery offset returns strange results when zooming as appose
  to normal offsetTop which we use to calculate whether the
  personal toolbar is moved
- Move only the views that are not already hidden avoiding thus
  duplications if there is more than one view to move to the more
  section
  • Loading branch information
ichim-david committed Sep 17, 2015
1 parent 874855d commit 4fd7ee0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Products/CMFPlone/static/patterns/toolbar/src/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,19 @@ define([
}), {path: '/'});
},
moveViewsToSubset: function($container, $views, $subset) {
var i, $content_view, length = $views.length - 1;
var view_should_move = $container.offset().top !== 0;
var i, $content_view,
container = $container[0],
length = $views.length - 1;

var view_should_move = container.offsetTop !== 0;
if (view_should_move) {
for (i = length; length >= 0; length -= 1) {
$content_view = $views.eq(i);
if ($content_view.is(":hidden")) {
continue;
}
$content_view.hide().clone(true, true).appendTo($subset).show();
if ($container.offset().top === 0) {
if ($container.offsetTop === 0) {
break;
}
}
Expand Down Expand Up @@ -280,7 +286,7 @@ define([
}
// check if the personal toolbar is not offseted if there isn't enough space
// and we already have the plone-toolbar-more-options added to the page.
if ($pers_bar_container.offset().top !== 0) {
if ($pers_bar_container[0].offsetTop !== 0) {
that.moveViewsToSubset($pers_bar_container, $content_views, $("#plone-toolbar-more-subset"));
}
},
Expand Down

0 comments on commit 4fd7ee0

Please sign in to comment.