1 |
85ad3d82
|
Assos Assos
|
|
2 |
|
|
(function($) {
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
Drupal.FieldGroup = Drupal.FieldGroup || {};
|
8 |
|
|
Drupal.FieldGroup.Effects = Drupal.FieldGroup.Effects || {};
|
9 |
|
|
Drupal.FieldGroup.groupWithfocus = null;
|
10 |
|
|
|
11 |
|
|
Drupal.FieldGroup.setGroupWithfocus = function(element) {
|
12 |
|
|
element.css({display: 'block'});
|
13 |
|
|
Drupal.FieldGroup.groupWithfocus = element;
|
14 |
|
|
}
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
Drupal.FieldGroup.Effects.processFieldset = {
|
20 |
|
|
execute: function (context, settings, type) {
|
21 |
|
|
if (type == 'form') {
|
22 |
|
|
|
23 |
|
|
$('fieldset.fieldset', context).once('fieldgroup-effects', function(i) {
|
24 |
|
|
if ($(this).is('.required-fields') && $(this).find('.form-required').length > 0) {
|
25 |
|
|
$('legend span.fieldset-legend', $(this)).eq(0).append(' ').append($('.form-required').eq(0).clone());
|
26 |
|
|
}
|
27 |
|
|
if ($('.error', $(this)).length) {
|
28 |
|
|
$('legend span.fieldset-legend', $(this)).eq(0).addClass('error');
|
29 |
|
|
Drupal.FieldGroup.setGroupWithfocus($(this));
|
30 |
|
|
}
|
31 |
|
|
});
|
32 |
|
|
}
|
33 |
|
|
}
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
Drupal.FieldGroup.Effects.processAccordion = {
|
40 |
|
|
execute: function (context, settings, type) {
|
41 |
|
|
$('div.field-group-accordion-wrapper', context).once('fieldgroup-effects', function () {
|
42 |
|
|
var wrapper = $(this);
|
43 |
|
|
|
44 |
27370441
|
Assos Assos
|
|
45 |
|
|
var active_index = false;
|
46 |
|
|
wrapper.find('.accordion-item').each(function(i) {
|
47 |
|
|
if ($(this).hasClass('field-group-accordion-active')) {
|
48 |
|
|
active_index = i;
|
49 |
|
|
}
|
50 |
|
|
});
|
51 |
|
|
|
52 |
85ad3d82
|
Assos Assos
|
wrapper.accordion({
|
53 |
27370441
|
Assos Assos
|
heightStyle: "content",
|
54 |
|
|
active: active_index,
|
55 |
85ad3d82
|
Assos Assos
|
collapsible: true,
|
56 |
|
|
changestart: function(event, ui) {
|
57 |
|
|
if ($(this).hasClass('effect-none')) {
|
58 |
|
|
ui.options.animated = false;
|
59 |
|
|
}
|
60 |
|
|
else {
|
61 |
|
|
ui.options.animated = 'slide';
|
62 |
|
|
}
|
63 |
|
|
}
|
64 |
|
|
});
|
65 |
|
|
|
66 |
|
|
if (type == 'form') {
|
67 |
|
|
|
68 |
|
|
var $firstErrorItem = false;
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
wrapper.find('div.field-group-accordion-item').each(function(i) {
|
72 |
|
|
|
73 |
|
|
if ($(this).is('.required-fields') && $(this).find('.form-required').length > 0) {
|
74 |
|
|
$('h3.ui-accordion-header a').eq(i).append(' ').append($('.form-required').eq(0).clone());
|
75 |
|
|
}
|
76 |
|
|
if ($('.error', $(this)).length) {
|
77 |
|
|
|
78 |
|
|
if (!$firstErrorItem) {
|
79 |
|
|
$firstErrorItem = $(this).parent().accordion("activate" , i);
|
80 |
|
|
}
|
81 |
|
|
$('h3.ui-accordion-header').eq(i).addClass('error');
|
82 |
|
|
}
|
83 |
|
|
});
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
if (!$firstErrorItem) {
|
87 |
|
|
$('.ui-accordion-content-active', $firstErrorItem).css({height: 'auto', width: 'auto', display: 'block'});
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
}
|
91 |
|
|
});
|
92 |
|
|
}
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
Drupal.FieldGroup.Effects.processHtabs = {
|
99 |
|
|
execute: function (context, settings, type) {
|
100 |
|
|
if (type == 'form') {
|
101 |
|
|
|
102 |
|
|
$('fieldset.horizontal-tabs-pane', context).once('fieldgroup-effects', function(i) {
|
103 |
|
|
if ($(this).is('.required-fields') && $(this).find('.form-required').length > 0) {
|
104 |
|
|
$(this).data('horizontalTab').link.find('strong:first').after($('.form-required').eq(0).clone()).after(' ');
|
105 |
|
|
}
|
106 |
|
|
if ($('.error', $(this)).length) {
|
107 |
|
|
$(this).data('horizontalTab').link.parent().addClass('error');
|
108 |
|
|
Drupal.FieldGroup.setGroupWithfocus($(this));
|
109 |
|
|
$(this).data('horizontalTab').focus();
|
110 |
|
|
}
|
111 |
|
|
});
|
112 |
|
|
}
|
113 |
|
|
}
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
Drupal.FieldGroup.Effects.processTabs = {
|
120 |
|
|
execute: function (context, settings, type) {
|
121 |
|
|
if (type == 'form') {
|
122 |
27370441
|
Assos Assos
|
|
123 |
|
|
var errorFocussed = false;
|
124 |
|
|
|
125 |
85ad3d82
|
Assos Assos
|
|
126 |
|
|
$('fieldset.vertical-tabs-pane', context).once('fieldgroup-effects', function(i) {
|
127 |
|
|
if ($(this).is('.required-fields') && $(this).find('.form-required').length > 0) {
|
128 |
|
|
$(this).data('verticalTab').link.find('strong:first').after($('.form-required').eq(0).clone()).after(' ');
|
129 |
|
|
}
|
130 |
|
|
if ($('.error', $(this)).length) {
|
131 |
|
|
$(this).data('verticalTab').link.parent().addClass('error');
|
132 |
27370441
|
Assos Assos
|
|
133 |
|
|
if (!errorFocussed) {
|
134 |
|
|
Drupal.FieldGroup.setGroupWithfocus($(this));
|
135 |
|
|
$(this).data('verticalTab').focus();
|
136 |
|
|
errorFocussed = true;
|
137 |
|
|
}
|
138 |
85ad3d82
|
Assos Assos
|
}
|
139 |
|
|
});
|
140 |
|
|
}
|
141 |
|
|
}
|
142 |
|
|
}
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
|
150 |
|
|
Drupal.FieldGroup.Effects.processDiv = {
|
151 |
|
|
execute: function (context, settings, type) {
|
152 |
|
|
|
153 |
|
|
$('div.collapsible', context).once('fieldgroup-effects', function() {
|
154 |
|
|
var $wrapper = $(this);
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
var $toggler = $('span.field-group-format-toggler:first', $wrapper);
|
160 |
|
|
var $link = $('<a class="field-group-format-title" href="#"></a>');
|
161 |
|
|
$link.prepend($toggler.contents());
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
if ($(this).is('.required-fields') && $(this).find('.form-required').length > 0) {
|
165 |
|
|
$link.append(' ').append($('.form-required').eq(0).clone());
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
$link.appendTo($toggler);
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
$link.click(function () {
|
172 |
|
|
var wrapper = $wrapper.get(0);
|
173 |
|
|
|
174 |
|
|
if (!wrapper.animating) {
|
175 |
|
|
wrapper.animating = true;
|
176 |
|
|
var speed = $wrapper.hasClass('speed-fast') ? 300 : 1000;
|
177 |
|
|
if ($wrapper.hasClass('effect-none') && $wrapper.hasClass('speed-none')) {
|
178 |
|
|
$('> .field-group-format-wrapper', wrapper).toggle();
|
179 |
|
|
}
|
180 |
|
|
else if ($wrapper.hasClass('effect-blind')) {
|
181 |
|
|
$('> .field-group-format-wrapper', wrapper).toggle('blind', {}, speed);
|
182 |
|
|
}
|
183 |
|
|
else {
|
184 |
|
|
$('> .field-group-format-wrapper', wrapper).toggle(speed);
|
185 |
|
|
}
|
186 |
|
|
wrapper.animating = false;
|
187 |
|
|
}
|
188 |
|
|
$wrapper.toggleClass('collapsed');
|
189 |
|
|
return false;
|
190 |
|
|
});
|
191 |
|
|
|
192 |
|
|
});
|
193 |
|
|
}
|
194 |
|
|
};
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
Drupal.behaviors.fieldGroup = {
|
200 |
|
|
attach: function (context, settings) {
|
201 |
e9f59589
|
Assos Assos
|
settings.field_group = settings.field_group || Drupal.settings.field_group;
|
202 |
85ad3d82
|
Assos Assos
|
if (settings.field_group == undefined) {
|
203 |
|
|
return;
|
204 |
|
|
}
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
$.each(Drupal.FieldGroup.Effects, function (func) {
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
var type = func.toLowerCase().replace("process", "");
|
211 |
|
|
if (settings.field_group[type] != undefined && $.isFunction(this.execute)) {
|
212 |
|
|
this.execute(context, settings, settings.field_group[type]);
|
213 |
|
|
}
|
214 |
|
|
});
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
$('.fieldset-wrapper .fieldset > legend').css({display: 'block'});
|
218 |
|
|
$('.vertical-tabs fieldset.fieldset').addClass('default-fallback');
|
219 |
|
|
|
220 |
|
|
|
221 |
27370441
|
Assos Assos
|
$('.group-wrapper .horizontal-tabs-panes > fieldset', context).once('group-wrapper-panes-processed', function() {
|
222 |
85ad3d82
|
Assos Assos
|
|
223 |
27370441
|
Assos Assos
|
var fieldgroupID = 'field_group-' + $(this).attr('id');
|
224 |
|
|
$(this).attr('id', fieldgroupID);
|
225 |
|
|
});
|
226 |
85ad3d82
|
Assos Assos
|
|
227 |
27370441
|
Assos Assos
|
$('.group-wrapper ul li').once('group-wrapper-ul-processed', function() {
|
228 |
85ad3d82
|
Assos Assos
|
var fieldGroupNavigationListIndex = $(this).index();
|
229 |
|
|
$(this).children('a').click(function() {
|
230 |
|
|
var fieldset = $('.group-wrapper fieldset').get(fieldGroupNavigationListIndex);
|
231 |
|
|
|
232 |
|
|
var hashUrl = $(fieldset).attr('id').replace(/^field_group-/, '').split(' ')[0];
|
233 |
|
|
window.location.hash = hashUrl;
|
234 |
|
|
});
|
235 |
|
|
});
|
236 |
27370441
|
Assos Assos
|
|
237 |
85ad3d82
|
Assos Assos
|
}
|
238 |
|
|
};
|
239 |
|
|
|
240 |
27370441
|
Assos Assos
|
})(jQuery); |