').insertAfter(element).append(element);\n\n $kcToggle.toggleClass('on', element.is(':checked'));\n\n var kctOn = '
';\n\n $kcToggle.append(kctInner);\n\n $kcToggle.click(function () {\n element.attr('checked', !element.attr('checked'));\n $(this).toggleClass('on');\n });\n };\n\n $.fn.kcToggle = function (options) {\n var toggle = this;\n return toggle.each(function () {\n var element = $(this);\n if (element.data('kcToggle')) {\n return;\n }\n var kcToggle = new Toggle(element, options);\n element.data('kcToggle', kcToggle);\n });\n };\n})(jQuery);\n'use strict';\n// render the formBuilder XML into html\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol ? \"symbol\" : typeof obj; };\n\nfunction FormRenderFn(options, element) {\n\n var formRender = this,\n defaults = {\n destroyTemplate: true, // @todo\n container: false,\n dataType: 'xml',\n formData: false,\n label: {\n selectColor: 'Select Color',\n noFormData: 'No form data.',\n formRendered: 'Form Rendered'\n },\n render: true,\n notify: {\n error: function error(message) {\n return console.error(message);\n },\n success: function success(message) {\n return console.log(message);\n },\n warning: function warning(message) {\n return console.warn(message);\n }\n }\n },\n _helpers = {};\n\n var opts = $.extend(true, defaults, options);\n\n /**\n * Require the html element if it has been lost\n *\n * @return {object} javascript object for html element\n */\n _helpers.getElement = function () {\n if (!element.id) {\n element.id = _helpers.makeId(element);\n }\n\n return document.getElementById(element.id);\n };\n\n /**\n * Make an ID for this element using current date and tag\n *\n * @param {Boolean} element\n * @return {String} new id for element\n */\n _helpers.makeId = function (element) {\n var epoch = new Date().getTime();\n\n return element.tagName + '-' + epoch;\n };\n\n if (!opts.formData && element) {\n element = _helpers.getElement();\n opts.formData = element.value;\n }\n\n /**\n * Generate markup wrapper where needed\n *\n * @param {string} tag\n * @param {String|Array|Object} content we wrap this\n * @param {object} attrs\n * @return {String}\n */\n _helpers.markup = function (tag) {\n var content = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];\n var attrs = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];\n\n var contentType = void 0,\n field = document.createElement(tag),\n getContentType = function getContentType(content) {\n return Array.isArray(content) ? 'array' : typeof content === 'undefined' ? 'undefined' : _typeof(content);\n },\n appendContent = {\n string: function string(content) {\n field.innerHTML = content;\n },\n object: function object(content) {\n return field.appendChild(content);\n },\n array: function array(content) {\n for (var i = 0; i < content.length; i++) {\n contentType = getContentType(content[i]);\n appendContent[contentType](content[i]);\n }\n }\n };\n\n for (var attr in attrs) {\n if (attrs.hasOwnProperty(attr)) {\n var name = _helpers.safeAttrName(attr);\n field.setAttribute(name, attrs[attr]);\n }\n }\n\n contentType = getContentType(content);\n\n if (content) {\n appendContent[contentType].call(this, content);\n }\n\n return field;\n };\n\n /**\n * Generate preview markup\n * @param {object} field\n * @return {string} preview markup for field\n * @todo\n */\n _helpers.fieldRender = function (field) {\n var fieldMarkup = '',\n fieldLabel = '',\n optionsMarkup = '';\n var fieldAttrs = _helpers.parseAttrs(field.attributes),\n fieldLabelText = fieldAttrs.label || '',\n fieldDesc = fieldAttrs.description || '',\n fieldRequired = '',\n fieldOptions = $('option', field);\n fieldAttrs.id = fieldAttrs.name;\n\n fieldAttrs.type = fieldAttrs.subtype || fieldAttrs.type;\n\n if (fieldAttrs.required) {\n fieldAttrs.required = null;\n fieldAttrs['aria-required'] = 'true';\n fieldRequired = '
';\n }\n\n if (fieldAttrs.type !== 'hidden') {\n if (fieldDesc) {\n fieldDesc = '
';\n }\n\n var fieldLabelVal = fieldAttrs.label;\n\n delete fieldAttrs.label;\n delete fieldAttrs.description;\n\n var fieldAttrsString = _helpers.attrString(fieldAttrs);\n\n switch (fieldAttrs.type) {\n case 'textarea':\n case 'rich-text':\n delete fieldAttrs.type;\n delete fieldAttrs.value;\n fieldMarkup = fieldLabel + '
';\n break;\n case 'select':\n fieldAttrs.type = fieldAttrs.type.replace('-group', '');\n\n if (fieldOptions.length) {\n fieldOptions.each(function (index, el) {\n index = index;\n var optionAttrs = _helpers.parseAttrs(el.attributes),\n optionAttrsString = _helpers.attrString(optionAttrs);\n optionsMarkup += '
';\n break;\n case 'checkbox-group':\n case 'radio-group':\n fieldAttrs.type = fieldAttrs.type.replace('-group', '');\n\n // delete fieldAttrs.className;\n\n if (fieldOptions.length) {\n (function () {\n var optionName = fieldAttrs.type === 'checkbox' ? fieldAttrs.name + '[]' : fieldAttrs.name;\n fieldOptions.each(function (index, el) {\n var optionAttrs = Object.assign({}, fieldAttrs, _helpers.parseAttrs(el.attributes)),\n optionAttrsString = void 0;\n\n if (optionAttrs.selected) {\n delete optionAttrs.selected;\n optionAttrs.checked = null;\n }\n\n optionAttrs.name = optionName;\n optionAttrs.id = fieldAttrs.id + '-' + index;\n optionAttrsString = _helpers.attrString(optionAttrs);\n optionsMarkup += '
';\n });\n })();\n }\n fieldMarkup = fieldLabel + '
';\n break;\n case 'text':\n case 'password':\n case 'email':\n case 'file':\n case 'hidden':\n case 'date':\n case 'autocomplete':\n fieldMarkup = fieldLabel + '
' + opts.label.selectColor;\n break;\n case 'button':\n case 'submit':\n fieldMarkup = '
' + fieldLabel;\n\n if (fieldAttrs.toggle) {\n setTimeout(function () {\n $(document.getElementById(fieldAttrs.id)).kcToggle();\n }, 100);\n }\n break;\n default:\n fieldMarkup = '<' + fieldAttrs.type + '>' + fieldLabelText + '' + fieldAttrs.type + '>';\n }\n\n if (fieldAttrs.type !== 'hidden') {\n var className = fieldAttrs.id ? 'form-group field-' + fieldAttrs.id : '';\n fieldMarkup = _helpers.markup('div', fieldMarkup, {\n className: className\n });\n } else {\n fieldMarkup = _helpers.markup('input', null, fieldAttrs);\n }\n\n return fieldMarkup;\n };\n\n /**\n * Convert camelCase into lowercase-hyphen\n *\n * @param {string} str\n * @return {string}\n */\n _helpers.hyphenCase = function (str) {\n str = str.replace(/[^\\w\\s\\-]/gi, '');\n str = str.replace(/([A-Z])/g, function ($1) {\n return '-' + $1.toLowerCase();\n });\n\n return str.replace(/\\s/g, '-').replace(/^-+/g, '');\n };\n\n _helpers.attrString = function (attrs) {\n var attributes = [];\n\n for (var attr in attrs) {\n if (attrs.hasOwnProperty(attr)) {\n attr = _helpers.safeAttr(attr, attrs[attr]);\n attributes.push(attr.name + attr.value);\n }\n }\n return attributes.join(' ');\n };\n\n _helpers.safeAttr = function (name, value) {\n var safeAttr = {\n className: 'class'\n };\n\n name = safeAttr[name] || name;\n value = value ? window.JSON.stringify(value) : false;\n value = value ? '=' + value : '';\n\n return {\n name: name,\n value: value\n };\n };\n\n _helpers.safeAttrName = function (name) {\n var safeAttr = {\n className: 'class'\n };\n\n return safeAttr[name] || _helpers.hyphenCase(name);\n };\n\n _helpers.parseAttrs = function (attrNodes) {\n var fieldAttrs = {};\n for (var attr in attrNodes) {\n if (attrNodes.hasOwnProperty(attr)) {\n fieldAttrs[attrNodes[attr].name] = attrNodes[attr].value;\n }\n }\n return fieldAttrs;\n };\n\n /**\n * Extend Element prototype to allow us to append fields\n *\n * @param {object} fields Node elements\n */\n Element.prototype.appendFormFields = function (fields) {\n var element = this;\n fields.reverse();\n for (var i = fields.length - 1; i >= 0; i--) {\n element.appendChild(fields[i]);\n }\n };\n\n /**\n * Extend Element prototype to remove content\n */\n Element.prototype.emptyContainer = function () {\n var element = this;\n while (element.lastChild) {\n element.removeChild(element.lastChild);\n }\n };\n\n // Begin the core plugin\n var rendered = [];\n\n var formData = $.parseXML(opts.formData),\n fields = $('field', formData);\n // @todo - form configuration settings (control position, creatorId, theme etc)\n // settings = $('settings', formData);\n\n // generate field markup if we have fields\n if (fields.length) {\n fields.each(function (index, field) {\n index = index;\n rendered.push(_helpers.fieldRender(field));\n });\n } else {\n var noData = _helpers.markup('div', opts.label.noFormData, {\n className: 'no-form-data'\n });\n rendered.push(noData);\n opts.notify.error(opts.label.noFormData);\n }\n\n if (opts.render) {\n if (opts.container) {\n opts.container = opts.container instanceof jQuery ? opts.container[0] : opts.container;\n opts.container.emptyContainer();\n opts.container.appendFormFields(rendered);\n } else if (element) {\n var renderedFormWrap = document.querySelector('.rendered-form');\n if (renderedFormWrap) {\n renderedFormWrap.emptyContainer();\n renderedFormWrap.appendFormFields(rendered);\n } else {\n renderedFormWrap = _helpers.markup('div', rendered, { className: 'rendered-form' });\n element.parentNode.insertBefore(renderedFormWrap, element.nextSibling);\n element.style.display = 'none';\n element.setAttribute('disabled', 'disabled');\n }\n }\n if (fields.length) {\n opts.notify.success(opts.label.formRendered);\n }\n } else {\n formRender.markup = rendered.map(function (elem) {\n return elem.innerHTML;\n }).join('');\n }\n\n return formRender;\n}\n\n(function ($) {\n\n $.fn.formRender = function (options) {\n this.each(function () {\n var formRender = new FormRenderFn(options, this);\n return formRender;\n });\n };\n})(jQuery);","'use strict';\n// render the formBuilder XML into html\nfunction FormRenderFn(options, element) {\n\n var formRender = this,\n defaults = {\n destroyTemplate: true, // @todo\n container: false,\n dataType: 'xml',\n formData: false,\n label: {\n selectColor: 'Select Color',\n noFormData: 'No form data.',\n formRendered: 'Form Rendered'\n },\n render: true,\n notify: {\n error: function(message) {\n return console.error(message);\n },\n success: function(message) {\n return console.log(message);\n },\n warning: function(message) {\n return console.warn(message);\n }\n }\n },\n _helpers = {};\n\n var opts = $.extend(true, defaults, options);\n\n\n /**\n * Require the html element if it has been lost\n *\n * @return {object} javascript object for html element\n */\n _helpers.getElement = function() {\n if (!element.id) {\n element.id = _helpers.makeId(element);\n }\n\n return document.getElementById(element.id);\n };\n\n /**\n * Make an ID for this element using current date and tag\n *\n * @param {Boolean} element\n * @return {String} new id for element\n */\n _helpers.makeId = function(element) {\n let epoch = new Date().getTime();\n\n return `${element.tagName}-${epoch}`;\n };\n\n if (!opts.formData && element) {\n element = _helpers.getElement();\n opts.formData = element.value;\n }\n\n /**\n * Generate markup wrapper where needed\n *\n * @param {string} tag\n * @param {String|Array|Object} content we wrap this\n * @param {object} attrs\n * @return {String}\n */\n _helpers.markup = function(tag, content = '', attrs = {}) {\n let contentType,\n field = document.createElement(tag),\n getContentType = function(content) {\n return Array.isArray(content) ? 'array' : typeof content;\n },\n appendContent = {\n string: function(content) {\n field.innerHTML = content;\n },\n object: function(content) {\n return field.appendChild(content);\n },\n array: function(content) {\n for (var i = 0; i < content.length; i++) {\n contentType = getContentType(content[i]);\n appendContent[contentType](content[i]);\n }\n }\n };\n\n for (var attr in attrs) {\n if (attrs.hasOwnProperty(attr)) {\n let name = _helpers.safeAttrName(attr);\n field.setAttribute(name, attrs[attr]);\n }\n }\n\n contentType = getContentType(content);\n\n if (content) {\n appendContent[contentType].call(this, content);\n }\n\n return field;\n };\n\n /**\n * Generate preview markup\n * @param {object} field\n * @return {string} preview markup for field\n * @todo\n */\n _helpers.fieldRender = function(field) {\n var fieldMarkup = '',\n fieldLabel = '',\n optionsMarkup = '';\n var fieldAttrs = _helpers.parseAttrs(field.attributes),\n fieldLabelText = fieldAttrs.label || '',\n fieldDesc = fieldAttrs.description || '',\n fieldRequired = '',\n fieldOptions = $('option', field);\n fieldAttrs.id = fieldAttrs.name;\n\n fieldAttrs.type = fieldAttrs.subtype || fieldAttrs.type;\n\n if (fieldAttrs.required) {\n fieldAttrs.required = null;\n fieldAttrs['aria-required'] = 'true';\n fieldRequired = `
`;\n }\n\n if (fieldAttrs.type !== 'hidden') {\n if (fieldDesc) {\n fieldDesc = `
`;\n }\n\n var fieldLabelVal = fieldAttrs.label;\n\n delete fieldAttrs.label;\n delete fieldAttrs.description;\n\n var fieldAttrsString = _helpers.attrString(fieldAttrs);\n\n switch (fieldAttrs.type) {\n case 'textarea':\n case 'rich-text':\n delete fieldAttrs.type;\n delete fieldAttrs.value;\n fieldMarkup = `${fieldLabel}
`;\n break;\n case 'select':\n fieldAttrs.type = fieldAttrs.type.replace('-group', '');\n\n if (fieldOptions.length) {\n fieldOptions.each(function(index, el) {\n index = index;\n let optionAttrs = _helpers.parseAttrs(el.attributes),\n optionAttrsString = _helpers.attrString(optionAttrs);\n optionsMarkup += `
`;\n break;\n case 'checkbox-group':\n case 'radio-group':\n fieldAttrs.type = fieldAttrs.type.replace('-group', '');\n\n // delete fieldAttrs.className;\n\n if (fieldOptions.length) {\n let optionName = fieldAttrs.type === 'checkbox' ? fieldAttrs.name + '[]' : fieldAttrs.name;\n fieldOptions.each(function(index, el) {\n let optionAttrs = Object.assign({}, fieldAttrs, _helpers.parseAttrs(el.attributes)),\n optionAttrsString;\n\n if (optionAttrs.selected) {\n delete optionAttrs.selected;\n optionAttrs.checked = null;\n }\n\n optionAttrs.name = optionName;\n optionAttrs.id = fieldAttrs.id + '-' + index;\n optionAttrsString = _helpers.attrString(optionAttrs);\n optionsMarkup += `
`;\n break;\n case 'text':\n case 'password':\n case 'email':\n case 'file':\n case 'hidden':\n case 'date':\n case 'autocomplete':\n fieldMarkup = `${fieldLabel}
${opts.label.selectColor}`;\n break;\n case 'button':\n case 'submit':\n fieldMarkup = `
${fieldLabel}`;\n\n if (fieldAttrs.toggle) {\n setTimeout(function() {\n $(document.getElementById(fieldAttrs.id)).kcToggle();\n }, 100);\n }\n break;\n default:\n fieldMarkup = `<${fieldAttrs.type}>${fieldLabelText}${fieldAttrs.type}>`;\n }\n\n if (fieldAttrs.type !== 'hidden') {\n let className = fieldAttrs.id ? 'form-group field-' + fieldAttrs.id : '';\n fieldMarkup = _helpers.markup('div', fieldMarkup, {\n className: className\n });\n } else {\n fieldMarkup = _helpers.markup('input', null, fieldAttrs);\n }\n\n return fieldMarkup;\n };\n\n /**\n * Convert camelCase into lowercase-hyphen\n *\n * @param {string} str\n * @return {string}\n */\n _helpers.hyphenCase = (str) => {\n str = str.replace(/[^\\w\\s\\-]/gi, '');\n str = str.replace(/([A-Z])/g, function($1) {\n return '-' + $1.toLowerCase();\n });\n\n return str.replace(/\\s/g, '-').replace(/^-+/g, '');\n };\n\n _helpers.attrString = function(attrs) {\n let attributes = [];\n\n for (var attr in attrs) {\n if (attrs.hasOwnProperty(attr)) {\n attr = _helpers.safeAttr(attr, attrs[attr]);\n attributes.push(attr.name + attr.value);\n }\n }\n return attributes.join(' ');\n };\n\n _helpers.safeAttr = function(name, value) {\n let safeAttr = {\n className: 'class'\n };\n\n name = safeAttr[name] || name;\n value = value ? window.JSON.stringify(value) : false;\n value = value ? `=${value}` : '';\n\n return {\n name,\n value\n };\n };\n\n _helpers.safeAttrName = function(name) {\n let safeAttr = {\n className: 'class'\n };\n\n return safeAttr[name] || _helpers.hyphenCase(name);\n };\n\n _helpers.parseAttrs = function(attrNodes) {\n var fieldAttrs = {};\n for (var attr in attrNodes) {\n if (attrNodes.hasOwnProperty(attr)) {\n fieldAttrs[attrNodes[attr].name] = attrNodes[attr].value;\n }\n }\n return fieldAttrs;\n };\n\n /**\n * Extend Element prototype to allow us to append fields\n *\n * @param {object} fields Node elements\n */\n Element.prototype.appendFormFields = function(fields) {\n var element = this;\n fields.reverse();\n for (var i = fields.length - 1; i >= 0; i--) {\n element.appendChild(fields[i]);\n }\n };\n\n /**\n * Extend Element prototype to remove content\n */\n Element.prototype.emptyContainer = function() {\n var element = this;\n while (element.lastChild) {\n element.removeChild(element.lastChild);\n }\n };\n\n // Begin the core plugin\n var rendered = [];\n\n var formData = $.parseXML(opts.formData),\n fields = $('field', formData);\n // @todo - form configuration settings (control position, creatorId, theme etc)\n // settings = $('settings', formData);\n\n // generate field markup if we have fields\n if (fields.length) {\n fields.each(function(index, field) {\n index = index;\n rendered.push(_helpers.fieldRender(field));\n });\n } else {\n let noData = _helpers.markup('div', opts.label.noFormData, {\n className: 'no-form-data'\n });\n rendered.push(noData);\n opts.notify.error(opts.label.noFormData);\n }\n\n if (opts.render) {\n if (opts.container) {\n opts.container = (opts.container instanceof jQuery) ? opts.container[0] : opts.container;\n opts.container.emptyContainer();\n opts.container.appendFormFields(rendered);\n } else if (element) {\n let renderedFormWrap = document.querySelector('.rendered-form');\n if (renderedFormWrap) {\n renderedFormWrap.emptyContainer();\n renderedFormWrap.appendFormFields(rendered);\n } else {\n renderedFormWrap = _helpers.markup('div', rendered, { className: 'rendered-form' });\n element.parentNode.insertBefore(renderedFormWrap, element.nextSibling);\n element.style.display = 'none';\n element.setAttribute('disabled', 'disabled');\n }\n }\n if (fields.length) {\n opts.notify.success(opts.label.formRendered);\n }\n } else {\n formRender.markup = rendered.map(function(elem) {\n return elem.innerHTML;\n }).join('');\n }\n\n return formRender;\n}\n\n(function($) {\n\n $.fn.formRender = function(options) {\n this.each(function() {\n let formRender = new FormRenderFn(options, this);\n return formRender;\n });\n };\n\n})(jQuery);\n","(function($) {\n 'use strict';\n\n var Toggle = function(element, options) {\n\n var defaults = {\n theme: 'fresh',\n labels: {\n off: 'Off',\n on: 'On'\n }\n };\n\n var opts = $.extend(defaults, options),\n $kcToggle = $('
').insertAfter(element).append(element);\n\n $kcToggle.toggleClass('on', element.is(':checked'));\n\n var kctOn = `
${opts.labels.on}
`,\n kctOff = `
${opts.labels.off}
`,\n kctHandle = `
`,\n kctInner = `
${kctOn}${kctHandle}${kctOff}
`;\n\n $kcToggle.append(kctInner);\n\n $kcToggle.click(function() {\n element.attr('checked', !element.attr('checked'));\n $(this).toggleClass('on');\n });\n\n };\n\n $.fn.kcToggle = function(options) {\n var toggle = this;\n return toggle.each(function() {\n var element = $(this);\n if (element.data('kcToggle')) {\n return;\n }\n var kcToggle = new Toggle(element, options);\n element.data('kcToggle', kcToggle);\n });\n };\n\n})(jQuery);\n"],"sourceRoot":"/source/"}
\ No newline at end of file
+{"version":3,"sources":["form-render.min.js","form-render.js","kc-toggle.js"],"names":["FormRenderFn","options","element","formRender","this","defaults","destroyTemplate","container","dataType","formData","label","selectColor","noFormData","formRendered","render","notify","error","message","console","success","log","warning","warn","_helpers","opts","$","extend","getElement","id","makeId","document","getElementById","epoch","Date","getTime","tagName","value","markup","tag","content","arguments","length","undefined","attrs","contentType","field","createElement","getContentType","Array","isArray","_typeof","appendContent","string","innerHTML","object","appendChild","array","i","attr","hasOwnProperty","name","safeAttrName","setAttribute","call","fieldRender","fieldMarkup","fieldLabel","optionsMarkup","fieldAttrs","parseAttrs","attributes","fieldLabelText","fieldDesc","description","fieldRequired","fieldOptions","type","subtype","required","fieldLabelVal","fieldAttrsString","attrString","replace","each","index","el","optionAttrs","optionAttrsString","textContent","optionName","Object","assign","selected","checked","toggle","setTimeout","kcToggle","className","hyphenCase","str","$1","toLowerCase","safeAttr","push","join","window","JSON","stringify","attrNodes","Element","prototype","appendFormFields","fields","reverse","emptyContainer","lastChild","removeChild","rendered","parseXML","noData","jQuery","renderedFormWrap","querySelector","parentNode","insertBefore","nextSibling","style","display","map","elem","Toggle","theme","labels","off","on","$kcToggle","insertAfter","append","toggleClass","is","kctOn","kctOff","kctHandle","kctInner","click","fn","data","Symbol","iterator","obj","constructor"],"mappings":"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","file":"form-render.min.js","sourcesContent":["'use strict';\n\n(function ($) {\n 'use strict';\n\n var Toggle = function Toggle(element, options) {\n\n var defaults = {\n theme: 'fresh',\n labels: {\n off: 'Off',\n on: 'On'\n }\n };\n\n var opts = $.extend(defaults, options),\n $kcToggle = $('
').insertAfter(element).append(element);\n\n $kcToggle.toggleClass('on', element.is(':checked'));\n\n var kctOn = '
' + opts.labels.on + '
',\n kctOff = '
' + opts.labels.off + '
',\n kctHandle = '
',\n kctInner = '
' + kctOn + kctHandle + kctOff + '
';\n\n $kcToggle.append(kctInner);\n\n $kcToggle.click(function () {\n element.attr('checked', !element.attr('checked'));\n $(this).toggleClass('on');\n });\n };\n\n $.fn.kcToggle = function (options) {\n var toggle = this;\n return toggle.each(function () {\n var element = $(this);\n if (element.data('kcToggle')) {\n return;\n }\n var kcToggle = new Toggle(element, options);\n element.data('kcToggle', kcToggle);\n });\n };\n})(jQuery);\n'use strict';\n// render the formBuilder XML into html\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol ? \"symbol\" : typeof obj; };\n\nfunction FormRenderFn(options, element) {\n\n var formRender = this,\n defaults = {\n destroyTemplate: true, // @todo\n container: false,\n dataType: 'xml',\n formData: false,\n label: {\n selectColor: 'Select Color',\n noFormData: 'No form data.',\n formRendered: 'Form Rendered'\n },\n render: true,\n notify: {\n error: function error(message) {\n return console.error(message);\n },\n success: function success(message) {\n return console.log(message);\n },\n warning: function warning(message) {\n return console.warn(message);\n }\n }\n },\n _helpers = {};\n\n var opts = $.extend(true, defaults, options);\n\n /**\n * Require the html element if it has been lost\n *\n * @return {object} javascript object for html element\n */\n _helpers.getElement = function () {\n if (!element.id) {\n element.id = _helpers.makeId(element);\n }\n\n return document.getElementById(element.id);\n };\n\n /**\n * Make an ID for this element using current date and tag\n *\n * @param {Boolean} element\n * @return {String} new id for element\n */\n _helpers.makeId = function (element) {\n var epoch = new Date().getTime();\n\n return element.tagName + '-' + epoch;\n };\n\n if (!opts.formData && element) {\n element = _helpers.getElement();\n opts.formData = element.value;\n }\n\n /**\n * Generate markup wrapper where needed\n *\n * @param {string} tag\n * @param {String|Array|Object} content we wrap this\n * @param {object} attrs\n * @return {String}\n */\n _helpers.markup = function (tag) {\n var content = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];\n var attrs = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];\n\n var contentType = void 0,\n field = document.createElement(tag),\n getContentType = function getContentType(content) {\n return Array.isArray(content) ? 'array' : typeof content === 'undefined' ? 'undefined' : _typeof(content);\n },\n appendContent = {\n string: function string(content) {\n field.innerHTML = content;\n },\n object: function object(content) {\n return field.appendChild(content);\n },\n array: function array(content) {\n for (var i = 0; i < content.length; i++) {\n contentType = getContentType(content[i]);\n appendContent[contentType](content[i]);\n }\n }\n };\n\n for (var attr in attrs) {\n if (attrs.hasOwnProperty(attr)) {\n var name = _helpers.safeAttrName(attr);\n field.setAttribute(name, attrs[attr]);\n }\n }\n\n contentType = getContentType(content);\n\n if (content) {\n appendContent[contentType].call(this, content);\n }\n\n return field;\n };\n\n /**\n * Generate preview markup\n * @param {object} field\n * @return {string} preview markup for field\n * @todo\n */\n _helpers.fieldRender = function (field) {\n var fieldMarkup = '',\n fieldLabel = '',\n optionsMarkup = '';\n var fieldAttrs = _helpers.parseAttrs(field.attributes),\n fieldLabelText = fieldAttrs.label || '',\n fieldDesc = fieldAttrs.description || '',\n fieldRequired = '',\n fieldOptions = $('option', field);\n fieldAttrs.id = fieldAttrs.name;\n\n fieldAttrs.type = fieldAttrs.subtype || fieldAttrs.type;\n\n if (fieldAttrs.required) {\n fieldAttrs.required = null;\n fieldAttrs['aria-required'] = 'true';\n fieldRequired = '
* ';\n }\n\n if (fieldAttrs.type !== 'hidden') {\n if (fieldDesc) {\n fieldDesc = '
? ';\n }\n fieldLabel = '
' + fieldLabelText + ' ' + fieldRequired + ' ' + fieldDesc + ' ';\n }\n\n var fieldLabelVal = fieldAttrs.label;\n\n delete fieldAttrs.label;\n delete fieldAttrs.description;\n\n var fieldAttrsString = _helpers.attrString(fieldAttrs);\n\n switch (fieldAttrs.type) {\n case 'textarea':\n case 'rich-text':\n delete fieldAttrs.type;\n delete fieldAttrs.value;\n fieldMarkup = fieldLabel + '
';\n break;\n case 'select':\n fieldAttrs.type = fieldAttrs.type.replace('-group', '');\n\n if (fieldOptions.length) {\n fieldOptions.each(function (index, el) {\n index = index;\n var optionAttrs = _helpers.parseAttrs(el.attributes),\n optionAttrsString = _helpers.attrString(optionAttrs);\n optionsMarkup += '
' + el.textContent + ' ';\n });\n }\n fieldMarkup = fieldLabel + '
' + optionsMarkup + ' ';\n break;\n case 'checkbox-group':\n case 'radio-group':\n fieldAttrs.type = fieldAttrs.type.replace('-group', '');\n\n // delete fieldAttrs.className;\n\n if (fieldOptions.length) {\n (function () {\n var optionName = fieldAttrs.type === 'checkbox' ? fieldAttrs.name + '[]' : fieldAttrs.name;\n fieldOptions.each(function (index, el) {\n var optionAttrs = Object.assign({}, fieldAttrs, _helpers.parseAttrs(el.attributes)),\n optionAttrsString = void 0;\n\n if (optionAttrs.selected) {\n delete optionAttrs.selected;\n optionAttrs.checked = null;\n }\n\n optionAttrs.name = optionName;\n optionAttrs.id = fieldAttrs.id + '-' + index;\n optionAttrsString = _helpers.attrString(optionAttrs);\n optionsMarkup += '
' + el.textContent + ' ';\n });\n })();\n }\n fieldMarkup = fieldLabel + '
' + optionsMarkup + '
';\n break;\n case 'text':\n case 'password':\n case 'email':\n case 'file':\n case 'hidden':\n case 'date':\n case 'autocomplete':\n fieldMarkup = fieldLabel + '
';\n break;\n case 'color':\n fieldMarkup = fieldLabel + '
' + opts.label.selectColor;\n break;\n case 'button':\n case 'submit':\n fieldMarkup = '
' + fieldLabelVal + ' ';\n break;\n case 'checkbox':\n fieldMarkup = '
' + fieldLabel;\n\n if (fieldAttrs.toggle) {\n setTimeout(function () {\n $(document.getElementById(fieldAttrs.id)).kcToggle();\n }, 100);\n }\n break;\n default:\n fieldMarkup = '<' + fieldAttrs.type + ' ' + fieldAttrsString + '>' + fieldLabelVal + '' + fieldAttrs.type + '>';\n }\n\n if (fieldAttrs.type !== 'hidden') {\n var className = fieldAttrs.id ? 'form-group field-' + fieldAttrs.id : '';\n fieldMarkup = _helpers.markup('div', fieldMarkup, {\n className: className\n });\n } else {\n fieldMarkup = _helpers.markup('input', null, fieldAttrs);\n }\n\n return fieldMarkup;\n };\n\n /**\n * Convert camelCase into lowercase-hyphen\n *\n * @param {string} str\n * @return {string}\n */\n _helpers.hyphenCase = function (str) {\n str = str.replace(/[^\\w\\s\\-]/gi, '');\n str = str.replace(/([A-Z])/g, function ($1) {\n return '-' + $1.toLowerCase();\n });\n\n return str.replace(/\\s/g, '-').replace(/^-+/g, '');\n };\n\n _helpers.attrString = function (attrs) {\n var attributes = [];\n\n for (var attr in attrs) {\n if (attrs.hasOwnProperty(attr)) {\n attr = _helpers.safeAttr(attr, attrs[attr]);\n attributes.push(attr.name + attr.value);\n }\n }\n return attributes.join(' ');\n };\n\n _helpers.safeAttr = function (name, value) {\n var safeAttr = {\n className: 'class'\n };\n\n name = safeAttr[name] || name;\n value = value ? window.JSON.stringify(value) : false;\n value = value ? '=' + value : '';\n\n return {\n name: name,\n value: value\n };\n };\n\n _helpers.safeAttrName = function (name) {\n var safeAttr = {\n className: 'class'\n };\n\n return safeAttr[name] || _helpers.hyphenCase(name);\n };\n\n _helpers.parseAttrs = function (attrNodes) {\n var fieldAttrs = {};\n for (var attr in attrNodes) {\n if (attrNodes.hasOwnProperty(attr)) {\n fieldAttrs[attrNodes[attr].name] = attrNodes[attr].value;\n }\n }\n return fieldAttrs;\n };\n\n /**\n * Extend Element prototype to allow us to append fields\n *\n * @param {object} fields Node elements\n */\n Element.prototype.appendFormFields = function (fields) {\n var element = this;\n fields.reverse();\n for (var i = fields.length - 1; i >= 0; i--) {\n element.appendChild(fields[i]);\n }\n };\n\n /**\n * Extend Element prototype to remove content\n */\n Element.prototype.emptyContainer = function () {\n var element = this;\n while (element.lastChild) {\n element.removeChild(element.lastChild);\n }\n };\n\n // Begin the core plugin\n var rendered = [];\n\n var formData = $.parseXML(opts.formData),\n fields = $('field', formData);\n // @todo - form configuration settings (control position, creatorId, theme etc)\n // settings = $('settings', formData);\n\n // generate field markup if we have fields\n if (fields.length) {\n fields.each(function (index, field) {\n index = index;\n rendered.push(_helpers.fieldRender(field));\n });\n } else {\n var noData = _helpers.markup('div', opts.label.noFormData, {\n className: 'no-form-data'\n });\n rendered.push(noData);\n opts.notify.error(opts.label.noFormData);\n }\n\n if (opts.render) {\n if (opts.container) {\n opts.container = opts.container instanceof jQuery ? opts.container[0] : opts.container;\n opts.container.emptyContainer();\n opts.container.appendFormFields(rendered);\n } else if (element) {\n var renderedFormWrap = document.querySelector('.rendered-form');\n if (renderedFormWrap) {\n renderedFormWrap.emptyContainer();\n renderedFormWrap.appendFormFields(rendered);\n } else {\n renderedFormWrap = _helpers.markup('div', rendered, { className: 'rendered-form' });\n element.parentNode.insertBefore(renderedFormWrap, element.nextSibling);\n element.style.display = 'none';\n element.setAttribute('disabled', 'disabled');\n }\n }\n if (fields.length) {\n opts.notify.success(opts.label.formRendered);\n }\n } else {\n formRender.markup = rendered.map(function (elem) {\n return elem.innerHTML;\n }).join('');\n }\n\n return formRender;\n}\n\n(function ($) {\n\n $.fn.formRender = function (options) {\n this.each(function () {\n var formRender = new FormRenderFn(options, this);\n return formRender;\n });\n };\n})(jQuery);","'use strict';\n// render the formBuilder XML into html\nfunction FormRenderFn(options, element) {\n\n var formRender = this,\n defaults = {\n destroyTemplate: true, // @todo\n container: false,\n dataType: 'xml',\n formData: false,\n label: {\n selectColor: 'Select Color',\n noFormData: 'No form data.',\n formRendered: 'Form Rendered'\n },\n render: true,\n notify: {\n error: function(message) {\n return console.error(message);\n },\n success: function(message) {\n return console.log(message);\n },\n warning: function(message) {\n return console.warn(message);\n }\n }\n },\n _helpers = {};\n\n var opts = $.extend(true, defaults, options);\n\n\n /**\n * Require the html element if it has been lost\n *\n * @return {object} javascript object for html element\n */\n _helpers.getElement = function() {\n if (!element.id) {\n element.id = _helpers.makeId(element);\n }\n\n return document.getElementById(element.id);\n };\n\n /**\n * Make an ID for this element using current date and tag\n *\n * @param {Boolean} element\n * @return {String} new id for element\n */\n _helpers.makeId = function(element) {\n let epoch = new Date().getTime();\n\n return `${element.tagName}-${epoch}`;\n };\n\n if (!opts.formData && element) {\n element = _helpers.getElement();\n opts.formData = element.value;\n }\n\n /**\n * Generate markup wrapper where needed\n *\n * @param {string} tag\n * @param {String|Array|Object} content we wrap this\n * @param {object} attrs\n * @return {String}\n */\n _helpers.markup = function(tag, content = '', attrs = {}) {\n let contentType,\n field = document.createElement(tag),\n getContentType = function(content) {\n return Array.isArray(content) ? 'array' : typeof content;\n },\n appendContent = {\n string: function(content) {\n field.innerHTML = content;\n },\n object: function(content) {\n return field.appendChild(content);\n },\n array: function(content) {\n for (var i = 0; i < content.length; i++) {\n contentType = getContentType(content[i]);\n appendContent[contentType](content[i]);\n }\n }\n };\n\n for (var attr in attrs) {\n if (attrs.hasOwnProperty(attr)) {\n let name = _helpers.safeAttrName(attr);\n field.setAttribute(name, attrs[attr]);\n }\n }\n\n contentType = getContentType(content);\n\n if (content) {\n appendContent[contentType].call(this, content);\n }\n\n return field;\n };\n\n /**\n * Generate preview markup\n * @param {object} field\n * @return {string} preview markup for field\n * @todo\n */\n _helpers.fieldRender = function(field) {\n var fieldMarkup = '',\n fieldLabel = '',\n optionsMarkup = '';\n var fieldAttrs = _helpers.parseAttrs(field.attributes),\n fieldLabelText = fieldAttrs.label || '',\n fieldDesc = fieldAttrs.description || '',\n fieldRequired = '',\n fieldOptions = $('option', field);\n fieldAttrs.id = fieldAttrs.name;\n\n fieldAttrs.type = fieldAttrs.subtype || fieldAttrs.type;\n\n if (fieldAttrs.required) {\n fieldAttrs.required = null;\n fieldAttrs['aria-required'] = 'true';\n fieldRequired = `
* `;\n }\n\n if (fieldAttrs.type !== 'hidden') {\n if (fieldDesc) {\n fieldDesc = `
? `;\n }\n fieldLabel = `
${fieldLabelText} ${fieldRequired} ${fieldDesc} `;\n }\n\n var fieldLabelVal = fieldAttrs.label;\n\n delete fieldAttrs.label;\n delete fieldAttrs.description;\n\n var fieldAttrsString = _helpers.attrString(fieldAttrs);\n\n switch (fieldAttrs.type) {\n case 'textarea':\n case 'rich-text':\n delete fieldAttrs.type;\n delete fieldAttrs.value;\n fieldMarkup = `${fieldLabel}
`;\n break;\n case 'select':\n fieldAttrs.type = fieldAttrs.type.replace('-group', '');\n\n if (fieldOptions.length) {\n fieldOptions.each(function(index, el) {\n index = index;\n let optionAttrs = _helpers.parseAttrs(el.attributes),\n optionAttrsString = _helpers.attrString(optionAttrs);\n optionsMarkup += `
${el.textContent} `;\n });\n }\n fieldMarkup = `${fieldLabel}
${optionsMarkup} `;\n break;\n case 'checkbox-group':\n case 'radio-group':\n fieldAttrs.type = fieldAttrs.type.replace('-group', '');\n\n // delete fieldAttrs.className;\n\n if (fieldOptions.length) {\n let optionName = fieldAttrs.type === 'checkbox' ? fieldAttrs.name + '[]' : fieldAttrs.name;\n fieldOptions.each(function(index, el) {\n let optionAttrs = Object.assign({}, fieldAttrs, _helpers.parseAttrs(el.attributes)),\n optionAttrsString;\n\n if (optionAttrs.selected) {\n delete optionAttrs.selected;\n optionAttrs.checked = null;\n }\n\n optionAttrs.name = optionName;\n optionAttrs.id = fieldAttrs.id + '-' + index;\n optionAttrsString = _helpers.attrString(optionAttrs);\n optionsMarkup += `
${el.textContent} `;\n });\n }\n fieldMarkup = `${fieldLabel}
${optionsMarkup}
`;\n break;\n case 'text':\n case 'password':\n case 'email':\n case 'file':\n case 'hidden':\n case 'date':\n case 'autocomplete':\n fieldMarkup = `${fieldLabel}
`;\n break;\n case 'color':\n fieldMarkup = `${fieldLabel}
${opts.label.selectColor}`;\n break;\n case 'button':\n case 'submit':\n fieldMarkup = `
${fieldLabelVal} `;\n break;\n case 'checkbox':\n fieldMarkup = `
${fieldLabel}`;\n\n if (fieldAttrs.toggle) {\n setTimeout(function() {\n $(document.getElementById(fieldAttrs.id)).kcToggle();\n }, 100);\n }\n break;\n default:\n fieldMarkup = `<${fieldAttrs.type} ${fieldAttrsString}>${fieldLabelVal}${fieldAttrs.type}>`;\n }\n\n if (fieldAttrs.type !== 'hidden') {\n let className = fieldAttrs.id ? 'form-group field-' + fieldAttrs.id : '';\n fieldMarkup = _helpers.markup('div', fieldMarkup, {\n className: className\n });\n } else {\n fieldMarkup = _helpers.markup('input', null, fieldAttrs);\n }\n\n return fieldMarkup;\n };\n\n /**\n * Convert camelCase into lowercase-hyphen\n *\n * @param {string} str\n * @return {string}\n */\n _helpers.hyphenCase = (str) => {\n str = str.replace(/[^\\w\\s\\-]/gi, '');\n str = str.replace(/([A-Z])/g, function($1) {\n return '-' + $1.toLowerCase();\n });\n\n return str.replace(/\\s/g, '-').replace(/^-+/g, '');\n };\n\n _helpers.attrString = function(attrs) {\n let attributes = [];\n\n for (var attr in attrs) {\n if (attrs.hasOwnProperty(attr)) {\n attr = _helpers.safeAttr(attr, attrs[attr]);\n attributes.push(attr.name + attr.value);\n }\n }\n return attributes.join(' ');\n };\n\n _helpers.safeAttr = function(name, value) {\n let safeAttr = {\n className: 'class'\n };\n\n name = safeAttr[name] || name;\n value = value ? window.JSON.stringify(value) : false;\n value = value ? `=${value}` : '';\n\n return {\n name,\n value\n };\n };\n\n _helpers.safeAttrName = function(name) {\n let safeAttr = {\n className: 'class'\n };\n\n return safeAttr[name] || _helpers.hyphenCase(name);\n };\n\n _helpers.parseAttrs = function(attrNodes) {\n var fieldAttrs = {};\n for (var attr in attrNodes) {\n if (attrNodes.hasOwnProperty(attr)) {\n fieldAttrs[attrNodes[attr].name] = attrNodes[attr].value;\n }\n }\n return fieldAttrs;\n };\n\n /**\n * Extend Element prototype to allow us to append fields\n *\n * @param {object} fields Node elements\n */\n Element.prototype.appendFormFields = function(fields) {\n var element = this;\n fields.reverse();\n for (var i = fields.length - 1; i >= 0; i--) {\n element.appendChild(fields[i]);\n }\n };\n\n /**\n * Extend Element prototype to remove content\n */\n Element.prototype.emptyContainer = function() {\n var element = this;\n while (element.lastChild) {\n element.removeChild(element.lastChild);\n }\n };\n\n // Begin the core plugin\n var rendered = [];\n\n var formData = $.parseXML(opts.formData),\n fields = $('field', formData);\n // @todo - form configuration settings (control position, creatorId, theme etc)\n // settings = $('settings', formData);\n\n // generate field markup if we have fields\n if (fields.length) {\n fields.each(function(index, field) {\n index = index;\n rendered.push(_helpers.fieldRender(field));\n });\n } else {\n let noData = _helpers.markup('div', opts.label.noFormData, {\n className: 'no-form-data'\n });\n rendered.push(noData);\n opts.notify.error(opts.label.noFormData);\n }\n\n if (opts.render) {\n if (opts.container) {\n opts.container = (opts.container instanceof jQuery) ? opts.container[0] : opts.container;\n opts.container.emptyContainer();\n opts.container.appendFormFields(rendered);\n } else if (element) {\n let renderedFormWrap = document.querySelector('.rendered-form');\n if (renderedFormWrap) {\n renderedFormWrap.emptyContainer();\n renderedFormWrap.appendFormFields(rendered);\n } else {\n renderedFormWrap = _helpers.markup('div', rendered, { className: 'rendered-form' });\n element.parentNode.insertBefore(renderedFormWrap, element.nextSibling);\n element.style.display = 'none';\n element.setAttribute('disabled', 'disabled');\n }\n }\n if (fields.length) {\n opts.notify.success(opts.label.formRendered);\n }\n } else {\n formRender.markup = rendered.map(function(elem) {\n return elem.innerHTML;\n }).join('');\n }\n\n return formRender;\n}\n\n(function($) {\n\n $.fn.formRender = function(options) {\n this.each(function() {\n let formRender = new FormRenderFn(options, this);\n return formRender;\n });\n };\n\n})(jQuery);\n","(function($) {\n 'use strict';\n\n var Toggle = function(element, options) {\n\n var defaults = {\n theme: 'fresh',\n labels: {\n off: 'Off',\n on: 'On'\n }\n };\n\n var opts = $.extend(defaults, options),\n $kcToggle = $('
').insertAfter(element).append(element);\n\n $kcToggle.toggleClass('on', element.is(':checked'));\n\n var kctOn = `
${opts.labels.on}
`,\n kctOff = `
${opts.labels.off}
`,\n kctHandle = `
`,\n kctInner = `
${kctOn}${kctHandle}${kctOff}
`;\n\n $kcToggle.append(kctInner);\n\n $kcToggle.click(function() {\n element.attr('checked', !element.attr('checked'));\n $(this).toggleClass('on');\n });\n\n };\n\n $.fn.kcToggle = function(options) {\n var toggle = this;\n return toggle.each(function() {\n var element = $(this);\n if (element.data('kcToggle')) {\n return;\n }\n var kcToggle = new Toggle(element, options);\n element.data('kcToggle', kcToggle);\n });\n };\n\n})(jQuery);\n"],"sourceRoot":"/source/"}
\ No newline at end of file
diff --git a/dist/form-builder.css b/dist/form-builder.css
index 9ef28082d..1f56c54aa 100644
--- a/dist/form-builder.css
+++ b/dist/form-builder.css
@@ -907,8 +907,7 @@ ol.sortable-options {
width: 100%;
height: 100%; }
-.kc-toggle
-.kct-on {
+.kc-toggle .kct-on {
color: #12a912; }
.kct-off {
diff --git a/dist/form-builder.js b/dist/form-builder.js
index 8c5ea9679..2f64a3bfa 100644
--- a/dist/form-builder.js
+++ b/dist/form-builder.js
@@ -587,7 +587,7 @@ function formBuilderHelpersFn(opts, formBuilder) {
var i,
preview = '',
epoch = new Date().getTime();
- attrs = Object.assign({}, attrs);
+ attrs = jQuery.extend({}, attrs);
attrs.type = attrs.subtype || attrs.type;
var toggle = attrs.toggle ? 'toggle' : '';
// attrs = _helpers.escapeAttrs(attrs);
@@ -644,7 +644,8 @@ function formBuilderHelpersFn(opts, formBuilder) {
preview = '
';
break;
default:
- preview = '<' + attrs.type + '>' + attrs.label + '' + attrs.type + '>';
+ attrsString = _helpers.attrString(attrs);
+ preview = '<' + attrs.type + ' ' + attrsString + '>' + attrs.label + '' + attrs.type + '>';
}
return preview;
diff --git a/dist/form-builder.min.js b/dist/form-builder.min.js
index 3ac928cf6..5c73a27b7 100644
--- a/dist/form-builder.min.js
+++ b/dist/form-builder.min.js
@@ -3,5 +3,5 @@ formBuilder - http://kevinchappell.github.io/formBuilder/
Version: 1.9.28
Author: Kevin Chappell
*/
-"use strict";function formBuilderHelpersFn(e,t){var a={doCancel:!1};return t.events=formBuilderEventsFn(),a.attrString=function(e){var t=[];for(var l in e)e.hasOwnProperty(l)&&(l=a.safeAttr(l,e[l]),t.push(l.name+l.value));var s=t.join(" ");return s},a.hyphenCase=function(e){return e=e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()}),e.replace(/\s/g,"-").replace(/^-+/g,"")},a.makeClassName=function(e){return e=e.replace(/[^\w\s\-]/gi,""),a.hyphenCase(e)},a.safeAttrName=function(e){var t={className:"class"};return t[e]||a.hyphenCase(e)},a.safeAttr=function(e,t){e=a.safeAttrName(e);var l=window.JSON.stringify(HTML_ENTITIES.encode(t));return t=t?"="+l:"",{name:e,value:t}},a.mobileClass=function(){var e="";return function(t){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=" fb-mobile")}(navigator.userAgent||navigator.vendor||window.opera),e},a.startMoving=function(e,t){e=e,t.item.show().addClass("moving"),a.startIndex=$("li",this).index(t.item)},a.stopMoving=function(e,t){e=e,t.item.removeClass("moving"),a.doCancel&&($(t.sender).sortable("cancel"),$(this).sortable("cancel")),a.save(),a.doCancel=!1},a.beforeStop=function(t,l){t=t;var s=document.getElementById(e.formID),o=s.children.length-1,r=[];a.stopIndex=l.placeholder.index()-1,!e.sortableControls&&l.item.parent().hasClass("frmb-control")&&r.push(!0),e.prepend&&r.push(0===a.stopIndex),e.append&&r.push(a.stopIndex+1===o),a.doCancel=r.some(function(e){return e===!0})},a.safename=function(e){return e.replace(/\s/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase()},a.forceNumber=function(e){return e.replace(/[^0-9]/g,"")},a.initTooltip=function(e){var t=e.find(".tooltip");e.mouseenter(function(){t.outerWidth()>200&&t.addClass("max-width"),t.css("left",e.width()+14),t.stop(!0,!0).fadeIn("fast")}).mouseleave(function(){e.find(".tooltip").stop(!0,!0).fadeOut("fast")}),t.hide()},a.getTypes=function(e){return{type:e.attr("type"),subtype:$(".fld-subtype",e).val()}},a.trimAttrs=function(e){var t=[null,void 0,"",!1];for(var l in e)a.inArray(e[l],t)&&delete e[l];return e},a.escapeAttrs=function(e){for(var t in e)e.hasOwnProperty(t)&&(e[t]=HTML_ENTITIES.encode(e[t]));return e},a.xmlSave=function(e){var l=$(e).toXML(a);return window.JSON.stringify(l)===window.JSON.stringify(t.formData)?!1:void(t.formData=l)},a.jsonSave=function(){e.notify.warning("json data not available yet")},a.save=function(){var l,s=a.getElement(),o=document.getElementById(e.formID),r={xml:a.xmlSave,json:a.jsonSave};return l=r[e.dataType](o),s&&(s.value=t.formData,window.jQuery?$(s).trigger("change"):s.onchange()),document.dispatchEvent(t.events.formSaved),l},a.getElement=function(){var l=!1;return t.element&&(l=t.element,l.id||a.makeId(l),l.onchange||(l.onchange=function(){e.notify.success(e.messages.formUpdated)})),l},a.incrementId=function(e){var t=e.lastIndexOf("-"),a=parseInt(e.substring(t+1))+1,l=e.substring(0,t);return l+"-"+a},a.makeId=function(){var e=arguments.length<=0||void 0===arguments[0]?!1:arguments[0],t=(new Date).getTime();return e.tagName+"-"+t},a.updatePreview=function(e){var t=e.data("fieldData")||{},l=e.attr("class");if(-1===l.indexOf("ui-sortable-handle")){var s,o=$(e).attr("type"),r=$(".prev-holder",e),n={label:$(".fld-label",e).val(),type:o},i=$(".fld-subtype",e).val();i&&(n.subtype=i);var c=$(".fld-maxlength",e).val();c&&(n.maxlength=c),n.className=$(".fld-className",e).val()||t.className||"";var d=$(".fld-placeholder",e).val();d&&(n.placeholder=d);var u=$(".btn-style",e).val();u&&(n.style=u),"checkbox"===o&&(n.toggle=$(".checkbox-toggle",e).is(":checked")),o.match(/(select|checkbox-group|radio-group)/)&&(n.values=[],n.multiple=$('[name="multiple"]',e).is(":checked"),$(".sortable-options li",e).each(function(){var e={};e.selected=$(".option-selected",this).is(":checked"),e.value=$(".option-value",this).val(),e.label=$(".option-label",this).val(),n.values.push(e)})),n.className=a.classNames(e,n),$(".fld-className",e).val(n.className),e.data("fieldData",n),s=a.fieldPreview(n),r.html(s),$("input[toggle]",r).kcToggle()}},a.fieldPreview=function(t){var l,s="",o=(new Date).getTime();t=Object.assign({},t),t.type=t.subtype||t.type;var r=t.toggle?"toggle":"",n=a.attrString(t);switch(t.type){case"textarea":case"rich-text":s="";break;case"button":case"submit":s=""+t.label+" ";break;case"select":var i="",c=t.multiple?"multiple":"";for(t.values.reverse(),t.placeholder&&(i+=""+t.placeholder+" "),l=t.values.length-1;l>=0;l--){var d=t.values[l].selected&&!t.placeholder?"selected":"";i+='"+t.values[l].label+" "}s="<"+t.type+' class="'+t.className+'" '+c+">"+i+""+t.type+">";break;case"checkbox-group":case"radio-group":var u=t.type.replace("-group",""),p=u+"-"+o;for(t.values.reverse(),l=t.values.length-1;l>=0;l--){var m=t.values[l].selected?"checked":"",f=u+"-"+o+"-"+l;s+=''+t.values[l].label+"
"}break;case"text":case"password":case"email":case"date":case"file":s=" ";break;case"color":s=' '+e.messages.selectColor;break;case"hidden":case"checkbox":s=' ";break;case"autocomplete":s=' ';break;default:s="<"+t.type+">"+t.label+""+t.type+">"}return s},a.updateMultipleSelect=function(){$(document.getElementById(e.formID)).on("change",'input[name="multiple"]',function(){var e=$(this).parents(".field-options:eq(0)").find(".sortable-options input.option-selected");this.checked?e.each(function(){$(this).prop("type","checkbox")}):e.each(function(){$(this).removeAttr("checked").prop("type","radio")})})},a.debounce=function(e){var t,a=arguments.length<=1||void 0===arguments[1]?250:arguments[1],l=arguments.length<=2||void 0===arguments[2]?!1:arguments[2];return function(){var s=this,o=arguments,r=function(){t=null,l||e.apply(s,o)},n=l&&!t;clearTimeout(t),t=setTimeout(r,a),n&&e.apply(s,o)}},a.htmlEncode=function(e){return $("
").text(e).html()},a.htmlDecode=function(e){return $("
").html(e).text()},a.validateForm=function(){var t=$(document.getElementById(e.formID)),a=[];$('input[name="label"], input[type="text"].option',t).each(function(){if(""===$(this).val()){var t=$(this).parents("li.form-field"),l=$(this);a.push({field:t,error:e.messages.labelEmpty,attribute:l})}}),a.length&&(alert("Error: "+a[0].error),$("html, body").animate({scrollTop:a[0].field.offset().top},1e3,function(){var e=$(".toggle-form",a[0].field).attr("id");$(".toggle-form",a[0].field).addClass("open").parent().next(".prev-holder").slideUp(250),$("#"+e+"-fld").slideDown(250,function(){a[0].attribute.addClass("error")})}))},a.disabledTT={className:"frmb-tt",add:function(t){var l=e.messages.fieldNonEditable;if(l){var s=a.markup("p",l,{className:a.disabledTT.className});t.append(s)}},remove:function(e){$(".frmb-tt",e).remove()}},a.classNames=function(t,l){var s=["checkbox","checkbox-group","radio-group"],o=["header","paragraph","button"],r=void 0;for(r=o.length-1;r>=0;r--)o=o.concat(e.messages.subtypes[o[r]]);s=s.concat(o);var n=l.type,i=l.style,c=t[0].querySelector(".fld-className").value,d=[].concat(c.split(" ")).reverse(),u={button:"btn",submit:"btn"},p=u[n];if(p){if(i){for(r=d.length-1;r>=0;r--){var m=new RegExp("(?:^|s)"+p+"-(.*?)(?:s|$)+","g"),f=d[r].match(m);f&&d.splice(r,1)}d.push(p+"-"+i)}d.push(p)}else a.inArray(n,s)||d.push("form-control");return a.unique(d.reverse()).join(" ").trim()},a.markup=function(e){var t=arguments.length<=1||void 0===arguments[1]?"":arguments[1],l=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],s=void 0,o=document.createElement(e),r=function(e){return Array.isArray(e)?"array":"undefined"==typeof e?"undefined":_typeof(e)},n={string:function(e){o.innerHTML=e},object:function(e){return o.appendChild(e)},array:function(e){for(var t=0;t=0;o--){var r=t.filter(function(e){return e.attrs.type===l[o]})[0];s.push(r)}return s.filter(Boolean)},a.forEach=function(e,t,a){for(var l=0;l1&&(t=e),t=a[e]})},e}(HTML_ENTITIES||{}),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};!function(e){var t=function(t,a){var l={theme:"fresh",labels:{off:"Off",on:"On"}},s=e.extend(l,a),o=e('
').insertAfter(t).append(t);o.toggleClass("on",t.is(":checked"));var r=''+s.labels.on+"
",n=''+s.labels.off+"
",i='
',c=''+r+i+n+"
";o.append(c),o.click(function(){t.attr("checked",!t.attr("checked")),e(this).toggleClass("on")})};e.fn.kcToggle=function(a){var l=this;return l.each(function(){var l=e(this);if(!l.data("kcToggle")){var s=new t(l,a);l.data("kcToggle",s)}})}}(jQuery),function(e){var t=function(t,a){var l=this,s={controlPosition:"right",controlOrder:["autocomplete","button","checkbox","checkbox-group","date","file","header","hidden","paragraph","radio-group","select","text","textarea"],dataType:"xml",disableFields:["autocomplete","hidden"],append:!1,prepend:!1,defaultFields:[],fieldRemoveWarn:!1,roles:{1:"Administrator"},messages:{addOption:"Add Option",allFieldsRemoved:"All fields were removed.",allowSelect:"Allow Select",autocomplete:"Autocomplete",button:"Button",cannotBeEmpty:"This field cannot be empty",checkboxGroup:"Checkbox Group",checkbox:"Checkbox",checkboxes:"Checkboxes",className:"Class",clearAllMessage:"Are you sure you want to clear all fields?",clearAll:"Clear",close:"Close",content:"Content",copy:"Copy To Clipboard",dateField:"Date Field",description:"Help Text",descriptionField:"Description",devMode:"Developer Mode",editNames:"Edit Names",editorTitle:"Form Elements",editXML:"Edit XML",fieldDeleteWarning:!1,fieldVars:"Field Variables",fieldNonEditable:"This field cannot be edited.",fieldRemoveWarning:"Are you sure you want to remove this field?",fileUpload:"File Upload",formUpdated:"Form Updated",getStarted:"Drag a field from the right to this area",header:"Header",hide:"Edit",hidden:"Hidden Input",label:"Label",labelEmpty:"Field Label cannot be empty",limitRole:"Limit access to one or more of the following roles:",mandatory:"Mandatory",maxlength:"Max Length",minOptionMessage:"This field requires a minimum of 2 options",name:"Name",no:"No",off:"Off",on:"On",option:"Option",optional:"optional",optionLabelPlaceholder:"Label",optionValuePlaceholder:"Value",optionEmpty:"Option value required",paragraph:"Paragraph",placeholder:"Placeholder",placeholders:{value:"Value",label:"Label",text:"",textarea:"",email:"Enter you email",placeholder:"",className:"space separated classes",password:"Enter your password"},preview:"Preview",radioGroup:"Radio Group",radio:"Radio",removeMessage:"Remove Element",remove:"×",required:"Required",richText:"Rich Text Editor",roles:"Access",save:"Save",selectOptions:"Options",select:"Select",selectColor:"Select Color",selectionsMessage:"Allow Multiple Selections",size:"Size",sizes:{xs:"Extra Small",sm:"Small",m:"Default",lg:"Large"},style:"Style",styles:{btn:{"default":"Default",danger:"Danger",info:"Info",primary:"Primary",success:"Success",warning:"Warning"}},subtype:"Type",subtypes:{text:["text","password","email","color"],button:["button","submit"],header:["h1","h2","h3"],paragraph:["p","address","blockquote","canvas","output"]},text:"Text Field",textArea:"Text Area",toggle:"Toggle",warning:"Warning!",viewXML:"</>",yes:"Yes"},notify:{error:function(e){return console.error(e)},success:function(e){return console.log(e)},warning:function(e){return console.warn(e)}},sortableControls:!1,prefix:"form-builder-"};s.messages.subtypes.password=s.messages.subtypes.text,s.messages.subtypes.email=s.messages.subtypes.text,s.messages.subtypes.color=s.messages.subtypes.text,s.messages.subtypes.submit=s.messages.subtypes.button;var o=e.extend(!0,s,t),r=e(a),n="frmb-"+e("ul[id^=frmb-]").length++;o.formID=n,l.element=a;var i=e("").attr("id",n).addClass("frmb"),c=formBuilderHelpersFn(o,l);l.layout=c.editorLayout(o.controlPosition);var d=n+"-fld-1",u=n+"-control-box",p=[{label:o.messages.textArea,attrs:{type:"textarea",className:"text-area",name:"textarea"}},{label:o.messages.text,attrs:{type:"text",className:"text-input",name:"text-input"}},{label:o.messages.select,attrs:{type:"select",className:"select",name:"select"}},{label:o.messages.radioGroup,attrs:{type:"radio-group",className:"radio-group",name:"radio-group"}},{label:o.messages.paragraph,attrs:{type:"paragraph",className:"paragraph"}},{label:o.messages.hidden,attrs:{type:"hidden",className:"hidden-input",name:"hidden-input"}},{label:o.messages.header,attrs:{type:"header",className:"header"}},{label:o.messages.fileUpload,attrs:{type:"file",className:"file-input",name:"file-input"}},{label:o.messages.dateField,attrs:{type:"date",className:"calendar",name:"date-input"}},{label:o.messages.checkboxGroup,attrs:{type:"checkbox-group",className:"checkbox-group",name:"checkbox-group"}},{label:o.messages.checkbox,attrs:{type:"checkbox",className:"checkbox",name:"checkbox"}},{label:o.messages.button,attrs:{type:"button",className:"button-input",name:"button"}},{label:o.messages.autocomplete,attrs:{type:"autocomplete",className:"autocomplete",name:"autocomplete"}}];p=c.orderFields(p),o.disableFields&&(p=p.filter(function(e){return!c.inArray(e.attrs.type,o.disableFields)}));var m=c.markup("ul",null,{id:u,className:"frmb-control"});o.sortableControls&&m.classList.add("sort-enabled");for(var f=e(m),v=p.length-1;v>=0;v--){var g=e(" ",{"class":"icon-"+p[v].attrs.className,type:p[v].type,name:p[v].className,label:p[v].label});g.data("newFieldData",p[v]);var h=c.markup("span",p[v].label);g.html(h).appendTo(f)}var b="xml"===o.dataType?o.messages.viewXML:o.messages.viewJSON,y=c.markup("button",b,{id:n+"-view-data",type:"button",className:"view-data btn btn-default"}),k=c.markup("button",o.messages.clearAll,{id:n+"-clear-all",type:"button",className:"clear-all btn btn-default"}),x=c.markup("button",o.messages.save,{className:"btn btn-primary "+o.prefix+"save",id:n+"-save",type:"button"}),w=c.markup("div",[k,y,x],{className:"form-actions btn-group"}).outerHTML;i.sortable({cursor:"move",opacity:.9,revert:150,beforeStop:c.beforeStop,start:c.startMoving,stop:c.stopMoving,cancel:"input, select, .disabled, .form-group, .btn",placeholder:"frmb-placeholder"}),f.sortable({helper:"clone",opacity:.9,connectWith:i,cursor:"move",placeholder:"ui-state-highlight",start:c.startMoving,stop:c.stopMoving,revert:150,beforeStop:c.beforeStop,update:function(e,t){return c.doCancel?!1:(e=e,void(t.item.parent()[0]===i[0]?(O(t.item,!0),c.doCancel=!0):(c.setFieldOrder(f),c.doCancel=!o.sortableControls)))}});var N=e("
",{id:n+"-stage-wrap","class":"stage-wrap "+l.layout.stage}),E=e("
",{id:n+"-form-wrap","class":"form-wrap form-builder"+c.mobileClass()});r.before(N).appendTo(N);var T=e("
",{id:n+"-cb-wrap","class":"cb-wrap "+l.layout.controls}).append(f[0],w);N.append(i,T),N.before(E),E.append(N,T);var C=c.debounce(function(t){if(t&&"keyup"===t.type&&"className"===this.name)return!1;var a=e(this).parents(".form-field:eq(0)");c.updatePreview(a),c.save()});i.on("change blur keyup",".form-elements input, .form-elements select, .form-elements textarea",C);var S=function(){var t=[];if(o.prepend&&!e(".disabled.prepend",i).length){var a=c.markup("li",o.prepend,{className:"disabled prepend"});t.push(!0),i.prepend(a)}if(o.append&&!e(".disabled.append",i).length){var l=c.markup("li",o.append,{className:"disabled append"});t.push(!0),i.append(l)}t.some(function(e){return e===!0})&&N.removeClass("empty")},O=function(t){var a=arguments.length<=1||void 0===arguments[1]?!1:arguments[1],l={};if(t instanceof jQuery){var s=t.data("newFieldData");if(s)l=s.attrs,l.label=s.label;else{var o=t[0].attributes;a||(l.values=t.children().map(function(t,a){return{label:e(a).text(),value:e(a).attr("value"),selected:Boolean(e(a).attr("selected"))}}));for(var r=o.length-1;r>=0;r--)l[o[r].name]=o[r].value}}else l=t;l.label=c.htmlEncode(l.label),l.name=a?M(l):l.name,l.role=l.role,l.className=l.className||l["class"],l.required="true"===l.required||l.required===!0,l.maxlength=l.maxlength,l.toggle=l.toggle,l.multiple=l.type.match(/(checkbox-group)/),l.description=void 0!==l.description?c.htmlEncode(l.description):"";var n=/(?:^|\s)btn-(.*?)(?:\s|$)/g.exec(l.className);n&&(l.style=n[1]),D(l),N.removeClass("empty")},A=function(){var t="";t=l.formData?l.formData:""!==r.val()?e.parseXML(l.element.value.trim()):!1;var a=e(t).find("field");if(a.length>0)l.formData=t,a.each(function(){O(e(this))});else if(!t)if(o.defaultFields&&o.defaultFields.length){o.defaultFields.reverse();for(var s=o.defaultFields.length-1;s>=0;s--)O(o.defaultFields[s]);N.removeClass("empty"),c.save()}else o.prepend||o.append||N.addClass("empty").attr("data-content",o.messages.getStarted);e("li.form-field:not(.disabled)",i).each(function(){c.updatePreview(e(this))}),S()},I=function(){var e={xml:A,json:function(){console.log("coming soon")}};e[o.dataType]()};i.on("mousemove","li.disabled",function(t){e(".frmb-tt",this).css({left:t.offsetX-16,top:t.offsetY-34})}),i.on("mouseenter","li.disabled",function(){c.disabledTT.add(e(this))}),i.on("mouseleave","li.disabled",function(){c.disabledTT.remove(e(this))});var M=function(e){var t=(new Date).getTime();return e.type+"-"+t},L=function(e){R(o.messages.textArea,H(e),e)},q=function(e){var t=e.type||"text";R(o.messages[t],H(e),e)},$=function(t){t.values&&t.values.length||(t.values=[{selected:!0},{selected:!1}],t.values=t.values.map(function(e,t){return e.label=o.messages.option+" "+(t+1),e.value=c.hyphenCase(e.label),e}));var a="";for(a+=H(t),a+='",R(o.messages.select,a,t),e(".sortable-options").sortable()},D=function(e){var t={select:$,"rich-text":L,textarea:L,"radio-group":$,"checkbox-group":$};e=e||"",t[e.type]?t[e.type](e):q(e)},H=function W(t){var a,W=[],l=void 0!==t.role?t.role.split(","):[];W.push(_("label",t)),t.size=t.size||"m",t.style=t.style||"default",W.push(F(t)),W.push(j(t)),W.push(B(t.style,t.type)),W.push(_("placeholder",t)),W.push(_("className",t)),W.push(_("name",t)),W.push('"),W.push(_("maxlength",t)),W.join("")},F=function(e){var t=["header","paragraph","button"],a=[],l="";if(t=t.concat(o.messages.subtypes.header,o.messages.subtypes.paragraph),-1===t.indexOf(e.type)&&a.push(!0),a.some(function(e){return e===!0})){var s=c.markup("label",o.messages.description,{"for":"description-"+d}),r=c.markup("input",null,{type:"text",className:"fld-description form-control",name:"description",id:"description-"+d,value:e.description}),n=c.markup("div",[s,r],{"class":"form-group description-wrap"});l=n.outerHTML}return l},j=function Y(e){var t=o.messages.subtypes,a=e.type,l=e.subtype||"",Y="",s=void 0;if(t[a]){var r=""+o.messages.subtype+" ";Y+='',t[a].forEach(function(e){s=l===e?"selected":"",Y+='"+e+" "}),Y+=" ",Y=''+r+" "+Y+"
"}return Y},B=function(e,t){var a={button:"btn"},l=o.messages.styles[a[t]],s="";if(l){var r=""+o.messages.style+" ";s+=' ',s+='',Object.keys(o.messages.styles[a[t]]).forEach(function(l){var r=e===l?"active":"";s+=''+o.messages.styles[a[t]][l]+" "}),s+="
",s=''+r+" "+s+"
"}return s},_=function(e,t){var a=["text","textarea","select"],l=["header"],s=["paragraph"],r=["checkbox","select","checkbox-group","date","autocomplete","radio-group","hidden","button","header"],n="label"===e?t.label:t[e]||"",i=o.messages[e];"label"===e&&c.inArray(t.type,s)&&(i=o.messages.content),l=l.concat(o.messages.subtypes.header,s),r=r.concat(s);var u=o.messages.placeholders,p=u[e]||"",m="",f=[];if("placeholder"!==e||c.inArray(t.type,a)||f.push(!0),"name"===e&&c.inArray(t.type,l)&&f.push(!0),"maxlength"===e&&c.inArray(t.type,r)&&f.push(!0),!f.some(function(e){return e===!0})){var v=""+i+" ";m+="label"===e&&c.inArray(t.type,s)?'":' ',m=''+v+" "+m+"
"}return m},P=function(e){var t=["header","paragraph","button"],a=[],l="";if(c.inArray(e.type,t)&&a.push(!0),!a.some(function(e){return e===!0})){l+='',l+=" ";var s=c.markup("input",null,{className:"required",type:"checkbox",name:"required-"+d,id:"required-"+d,value:1});s.defaultChecked=e.required,l+=s.outerHTML,l+=c.markup("label",o.messages.required,{className:"required-label","for":"required-"+d}).outerHTML,l+="
"}return l},R=function(t,a,l){var s=e(a).find('input[name="label"]').val(),r=s?s:t,n=c.markup("a",o.messages.remove,{id:"del_"+d,className:"del-button btn delete-confirm",title:o.messages.removeMessage}),u=c.markup("a",null,{id:d+"-edit",className:"toggle-form btn icon-pencil",title:o.messages.hide}),p=l.required,m=l.toggle||void 0,f=""!==l.description?'? ':"",v=c.markup("div",[u,n],{className:"field-actions"}).outerHTML;v+=''+r+" "+f+' * ",v+=c.markup("div","",{className:"prev-holder"}).outerHTML,v+='";var g=c.markup("li",v,{"class":l.type+"-field form-field",type:l.type,id:d}),h=e(g);h.data("fieldData",{attrs:l}),"undefined"!=typeof c.stopIndex?e("> li",i).eq(c.stopIndex).after(h):i.append(h),
+"use strict";function formBuilderHelpersFn(e,t){var a={doCancel:!1};return t.events=formBuilderEventsFn(),a.attrString=function(e){var t=[];for(var l in e)e.hasOwnProperty(l)&&(l=a.safeAttr(l,e[l]),t.push(l.name+l.value));var s=t.join(" ");return s},a.hyphenCase=function(e){return e=e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()}),e.replace(/\s/g,"-").replace(/^-+/g,"")},a.makeClassName=function(e){return e=e.replace(/[^\w\s\-]/gi,""),a.hyphenCase(e)},a.safeAttrName=function(e){var t={className:"class"};return t[e]||a.hyphenCase(e)},a.safeAttr=function(e,t){e=a.safeAttrName(e);var l=window.JSON.stringify(HTML_ENTITIES.encode(t));return t=t?"="+l:"",{name:e,value:t}},a.mobileClass=function(){var e="";return function(t){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=" fb-mobile")}(navigator.userAgent||navigator.vendor||window.opera),e},a.startMoving=function(e,t){e=e,t.item.show().addClass("moving"),a.startIndex=$("li",this).index(t.item)},a.stopMoving=function(e,t){e=e,t.item.removeClass("moving"),a.doCancel&&($(t.sender).sortable("cancel"),$(this).sortable("cancel")),a.save(),a.doCancel=!1},a.beforeStop=function(t,l){t=t;var s=document.getElementById(e.formID),o=s.children.length-1,r=[];a.stopIndex=l.placeholder.index()-1,!e.sortableControls&&l.item.parent().hasClass("frmb-control")&&r.push(!0),e.prepend&&r.push(0===a.stopIndex),e.append&&r.push(a.stopIndex+1===o),a.doCancel=r.some(function(e){return e===!0})},a.safename=function(e){return e.replace(/\s/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase()},a.forceNumber=function(e){return e.replace(/[^0-9]/g,"")},a.initTooltip=function(e){var t=e.find(".tooltip");e.mouseenter(function(){t.outerWidth()>200&&t.addClass("max-width"),t.css("left",e.width()+14),t.stop(!0,!0).fadeIn("fast")}).mouseleave(function(){e.find(".tooltip").stop(!0,!0).fadeOut("fast")}),t.hide()},a.getTypes=function(e){return{type:e.attr("type"),subtype:$(".fld-subtype",e).val()}},a.trimAttrs=function(e){var t=[null,void 0,"",!1];for(var l in e)a.inArray(e[l],t)&&delete e[l];return e},a.escapeAttrs=function(e){for(var t in e)e.hasOwnProperty(t)&&(e[t]=HTML_ENTITIES.encode(e[t]));return e},a.xmlSave=function(e){var l=$(e).toXML(a);return window.JSON.stringify(l)===window.JSON.stringify(t.formData)?!1:void(t.formData=l)},a.jsonSave=function(){e.notify.warning("json data not available yet")},a.save=function(){var l,s=a.getElement(),o=document.getElementById(e.formID),r={xml:a.xmlSave,json:a.jsonSave};return l=r[e.dataType](o),s&&(s.value=t.formData,window.jQuery?$(s).trigger("change"):s.onchange()),document.dispatchEvent(t.events.formSaved),l},a.getElement=function(){var l=!1;return t.element&&(l=t.element,l.id||a.makeId(l),l.onchange||(l.onchange=function(){e.notify.success(e.messages.formUpdated)})),l},a.incrementId=function(e){var t=e.lastIndexOf("-"),a=parseInt(e.substring(t+1))+1,l=e.substring(0,t);return l+"-"+a},a.makeId=function(){var e=arguments.length<=0||void 0===arguments[0]?!1:arguments[0],t=(new Date).getTime();return e.tagName+"-"+t},a.updatePreview=function(e){var t=e.data("fieldData")||{},l=e.attr("class");if(-1===l.indexOf("ui-sortable-handle")){var s,o=$(e).attr("type"),r=$(".prev-holder",e),n={label:$(".fld-label",e).val(),type:o},i=$(".fld-subtype",e).val();i&&(n.subtype=i);var c=$(".fld-maxlength",e).val();c&&(n.maxlength=c),n.className=$(".fld-className",e).val()||t.className||"";var d=$(".fld-placeholder",e).val();d&&(n.placeholder=d);var u=$(".btn-style",e).val();u&&(n.style=u),"checkbox"===o&&(n.toggle=$(".checkbox-toggle",e).is(":checked")),o.match(/(select|checkbox-group|radio-group)/)&&(n.values=[],n.multiple=$('[name="multiple"]',e).is(":checked"),$(".sortable-options li",e).each(function(){var e={};e.selected=$(".option-selected",this).is(":checked"),e.value=$(".option-value",this).val(),e.label=$(".option-label",this).val(),n.values.push(e)})),n.className=a.classNames(e,n),$(".fld-className",e).val(n.className),e.data("fieldData",n),s=a.fieldPreview(n),r.html(s),$("input[toggle]",r).kcToggle()}},a.fieldPreview=function(t){var l,s="",o=(new Date).getTime();t=jQuery.extend({},t),t.type=t.subtype||t.type;var r=t.toggle?"toggle":"",n=a.attrString(t);switch(t.type){case"textarea":case"rich-text":s="";break;case"button":case"submit":s=""+t.label+" ";break;case"select":var i="",c=t.multiple?"multiple":"";for(t.values.reverse(),t.placeholder&&(i+=""+t.placeholder+" "),l=t.values.length-1;l>=0;l--){var d=t.values[l].selected&&!t.placeholder?"selected":"";i+='"+t.values[l].label+" "}s="<"+t.type+' class="'+t.className+'" '+c+">"+i+""+t.type+">";break;case"checkbox-group":case"radio-group":var u=t.type.replace("-group",""),p=u+"-"+o;for(t.values.reverse(),l=t.values.length-1;l>=0;l--){var m=t.values[l].selected?"checked":"",f=u+"-"+o+"-"+l;s+=''+t.values[l].label+"
"}break;case"text":case"password":case"email":case"date":case"file":s=" ";break;case"color":s=' '+e.messages.selectColor;break;case"hidden":case"checkbox":s=' ";break;case"autocomplete":s=' ';break;default:n=a.attrString(t),s="<"+t.type+" "+n+">"+t.label+""+t.type+">"}return s},a.updateMultipleSelect=function(){$(document.getElementById(e.formID)).on("change",'input[name="multiple"]',function(){var e=$(this).parents(".field-options:eq(0)").find(".sortable-options input.option-selected");this.checked?e.each(function(){$(this).prop("type","checkbox")}):e.each(function(){$(this).removeAttr("checked").prop("type","radio")})})},a.debounce=function(e){var t,a=arguments.length<=1||void 0===arguments[1]?250:arguments[1],l=arguments.length<=2||void 0===arguments[2]?!1:arguments[2];return function(){var s=this,o=arguments,r=function(){t=null,l||e.apply(s,o)},n=l&&!t;clearTimeout(t),t=setTimeout(r,a),n&&e.apply(s,o)}},a.htmlEncode=function(e){return $("
").text(e).html()},a.htmlDecode=function(e){return $("
").html(e).text()},a.validateForm=function(){var t=$(document.getElementById(e.formID)),a=[];$('input[name="label"], input[type="text"].option',t).each(function(){if(""===$(this).val()){var t=$(this).parents("li.form-field"),l=$(this);a.push({field:t,error:e.messages.labelEmpty,attribute:l})}}),a.length&&(alert("Error: "+a[0].error),$("html, body").animate({scrollTop:a[0].field.offset().top},1e3,function(){var e=$(".toggle-form",a[0].field).attr("id");$(".toggle-form",a[0].field).addClass("open").parent().next(".prev-holder").slideUp(250),$("#"+e+"-fld").slideDown(250,function(){a[0].attribute.addClass("error")})}))},a.disabledTT={className:"frmb-tt",add:function(t){var l=e.messages.fieldNonEditable;if(l){var s=a.markup("p",l,{className:a.disabledTT.className});t.append(s)}},remove:function(e){$(".frmb-tt",e).remove()}},a.classNames=function(t,l){var s=["checkbox","checkbox-group","radio-group"],o=["header","paragraph","button"],r=void 0;for(r=o.length-1;r>=0;r--)o=o.concat(e.messages.subtypes[o[r]]);s=s.concat(o);var n=l.type,i=l.style,c=t[0].querySelector(".fld-className").value,d=[].concat(c.split(" ")).reverse(),u={button:"btn",submit:"btn"},p=u[n];if(p){if(i){for(r=d.length-1;r>=0;r--){var m=new RegExp("(?:^|s)"+p+"-(.*?)(?:s|$)+","g"),f=d[r].match(m);f&&d.splice(r,1)}d.push(p+"-"+i)}d.push(p)}else a.inArray(n,s)||d.push("form-control");return a.unique(d.reverse()).join(" ").trim()},a.markup=function(e){var t=arguments.length<=1||void 0===arguments[1]?"":arguments[1],l=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],s=void 0,o=document.createElement(e),r=function(e){return Array.isArray(e)?"array":"undefined"==typeof e?"undefined":_typeof(e)},n={string:function(e){o.innerHTML=e},object:function(e){return o.appendChild(e)},array:function(e){for(var t=0;t=0;o--){var r=t.filter(function(e){return e.attrs.type===l[o]})[0];s.push(r)}return s.filter(Boolean)},a.forEach=function(e,t,a){for(var l=0;l1&&(t=e),t=a[e]})},e}(HTML_ENTITIES||{}),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};!function(e){var t=function(t,a){var l={theme:"fresh",labels:{off:"Off",on:"On"}},s=e.extend(l,a),o=e('
').insertAfter(t).append(t);o.toggleClass("on",t.is(":checked"));var r=''+s.labels.on+"
",n=''+s.labels.off+"
",i='
',c=''+r+i+n+"
";o.append(c),o.click(function(){t.attr("checked",!t.attr("checked")),e(this).toggleClass("on")})};e.fn.kcToggle=function(a){var l=this;return l.each(function(){var l=e(this);if(!l.data("kcToggle")){var s=new t(l,a);l.data("kcToggle",s)}})}}(jQuery),function(e){var t=function(t,a){var l=this,s={controlPosition:"right",controlOrder:["autocomplete","button","checkbox","checkbox-group","date","file","header","hidden","paragraph","radio-group","select","text","textarea"],dataType:"xml",disableFields:["autocomplete","hidden"],append:!1,prepend:!1,defaultFields:[],fieldRemoveWarn:!1,roles:{1:"Administrator"},messages:{addOption:"Add Option",allFieldsRemoved:"All fields were removed.",allowSelect:"Allow Select",autocomplete:"Autocomplete",button:"Button",cannotBeEmpty:"This field cannot be empty",checkboxGroup:"Checkbox Group",checkbox:"Checkbox",checkboxes:"Checkboxes",className:"Class",clearAllMessage:"Are you sure you want to clear all fields?",clearAll:"Clear",close:"Close",content:"Content",copy:"Copy To Clipboard",dateField:"Date Field",description:"Help Text",descriptionField:"Description",devMode:"Developer Mode",editNames:"Edit Names",editorTitle:"Form Elements",editXML:"Edit XML",fieldDeleteWarning:!1,fieldVars:"Field Variables",fieldNonEditable:"This field cannot be edited.",fieldRemoveWarning:"Are you sure you want to remove this field?",fileUpload:"File Upload",formUpdated:"Form Updated",getStarted:"Drag a field from the right to this area",header:"Header",hide:"Edit",hidden:"Hidden Input",label:"Label",labelEmpty:"Field Label cannot be empty",limitRole:"Limit access to one or more of the following roles:",mandatory:"Mandatory",maxlength:"Max Length",minOptionMessage:"This field requires a minimum of 2 options",name:"Name",no:"No",off:"Off",on:"On",option:"Option",optional:"optional",optionLabelPlaceholder:"Label",optionValuePlaceholder:"Value",optionEmpty:"Option value required",paragraph:"Paragraph",placeholder:"Placeholder",placeholders:{value:"Value",label:"Label",text:"",textarea:"",email:"Enter you email",placeholder:"",className:"space separated classes",password:"Enter your password"},preview:"Preview",radioGroup:"Radio Group",radio:"Radio",removeMessage:"Remove Element",remove:"×",required:"Required",richText:"Rich Text Editor",roles:"Access",save:"Save",selectOptions:"Options",select:"Select",selectColor:"Select Color",selectionsMessage:"Allow Multiple Selections",size:"Size",sizes:{xs:"Extra Small",sm:"Small",m:"Default",lg:"Large"},style:"Style",styles:{btn:{"default":"Default",danger:"Danger",info:"Info",primary:"Primary",success:"Success",warning:"Warning"}},subtype:"Type",subtypes:{text:["text","password","email","color"],button:["button","submit"],header:["h1","h2","h3"],paragraph:["p","address","blockquote","canvas","output"]},text:"Text Field",textArea:"Text Area",toggle:"Toggle",warning:"Warning!",viewXML:"</>",yes:"Yes"},notify:{error:function(e){return console.error(e)},success:function(e){return console.log(e)},warning:function(e){return console.warn(e)}},sortableControls:!1,prefix:"form-builder-"};s.messages.subtypes.password=s.messages.subtypes.text,s.messages.subtypes.email=s.messages.subtypes.text,s.messages.subtypes.color=s.messages.subtypes.text,s.messages.subtypes.submit=s.messages.subtypes.button;var o=e.extend(!0,s,t),r=e(a),n="frmb-"+e("ul[id^=frmb-]").length++;o.formID=n,l.element=a;var i=e("").attr("id",n).addClass("frmb"),c=formBuilderHelpersFn(o,l);l.layout=c.editorLayout(o.controlPosition);var d=n+"-fld-1",u=n+"-control-box",p=[{label:o.messages.textArea,attrs:{type:"textarea",className:"text-area",name:"textarea"}},{label:o.messages.text,attrs:{type:"text",className:"text-input",name:"text-input"}},{label:o.messages.select,attrs:{type:"select",className:"select",name:"select"}},{label:o.messages.radioGroup,attrs:{type:"radio-group",className:"radio-group",name:"radio-group"}},{label:o.messages.paragraph,attrs:{type:"paragraph",className:"paragraph"}},{label:o.messages.hidden,attrs:{type:"hidden",className:"hidden-input",name:"hidden-input"}},{label:o.messages.header,attrs:{type:"header",className:"header"}},{label:o.messages.fileUpload,attrs:{type:"file",className:"file-input",name:"file-input"}},{label:o.messages.dateField,attrs:{type:"date",className:"calendar",name:"date-input"}},{label:o.messages.checkboxGroup,attrs:{type:"checkbox-group",className:"checkbox-group",name:"checkbox-group"}},{label:o.messages.checkbox,attrs:{type:"checkbox",className:"checkbox",name:"checkbox"}},{label:o.messages.button,attrs:{type:"button",className:"button-input",name:"button"}},{label:o.messages.autocomplete,attrs:{type:"autocomplete",className:"autocomplete",name:"autocomplete"}}];p=c.orderFields(p),o.disableFields&&(p=p.filter(function(e){return!c.inArray(e.attrs.type,o.disableFields)}));var m=c.markup("ul",null,{id:u,className:"frmb-control"});o.sortableControls&&m.classList.add("sort-enabled");for(var f=e(m),v=p.length-1;v>=0;v--){var g=e(" ",{"class":"icon-"+p[v].attrs.className,type:p[v].type,name:p[v].className,label:p[v].label});g.data("newFieldData",p[v]);var h=c.markup("span",p[v].label);g.html(h).appendTo(f)}var b="xml"===o.dataType?o.messages.viewXML:o.messages.viewJSON,y=c.markup("button",b,{id:n+"-view-data",type:"button",className:"view-data btn btn-default"}),k=c.markup("button",o.messages.clearAll,{id:n+"-clear-all",type:"button",className:"clear-all btn btn-default"}),x=c.markup("button",o.messages.save,{className:"btn btn-primary "+o.prefix+"save",id:n+"-save",type:"button"}),w=c.markup("div",[k,y,x],{className:"form-actions btn-group"}).outerHTML;i.sortable({cursor:"move",opacity:.9,revert:150,beforeStop:c.beforeStop,start:c.startMoving,stop:c.stopMoving,cancel:"input, select, .disabled, .form-group, .btn",placeholder:"frmb-placeholder"}),f.sortable({helper:"clone",opacity:.9,connectWith:i,cursor:"move",placeholder:"ui-state-highlight",start:c.startMoving,stop:c.stopMoving,revert:150,beforeStop:c.beforeStop,update:function(e,t){return c.doCancel?!1:(e=e,void(t.item.parent()[0]===i[0]?(A(t.item,!0),c.doCancel=!0):(c.setFieldOrder(f),c.doCancel=!o.sortableControls)))}});var N=e("
",{id:n+"-stage-wrap","class":"stage-wrap "+l.layout.stage}),E=e("
",{id:n+"-form-wrap","class":"form-wrap form-builder"+c.mobileClass()});r.before(N).appendTo(N);var T=e("
",{id:n+"-cb-wrap","class":"cb-wrap "+l.layout.controls}).append(f[0],w);N.append(i,T),N.before(E),E.append(N,T);var C=c.debounce(function(t){if(t&&"keyup"===t.type&&"className"===this.name)return!1;var a=e(this).parents(".form-field:eq(0)");c.updatePreview(a),c.save()});i.on("change blur keyup",".form-elements input, .form-elements select, .form-elements textarea",C);var S=function(){var t=[];if(o.prepend&&!e(".disabled.prepend",i).length){var a=c.markup("li",o.prepend,{className:"disabled prepend"});t.push(!0),i.prepend(a)}if(o.append&&!e(".disabled.append",i).length){var l=c.markup("li",o.append,{className:"disabled append"});t.push(!0),i.append(l)}t.some(function(e){return e===!0})&&N.removeClass("empty")},A=function(t){var a=arguments.length<=1||void 0===arguments[1]?!1:arguments[1],l={};if(t instanceof jQuery){var s=t.data("newFieldData");if(s)l=s.attrs,l.label=s.label;else{var o=t[0].attributes;a||(l.values=t.children().map(function(t,a){return{label:e(a).text(),value:e(a).attr("value"),selected:Boolean(e(a).attr("selected"))}}));for(var r=o.length-1;r>=0;r--)l[o[r].name]=o[r].value}}else l=t;l.label=c.htmlEncode(l.label),l.name=a?M(l):l.name,l.role=l.role,l.className=l.className||l["class"],l.required="true"===l.required||l.required===!0,l.maxlength=l.maxlength,l.toggle=l.toggle,l.multiple=l.type.match(/(checkbox-group)/),l.description=void 0!==l.description?c.htmlEncode(l.description):"";var n=/(?:^|\s)btn-(.*?)(?:\s|$)/g.exec(l.className);n&&(l.style=n[1]),D(l),N.removeClass("empty")},O=function(){var t="";t=l.formData?l.formData:""!==r.val()?e.parseXML(l.element.value.trim()):!1;var a=e(t).find("field");if(a.length>0)l.formData=t,a.each(function(){A(e(this))});else if(!t)if(o.defaultFields&&o.defaultFields.length){o.defaultFields.reverse();for(var s=o.defaultFields.length-1;s>=0;s--)A(o.defaultFields[s]);N.removeClass("empty"),c.save()}else o.prepend||o.append||N.addClass("empty").attr("data-content",o.messages.getStarted);e("li.form-field:not(.disabled)",i).each(function(){c.updatePreview(e(this))}),S()},I=function(){var e={xml:O,json:function(){console.log("coming soon")}};e[o.dataType]()};i.on("mousemove","li.disabled",function(t){e(".frmb-tt",this).css({left:t.offsetX-16,top:t.offsetY-34})}),i.on("mouseenter","li.disabled",function(){c.disabledTT.add(e(this))}),i.on("mouseleave","li.disabled",function(){c.disabledTT.remove(e(this))});var M=function(e){var t=(new Date).getTime();return e.type+"-"+t},L=function(e){R(o.messages.textArea,H(e),e)},q=function(e){var t=e.type||"text";R(o.messages[t],H(e),e)},$=function(t){t.values&&t.values.length||(t.values=[{selected:!0},{selected:!1}],t.values=t.values.map(function(e,t){return e.label=o.messages.option+" "+(t+1),e.value=c.hyphenCase(e.label),e}));var a="";for(a+=H(t),a+='",R(o.messages.select,a,t),e(".sortable-options").sortable()},D=function(e){var t={select:$,"rich-text":L,textarea:L,"radio-group":$,"checkbox-group":$};e=e||"",t[e.type]?t[e.type](e):q(e)},H=function W(t){var a,W=[],l=void 0!==t.role?t.role.split(","):[];W.push(_("label",t)),t.size=t.size||"m",t.style=t.style||"default",W.push(F(t)),W.push(j(t)),W.push(B(t.style,t.type)),W.push(_("placeholder",t)),W.push(_("className",t)),W.push(_("name",t)),W.push('"),W.push(_("maxlength",t)),W.join("")},F=function(e){var t=["header","paragraph","button"],a=[],l="";if(t=t.concat(o.messages.subtypes.header,o.messages.subtypes.paragraph),-1===t.indexOf(e.type)&&a.push(!0),a.some(function(e){return e===!0})){var s=c.markup("label",o.messages.description,{"for":"description-"+d}),r=c.markup("input",null,{type:"text",className:"fld-description form-control",name:"description",id:"description-"+d,value:e.description}),n=c.markup("div",[s,r],{"class":"form-group description-wrap"});l=n.outerHTML}return l},j=function Q(e){var t=o.messages.subtypes,a=e.type,l=e.subtype||"",Q="",s=void 0;if(t[a]){var r=""+o.messages.subtype+" ";Q+='',t[a].forEach(function(e){s=l===e?"selected":"",Q+='"+e+" "}),Q+=" ",Q=''+r+" "+Q+"
"}return Q},B=function(e,t){var a={button:"btn"},l=o.messages.styles[a[t]],s="";if(l){var r=""+o.messages.style+" ";s+=' ',s+='',Object.keys(o.messages.styles[a[t]]).forEach(function(l){var r=e===l?"active":"";s+=''+o.messages.styles[a[t]][l]+" "}),s+="
",s=''+r+" "+s+"
"}return s},_=function(e,t){var a=["text","textarea","select"],l=["header"],s=["paragraph"],r=["checkbox","select","checkbox-group","date","autocomplete","radio-group","hidden","button","header"],n="label"===e?t.label:t[e]||"",i=o.messages[e];"label"===e&&c.inArray(t.type,s)&&(i=o.messages.content),l=l.concat(o.messages.subtypes.header,s),r=r.concat(s);var u=o.messages.placeholders,p=u[e]||"",m="",f=[];if("placeholder"!==e||c.inArray(t.type,a)||f.push(!0),"name"===e&&c.inArray(t.type,l)&&f.push(!0),"maxlength"===e&&c.inArray(t.type,r)&&f.push(!0),!f.some(function(e){return e===!0})){var v=""+i+" ";m+="label"===e&&c.inArray(t.type,s)?'":' ',m=''+v+" "+m+"
"}return m},P=function(e){var t=["header","paragraph","button"],a=[],l="";if(c.inArray(e.type,t)&&a.push(!0),!a.some(function(e){return e===!0})){l+='',l+=" ";var s=c.markup("input",null,{className:"required",type:"checkbox",name:"required-"+d,id:"required-"+d,value:1});s.defaultChecked=e.required,l+=s.outerHTML,l+=c.markup("label",o.messages.required,{className:"required-label","for":"required-"+d}).outerHTML,l+="
"}return l},R=function(t,a,l){var s=e(a).find('input[name="label"]').val(),r=s?s:t,n=c.markup("a",o.messages.remove,{id:"del_"+d,className:"del-button btn delete-confirm",title:o.messages.removeMessage}),u=c.markup("a",null,{id:d+"-edit",className:"toggle-form btn icon-pencil",title:o.messages.hide}),p=l.required,m=l.toggle||void 0,f=""!==l.description?'? ':"",v=c.markup("div",[u,n],{className:"field-actions"}).outerHTML;v+=''+r+" "+f+' * ",v+=c.markup("div","",{className:"prev-holder"}).outerHTML,v+='";var g=c.markup("li",v,{"class":l.type+"-field form-field",type:l.type,id:d}),h=e(g);h.data("fieldData",{attrs:l}),"undefined"!=typeof c.stopIndex?e("> li",i).eq(c.stopIndex).after(h):i.append(h),
c.updatePreview(h),e(document.getElementById("frm-"+d+"-item")).hide().slideDown(250),d=c.incrementId(d)},U=function(e,t,a,l){var s={selected:l?"checkbox":"radio"},r={selected:a,label:"",value:""},n=Object.assign(r,t),i=[];for(var d in n)if(n.hasOwnProperty(d)){var u={type:s[d]||"text","class":"option-"+d,placeholder:o.messages.placeholders[d],value:n[d],name:e},p=c.markup("input",null,u);"selected"===d&&(p.checked=n.selected),i.push(p)}var m={className:"remove btn",title:o.messages.removeMessage};i.push(c.markup("a",o.messages.remove,m));var f=c.markup("li",i);return f.outerHTML};i.on("click touchstart",".remove",function(t){var a=e(this).parents(".form-field:eq(0)");t.preventDefault();var l=e(this).parents(".sortable-options:eq(0)").children("li").length;2>=l?o.notify.error("Error: "+o.messages.minOptionMessage):e(this).parent("li").slideUp("250",function(){e(this).remove()}),C.call(a)}),i.on("touchstart","input",function(t){if(t.handled===!0)return!1;if("checkbox"===e(this).attr("type"))e(this).trigger("click");else{e(this).focus();var a=e(this).val();e(this).val(a)}}),i.on("click touchstart",".toggle-form",function(t){if(t.stopPropagation(),t.preventDefault(),t.handled===!0)return!1;var a=e(this).parents(".form-field:eq(0)").attr("id");c.toggleEdit(a),t.handled=!0}),c.toggleEdit=function(t){var a=document.getElementById(t),l=e(".toggle-form",a),s=e(".frm-holder",a);a.classList.toggle("editing"),l.toggleClass("open"),e(".prev-holder",a).slideToggle(250),s.slideToggle(250)},i.on("keyup change",'[name="label"]',function(){e(".field-label",e(this).closest("li")).text(e(this).val())}),i.delegate("input.error","keyup",function(){e(this).removeClass("error")}),i.on("keyup",'input[name="description"]',function(){var t=e(this).parents(".form-field:eq(0)"),a=e(".tooltip-element",t),l=e(this).val();if(""!==l)if(a.length)a.attr("tooltip",l).css("display","inline-block");else{var s='? ';e(".field-label",t).after(s)}else a.length&&a.css("display","none")}),c.updateMultipleSelect(),i.delegate('input[name="name"]',"keyup",function(){e(this).val(c.safename(e(this).val())),""===e(this).val()?e(this).addClass("field_error").attr("placeholder",o.messages.cannotBeEmpty):e(this).removeClass("field_error")}),i.delegate("input.fld-maxlength","keyup",function(){e(this).val(c.forceNumber(e(this).val()))}),i.on("click touchstart",".delete-confirm",function(t){t.preventDefault();var a=this.getBoundingClientRect(),l=document.body.getBoundingClientRect(),s={pageX:a.left+a.width/2,pageY:a.top-l.top-12},r=e(this).parents(".form-field:eq(0)").attr("id"),n=e(document.getElementById(r)),d=function(){n.slideUp(250,function(){n.removeClass("deleting"),n.remove(),c.save(),i[0].childNodes.length||N.addClass("empty").attr("data-content",o.messages.getStarted)})};if(document.addEventListener("modalClosed",function(){n.removeClass("deleting")},!1),o.fieldRemoveWarn){var u=c.markup("h3",o.messages.warning),p=c.markup("p",o.messages.fieldRemoveWarning);c.confirm([u,p],d,s),n.addClass("deleting")}else d(n)}),i.on("click",".style-wrap button",function(){var t=e(this).val(),a=e(this).parent(),l=a.prev(".btn-style");l.val(t),e(this).siblings(".btn").removeClass("active"),e(this).addClass("active"),C.call(a)}),i.on("click","input.required",function(){var t=e(this).parents("li.form-field").find(".required-asterisk");t.toggle()}),i.on("click",'input[name="enable_roles"]',function(){var t=e(this).siblings("div.available-roles"),a=e(this);t.slideToggle(250,function(){a.is(":checked")||e('input[type="checkbox"]',t).removeAttr("checked")})}),i.on("click",".add-opt",function(t){t.preventDefault();var a=e(this).parents(".field-options:eq(0)"),l=e('[name="multiple"]',a),s=e(".option-selected:eq(0)",a),o=!1;o=l.length?l.prop("checked"):"checkbox"===s.attr("type");var r=s.attr("name");e(".sortable-options",a).append(U(r,!1,!1,o)),c.updateMultipleSelect()}),i.on("click touchstart",".close-field",function(){var t=e(this).parents("li.form-field:eq(0)").attr("id");c.toggleEdit(t)}),i.on("mouseover mouseout",".remove, .del-button",function(){e(this).parents("li:eq(0)").toggleClass("delete")});var z=e(document.getElementById(n+"-view-data"));z.click(function(e){e.preventDefault();var t=c.htmlEncode(r.val()),a=c.markup("code",t,{className:"xml"}),l=c.markup("pre",a);c.dialog(l,null,"data-dialog")});var X=e(document.getElementById(n+"-clear-all"));return X.click(function(){var t=e("li.form-field"),a=this.getBoundingClientRect(),l=document.body.getBoundingClientRect(),s={pageX:a.left+a.width/2,pageY:a.top-l.top-12};t.length?c.confirm(o.messages.clearAllMessage,function(){c.removeAllfields(),o.notify.success(o.messages.allFieldsRemoved),c.save()},s):c.dialog("There are no fields to clear",{pageX:s.pageX,pageY:s.pageY})}),e(document.getElementById(n+"-save")).click(function(e){e.preventDefault(),c.save(),c.validateForm(e)}),r.parent().find('p[id*="ideaTemplate"]').remove(),r.wrap('
'),I(),i.css("min-height",f.height()),document.dispatchEvent(l.events.loaded),l};e.fn.formBuilder=function(a){return this.each(function(){var l,s=this;if(e(s).data("formBuilder")){var o=e(s).parents(".form-builder:eq(0)"),r=e(s).clone();o.before(r),o.remove(),l=new t(a,r[0]),r.data("formBuilder",l)}else l=new t(a,s),e(s).data("formBuilder",l)})}}(jQuery),function(e){e.fn.toXML=function(t){var a="",l=function(a){var l=[];return e(".sortable-options li",a).each(function(){var a=e(this),s={value:e(".option-value",a).val(),selected:e(".option-selected",a).is(":checked")},o=t.markup("option",e(".option-label",a).val(),s).outerHTML;l.push("\n "+o)}),l.join("")+"\n "};return this.each(function(){var s=this;s.childNodes.length>=1&&(a+="\n ",t.forEach(s.childNodes,function(s,o){s=s;var r=e(o),n=r.data("fieldData");if(!r.hasClass("disabled")){var i=e(".roles-field:checked",o).map(function(){return this.value}).get(),c=t.getTypes(r),d={className:n.className,description:e("input.fld-description",r).val(),label:e(".fld-label",r).val(),maxlength:e("input.fld-maxlength",r).val(),multiple:e('input[name="multiple"]',r).is(":checked"),name:e("input.fld-name",r).val(),placeholder:e("input.fld-placeholder",r).val(),required:e("input.required",r).is(":checked"),toggle:e(".checkbox-toggle",r).is(":checked"),type:c.type,subtype:c.subtype};i.length&&(d.role=i.join(",")),d=t.trimAttrs(d),d=t.escapeAttrs(d);var u,p=d.type.match(/(select|checkbox-group|radio-group)/),m="";p&&(m=l(r)),u=t.markup("field",m,d),a+="\n "+u.outerHTML}}),a+="\n \n ")}),a}}(jQuery),"function"!=typeof Object.assign&&!function(){Object.assign=function(e){if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),a=1;a' + fieldLabelText + '' + fieldAttrs.type + '>';
+ fieldMarkup = '<' + fieldAttrs.type + ' ' + fieldAttrsString + '>' + fieldLabelVal + '' + fieldAttrs.type + '>';
}
if (fieldAttrs.type !== 'hidden') {
diff --git a/dist/form-render.min.js b/dist/form-render.min.js
index 43ae5ea18..d2bfaae41 100644
--- a/dist/form-render.min.js
+++ b/dist/form-render.min.js
@@ -3,4 +3,4 @@ formBuilder - http://kevinchappell.github.io/formBuilder/
Version: 1.9.28
Author: Kevin Chappell
*/
-"use strict";function FormRenderFn(e,t){var r=this,n={destroyTemplate:!0,container:!1,dataType:"xml",formData:!1,label:{selectColor:"Select Color",noFormData:"No form data.",formRendered:"Form Rendered"},render:!0,notify:{error:function(e){return console.error(e)},success:function(e){return console.log(e)},warning:function(e){return console.warn(e)}}},a={},o=$.extend(!0,n,e);a.getElement=function(){return t.id||(t.id=a.makeId(t)),document.getElementById(t.id)},a.makeId=function(e){var t=(new Date).getTime();return e.tagName+"-"+t},!o.formData&&t&&(t=a.getElement(),o.formData=t.value),a.markup=function(e){var t=arguments.length<=1||void 0===arguments[1]?"":arguments[1],r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],n=void 0,o=document.createElement(e),i=function(e){return Array.isArray(e)?"array":"undefined"==typeof e?"undefined":_typeof(e)},l={string:function(e){o.innerHTML=e},object:function(e){return o.appendChild(e)},array:function(e){for(var t=0;t*'),"hidden"!==i.type&&(s&&(s='? '),r=''+l+" "+c+" "+s+" ");var u=i.label;delete i.label,delete i.description;var f=a.attrString(i);switch(i.type){case"textarea":case"rich-text":delete i.type,delete i.value,t=r+"";break;case"select":i.type=i.type.replace("-group",""),d.length&&d.each(function(e,t){e=e;var r=a.parseAttrs(t.attributes),o=a.attrString(r);n+=""+t.textContent+" "}),t=r+""+n+" ";break;case"checkbox-group":case"radio-group":i.type=i.type.replace("-group",""),d.length&&!function(){var e="checkbox"===i.type?i.name+"[]":i.name;d.each(function(t,r){var o=Object.assign({},i,a.parseAttrs(r.attributes)),l=void 0;o.selected&&(delete o.selected,o.checked=null),o.name=e,o.id=i.id+"-"+t,l=a.attrString(o),n+=" '+r.textContent+" "})}(),t=r+''+n+"
";break;case"text":case"password":case"email":case"file":case"hidden":case"date":case"autocomplete":t=r+" ";break;case"color":t=r+" "+o.label.selectColor;break;case"button":case"submit":t=""+u+" ";break;case"checkbox":t=" "+r,i.toggle&&setTimeout(function(){$(document.getElementById(i.id)).kcToggle()},100);break;default:t="<"+i.type+">"+l+""+i.type+">"}if("hidden"!==i.type){var p=i.id?"form-group field-"+i.id:"";t=a.markup("div",t,{className:p})}else t=a.markup("input",null,i);return t},a.hyphenCase=function(e){return e=e.replace(/[^\w\s\-]/gi,""),e=e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()}),e.replace(/\s/g,"-").replace(/^-+/g,"")},a.attrString=function(e){var t=[];for(var r in e)e.hasOwnProperty(r)&&(r=a.safeAttr(r,e[r]),t.push(r.name+r.value));return t.join(" ")},a.safeAttr=function(e,t){var r={className:"class"};return e=r[e]||e,t=t?window.JSON.stringify(t):!1,t=t?"="+t:"",{name:e,value:t}},a.safeAttrName=function(e){var t={className:"class"};return t[e]||a.hyphenCase(e)},a.parseAttrs=function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[e[r].name]=e[r].value);return t},Element.prototype.appendFormFields=function(e){var t=this;e.reverse();for(var r=e.length-1;r>=0;r--)t.appendChild(e[r])},Element.prototype.emptyContainer=function(){for(var e=this;e.lastChild;)e.removeChild(e.lastChild)};var i=[],l=$.parseXML(o.formData),s=$("field",l);if(s.length)s.each(function(e,t){e=e,i.push(a.fieldRender(t))});else{var c=a.markup("div",o.label.noFormData,{className:"no-form-data"});i.push(c),o.notify.error(o.label.noFormData)}if(o.render){if(o.container)o.container=o.container instanceof jQuery?o.container[0]:o.container,o.container.emptyContainer(),o.container.appendFormFields(i);else if(t){var d=document.querySelector(".rendered-form");d?(d.emptyContainer(),d.appendFormFields(i)):(d=a.markup("div",i,{className:"rendered-form"}),t.parentNode.insertBefore(d,t.nextSibling),t.style.display="none",t.setAttribute("disabled","disabled"))}s.length&&o.notify.success(o.label.formRendered)}else r.markup=i.map(function(e){return e.innerHTML}).join("");return r}!function(e){var t=function(t,r){var n={theme:"fresh",labels:{off:"Off",on:"On"}},a=e.extend(n,r),o=e('
').insertAfter(t).append(t);o.toggleClass("on",t.is(":checked"));var i=''+a.labels.on+"
",l=''+a.labels.off+"
",s='
',c=''+i+s+l+"
";o.append(c),o.click(function(){t.attr("checked",!t.attr("checked")),e(this).toggleClass("on")})};e.fn.kcToggle=function(r){var n=this;return n.each(function(){var n=e(this);if(!n.data("kcToggle")){var a=new t(n,r);n.data("kcToggle",a)}})}}(jQuery);var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};!function(e){e.fn.formRender=function(e){this.each(function(){var t=new FormRenderFn(e,this);return t})}}(jQuery);
\ No newline at end of file
+"use strict";function FormRenderFn(e,t){var r=this,n={destroyTemplate:!0,container:!1,dataType:"xml",formData:!1,label:{selectColor:"Select Color",noFormData:"No form data.",formRendered:"Form Rendered"},render:!0,notify:{error:function(e){return console.error(e)},success:function(e){return console.log(e)},warning:function(e){return console.warn(e)}}},a={},o=$.extend(!0,n,e);a.getElement=function(){return t.id||(t.id=a.makeId(t)),document.getElementById(t.id)},a.makeId=function(e){var t=(new Date).getTime();return e.tagName+"-"+t},!o.formData&&t&&(t=a.getElement(),o.formData=t.value),a.markup=function(e){var t=arguments.length<=1||void 0===arguments[1]?"":arguments[1],r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],n=void 0,o=document.createElement(e),i=function(e){return Array.isArray(e)?"array":"undefined"==typeof e?"undefined":_typeof(e)},l={string:function(e){o.innerHTML=e},object:function(e){return o.appendChild(e)},array:function(e){for(var t=0;t*'),"hidden"!==i.type&&(s&&(s='? '),r=''+l+" "+c+" "+s+" ");var u=i.label;delete i.label,delete i.description;var f=a.attrString(i);switch(i.type){case"textarea":case"rich-text":delete i.type,delete i.value,t=r+"";break;case"select":i.type=i.type.replace("-group",""),d.length&&d.each(function(e,t){e=e;var r=a.parseAttrs(t.attributes),o=a.attrString(r);n+=""+t.textContent+" "}),t=r+""+n+" ";break;case"checkbox-group":case"radio-group":i.type=i.type.replace("-group",""),d.length&&!function(){var e="checkbox"===i.type?i.name+"[]":i.name;d.each(function(t,r){var o=Object.assign({},i,a.parseAttrs(r.attributes)),l=void 0;o.selected&&(delete o.selected,o.checked=null),o.name=e,o.id=i.id+"-"+t,l=a.attrString(o),n+=" '+r.textContent+" "})}(),t=r+''+n+"
";break;case"text":case"password":case"email":case"file":case"hidden":case"date":case"autocomplete":t=r+" ";break;case"color":t=r+" "+o.label.selectColor;break;case"button":case"submit":t=""+u+" ";break;case"checkbox":t=" "+r,i.toggle&&setTimeout(function(){$(document.getElementById(i.id)).kcToggle()},100);break;default:t="<"+i.type+" "+f+">"+u+""+i.type+">"}if("hidden"!==i.type){var p=i.id?"form-group field-"+i.id:"";t=a.markup("div",t,{className:p})}else t=a.markup("input",null,i);return t},a.hyphenCase=function(e){return e=e.replace(/[^\w\s\-]/gi,""),e=e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()}),e.replace(/\s/g,"-").replace(/^-+/g,"")},a.attrString=function(e){var t=[];for(var r in e)e.hasOwnProperty(r)&&(r=a.safeAttr(r,e[r]),t.push(r.name+r.value));return t.join(" ")},a.safeAttr=function(e,t){var r={className:"class"};return e=r[e]||e,t=t?window.JSON.stringify(t):!1,t=t?"="+t:"",{name:e,value:t}},a.safeAttrName=function(e){var t={className:"class"};return t[e]||a.hyphenCase(e)},a.parseAttrs=function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[e[r].name]=e[r].value);return t},Element.prototype.appendFormFields=function(e){var t=this;e.reverse();for(var r=e.length-1;r>=0;r--)t.appendChild(e[r])},Element.prototype.emptyContainer=function(){for(var e=this;e.lastChild;)e.removeChild(e.lastChild)};var i=[],l=$.parseXML(o.formData),s=$("field",l);if(s.length)s.each(function(e,t){e=e,i.push(a.fieldRender(t))});else{var c=a.markup("div",o.label.noFormData,{className:"no-form-data"});i.push(c),o.notify.error(o.label.noFormData)}if(o.render){if(o.container)o.container=o.container instanceof jQuery?o.container[0]:o.container,o.container.emptyContainer(),o.container.appendFormFields(i);else if(t){var d=document.querySelector(".rendered-form");d?(d.emptyContainer(),d.appendFormFields(i)):(d=a.markup("div",i,{className:"rendered-form"}),t.parentNode.insertBefore(d,t.nextSibling),t.style.display="none",t.setAttribute("disabled","disabled"))}s.length&&o.notify.success(o.label.formRendered)}else r.markup=i.map(function(e){return e.innerHTML}).join("");return r}!function(e){var t=function(t,r){var n={theme:"fresh",labels:{off:"Off",on:"On"}},a=e.extend(n,r),o=e('
').insertAfter(t).append(t);o.toggleClass("on",t.is(":checked"));var i=''+a.labels.on+"
",l=''+a.labels.off+"
",s='
',c=''+i+s+l+"
";o.append(c),o.click(function(){t.attr("checked",!t.attr("checked")),e(this).toggleClass("on")})};e.fn.kcToggle=function(r){var n=this;return n.each(function(){var n=e(this);if(!n.data("kcToggle")){var a=new t(n,r);n.data("kcToggle",a)}})}}(jQuery);var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};!function(e){e.fn.formRender=function(e){this.each(function(){var t=new FormRenderFn(e,this);return t})}}(jQuery);
\ No newline at end of file
diff --git a/package.json b/package.json
index dfcc859fe..be4eb83d3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "formBuilder",
- "version": "1.9.28",
+ "version": "1.9.3",
"main": "dist/form-builder.js",
"files": [
"dist/form-builder.js",
diff --git a/src/js/form-render.js b/src/js/form-render.js
index 0f07784b8..80af6f1c6 100644
--- a/src/js/form-render.js
+++ b/src/js/form-render.js
@@ -216,7 +216,7 @@ function FormRenderFn(options, element) {
}
break;
default:
- fieldMarkup = `<${fieldAttrs.type}>${fieldLabelText}${fieldAttrs.type}>`;
+ fieldMarkup = `<${fieldAttrs.type} ${fieldAttrsString}>${fieldLabelVal}${fieldAttrs.type}>`;
}
if (fieldAttrs.type !== 'hidden') {
diff --git a/src/js/helpers.js b/src/js/helpers.js
index c4a1086c7..5681903cb 100644
--- a/src/js/helpers.js
+++ b/src/js/helpers.js
@@ -394,7 +394,7 @@ function formBuilderHelpersFn(opts, formBuilder) {
var i,
preview = '',
epoch = new Date().getTime();
- attrs = Object.assign({}, attrs);
+ attrs = jQuery.extend({}, attrs)
attrs.type = attrs.subtype || attrs.type;
let toggle = attrs.toggle ? 'toggle' : '';
// attrs = _helpers.escapeAttrs(attrs);
@@ -451,7 +451,8 @@ function formBuilderHelpersFn(opts, formBuilder) {
preview = ` `;
break;
default:
- preview = `<${attrs.type}>${attrs.label}${attrs.type}>`;
+ attrsString = _helpers.attrString(attrs);
+ preview = `<${attrs.type} ${attrsString}>${attrs.label}${attrs.type}>`;
}
return preview;