/* global FusionPageBuilderApp */ var FusionPageBuilder = FusionPageBuilder || {}; ( function() { jQuery( document ).ready( function() { // Fusion Form Select View. FusionPageBuilder.fusion_form_select = FusionPageBuilder.FormComponentView.extend( { /** * Modify template attributes. * * @since 3.1 * @param {Object} atts - The attributes object. * @return {Object} */ filterTemplateAtts: function( atts ) { var attributes = {}; // Create attribute objects; attributes.styles = this.buildStyles( atts.values ); attributes.html = this.generateFormFieldHtml( this.generateSelectField( atts.values ) ); return attributes; }, generateSelectField: function( values ) { var elementData, elementHtml, options = '', html = ''; if ( 'undefined' === typeof values.options || ! values.options ) { return html; } values.options = JSON.parse( FusionPageBuilderApp.base64Decode( values.options ) ); elementData = this.elementData( values ); if ( '' !== values.tooltip ) { elementData.label += this.getFieldTooltip( values ); } if ( 'yes' === values.multiselect ) { let height = values.options.length; height = 5 < height ? '6.5' : height + 1.5; elementData.style = ' style="height:' + height + 'em;"'; } if ( 'undefined' !== typeof values.placeholder && '' !== values.placeholder && 'yes' !== values.multiselect ) { options += ''; } _.each( values.options, function( option ) { var selected = option[ 0 ] ? ' selected ' : ''; var label = option[ 1 ].trim(); var value = '' !== option[ 2 ] ? option[ 2 ].trim() : label; options += ''; } ); elementHtml = '
'; elementHtml += ''; elementHtml += 'yes' === values.multiselect ? '' : '
'; elementHtml += '
'; elementHtml = this.generateIconHtml( values, elementHtml ); html = this.generateLabelHtml( html, elementHtml, elementData.label ); return html; } } ); } ); }( jQuery ) );