1(function($) { 2 3/** 4 * Drupal FieldGroup object. 5 */ 6Drupal.FieldGroup = Drupal.FieldGroup || {}; 7Drupal.FieldGroup.Effects = Drupal.FieldGroup.Effects || {}; 8Drupal.FieldGroup.groupWithfocus = null; 9 10Drupal.FieldGroup.setGroupWithfocus = function(element) { 11 element.css({display: 'block'}); 12 Drupal.FieldGroup.groupWithfocus = element; 13} 14 15/** 16 * Implements Drupal.FieldGroup.processHook(). 17 */ 18Drupal.FieldGroup.Effects.processFieldset = { 19 execute: function (context, settings, type) { 20 if (type == 'form') { 21 // Add required fields mark to any fieldsets containing required fields 22 $('fieldset.fieldset', context).once('fieldgroup-effects', function(i) { 23 if ($(this).is('.required-fields') && $(this).find('.form-required').length > 0) { 24 $('legend span.fieldset-legend', $(this)).eq(0).append(' ').append($('.form-required').eq(0).clone()); 25 } 26 if ($('.error', $(this)).length) { 27 $('legend span.fieldset-legend', $(this)).eq(0).addClass('error'); 28 Drupal.FieldGroup.setGroupWithfocus($(this)); 29 } 30 }); 31 } 32 } 33} 34 35/** 36 * Implements Drupal.FieldGroup.processHook(). 37 */ 38Drupal.FieldGroup.Effects.processAccordion = { 39 execute: function (context, settings, type) { 40 $('div.field-group-accordion-wrapper', context).once('fieldgroup-effects', function () { 41 var wrapper = $(this); 42 43 wrapper.accordion({ 44 autoHeight: false, 45 active: '.field-group-accordion-active', 46 collapsible: true, 47 changestart: function(event, ui) { 48 if ($(this).hasClass('effect-none')) { 49 ui.options.animated = false; 50 } 51 else { 52 ui.options.animated = 'slide'; 53 } 54 } 55 }); 56 57 if (type == 'form') { 58 59 var $firstErrorItem = false; 60 61 // Add required fields mark to any element containing required fields 62 wrapper.find('div.field-group-accordion-item').each(function(i) { 63 64 if ($(this).is('.required-fields') && $(this).find('.form-required').length > 0) { 65 $('h3.ui-accordion-header a').eq(i).append(' ').append($('.form-required').eq(0).clone()); 66 } 67 if ($('.error', $(this)).length) { 68 // Save first error item, for focussing it. 69 if (!$firstErrorItem) { 70 $firstErrorItem = $(this).parent().accordion("activate" , i); 71 } 72 $('h3.ui-accordion-header').eq(i).addClass('error'); 73 } 74 }); 75 76 // Save first error item, for focussing it. 77 if (!$firstErrorItem) { 78 $('.ui-accordion-content-active', $firstErrorItem).css({height: 'auto', width: 'auto', display: 'block'}); 79 } 80 81 } 82 }); 83 } 84} 85 86/** 87 * Implements Drupal.FieldGroup.processHook(). 88 */ 89Drupal.FieldGroup.Effects.processHtabs = { 90 execute: function (context, settings, type) { 91 if (type == 'form') { 92 // Add required fields mark to any element containing required fields 93 $('fieldset.horizontal-tabs-pane', context).once('fieldgroup-effects', function(i) { 94 if ($(this).is('.required-fields') && $(this).find('.form-required').length > 0) { 95 $(this).data('horizontalTab').link.find('strong:first').after($('.form-required').eq(0).clone()).after(' '); 96 } 97 if ($('.error', $(this)).length) { 98 $(this).data('horizontalTab').link.parent().addClass('error'); 99 Drupal.FieldGroup.setGroupWithfocus($(this)); 100 $(this).data('horizontalTab').focus(); 101 } 102 }); 103 } 104 } 105} 106 107/** 108 * Implements Drupal.FieldGroup.processHook(). 109 */ 110Drupal.FieldGroup.Effects.processTabs = { 111 execute: function (context, settings, type) { 112 if (type == 'form') { 113 // Add required fields mark to any fieldsets containing required fields 114 $('fieldset.vertical-tabs-pane', context).once('fieldgroup-effects', function(i) { 115 if ($(this).is('.required-fields') && $(this).find('.form-required').length > 0) { 116 $(this).data('verticalTab').link.find('strong:first').after($('.form-required').eq(0).clone()).after(' '); 117 } 118 if ($('.error', $(this)).length) { 119 $(this).data('verticalTab').link.parent().addClass('error'); 120 Drupal.FieldGroup.setGroupWithfocus($(this)); 121 $(this).data('verticalTab').focus(); 122 } 123 }); 124 } 125 } 126} 127 128/** 129 * Implements Drupal.FieldGroup.processHook(). 130 * 131 * TODO clean this up meaning check if this is really 132 * necessary. 133 */ 134Drupal.FieldGroup.Effects.processDiv = { 135 execute: function (context, settings, type) { 136 137 $('div.collapsible', context).once('fieldgroup-effects', function() { 138 var $wrapper = $(this); 139 140 // Turn the legend into a clickable link, but retain span.field-group-format-toggler 141 // for CSS positioning. 142 143 var $toggler = $('span.field-group-format-toggler:first', $wrapper); 144 var $link = $('<a class="field-group-format-title" href="#"></a>'); 145 $link.prepend($toggler.contents()); 146 147 // Add required field markers if needed 148 if ($(this).is('.required-fields') && $(this).find('.form-required').length > 0) { 149 $link.append(' ').append($('.form-required').eq(0).clone()); 150 } 151 152 $link.appendTo($toggler); 153 154 // .wrapInner() does not retain bound events. 155 $link.click(function () { 156 var wrapper = $wrapper.get(0); 157 // Don't animate multiple times. 158 if (!wrapper.animating) { 159 wrapper.animating = true; 160 var speed = $wrapper.hasClass('speed-fast') ? 300 : 1000; 161 if ($wrapper.hasClass('effect-none') && $wrapper.hasClass('speed-none')) { 162 $('> .field-group-format-wrapper', wrapper).toggle(); 163 } 164 else if ($wrapper.hasClass('effect-blind')) { 165 $('> .field-group-format-wrapper', wrapper).toggle('blind', {}, speed); 166 } 167 else { 168 $('> .field-group-format-wrapper', wrapper).toggle(speed); 169 } 170 wrapper.animating = false;
171 } 172 $wrapper.toggleClass('collapsed'); 173 return false; 174 }); 175 176 }); 177 } 178}; 179 180/** 181 * Behaviors. 182 */ 183Drupal.behaviors.fieldGroup = { 184 attach: function (context, settings) { 185 settings.field_group = settings.field_group || Drupal.settings.field_group; 186 if (settings.field_group == undefined) { 187 return; 188 } 189 190 // Execute all of them. 191 $.each(Drupal.FieldGroup.Effects, function (func) { 192 // We check for a wrapper function in Drupal.field_group as 193 // alternative for dynamic string function calls. 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 // Fixes css for fieldgroups under vertical tabs. 201 $('.fieldset-wrapper .fieldset > legend').css({display: 'block'}); 202 $('.vertical-tabs fieldset.fieldset').addClass('default-fallback'); 203 204 205 // Add a new ID to each fieldset. 206 $('.group-wrapper fieldset').each(function() { 207 // Tats bad, but we have to keep the actual id to prevent layouts to break. 208 var fieldgorupID = 'field_group-' + $(this).attr('id') + ' ' + $(this).attr('id'); 209 $(this).attr('id', fieldgorupID); 210 }) 211 // Set the hash in url to remember last userselection. 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 // Grab the first id, holding the wanted hashurl. 217 var hashUrl = $(fieldset).attr('id').replace(/^field_group-/, '').split(' ')[0]; 218 window.location.hash = hashUrl; 219 }); 220 }); 221 } 222}; 223 224})(jQuery);;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.