Current Path :
/
home
/
develito
/
httpdocs
/
components
/
com_raforms
/
views
/
fform
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/develito/httpdocs/components/com_raforms/views/fform/view.raw.php
<?php /* ------------------------------------------------------------------------ # com_raforms - rootArea Forms # ------------------------------------------------------------------------ # author Markus Döhla # copyright Copyright (C) 2012 rootarea.de. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # @license - Please read policy about plugins development in administrator/components/com_raforms/license-plugins.txt carefully # @license - Additional EULA on www.rootarea.de DOES NOT apply to ANY lite packages # Websites: http://www.rootarea.de # Technical Support: Forum - http://www.rootarea.de/en/forum ------------------------------------------------------------------------- */ //-- No direct access defined('_JEXEC') or die('=;)'); jimport('joomla.application.component.view'); class RAformsViewFForm extends JViewLegacy { function display($tpl = 'raw') { $app = JFactory::getApplication(); $document = JFactory::getDocument(); $this->user = JFactory::getUser(); $this->params = $app->getParams(); $this->showDeleteButton = false; $this->edit = false; $this->allowedit = false; $this->comments = false; $this->commentPosition = 1; $form = &$this->getModel('raform'); $formData = $form->getData(); // To prevent loading plugin javascript before mootools, // we load the framework into the document here JHTML::_('behavior.framework', true); // add standard javascript $this->addStandardJS(); // add CSS if applicable if (!empty($formData->config['form-css'])) { $document->addStyleDeclaration($formData->config['form-css']); } // get frontend form elements $raforms = &$this->getModel('fform'); $this->form = $raforms->getFormattedForm(); $submitformname = 'raforms-form-' . $form->formid; // add extended javascript $this->addExtendedJS($submitformname); // Set formname as pagetitle $document->setTitle( $this->form->formname ); parent::display($tpl); } function addStandardJS ($submitformname) { $document = JFactory::getDocument(); $javascript = <<<EOT window.addEvent('domready', function() {\n document.getElements('input').each(function(el) { if ( el.getParent('div.formField') && ['checkbox', 'radio', 'text'].contains(el.get('type'))) { el.getParent('div.formField').store('background', el.getParent('div.formField').getStyle('background-color')); } }); document.getElements('select').each(function(el) { if ( el.getParent('div.formField') ) { el.getParent('div.formField').store('background', el.getParent('div.formField').getStyle('background-color')); } }); document.getElements('textarea').each(function(el) { if ( el.getParent('div.formField') ) { el.getParent('div.formField').store('background', el.getParent('div.formField').getStyle('background-color')); } }); window.raformsValidate = new Form.Validator.Inline($('$submitformname'), { useTitles: true, evaluateOnSubmit: false, evaluateFieldsOnChange: false, evaluateFieldsOnBlur: false });\n raformsValidate.addAllThese([ ['validate-one-required', { errorMsg: '', test: function(element, props){ var p = element.getParent('div.formField'); var retval = false; return p.getElements('input').some(function(el) { if (['checkbox', 'radio'].contains(el.get('type'))) { if (el.get('checked')) { element.getParent('div.formField').setStyle('background-color', element.getParent('div.formField').retrieve('background')); retval = true; } else { element.getParent('div.formField').setStyle('background-color', '#FF0000'); } } else { if (el.get('value')) { element.getParent('div.formField').setStyle('background-color', element.getParent('div.formField').retrieve('background')); retval = true; } else { element.getParent('div.formField').setStyle('background-color', '#FF0000'); } } return retval; }); } }], ['required', { errorMsg: '', test: function(element) { if ((element.get('value') == null) || (element.get('value').length == 0)) { element.getParent('div.formField').setStyle('background-color', '#FF0000'); return false; } else { element.getParent('div.formField').setStyle('background-color', element.getParent('div.formField').retrieve('background')); } return true; } }], ['validate-email', { errorMsg: '', test: function(element) { if (!(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i).test(element.get('value'))) { element.getParent('div.formField').setStyle('background-color', '#FF0000'); return false; } else { element.getParent('div.formField').setStyle('background-color', element.getParent('div.formField').retrieve('background')); } return true; } }] ]); });\n EOT; $document->addScriptDeclaration($javascript); } function addExtendedJS() { $document = JFactory::getDocument(); $javascript = <<<EOT window.addEvent('domready', function() {\n EOT; if (!$this->allowedit) { $javascript .= <<<EOT $$('#$submitformname input').each ( function (el) { var typ = el.get('type'); if (typ == 'text') { var val = el.get('value'); new Element ('div', {'text': val}).replaces(el); } if (typ == 'checkbox' || typ == 'radio') { el.disabled = true; } }); var selOpt = []; $$('#$submitformname select').each ( function (el) { var texts = el.getSelected().get('text'); new Element ('div', {'text': texts.join(', ')}).replaces(el); }); $$('#$submitformname textarea').each ( function (el) { // exclude comment textarea if (el.get('id') != 'comment') { var val = el.get('text'); var style = el.get('style'); style = (!style.match(/;$/)) ? style + ';' : style; new Element ('div', {'text': val, 'style': style + ' overflow: auto;'}).replaces(el); } }); $$('.formLabel').setStyle('font-weight', 'bold'); EOT; } $javascript .= <<<EOT });\n EOT; $document->addScriptDeclaration($javascript); } } ?>