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