1 |
6c38d829
|
Assos Assos
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
(function($) {
|
5 |
|
|
Drupal.behaviors.rubik = {};
|
6 |
e5461e73
|
Julien Enselme
|
Drupal.behaviors.rubik.attach = function(context, settings) {
|
7 |
6c38d829
|
Assos Assos
|
|
8 |
|
|
|
9 |
e5461e73
|
Julien Enselme
|
$('div.form:has(div.column-main div.form-actions):not(.rubik-processed)', context).each(function() {
|
10 |
6c38d829
|
Assos Assos
|
var form = $(this);
|
11 |
|
|
var offset = $('div.column-side div.form-actions', form).height() + $('div.column-side div.form-actions', form).offset().top;
|
12 |
fc457866
|
Mathieu Schiano
|
$(window).scroll(function() {
|
13 |
6c38d829
|
Assos Assos
|
if ($(this).scrollTop() > offset) {
|
14 |
e5461e73
|
Julien Enselme
|
$('div.column-main .column-wrapper > div.form-actions#edit-actions', form).show();
|
15 |
6c38d829
|
Assos Assos
|
}
|
16 |
|
|
else {
|
17 |
e5461e73
|
Julien Enselme
|
$('div.column-main .column-wrapper > div.form-actions#edit-actions', form).hide();
|
18 |
6c38d829
|
Assos Assos
|
}
|
19 |
|
|
});
|
20 |
|
|
form.addClass('rubik-processed');
|
21 |
|
|
});
|
22 |
|
|
|
23 |
|
|
$('a.toggler:not(.rubik-processed)', context).each(function() {
|
24 |
|
|
var id = $(this).attr('href').split('#')[1];
|
25 |
|
|
|
26 |
|
|
if ($('#' + id).size() > 0) {
|
27 |
|
|
$(this).click(function() {
|
28 |
e5461e73
|
Julien Enselme
|
var toggleable = $('#' + id);
|
29 |
6c38d829
|
Assos Assos
|
toggleable.toggle();
|
30 |
|
|
$(this).toggleClass('toggler-active');
|
31 |
|
|
return false;
|
32 |
|
|
});
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
else {
|
36 |
|
|
$(this).addClass('toggler-disabled');
|
37 |
|
|
$(this).click(function() { return false; });
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
$(this).addClass('rubik-processed');
|
41 |
|
|
});
|
42 |
e5461e73
|
Julien Enselme
|
|
43 |
|
|
|
44 |
6c38d829
|
Assos Assos
|
var activeli = $('.primary-tabs li.active .secondary-tabs li.active');
|
45 |
e5461e73
|
Julien Enselme
|
if (activeli.length === 0) {
|
46 |
6c38d829
|
Assos Assos
|
$('.primary-tabs li.active .secondary-tabs li:first-child a').css('display', 'block');
|
47 |
|
|
}
|
48 |
e5461e73
|
Julien Enselme
|
|
49 |
|
|
$('.secondary-tabs li a, .secondary-tabs', context).bind('focus blur', function(){
|
50 |
|
|
$(this).parents('.secondary-tabs').toggleClass('focused');
|
51 |
|
|
});
|
52 |
|
|
|
53 |
fc457866
|
Mathieu Schiano
|
|
54 |
|
|
var disableSticky = (settings.rubik !== undefined) ? settings.rubik.disable_sticky : false;
|
55 |
|
|
if ($('#content .column-side .column-wrapper').length !== 0 ) {
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
$('.rubik_sidebar_field', context).once('rubik', function() {
|
59 |
|
|
$('.column-side .column-wrapper').append($(this));
|
60 |
|
|
});
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
if (!disableSticky) {
|
64 |
|
|
var rubikColumn = $('#content .column-side .column-wrapper', context);
|
65 |
|
|
if (rubikColumn && rubikColumn.offset()) {
|
66 |
e5461e73
|
Julien Enselme
|
var rubikStickySidebar = rubikColumn.offset().top;
|
67 |
fc457866
|
Mathieu Schiano
|
$(window).scroll(function() {
|
68 |
|
|
if ($(window).scrollTop() > rubikStickySidebar) {
|
69 |
e5461e73
|
Julien Enselme
|
rubikColumn.each(function() {
|
70 |
|
|
$(this).addClass("fixed");
|
71 |
|
|
$(this).width($(this).parent().width());
|
72 |
|
|
});
|
73 |
fc457866
|
Mathieu Schiano
|
}
|
74 |
|
|
else {
|
75 |
e5461e73
|
Julien Enselme
|
rubikColumn.each(function() {
|
76 |
|
|
$(this).removeClass("fixed");
|
77 |
|
|
$(this).width($(this).parent().width());
|
78 |
|
|
});
|
79 |
|
|
}
|
80 |
|
|
});
|
81 |
fc457866
|
Mathieu Schiano
|
}
|
82 |
e5461e73
|
Julien Enselme
|
}
|
83 |
|
|
|
84 |
|
|
}
|
85 |
|
|
|
86 |
fc457866
|
Mathieu Schiano
|
|
87 |
|
|
var $primaryTabsWrap = $('.primary-tabs');
|
88 |
|
|
if ($primaryTabsWrap.length) {
|
89 |
|
|
var $primaryTabs = $primaryTabsWrap.find('> li');
|
90 |
|
|
|
91 |
|
|
adjustPrimaryTabs();
|
92 |
|
|
|
93 |
|
|
$(window).resize(function() {
|
94 |
|
|
adjustPrimaryTabs();
|
95 |
|
|
});
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
function adjustPrimaryTabs() {
|
99 |
|
|
|
100 |
|
|
var parentPosition = $primaryTabs.offset().top;
|
101 |
|
|
|
102 |
|
|
var count = [];
|
103 |
|
|
var rowNumber = 1;
|
104 |
|
|
|
105 |
|
|
$primaryTabs.removeClass('last-row-link');
|
106 |
|
|
$primaryTabs.removeClass('first-row-link');
|
107 |
|
|
|
108 |
|
|
$primaryTabs.each(function(index) {
|
109 |
|
|
var $this = $(this);
|
110 |
|
|
|
111 |
|
|
if (count[rowNumber] != $this.offset().top) {
|
112 |
|
|
|
113 |
|
|
rowNumber++;
|
114 |
|
|
count[rowNumber] = $this.offset().top;
|
115 |
|
|
|
116 |
|
|
$this.addClass('first-row-link');
|
117 |
|
|
|
118 |
|
|
if ($this.prev('li').length) {
|
119 |
|
|
$this.prev('li').addClass('last-row-link');
|
120 |
|
|
}
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
if (index === ($primaryTabs.length - 1)) {
|
124 |
|
|
$this.addClass('last-row-link');
|
125 |
|
|
}
|
126 |
|
|
});
|
127 |
|
|
}
|
128 |
|
|
|
129 |
e5461e73
|
Julien Enselme
|
};
|
130 |
6c38d829
|
Assos Assos
|
})(jQuery); |