1// create layout for contact form 2;(function($) { 3 // options 4 function layoutContactForm(options) { 5 this.options = $.extend({ 6 commentClass: '.form-input-comments', 7 commonLayoutWrapper: '<div class="contact-form-columns">', 8 inputHolder: '.form__group' 9 }, options); 10 11 this.init(); 12 } 13 14 // prototype 15 layoutContactForm.prototype = { 16 init: function() { 17 this.findElements(); 18 this.wrapElements(); 19 }, 20 findElements: function() { 21 this.holder = $(this.options.holder); 22 this.comments = this.holder.find(this.options.commentClass); 23 this.inputHolder = this.holder.find(this.options.inputHolder); 24 }, 25 wrapElements: function() { 26 var self = this; 27 28 // check if comments field exists 29 if (!!self.comments.length) { 30 self.inputHolder.wrapAll(self.options.commonLayoutWrapper); 31 // reset textarea to default size 32 self.comments.find('textarea').css({ 33 'width': '', 34 'height': '' 35 }); 36 } 37 }, 38 destroy: function() { 39 if (this.comments.length) { 40 this.inputHolder.unwrap(this.options.commonLayoutWrapper); 41 } 42 this.holder.removeData('layoutContactForm'); 43 } 44 }; 45 46 // jquery plugin 47 $.fn.layoutContactForm = function(opt) { 48 return this.each(function() { 49 if(typeof $(this).data('layoutContactForm') === 'undefined') { 50 $(this).data('layoutContactForm', new layoutContactForm($.extend(opt, { holder: this }))); 51 } 52 }); 53 }; 54})(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.