1 |
85ad3d82
|
Assos Assos
|
(function ($) {
|
2 |
|
|
|
3 |
|
|
|
4 |
e9f59589
|
Assos Assos
|
|
5 |
85ad3d82
|
Assos Assos
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
Drupal.behaviors.MultiPage = {
|
9 |
|
|
attach: function (context) {
|
10 |
|
|
$('.multipage-panes', context).once('multipage', function () {
|
11 |
|
|
|
12 |
|
|
var focusID = $(':hidden.multipage-active-control', this).val();
|
13 |
|
|
var paneWithFocus;
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
var $panes = $('> div.field-group-multipage', this);
|
17 |
|
|
var $form = $panes.parents('form');
|
18 |
|
|
if ($panes.length == 0) {
|
19 |
|
|
return;
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
var $controls;
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
$panes.each(function () {
|
27 |
e9f59589
|
Assos Assos
|
|
28 |
85ad3d82
|
Assos Assos
|
$controls = $('<div class="multipage-controls-list clearfix"></div>');
|
29 |
|
|
$(this).append($controls);
|
30 |
e9f59589
|
Assos Assos
|
|
31 |
85ad3d82
|
Assos Assos
|
|
32 |
|
|
if (Drupal.settings.field_group.multipage_move_submit && $('.form-actions').length) {
|
33 |
|
|
$('.form-actions', $form).remove().appendTo($($controls, $panes.last()));
|
34 |
|
|
}
|
35 |
e9f59589
|
Assos Assos
|
|
36 |
85ad3d82
|
Assos Assos
|
var multipageControl = new Drupal.multipageControl({
|
37 |
|
|
title: $('> .multipage-pane-title', this).text(),
|
38 |
|
|
wrapper: $(this),
|
39 |
|
|
has_next: $(this).next().length,
|
40 |
|
|
has_previous: $(this).prev().length
|
41 |
|
|
});
|
42 |
e9f59589
|
Assos Assos
|
|
43 |
85ad3d82
|
Assos Assos
|
$controls.append(multipageControl.item);
|
44 |
|
|
$(this)
|
45 |
|
|
.addClass('multipage-pane')
|
46 |
|
|
.data('multipageControl', multipageControl);
|
47 |
|
|
|
48 |
|
|
if (this.id == focusID) {
|
49 |
|
|
paneWithFocus = $(this);
|
50 |
|
|
}
|
51 |
e9f59589
|
Assos Assos
|
|
52 |
85ad3d82
|
Assos Assos
|
});
|
53 |
|
|
|
54 |
|
|
if (paneWithFocus === undefined) {
|
55 |
|
|
|
56 |
|
|
|
57 |
e9f59589
|
Assos Assos
|
var hash = window.location.hash.replace(/[=%;,\/]/g, "");
|
58 |
|
|
if (hash !== '#' && $(hash, this).length) {
|
59 |
85ad3d82
|
Assos Assos
|
paneWithFocus = $(window.location.hash, this).closest('.multipage-pane');
|
60 |
|
|
}
|
61 |
|
|
else {
|
62 |
|
|
paneWithFocus = $('multipage-open', this).length ? $('multipage-open', this) : $('> .multipage-pane:first', this);
|
63 |
|
|
}
|
64 |
|
|
}
|
65 |
|
|
if (paneWithFocus !== undefined) {
|
66 |
|
|
paneWithFocus.data('multipageControl').focus();
|
67 |
|
|
}
|
68 |
|
|
});
|
69 |
|
|
}
|
70 |
|
|
};
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
Drupal.multipageControl = function (settings) {
|
81 |
|
|
var self = this;
|
82 |
|
|
var controls = Drupal.theme('multipage', settings);
|
83 |
|
|
$.extend(self, settings, controls);
|
84 |
|
|
|
85 |
27370441
|
Assos Assos
|
this.nextLink.click(function (e) {
|
86 |
|
|
e.preventDefault();
|
87 |
85ad3d82
|
Assos Assos
|
self.nextPage();
|
88 |
|
|
});
|
89 |
e9f59589
|
Assos Assos
|
|
90 |
27370441
|
Assos Assos
|
this.previousLink.click(function (e) {
|
91 |
|
|
e.preventDefault();
|
92 |
85ad3d82
|
Assos Assos
|
self.previousPage();
|
93 |
|
|
});
|
94 |
e9f59589
|
Assos Assos
|
|
95 |
85ad3d82
|
Assos Assos
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
};
|
118 |
|
|
|
119 |
|
|
Drupal.multipageControl.prototype = {
|
120 |
e9f59589
|
Assos Assos
|
|
121 |
85ad3d82
|
Assos Assos
|
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
focus: function () {
|
125 |
|
|
this.wrapper
|
126 |
|
|
.show()
|
127 |
|
|
.siblings('div.multipage-pane')
|
128 |
|
|
.each(function () {
|
129 |
|
|
var tab = $(this).data('multipageControl');
|
130 |
|
|
tab.wrapper.hide();
|
131 |
|
|
})
|
132 |
|
|
.end()
|
133 |
|
|
.siblings(':hidden.multipage-active-control')
|
134 |
|
|
.val(this.wrapper.attr('id'));
|
135 |
|
|
|
136 |
|
|
$('#active-multipage-control').remove();
|
137 |
|
|
this.nextLink.after('<span id="active-multipage-control" class="element-invisible">' + Drupal.t('(active page)') + '</span>');
|
138 |
|
|
},
|
139 |
e9f59589
|
Assos Assos
|
|
140 |
85ad3d82
|
Assos Assos
|
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
nextPage: function () {
|
144 |
|
|
this.wrapper.next().data('multipageControl').focus();
|
145 |
|
|
$('html, body').scrollTop(this.wrapper.parents('.field-group-multipage-group-wrapper').offset().top);
|
146 |
|
|
},
|
147 |
e9f59589
|
Assos Assos
|
|
148 |
85ad3d82
|
Assos Assos
|
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
previousPage: function () {
|
152 |
|
|
this.wrapper.prev().data('multipageControl').focus();
|
153 |
|
|
$('html, body').scrollTop(this.wrapper.parents('.field-group-multipage-group-wrapper').offset().top);
|
154 |
|
|
},
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
tabShow: function () {
|
160 |
|
|
|
161 |
|
|
this.item.show();
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
this.item.parent().children('.multipage-control').removeClass('first')
|
166 |
|
|
.filter(':visible:first').addClass('first');
|
167 |
|
|
|
168 |
|
|
this.wrapper.removeClass('multipage-control-hidden').show();
|
169 |
|
|
|
170 |
|
|
this.focus();
|
171 |
|
|
return this;
|
172 |
|
|
},
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
tabHide: function () {
|
178 |
|
|
|
179 |
|
|
this.item.hide();
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
this.item.parent().children('.multipage-control').removeClass('first')
|
184 |
|
|
.filter(':visible:first').addClass('first');
|
185 |
|
|
|
186 |
|
|
this.wrapper.addClass('horizontal-tab-hidden').hide();
|
187 |
|
|
|
188 |
|
|
var $firstTab = this.wrapper.siblings('.multipage-pane:not(.multipage-control-hidden):first');
|
189 |
|
|
if ($firstTab.length) {
|
190 |
|
|
$firstTab.data('multipageControl').focus();
|
191 |
|
|
}
|
192 |
|
|
return this;
|
193 |
|
|
}
|
194 |
|
|
};
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
Drupal.theme.prototype.multipage = function (settings) {
|
211 |
|
|
|
212 |
|
|
var controls = {};
|
213 |
|
|
controls.item = $('<span class="multipage-button"></span>');
|
214 |
e9f59589
|
Assos Assos
|
|
215 |
85ad3d82
|
Assos Assos
|
controls.previousLink = $('<input type="button" class="form-submit multipage-link-previous" value="" />');
|
216 |
|
|
controls.previousTitle = Drupal.t('Previous page');
|
217 |
e9f59589
|
Assos Assos
|
controls.item.append(controls.previousLink.val(controls.previousTitle));
|
218 |
|
|
|
219 |
85ad3d82
|
Assos Assos
|
controls.nextLink = $('<input type="button" class="form-submit multipage-link-next" value="" />');
|
220 |
|
|
controls.nextTitle = Drupal.t('Next page');
|
221 |
|
|
controls.item.append(controls.nextLink.val(controls.nextTitle));
|
222 |
e9f59589
|
Assos Assos
|
|
223 |
85ad3d82
|
Assos Assos
|
if (!settings.has_next) {
|
224 |
|
|
controls.nextLink.hide();
|
225 |
|
|
}
|
226 |
|
|
if (!settings.has_previous) {
|
227 |
|
|
controls.previousLink.hide();
|
228 |
|
|
}
|
229 |
e9f59589
|
Assos Assos
|
|
230 |
85ad3d82
|
Assos Assos
|
return controls;
|
231 |
|
|
};
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
Drupal.FieldGroup = Drupal.FieldGroup || {};
|
235 |
|
|
Drupal.FieldGroup.Effects = Drupal.FieldGroup.Effects || {};
|
236 |
|
|
|
237 |
|
|
|
238 |
|
|
|
239 |
|
|
|
240 |
|
|
Drupal.FieldGroup.Effects.processMultipage = {
|
241 |
|
|
execute: function (context, settings, type) {
|
242 |
|
|
if (type == 'form') {
|
243 |
e9f59589
|
Assos Assos
|
|
244 |
85ad3d82
|
Assos Assos
|
var $firstErrorItem = false;
|
245 |
e9f59589
|
Assos Assos
|
|
246 |
85ad3d82
|
Assos Assos
|
|
247 |
|
|
$('div.multipage-pane').each(function(i){
|
248 |
|
|
if ($('.error', $(this)).length) {
|
249 |
e9f59589
|
Assos Assos
|
|
250 |
85ad3d82
|
Assos Assos
|
|
251 |
|
|
if (!$firstErrorItem) {
|
252 |
|
|
$firstErrorItem = $(this).data('multipageControl');
|
253 |
e9f59589
|
Assos Assos
|
}
|
254 |
|
|
|
255 |
85ad3d82
|
Assos Assos
|
Drupal.FieldGroup.setGroupWithfocus($(this));
|
256 |
|
|
$(this).data('multipageControl').focus();
|
257 |
|
|
}
|
258 |
|
|
});
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
if ($firstErrorItem) {
|
262 |
|
|
$firstErrorItem.focus();
|
263 |
|
|
}
|
264 |
e9f59589
|
Assos Assos
|
|
265 |
85ad3d82
|
Assos Assos
|
}
|
266 |
|
|
}
|
267 |
|
|
}
|
268 |
|
|
|
269 |
|
|
})(jQuery);
|