1 2(function($) { 3 4/** 5 * Drupal FieldGroup object. 6 */ 7Drupal.FieldGroup = Drupal.FieldGroup || {}; 8Drupal.FieldGroup.Effects = Drupal.FieldGroup.Effects || {}; 9Drupal.FieldGroup.groupWithfocus = null; 10 11Drupal.FieldGroup.setGroupWithfocus = function(element) { 12 element.css({display: 'block'}); 13 Drupal.FieldGroup.groupWithfocus = element; 14} 15 16/** 17 * Implements Drupal.FieldGroup.processHook(). 18 */ 19Drupal.FieldGroup.Effects.processFieldset = { 20 execute: function (context, settings, type) { 21 if (type == 'form') { 22 // Add required fields mark to any fieldsets containing required fields 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 * Implements Drupal.FieldGroup.processHook(). 38 */ 39Drupal.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 // Get the index to set active. 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 wrapper.accordion({ 53 heightStyle: "content", // jQuery UI >= v1.9 54 autoHeight: false, // jQuery UI < v1.9 55 active: active_index, 56 collapsible: true, 57 changestart: function(event, ui) { 58 if ($(this).hasClass('effect-none')) { 59 ui.options.animated = false; 60 } 61 else { 62 ui.options.animated = 'slide'; 63 } 64 } 65 }); 66 67 if (type == 'form') { 68 69 var $firstErrorItem = false; 70 71 // Add required fields mark to any element containing required fields 72 wrapper.find('div.field-group-accordion-item').each(function(i) { 73 74 if ($(this).is('.required-fields') && $(this).find('.form-required').length > 0) { 75 $('h3.ui-accordion-header a').eq(i).append(' ').append($('.form-required').eq(0).clone()); 76 } 77 if ($('.error', $(this)).length) { 78 // Save first error item, for focussing it. 79 if (!$firstErrorItem) { 80 $firstErrorItem = $(this).parent().accordion("option", "active", i); 81 } 82 $('h3.ui-accordion-header').eq(i).addClass('error'); 83 } 84 }); 85 86 // Save first error item, for focussing it. 87 if (!$firstErrorItem) { 88 $('.ui-accordion-content-active', $firstErrorItem).css({height: 'auto', width: 'auto', display: 'block'}); 89 } 90 91 } 92 }); 93 } 94} 95 96/** 97 * Implements Drupal.FieldGroup.processHook(). 98 */ 99Drupal.FieldGroup.Effects.processHtabs = { 100 execute: function (context, settings, type) { 101 if (type == 'form') { 102 // Add required fields mark to any element containing required fields 103 $('fieldset.horizontal-tabs-pane', context).once('fieldgroup-effects', function(i) { 104 if ($(this).is('.required-fields') && $(this).find('.form-required').length > 0) { 105 $(this).data('horizontalTab').link.find('strong:first').after($('.form-required').eq(0).clone()).after(' '); 106 } 107 if ($('.error', $(this)).length) { 108 $(this).data('horizontalTab').link.parent().addClass('error'); 109 Drupal.FieldGroup.setGroupWithfocus($(this)); 110 $(this).data('horizontalTab').focus(); 111 } 112 }); 113 } 114 } 115} 116 117/** 118 * Implements Drupal.FieldGroup.processHook(). 119 */ 120Drupal.FieldGroup.Effects.processTabs = { 121 execute: function (context, settings, type) { 122 if (type == 'form') { 123 124 var errorFocussed = false; 125 126 // Add required fields mark to any fieldsets containing required fields 127 $('fieldset.vertical-tabs-pane', context).once('fieldgroup-effects', function(i) { 128 if ($(this).is('.required-fields') && $(this).find('.form-required').length > 0) { 129 $(this).data('verticalTab').link.find('strong:first').after($('.form-required').eq(0).clone()).after(' '); 130 } 131 if ($('.error', $(this)).length) { 132 $(this).data('verticalTab').link.parent().addClass('error'); 133 // Focus the first tab with error. 134 if (!errorFocussed) { 135 Drupal.FieldGroup.setGroupWithfocus($(this)); 136 $(this).data('verticalTab').focus(); 137 errorFocussed = true; 138 } 139 } 140 }); 141 } 142 } 143} 144 145/** 146 * Implements Drupal.FieldGroup.processHook(). 147 * 148 * TODO clean this up meaning check if this is really 149 * necessary. 150 */ 151Drupal.FieldGroup.Effects.processDiv = { 152 execute: function (context, settings, type) { 153 154 $('div.collapsible', context).once('fieldgroup-effects', function() { 155 var $wrapper = $(this); 156 157 // Turn the legend into a clickable link, but retain span.field-group-format-toggler 158 // for CSS positioning. 159 160 var $toggler = $('span.field-group-format-toggler:first', $wrapper); 161 var $link = $('<a class="field-group-format-title" href="#"></a>'); 162 $link.prepend($toggler.contents()); 163 164 // Add required field markers if needed 165 if ($(this).is('.required-fields') && $(this).find('.form-required').length > 0) { 166 $link.append(' ').append($('.form-required').eq(0).clone()); 167 } 168 169 $link.appendTo($toggler); 170 171 // .wrapInner() does not retain bound events. 172 $link.click(function () { 173 var wrapper = $wrapper.get(0); 174 // Don't animate multiple times. 175 if (!wrapper.animating) { 176 wrapper.animating = true; 177 var speed = $wrapper.hasClass('speed-fast') ? 300 : 1000; 178 if ($wrapper.hasClass('effect-none') && $wrapper.hasClass('speed-none')) { 179 $('> .field-group-format-wrapper', wrapper).toggle(); 180 wrapper.animating = false;
181 } 182 else if ($wrapper.hasClass('effect-blind')) { 183 $('> .field-group-format-wrapper', wrapper).toggle('blind', {}, speed); 184 wrapper.animating = false; 185 } 186 else { 187 $('> .field-group-format-wrapper', wrapper).toggle(speed, function() { 188 wrapper.animating = false; 189 }); 190 } 191 } 192 $wrapper.toggleClass('collapsed'); 193 return false; 194 }); 195 196 }); 197 } 198}; 199 200/** 201 * Behaviors. 202 */ 203Drupal.behaviors.fieldGroup = { 204 attach: function (context, settings) { 205 settings.field_group = settings.field_group || Drupal.settings.field_group; 206 if (settings.field_group == undefined) { 207 return; 208 } 209 210 // Execute all of them. 211 $.each(Drupal.FieldGroup.Effects, function (func) { 212 // We check for a wrapper function in Drupal.field_group as 213 // alternative for dynamic string function calls. 214 var type = func.toLowerCase().replace("process", ""); 215 if (settings.field_group[type] != undefined && $.isFunction(this.execute)) { 216 this.execute(context, settings, settings.field_group[type]); 217 } 218 }); 219 220 // Fixes css for fieldgroups under vertical tabs. 221 $('.fieldset-wrapper .fieldset > legend').css({display: 'block'}); 222 $('.vertical-tabs fieldset.fieldset').addClass('default-fallback'); 223 224 // Add a new ID to each fieldset. 225 $('.group-wrapper .horizontal-tabs-panes > fieldset', context).once('group-wrapper-panes-processed', function() { 226 // Tats bad, but we have to keep the actual id to prevent layouts to break. 227 var fieldgroupID = 'field_group-' + $(this).attr('id'); 228 $(this).attr('id', fieldgroupID); 229 }); 230 // Set the hash in url to remember last userselection. 231 $('.group-wrapper ul li').once('group-wrapper-ul-processed', function() { 232 var fieldGroupNavigationListIndex = $(this).index(); 233 $(this).children('a').click(function() { 234 var fieldset = $('.group-wrapper fieldset').get(fieldGroupNavigationListIndex); 235 // Grab the first id, holding the wanted hashurl. 236 var hashUrl = $(fieldset).attr('id').replace(/^field_group-/, '').split(' ')[0]; 237 window.location.hash = hashUrl; 238 }); 239 }); 240 241 } 242}; 243 244})(jQuery); 245;
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.