assets/src/js/admin-form-builder/element-type.js
( function( torroBuilder, _ ) {
'use strict';
/**
* An element type.
*
* @class
*
* @param {object} attributes Element type attributes.
*/
function ElementType( attributes ) {
this.attributes = attributes;
}
_.extend( ElementType.prototype, {
/**
* Returns the element type slug.
*
* @since 1.0.0
* @access public
*
* @returns {string} Element type slug.
*/
getSlug: function() {
return this.attributes.slug;
},
/**
* Returns the element type title.
*
* @since 1.0.0
* @access public
*
* @returns {string} Element type title.
*/
getTitle: function() {
return this.attributes.title;
},
/**
* Returns the element type description.
*
* @since 1.0.0
* @access public
*
* @returns {string} Element type description.
*/
getDescription: function() {
return this.attributes.description;
},
/**
* Returns the element type icon CSS class.
*
* @since 1.0.0
* @access public
*
* @returns {string} Element type icon CSS class.
*/
getIconCssClass: function() {
return this.attributes.icon_css_class;
},
/**
* Returns the element type icon SVG ID.
*
* @since 1.0.0
* @access public
*
* @returns {string} Element type icon SVG ID.
*/
getIconSvgId: function() {
return this.attributes.icon_svg_id;
},
/**
* Returns the element type icon URL.
*
* @since 1.0.0
* @access public
*
* @returns {string} Element type icon URL.
*/
getIconUrl: function() {
return this.attributes.icon_url;
},
/**
* Checks whether the element type is a non input element type.
*
* @since 1.0.0
* @access public
*
* @returns {string} True if the element type is a non input element type, false otherwise.
*/
isNonInput: function() {
return this.attributes.non_input;
},
/**
* Checks whether the element type is evaluable.
*
* @since 1.0.0
* @access public
*
* @returns {string} True if the element type is evaluable, false otherwise.
*/
isEvaluable: function() {
return this.attributes.evaluable;
},
/**
* Checks whether the element type contains multiple fields.
*
* @since 1.0.0
* @access public
*
* @returns {string} True if the element type contains multiple fields, false otherwise.
*/
isMultiField: function() {
return this.attributes.multifield;
},
/**
* Returns the settings sections that belong to the element type.
*
* @since 1.0.0
* @access public
*
* @returns {object[]} Element type sections.
*/
getSections: function() {
return this.attributes.sections;
},
/**
* Returns the settings fields that belong to the element type.
*
* @since 1.0.0
* @access public
*
* @returns {object[]} Element type fields.
*/
getFields: function() {
return this.attributes.fields;
}
});
torroBuilder.ElementType = ElementType;
})( window.torro.Builder, window._ );