Révision e5461e73
Ajouté par Julien Enselme il y a environ 9 ans
drupal7/sites/all/themes/rubik/js/rubik.js | ||
---|---|---|
3 | 3 |
*/ |
4 | 4 |
(function($) { |
5 | 5 |
Drupal.behaviors.rubik = {}; |
6 |
Drupal.behaviors.rubik.attach = function(context) { |
|
6 |
Drupal.behaviors.rubik.attach = function(context, settings) {
|
|
7 | 7 |
// If there are both main column and side column buttons, only show the main |
8 | 8 |
// column buttons if the user scrolls past the ones to the side. |
9 |
$('div.form:has(div.column-main div.form-actions):not(.rubik-processed)').each(function() { |
|
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 | 12 |
$(window).scroll(function () { |
13 | 13 |
if ($(this).scrollTop() > offset) { |
14 |
$('div.column-main div.form-actions', form).show();
|
|
14 |
$('div.column-main .column-wrapper > div.form-actions#edit-actions', form).show();
|
|
15 | 15 |
} |
16 | 16 |
else { |
17 |
$('div.column-main div.form-actions', form).hide();
|
|
17 |
$('div.column-main .column-wrapper > div.form-actions#edit-actions', form).hide();
|
|
18 | 18 |
} |
19 | 19 |
}); |
20 | 20 |
form.addClass('rubik-processed'); |
... | ... | |
25 | 25 |
// Target exists, add click handler. |
26 | 26 |
if ($('#' + id).size() > 0) { |
27 | 27 |
$(this).click(function() { |
28 |
toggleable = $('#' + id); |
|
28 |
var toggleable = $('#' + id);
|
|
29 | 29 |
toggleable.toggle(); |
30 | 30 |
$(this).toggleClass('toggler-active'); |
31 | 31 |
return false; |
... | ... | |
39 | 39 |
// Mark as processed. |
40 | 40 |
$(this).addClass('rubik-processed'); |
41 | 41 |
}); |
42 |
}; |
|
43 |
$(document).ready(function() { |
|
44 |
// If there's no active secondary tab, make the first one show. |
|
42 |
|
|
43 |
// If there's no active secondary tab, make the first one show. |
|
45 | 44 |
var activeli = $('.primary-tabs li.active .secondary-tabs li.active'); |
46 |
if (activeli.length == 0) { |
|
45 |
if (activeli.length === 0) {
|
|
47 | 46 |
$('.primary-tabs li.active .secondary-tabs li:first-child a').css('display', 'block'); |
48 | 47 |
} |
49 |
}); |
|
48 |
|
|
49 |
$('.secondary-tabs li a, .secondary-tabs', context).bind('focus blur', function(){ |
|
50 |
$(this).parents('.secondary-tabs').toggleClass('focused'); |
|
51 |
}); |
|
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()){ |
|
59 |
var rubikStickySidebar = rubikColumn.offset().top; |
|
60 |
$(window).scroll(function(){ |
|
61 |
if( $(window).scrollTop() > rubikStickySidebar ) { |
|
62 |
rubikColumn.each(function() { |
|
63 |
$(this).addClass("fixed"); |
|
64 |
$(this).width($(this).parent().width()); |
|
65 |
}); |
|
66 |
} else { |
|
67 |
rubikColumn.each(function() { |
|
68 |
$(this).removeClass("fixed"); |
|
69 |
$(this).width($(this).parent().width()); |
|
70 |
}); |
|
71 |
} |
|
72 |
}); |
|
73 |
} |
|
74 |
|
|
75 |
// Move fields to sidebar. |
|
76 |
$('.rubik_sidebar_field', context).once('rubik', function() { |
|
77 |
$('.column-side .column-wrapper').append($(this)); |
|
78 |
}); |
|
79 |
} |
|
80 |
|
|
81 |
}; |
|
50 | 82 |
})(jQuery); |
Formats disponibles : Unified diff
Update Rubik 4.0-rc1 4.2