1
|
(function($) {
|
2
|
|
3
|
Drupal.behaviors.moduleFilterDynamicPosition = {
|
4
|
attach: function(context) {
|
5
|
var $window = $(window);
|
6
|
|
7
|
$('#module-filter-wrapper', context).once('dynamic-position', function() {
|
8
|
|
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
|
|
16
|
var bottom = $tabs.offset().top + $tabs.outerHeight();
|
17
|
if ($submit.hasClass('fixed-bottom')) {
|
18
|
bottom += $submit.height();
|
19
|
}
|
20
|
if (bottom >= $window.height() + $window.scrollTop()) {
|
21
|
$submit.addClass('fixed fixed-bottom');
|
22
|
$tabs.css('padding-bottom', $submit.height());
|
23
|
}
|
24
|
else {
|
25
|
$submit.removeClass('fixed fixed-bottom');
|
26
|
$tabs.css('padding-bottom', 0);
|
27
|
}
|
28
|
|
29
|
|
30
|
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
|
}
|
35
|
}
|
36
|
};
|
37
|
|
38
|
|
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
|
}
|
46
|
};
|
47
|
|
48
|
})(jQuery);
|