%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom645759/wp-content/plugins/fusion-builder/front-end/views/form/
Upload File :
Create Path :
Current File : /dom645759/wp-content/plugins/fusion-builder/front-end/views/form/view-rich-text.js

var FusionPageBuilder = FusionPageBuilder || {};

( function() {

	jQuery( document ).ready( function() {
		// Fusion Form Rich Text View. Mirrors FusionForm_Rich_Text::render_input_field(); the editor isn't editable here.
		FusionPageBuilder.fusion_form_rich_text = FusionPageBuilder.FormComponentView.extend( {

			/**
			 * Modify template attributes.
			 *
			 * @since 3.17
			 * @param {Object} atts - The attributes object.
			 * @return {Object}
			 */
			filterTemplateAtts: function( atts ) {
				var attributes = {};

				attributes.styles = this.buildStyles( atts.values );
				attributes.html   = this.generateFormFieldHtml( this.generateRichTextField( atts.values ) );

				return attributes;
			},

			/**
			 * The toolbar buttons of the tools chosen.
			 *
			 * @since 3.17
			 * @param {Array} tools - The tools.
			 * @return {string}
			 */
			generateToolbar: function( tools ) {
				var buttons = [
						[ 'bold', 'bold', 'bold' ],
						[ 'italic', 'italic', 'italic' ],
						[ 'color', 'color', 'text-color' ],
						[ 'h2', 'heading', 'heading-2' ],
						[ 'h3', 'heading', 'heading-3' ],
						[ 'h4', 'heading', 'heading-4' ],
						[ 'ul', 'lists', 'list-ul' ],
						[ 'ol', 'lists', 'list-ol' ],
						[ 'quote', 'quote', 'quote' ],
						[ 'left', 'align', 'align-left' ],
						[ 'center', 'align', 'align-center' ],
						[ 'right', 'align', 'align-right' ],
						[ 'link', 'link', 'link' ],
						[ 'image', 'image', 'image' ],
						[ 'button', 'button', 'button' ],
						[ 'checklist', 'checklist', 'check-square-o' ],
					],
					html = '';

				// In the order the tools were chosen in.
				_.each( tools, function( tool ) {
					_.each( buttons, function( button ) {
						if ( tool === button[ 1 ] ) {
							html += '<button type="button" class="awb-form-rich-text__tool" data-command="' + button[ 0 ] + '" tabindex="-1"><i class="awb-icon-' + button[ 2 ] + '" aria-hidden="true"></i></button>';
						}
					} );
				} );

				return html ? '<div class="awb-form-rich-text__toolbar">' + html + '</div>' : '';
			},

			/**
			 * The field.
			 *
			 * @since 3.17
			 * @param {Object} atts - The element values.
			 * @return {string}
			 */
			generateRichTextField: function( atts ) {
				var elementData = this.elementData( atts ),
					tools       = 'string' === typeof atts.toolbar ? atts.toolbar.split( ',' ) : [],
					rows        = Math.max( 2, parseInt( atts.rows, 10 ) || 6 ),
					placeholder = atts.placeholder ? atts.placeholder + ( 'yes' === atts.required ? ' *' : '' ) : '',
					elementHtml;

				elementData = this.generateTooltipHtml( atts, elementData );

				elementHtml  = '<div class="awb-form-rich-text" style="--awb-rich-text-rows:' + rows + ';">';
				elementHtml += this.generateToolbar( tools );
				elementHtml += '<div class="awb-form-rich-text__body">';
				elementHtml += '<div class="awb-form-rich-text__editor is-empty" data-placeholder="' + _.awbEscAttr( placeholder ) + '"></div>';
				elementHtml += '</div></div>';

				return this.generateLabelHtml( '', elementHtml, elementData.label );
			}

		} );
	} );
}( jQuery ) );

Zerion Mini Shell 1.0