{"version":3,"sources":["keditor-component-form.js"],"names":["$","KEditor","keditor","flog","log","components","initFormBuilder","component","self","this","formBuilderArea","find","formData","formContent","prepend","btnEditForm","btnPreviewForm","formBuilder","disableInjectedStyle","showActionButtons","dataType","html","disableFields","disabledAttrs","typeUserDisabledAttrs","checkbox-group","on","e","preventDefault","hasClass","show","hide","addClass","removeClass","renderForm","data","formRender","actions","getData","children","each","div","dataGrid","attr","split","wrap","label","input","subDiv","length","init","contentArea","container","componentContent","append","getContent","remove","settingEnabled","settingTitle","initSettingForm","form","getSettingComponent","value","css","showSettingForm","layout","val","jQuery"],"mappings":"CAAA,SAAWA,GACP,GAAIC,GAAUD,EAAEE,QACZC,EAAOF,EAAQG,GAEnBH,GAAQI,WAAiB,MACrBC,gBAAiB,SAAUC,GACvB,GAAIC,GAAOC,KAEPC,EAAkBH,EAAUI,KAAK,sBACjCC,EAAWL,EAAUI,KAAK,cAC1BE,EAAcN,EAAUI,KAAK,gBAEjCJ,GAAUI,KAAK,8BAA8BG,QACzC,mNAMJ,IAAIC,GAAcR,EAAUI,KAAK,kBAC7BK,EAAiBT,EAAUI,KAAK,oBAEpCD,GAAgBO,aACZC,sBAAsB,EACtBC,mBAAmB,EACnBC,SAAU,OACVR,SAAUA,EAASS,OACnBC,eACI,eACA,YACA,UAEJC,eAAgB,UAEhBC,uBACIC,kBACI,SACA,aAKZV,EAAYW,GAAG,QAAS,SAAUC,GAC9BA,EAAEC,iBAEGb,EAAYc,SAAS,cACtBnB,EAAgBoB,OAChBjB,EAAYkB,OACZhB,EAAYiB,SAAS,YACrBhB,EAAeiB,YAAY,eAInCjB,EAAeU,GAAG,QAAS,SAAUC,GACjCA,EAAEC,iBAEGZ,EAAea,SAAS,cACzBrB,EAAK0B,WAAW3B,GAEhBG,EAAgBqB,OAChBlB,EAAYiB,OACZf,EAAYkB,YAAY,YACxBjB,EAAegB,SAAS,gBAKpCE,WAAY,SAAU3B,EAAWU,GAC7B,GAAIJ,GAAcN,EAAUI,KAA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C,KAAKqD,OACnCtD,EAAK0B,WAAW3B,MAIxByD,gBAAiB,SAAUJ,EAAMrD,EAAWL,GACxCC,EAAK,mCAAoCI,EACzC,IAAIM,GAAcN,EAAUI,KAAK,iBAE7BsD,EAAS,EACTpD,GAAYgB,SAAS,eACrBoC,EAAS,cACFpD,EAAYgB,SAAS,qBAC5BoC,EAAS,mBAGbL,EAAKjD,KAAK,oBAAoBuD,IAAIrD,EAAY8B,KAAK,WAAa,IAChEiB,EAAKjD,KAAK,kBAAkBuD,IAAIrD,EAAY8B,KAAK,WAAa,OAC9DiB,EAAKjD,KAAK,mBAAmBuD,IAAIrD,EAAY8B,KAAK,YAClDiB,EAAKjD,KAAK,kBAAkBuD,IAAID,GAChCL,EAAKjD,KAAK,wBAAwBoD,IAAI,UAAsB,oBAAXE,EAA+B,QAAU,QAC1FL,EAAKjD,KAAK,gBAAgBuD,IAAIrD,EAAY8B,KAAK,cAAgB,UAIxEwB","file":"keditor-component-form.min.js","sourcesContent":["(function ($) {\r\n var KEditor = $.keditor;\r\n var flog = KEditor.log;\r\n \r\n KEditor.components['form'] = {\r\n initFormBuilder: function (component) {\r\n var self = this;\r\n \r\n var formBuilderArea = component.find('.form-builder-area');\r\n var formData = component.find('.form-data');\r\n var formContent = component.find('.form-content');\r\n \r\n component.find('.keditor-component-content').prepend(\r\n '

' +\r\n ' Preview form ' +\r\n ' Edit form' +\r\n '

'\r\n );\r\n \r\n var btnEditForm = component.find('.btn-edit-form');\r\n var btnPreviewForm = component.find('.btn-preview-form');\r\n \r\n formBuilderArea.formBuilder({\r\n disableInjectedStyle: true,\r\n showActionButtons: false,\r\n dataType: 'json',\r\n formData: formData.html(),\r\n disableFields: [\r\n 'autocomplete',\r\n 'paragraph',\r\n 'header'\r\n ],\r\n disabledAttrs: ['access'],\r\n \r\n typeUserDisabledAttrs: {\r\n 'checkbox-group': [\r\n 'toggle',\r\n 'inline'\r\n ]\r\n }\r\n });\r\n \r\n btnEditForm.on('click', function (e) {\r\n e.preventDefault();\r\n \r\n if (!btnEditForm.hasClass('disabled')) {\r\n formBuilderArea.show();\r\n formContent.hide();\r\n btnEditForm.addClass('disabled');\r\n btnPreviewForm.removeClass('disabled');\r\n }\r\n });\r\n \r\n btnPreviewForm.on('click', function (e) {\r\n e.preventDefault();\r\n \r\n if (!btnPreviewForm.hasClass('disabled')) {\r\n self.renderForm(component);\r\n \r\n formBuilderArea.hide();\r\n formContent.show();\r\n btnEditForm.removeClass('disabled');\r\n btnPreviewForm.addClass('disabled');\r\n }\r\n });\r\n },\r\n \r\n renderForm: function (component, formBuilder) {\r\n var formContent = component.find('.form-content');\r\n \r\n if (!formBuilder) {\r\n var formBuilderArea = component.find('.form-builder-area');\r\n formBuilder = formBuilderArea.data('formBuilder');\r\n }\r\n \r\n formContent.formRender({\r\n dataType: 'json',\r\n formData: formBuilder.actions.getData('json')\r\n });\r\n \r\n if (formContent.hasClass('form-horizontal')) {\r\n formContent.children('div').each(function () {\r\n var div = $(this);\r\n var dataGrid = formContent.attr('data-grid') || '4-8';\r\n dataGrid = dataGrid.split('-');\r\n \r\n if (div.attr('class')) {\r\n if (div.hasClass('fb-button')) {\r\n div.find('button').wrap('
');\r\n } else {\r\n var label = div.children('label');\r\n var input = div.children('input, select, textarea');\r\n var subDiv = div.children('div');\r\n \r\n label.addClass('control-label col-sm-' + dataGrid[0]);\r\n \r\n if (subDiv.length > 0) {\r\n subDiv.addClass('col-sm-' + dataGrid[1]);\r\n } else {\r\n input.addClass('form-control').wrap('
');\r\n }\r\n }\r\n }\r\n });\r\n }\r\n },\r\n \r\n init: function (contentArea, container, component, keditor) {\r\n flog('init \"form\" component', component);\r\n \r\n var componentContent = component.find('.keditor-component-content');\r\n var formBuilder = component.find('.form-builder-area');\r\n var formContent = component.find('.form-content');\r\n var formData = component.find('.form-data');\r\n \r\n if (formData.length === 0) {\r\n componentContent.append('
')\r\n }\r\n \r\n if (formContent.length === 0) {\r\n componentContent.append('
')\r\n } else {\r\n formContent.hide()\r\n }\r\n \r\n if (formBuilder.length === 0) {\r\n formBuilder = $('
');\r\n componentContent.append(formBuilder);\r\n }\r\n \r\n this.initFormBuilder(component);\r\n },\r\n \r\n getContent: function (component, keditor) {\r\n flog('getContent \"form\" component', component);\r\n \r\n var self = this;\r\n var componentContent = component.find('.keditor-component-content');\r\n var formData = component.find('.form-data');\r\n var formBuilderArea = $('#' + component.attr('id')).find('.form-builder-area');\r\n var formBuilder = formBuilderArea.data('formBuilder');\r\n \r\n self.renderForm(component, formBuilder);\r\n formData.html(formBuilder.actions.getData('json'));\r\n component.find('.form-builder-area, .form-builder-tools').remove();\r\n component.find('.form-content').show();\r\n \r\n return componentContent.html();\r\n },\r\n \r\n settingEnabled: true,\r\n \r\n settingTitle: 'Form Settings',\r\n \r\n initSettingForm: function (form, keditor) {\r\n flog('initSettingForm \"form\" component');\r\n \r\n var self = this;\r\n \r\n form.html(\r\n '
' +\r\n '
' +\r\n ' ' +\r\n '
' +\r\n ' ' +\r\n '
' +\r\n '
' +\r\n '
' +\r\n ' ' +\r\n '
' +\r\n ' ' +\r\n '
' +\r\n '
' +\r\n '
' +\r\n ' ' +\r\n '
' +\r\n ' ' +\r\n '
' +\r\n '
' +\r\n '
' +\r\n ' ' +\r\n '
' +\r\n ' ' +\r\n '
' +\r\n '
' +\r\n '
' +\r\n ' ' +\r\n '
' +\r\n ' ' +\r\n ' This setting is for width of label and control with number of cols as unit' +\r\n '
' +\r\n '
' +\r\n '
'\r\n );\r\n \r\n \r\n form.find('.txt-form-action').on('change', function () {\r\n var component = keditor.getSettingComponent();\r\n var formContent = component.find('.form-content');\r\n \r\n formContent.attr('action', this.value);\r\n });\r\n \r\n form.find('.select-method').on('change', function () {\r\n var component = keditor.getSettingComponent();\r\n var formContent = component.find('.form-content');\r\n \r\n formContent.attr('action', this.value);\r\n });\r\n \r\n form.find('.select-enctype').on('change', function () {\r\n var component = keditor.getSettingComponent();\r\n var formContent = component.find('.form-content');\r\n \r\n formContent.attr('enctype', this.value);\r\n });\r\n \r\n form.find('.select-layout').on('change', function () {\r\n var component = keditor.getSettingComponent();\r\n var formContent = component.find('.form-content');\r\n \r\n formContent.removeClass('form-inline form-horizontal');\r\n if (this.value) {\r\n formContent.addClass(this.value);\r\n }\r\n self.renderForm(component);\r\n form.find('.select-grid-wrapper').css('display', this.value === 'form-horizontal' ? 'block' : 'none');\r\n });\r\n \r\n form.find('.select-grid').on('change', function () {\r\n var component = keditor.getSettingComponent();\r\n var formContent = component.find('.form-content');\r\n \r\n formContent.attr('data-grid', this.value);\r\n self.renderForm(component);\r\n });\r\n },\r\n \r\n showSettingForm: function (form, component, keditor) {\r\n flog('showSettingForm \"form\" component', component);\r\n var formContent = component.find('.form-content');\r\n \r\n var layout = '';\r\n if (formContent.hasClass('form-inline')) {\r\n layout = 'form-inline';\r\n } else if (formContent.hasClass('form-horizontal')) {\r\n layout = 'form-horizontal';\r\n }\r\n \r\n form.find('.txt-form-action').val(formContent.attr('action') || '');\r\n form.find('.select-method').val(formContent.attr('method') || 'get');\r\n form.find('.select-enctype').val(formContent.attr('enctype'));\r\n form.find('.select-layout').val(layout);\r\n form.find('.select-grid-wrapper').css('display', layout === 'form-horizontal' ? 'block' : 'none');\r\n form.find('.select-grid').val(formContent.attr('data-grid') || '4-8');\r\n }\r\n };\r\n \r\n})(jQuery);\r\n"]}