Projet

Général

Profil

Paste
Télécharger (1,58 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / module_filter / js / dynamic_position.js @ 13755f8d

1 85ad3d82 Assos Assos
(function($) {
2 8a7e43dd Florent Torregrosa
3
Drupal.behaviors.moduleFilterDynamicPosition = {
4
  attach: function(context) {
5
    var $window = $(window);
6
7
    $('#module-filter-wrapper', context).once('dynamic-position', function() {
8
      // Move the submit button just below the tabs.
9
      $('#module-filter-tabs').append($('#module-filter-submit'));
10
11
      var positionSubmit = function() {
12
        var $tabs = $('#module-filter-tabs');
13
        var $submit = $('#module-filter-submit', $tabs);
14
15 85ad3d82 Assos Assos
        // Vertical movement.
16 8a7e43dd Florent Torregrosa
        var bottom = $tabs.offset().top + $tabs.outerHeight();
17
        if ($submit.hasClass('fixed-bottom')) {
18
          bottom += $submit.height();
19 85ad3d82 Assos Assos
        }
20 8a7e43dd Florent Torregrosa
        if (bottom >= $window.height() + $window.scrollTop()) {
21
          $submit.addClass('fixed fixed-bottom');
22
          $tabs.css('padding-bottom', $submit.height());
23 85ad3d82 Assos Assos
        }
24
        else {
25 8a7e43dd Florent Torregrosa
          $submit.removeClass('fixed fixed-bottom');
26
          $tabs.css('padding-bottom', 0);
27 85ad3d82 Assos Assos
        }
28
29
        // Horizontal movement.
30 8a7e43dd Florent Torregrosa
        if ($submit.hasClass('fixed-bottom') || $submit.hasClass('fixed-top')) {
31
          var left = $tabs.offset().left - $window.scrollLeft();
32
          if (left != $submit.offset().left - $window.scrollLeft()) {
33
            $submit.css('left', left);
34 85ad3d82 Assos Assos
          }
35
        }
36 8a7e43dd Florent Torregrosa
      };
37
38
      // Control the positioning.
39
      $window.scroll(positionSubmit);
40
      $window.resize(positionSubmit);
41
      var moduleFilter = $('input[name="module_filter[name]"]').data('moduleFilter');
42
      moduleFilter.element.bind('moduleFilter:adjustHeight', positionSubmit);
43
      moduleFilter.adjustHeight();
44
    });
45 85ad3d82 Assos Assos
  }
46 8a7e43dd Florent Torregrosa
};
47
48 85ad3d82 Assos Assos
})(jQuery);