Révision fc457866
Ajouté par Mathieu Schiano Di Schiabica il y a plus de 8 ans
drupal7/sites/all/themes/rubik/js/rubik.js | ||
---|---|---|
9 | 9 |
$('div.form:has(div.column-main div.form-actions):not(.rubik-processed)', context).each(function() { |
10 | 10 |
var form = $(this); |
11 | 11 |
var offset = $('div.column-side div.form-actions', form).height() + $('div.column-side div.form-actions', form).offset().top; |
12 |
$(window).scroll(function () {
|
|
12 |
$(window).scroll(function() { |
|
13 | 13 |
if ($(this).scrollTop() > offset) { |
14 | 14 |
$('div.column-main .column-wrapper > div.form-actions#edit-actions', form).show(); |
15 | 15 |
} |
... | ... | |
50 | 50 |
$(this).parents('.secondary-tabs').toggleClass('focused'); |
51 | 51 |
}); |
52 | 52 |
|
53 |
// Sticky sidebar |
|
54 |
// Disable this functionality if the user chooses. |
|
55 |
var disableSticky = settings.rubik.disable_sticky; |
|
56 |
if ($('#content .column-side .column-wrapper').length !== 0 && !disableSticky) { |
|
57 |
var rubikColumn = $('#content .column-side .column-wrapper', context); |
|
58 |
if(rubikColumn && rubikColumn.offset()){ |
|
53 |
// Sticky sidebar functionality. |
|
54 |
var disableSticky = (settings.rubik !== undefined) ? settings.rubik.disable_sticky : false; |
|
55 |
if ($('#content .column-side .column-wrapper').length !== 0 ) { |
|
56 |
|
|
57 |
// Move fields to sidebar if it exists. |
|
58 |
$('.rubik_sidebar_field', context).once('rubik', function() { |
|
59 |
$('.column-side .column-wrapper').append($(this)); |
|
60 |
}); |
|
61 |
|
|
62 |
// Check if the sidebar should be made sticky. |
|
63 |
if (!disableSticky) { |
|
64 |
var rubikColumn = $('#content .column-side .column-wrapper', context); |
|
65 |
if (rubikColumn && rubikColumn.offset()) { |
|
59 | 66 |
var rubikStickySidebar = rubikColumn.offset().top; |
60 |
$(window).scroll(function(){ |
|
61 |
if( $(window).scrollTop() > rubikStickySidebar ) {
|
|
67 |
$(window).scroll(function() {
|
|
68 |
if ($(window).scrollTop() > rubikStickySidebar) {
|
|
62 | 69 |
rubikColumn.each(function() { |
63 | 70 |
$(this).addClass("fixed"); |
64 | 71 |
$(this).width($(this).parent().width()); |
65 | 72 |
}); |
66 |
} else { |
|
73 |
} |
|
74 |
else { |
|
67 | 75 |
rubikColumn.each(function() { |
68 | 76 |
$(this).removeClass("fixed"); |
69 | 77 |
$(this).width($(this).parent().width()); |
70 | 78 |
}); |
71 | 79 |
} |
72 | 80 |
}); |
81 |
} |
|
73 | 82 |
} |
74 | 83 |
|
75 |
// Move fields to sidebar. |
|
76 |
$('.rubik_sidebar_field', context).once('rubik', function() { |
|
77 |
$('.column-side .column-wrapper').append($(this)); |
|
78 |
}); |
|
79 | 84 |
} |
80 | 85 |
|
86 |
// Cache the primary tabs. |
|
87 |
var $primaryTabsWrap = $('.primary-tabs'); |
|
88 |
if ($primaryTabsWrap.length) { |
|
89 |
var $primaryTabs = $primaryTabsWrap.find('> li'); |
|
90 |
// Trigger adjusting function upon first page load. |
|
91 |
adjustPrimaryTabs(); |
|
92 |
// Trigger adjusting function upon any screen resizing. |
|
93 |
$(window).resize(function() { |
|
94 |
adjustPrimaryTabs(); |
|
95 |
}); |
|
96 |
} |
|
97 |
|
|
98 |
function adjustPrimaryTabs() { |
|
99 |
// Get the position of whole element. |
|
100 |
var parentPosition = $primaryTabs.offset().top; |
|
101 |
// Complicated count. |
|
102 |
var count = []; |
|
103 |
var rowNumber = 1; |
|
104 |
// Remove remainings of other classes we attached. |
|
105 |
$primaryTabs.removeClass('last-row-link'); |
|
106 |
$primaryTabs.removeClass('first-row-link'); |
|
107 |
// Loop through and compare the position of each tab. |
|
108 |
$primaryTabs.each(function(index) { |
|
109 |
var $this = $(this); |
|
110 |
// New row. |
|
111 |
if (count[rowNumber] != $this.offset().top) { |
|
112 |
// Increase the count for this row. |
|
113 |
rowNumber++; |
|
114 |
count[rowNumber] = $this.offset().top; |
|
115 |
// Add "first" class to this element. |
|
116 |
$this.addClass('first-row-link'); |
|
117 |
// Add "last" class to the previous element, if there is one. |
|
118 |
if ($this.prev('li').length) { |
|
119 |
$this.prev('li').addClass('last-row-link'); |
|
120 |
} |
|
121 |
} |
|
122 |
// Add "last" class if this is the last element. |
|
123 |
if (index === ($primaryTabs.length - 1)) { |
|
124 |
$this.addClass('last-row-link'); |
|
125 |
} |
|
126 |
}); |
|
127 |
} |
|
128 |
|
|
81 | 129 |
}; |
82 | 130 |
})(jQuery); |
Formats disponibles : Unified diff
Update rubik 4.2 -> 4.3