1(function () { 2 var window = this, 3 $ = window.jQuery, 4 DDC = (window.DDC = (window.DDC || {})); 5 6 DDC.modules.dynamicField.refresh = function () { 7 var dynamicFieldFormChange = function () { 8 var data = DDC.getUrlParams('?' + 9 $(this).serialize()); 10 11 /* 12 * Multiple selects don't serialize quite the way 13 * we want by default. For the purposes of dynamic 14 * fields, we want a comma-separated list from a 15 * multiple select of all its selected options' values. 16 * 17 * This routine updates the serialized values of any 18 * multiple selects to be comma-separated lists 19 * instead of URL parameter strings (the 20 * not-so-useful default). 21 */ 22 23 var multipleCheckboxValues = []; 24 $('input[type="checkbox"]', this).each(function () { 25 if ($(this).is(":checked")) { 26 multipleCheckboxValues.push($(this).val()); 27 } 28 data[this.name] = multipleCheckboxValues.join(', '); 29 }); 30 31 $('[multiple]', this).each(function () { 32 var multipleValues = [], 33 i; 34 35 for (i = 0; i < this.options.length; i++) { 36 if (this.options[i].selected) { 37 multipleValues.push($(this.options[i]).val()); 38 } 39 } 40 41 data[this.name] = multipleValues.join(', '); 42 }); 43 44 $(document).trigger('dynamicFields', [data]); 45 }; 46 47 $(DDC.modules.dynamicField.selector).each(function () { 48 var self = this; 49 50 if (!$(this).data('dynamic-field-initialized')) { 51 if ($(this).is('option')) { 52 $(this) 53 .attr('data-text', $(this).text()) 54 .text(''); 55 } else if (!$(this).attr('data-val')) { 56 $(this) 57 .attr('data-val', $(this).val()) 58 .val(''); 59 } 60 $(this).data('dynamic-field-initialized', true); 61 } 62 if (!$(this).parents('form').data('dynamic-field-initialized')) { 63 $(this).parents('form') 64 .bind('change', dynamicFieldFormChange) 65 .data('dynamic-field-initialized', true); 66 67 setTimeout(function () { 68 $(self).trigger('change'); 69 }, 250); 70 } 71 }); 72 }; 73}());
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.