PageSourceSearch

https://wslr.org/wp-content/plugins/smart-forms/js/form-generator.js?ver=5

js wslr.org collected 2026-10-03 22:56:57 UTC 29,755 bytes, 851 lines download raw bytes

1function smartFormGenerator(options){
2    this.client_form_options=options.client_form_options;
3    this.Extensions=[];
4    RedNaoEventManager.Publish('GetClientExtension',{Generator:this,Extensions:this.Extensions});
5    this.MultipleStepsManager=null;
6    this.RedirectUrl='';
7    this.InitializeConditionalLogic();
8    this.SetDefaultIfUndefined('InvalidInputMessage','*Please fill all the required fields');
9    this.SubmittingThroughIframe=false;
10
11    this.JavascriptCodes=[];
12    if(typeof this.client_form_options.JavascriptCode!='undefined')
13    {
14        if(typeof this.client_form_options.JavascriptCode=='string')
15            this.client_form_options.JavaScriptCode=[{
16                JavascriptCode:this.client_form_options.JavascriptCode,
17                ActionType:'customjs'
18            }];
19    }
20
21    if(typeof this.client_form_options.ToolTipPosition=='undefined')
22        this.client_form_options.ToolTipPosition='none';
23
24    var i;
25    for(i=0;i<this.client_form_options.JavascriptCode.length;i++)
26    {
27        try{
28            this.JavascriptCodes.push(eval(this.client_form_options.JavascriptCode[i].JavascriptCode)());
29
30        }catch(exception)
31        {
32
33        }
34    }
35
36    if(typeof this.client_form_options.Theme!='undefined'&&this.client_form_options.Theme=='material'){
37        this.Theme='material';
38        rnJQuery.RNLoadLibrary([smartFormsPath+'js/bootstrap/material.min.js'],[smartFormsPath+'css/bootstrap/bootstrap-material-scoped.css'],function(){
39
40        });
41    }else
42        this.Theme='basic';
43
44
45    this.form_id=options.form_id;
46    this.options=options;
47    this.RedNaoFormElements=[];
48    this.FormElements=[];
49    var elementOptions=options.elements;
50    this.client_form_options.DocumentWidth=rnJQuery(window).width();
51    for(i=0;i<elementOptions.length;i++)
52    {
53        elementOptions[i].FormId=this.form_id;
54        var element=sfRedNaoCreateFormElementByName(elementOptions[i].ClassName,elementOptions[i]);
55        element.FormId=this.form_id;
56        element.Generator=this;
57        element.InvalidInputMessage=RedNaoEscapeHtml(this.client_form_options.InvalidInputMessage);
58        element.ClientOptions=this.client_form_options;
59        this.RedNaoFormElements.push(element);
60        this.FormElements.push(element);
61    }
62
63    for(i=0;i<this.FormElements.length;i++)
64    {
65        this.FormElements[i].InitializeFieldLinking(this.FormElements);
66    }
67
68    this.containerName=options.container;
69    if(typeof this.client_form_options.CSS!='undefined')
70        this.CreateCSS();
71    if(this.client_form_options.redirect_to_cb=="y"&&typeof this.client_form_options.redirect_to=='string')
72    {
73        this.client_form_options.redirect_to={
74            URL:this.client_form_options.redirect_to,
75            RCSettings:{
76                Redirect:'always',
77                ConditionSettings:[]
78            }
79        }
80    }
81    this.CreateForm();
82
83}
84
85smartFormGenerator.prototype.GetCurrentData=function()
86{
87  return RedNaoFormulaManagerVar.Data;
88};
89
90smartFormGenerator.prototype.GetFormId=function()
91{
92    if(typeof this.FormId=='undefined')
93        return 0;
94    return this.FormId;
95};
96
97smartFormGenerator.prototype.CreateCSS=function()
98{
99    if(SmartFormsIsIE8OrEarlier())
100        return;
101
102    var $style=rnJQuery("<style type='text/css'></style>");
103
104    if(this.client_form_options.CSS==null)
105        this.client_form_options.CSS='';
106
107    $style.append(this.client_form_options.CSS.replace(/<[^>]*>/g, ''));
108    rnJQuery("head").append($style);
109};
110
111smartFormGenerator.prototype.InitializeConditionalLogic=function()
112{
113    if(typeof this.client_form_options.Conditions !='undefined')
114    {
115        for(var i=0;i<this.client_form_options.Conditions.length;i++)
116        {
117            var condition=this.client_form_options.Conditions[i];
118            this.client_form_options.Conditions[i]=SmartFormsGetConditionalHandlerByType(condition.Type,condition);
119        }
120    }else
121        this.client_form_options.Conditions=[];
122};
123
124smartFormGenerator.prototype.SetDefaultIfUndefined=function(propertyName,defaultValue)
125{
126    if(typeof this.client_form_options[propertyName]=='undefined')
127        this.client_form_options[propertyName]=defaultValue;
128    if(typeof this.client_form_options.CaptchaVersion=='undefined')
129        this.client_form_options.CaptchaVersion='1';
130};
131
132smartFormGenerator.prototype.CreateForm=function(){
133    SmartFormsModules.ContainerManager.ClearContainer(this.options.form_id);
134    var container=this.GetRootContainer();
135    container.empty();
136    var themeStyle=this.Theme=='material'?'rnbsm':'';
137    this.JQueryForm=rnJQuery('<form id="sf'+this.form_id+'" class="form-horizontal '+themeStyle+'" ></form>');
138    this.JQueryForm.css('visibility','hidden');
139    container.append(this.JQueryForm);
140
141    this.JQueryForm.parent().removeClass('compact').removeClass('exptop').removeClass('expleft');
142    var labelLayout='auto';
143    if(typeof this.client_form_options.LabelLayout!='undefined')
144        labelLayout=this.client_form_options.LabelLayout;
145    if(this.JQueryForm.width()<=500)
146        this.JQueryForm.parent().addClass('compact');
147    if(labelLayout=='top')
148        this.JQueryForm.parent().addClass('exptop');
149    if(labelLayout=='left')
150        this.JQueryForm.parent().addClass('expleft');
151
152    var i;
153    for(i=0;i<this.RedNaoFormElements.length;i++)
154    {
155        this.RedNaoFormElements[i].AppendElementToContainer(this.JQueryForm);
156    }
157    this.JQueryForm.append('<div class="sfClearFloat"></div>');
158
159
160
161
162
163    var self=this;
164    //if(RedNaoGetValueOrNull(this.client_form_options.Campaign))
165      //  this.CreatePayPalHiddenFields();
166
167    this.SubmittingRedNaoDonationForm='n';
168    RedNaoEventManager.Publish('FormCreated',{Generator:this});
169    this.JQueryForm.submit(function(e){
170        if(self.SubmittingRedNaoDonationForm=='y')
171        {
172            self.SubmittingRedNaoDonationForm='n';
173            return;
174        }
175
176        if(self.SubmittingThroughIframe==true)
177        {
178            self.SubmittingThroughIframe=false;
179            return;
180        }
181
182        e.preventDefault();
183        e.stopPropagation();
184        self.SaveForm();
185    });
186
187
188
189    if(typeof this.client_form_options.FormType!='undefined'&&this.client_form_options.FormType=='sec')
190    {
191        rnJQuery.RNLoadLibrary([smartFormsPath+'js/utilities/fuelux/wizard.js' ,smartFormsPath+'js/multiple_steps/multiple_steps_base.js'],[smartFormsPath+'js/utilities/fuelux/fuelux.css'],function(){
192            self.InitializeMultipleSteps();
193            self.FormLoaded();
194        });
195    }else
196    {
197        this.FormLoaded();
198    }
199
200};
201
202smartFormGenerator.prototype.FireExtensionMethod=function(methodName,args)
203{
204    var result=undefined;
205    for(var i=0;i<this.Extensions.length;i++)
206    {
207        if(typeof this.Extensions[i][methodName]!='undefined')
208        {
209            var auxResult = this.Extensions[i][methodName](this, args);
210            if (typeof auxResult != 'undefined')
211                result = auxResult;
212        }
213    }
214
215    return result;
216};
217
218smartFormGenerator.prototype.FormLoaded=function()
219{
220    this.FireExtensionMethod('BeforeInitializingFieldData');
221    var i;
222    for(i=0;i<this.RedNaoFormElements.length;i++)
223    {
224        if(this.RedNaoFormElements[i].StoresInformation())
225            RedNaoFormulaManagerVar.SetFormulaValue(this.RedNaoFormElements[i],this.RedNaoFormElements[i].Id,this.RedNaoFormElements[i].GetValueString())
226    }
227
228    RedNaoFormulaManagerVar.RefreshAllFormulas();
229    if(RedNaoGetValueOrNull(this.client_form_options.Campaign))
230        this.CreatePayPalHiddenFields();
231    this.ExecuteConditionalLogicInAllFields();
232    this.JQueryForm.css('visibility', 'visible');
233    try{
234        for(i=0;i<this.JavascriptCodes.length;i++)
235            this.JavascriptCodes[i].AfterFormLoaded(this);
236    }catch(exception)
237    {
238
239    }
240
241    RedNaoEventManager.Publish('AfterFormLoaded',{Generator:this});
242
243};
244
245smartFormGenerator.prototype.ExecuteConditionalLogicInAllFields=function()
246{
247    for(var i=0;i<this.client_form_options.Conditions.length;i++)
248    {
249        this.client_form_options.Conditions[i].Initialize(this,RedNaoFormulaManagerVar.Data);
250    }
251};
252
253smartFormGenerator.prototype.InitializeMultipleSteps=function()
254{
255    this.MultipleStepsManager=new SfMultipleStepsBase(this.client_form_options.SplitSteps,this.JQueryForm,this.FormElements,this);
256    this.MultipleStepsManager.Generate();
257};
258
259smartFormGenerator.prototype.CreatePayPalHiddenFields=function()
260{
261    this.PaypalForm=jQuery('<form style="display: none"></form>');
262    jQuery(document.body).append(this.PaypalForm);
263
264    if(smartDonationsSandbox=='y')
265        this.PaypalForm.attr('action','https://www.sandbox.paypal.com/cgi-bin/webscr');
266    else
267        this.PaypalForm.attr('action','https://www.paypal.com/cgi-bin/webscr');
268    this.PaypalForm.attr('method','POST');
269    this.PaypalForm.attr('target','_self');
270
271    var target="_self";
272    if(window.self !== window.top)
273        target="_parent";
274    this.JQueryForm.attr('target',target);
275
276    var type="_donations";
277    var options=this.client_form_options;
278    if(typeof options.PayPalType!='undefined'&&options.PayPalType=='payment')
279        type='_xclick';
280    this.PaypalForm.append(' <input type="hidden" name="cmd" class="smartDonationsPaypalCommand" value="'+type+'">\
281                <input type="hidden" name="item_name" value="'+options.PayPalDescription+'">\
282                <input type="hidden" name="business" value="'+options.PayPalEmail+'">\
283                <input type="hidden" name="lc" value="US">                       \
284                <input type="hidden" name="no_note" value="0">                    \
285                <input type="hidden" name="currency_code" value="'+options.PayPalCurrency+'">             \
286                <input type="hidden" name="bn" value="Rednao_SP">\
287                <input type="hidden" name="custom" value=type=form&campaign_id='+options.Campaign+'&formId='+this.options.form_id+'>\
288                <input type="hidden" name="amount" class="amountToDonate" value="0">\
289                <input name="bn" value="Rednao_SP" type="hidden">\
290                <input type="hidden" name="notify_url" value="'+smartDonationsRootPath+'ipn/rednao_paypal_ipn.php">'
291        );
292
293    if(RedNaoGetValueOrEmpty(this.client_form_options.redirect_to_cb)=="y")
294        this.PaypalForm.append('<input type="hidden" name="return" value="">');
295
296};
297
298smartFormGenerator.prototype.GenerationCompleted=function()
299{
300    var form=this.GetRootContainer().find('form');
301    form.addClass('formelements').attr('id','redNaoElementlist');
302
303    for(var i=0;i<this.FormElements.length;i++)
304    {
305        this.FormElements[i].AppendElementToContainer(form);
306    }
307
308    var self=this;
309    form.find('.redNaoDonationButton').click(function()
310        {
311
312            try{
313
314                self.SaveForm();
315
316            }catch(error)
317            {
318
319
320            }finally{
321                //noinspection ReturnInsideFinallyBlockJS
322                return false;
323            }
324        }
325    );
326
327};
328
329smartFormGenerator.prototype.GenerateDefaultStyle=function()
330{
331    this.styles.formelements="width:600px;padding:10px;margin:0px;";
332};
333
334
335smartFormGenerator.prototype.SaveForm=function()
336{
337    var formValues={};
338    var formIsValid=true;
339    var amount=0;
340
341    this.GetRootContainer().find('.redNaoValidationMessage').remove();
342    this.GetRootContainer().find('.redNaoSubmitButton').removeClass('btn-danger');
343    this.GetRootContainer().find('.redNaoInputText,.redNaoRealCheckBox,.redNaoInputRadio,.redNaoInputCheckBox,.redNaoSelect,.redNaoTextArea,.redNaoInvalid,.has-error').removeClass('redNaoInvalid').removeClass('has-error');
344    var isUsingAFileUploader=false;
345
346    var self=this;
347    var afterValidation=function(){
348        var firstInvalidField=null;
349        for(var i=0;i<self.FormElements.length;i++)
350        {
351            self.FormElements[i].ClearInvalidStyle();
352            if(self.FormElements[i].Options.ClassName=="sfFileUpload"||self.FormElements[i].Options.ClassName=="rednaoimageupload")
353                isUsingAFileUploader=true;
354
355            if(self.FormElements[i].Options.ClassName=='rednaorepeater')
356            {
357                for(var t=0;t<self.FormElements[i].Fields.length;t++)
358                {
359                    if(self.FormElements[i].Fields[t].Options.ClassName=='sfFileUpload'||self.FormElements[i].Fields[t].Options.ClassName=='rednaoimageupload')
360                        isUsingAFileUploader=true;
361                }
362            }
363
364            if(!self.FormElements[i].IsIgnored()&&!self.FormElements[i].IsValid())
365            {
366                formIsValid=false;
367                if(firstInvalidField==null)
368                    firstInvalidField=self.FormElements[i];
369                continue;
370            }
371            if(self.FormElements[i].StoresInformation())
372            {
373                var value=self.FormElements[i].GetValueString();
374                amount+=self.FormElements[i].amount;
375                formValues[self.FormElements[i].Id]=value;
376            }
377        }
378        if(!formIsValid)
379        {
380            //self.GetRootContainer().prepend('<p class="redNaoValidationMessage" style="margin:0;padding: 0; font-style: italic; color:red;font-family:Arial,serif;font-size:12px;">'+RedNaoEscapeHtml(self.client_form_options.InvalidInputMessage)+'</p>');
381            self.GetRootContainer().find('.redNaoSubmitButton').addClass('btn-danger');
382            self.ScrollTo(firstInvalidField.JQueryElement);
383            return;
384        }
385
386
387        if(formValues.length>0)
388            formValues=formValues.substr(1);
389
390        try{
391
392            for(i=0;i<self.JavascriptCodes.length;i++)
393            {
394                if(typeof self.JavascriptCodes[i].BeforeFormSubmit!='undefined'&&(self.JavascriptCodes[i].BeforeFormSubmit(formValues,self.FormElements)==false))
395                    return;
396            }
397
398        }catch(exception)
399        {
400
401        }
402
403        self.ProcessRedirectUrl().then(function(result){
404
405            self.RedirectUrl=result;
406            if(RedNaoGetValueOrNull(self.client_form_options.Campaign)){
407                if(typeof self.client_form_options.PayPalCondition=='undefined'||typeof self.client_form_options.PayPalCondition.DonationSettings=='undefined'||self.client_form_options.PayPalCondition.DonationSettings.RequestPayment=='always')
408                {
409                    self.SendToSmartDonations(formValues, isUsingAFileUploader);
410                }
411                else
412                {
413                    var calculation = RedNaoEventManager.Publish('CalculateCondition', {
414                        Condition: self.client_form_options.PayPalCondition.DonationSettings.ConditionSettings,
415                        Values: self.GetCurrentData()
416                    });
417                    calculation.then(function (result) {
418                        if (result)
419                            self.SendToSmartDonations(formValues, isUsingAFileUploader);
420                        else
421                            self.PreSendToSmartForms(formValues, isUsingAFileUploader);
422                    });
423                }
424            }
425
426            else
427                self.PreSendToSmartForms(formValues,isUsingAFileUploader);
428
429            try{
430                rnJQuery('body, input[type="submit"]').addClass('redNaoWait');
431                self.JQueryForm.find('input[type="submit"],.redNaoMSButton').attr('disabled','disabled');
432            }catch(exception)
433            {
434
435            }
436        });
437
438
439    };
440
441    var args={Generator:this,Promises:[]};
442    RedNaoEventManager.Publish('BeforeValidatingForm',args);
443    if(args.Promises.length>0)
444        Promise.all(args.Promises).then(afterValidation);
445    else
446        afterValidation();
447};
448
449smartFormGenerator.prototype.ScrollTo=function($elementToScrollTo)
450{
451    var scroll = $elementToScrollTo.offset();
452    if (window.pageYOffset>scroll.top)
453        rnJQuery('html, body').animate({scrollTop: scroll.top-50}, 200);
454};
455
456smartFormGenerator.prototype.PreSendToSmartForms=function(formValues,isUsingAFileUploader)
457{
458    var handled=this.FireExtensionMethod('BeforeSendingToSmartFormsForm',formValues);
459    var self=this;
460    if(typeof handled!='undefined'&&handled instanceof Promise)
461    {
462        RedNaoEventManager.Publish('FormSubmitted',{Generator:self});
463        handled.then(function(result){
464            if(result)
465                self.SendToSmartForms(formValues,isUsingAFileUploader);
466            else
467                RedNaoEventManager.Publish('FormSubmittedCompleted',{Generator:self});
468        });
469    }else{
470        self.SendToSmartForms(formValues,isUsingAFileUploader);
471    }
472
473
474};
475
476smartFormGenerator.prototype.SendToSmartForms=function(formValues,isUsingAFileUploader)
477{
478
479    var data={
480        form_id:this.form_id,
481        action:"rednao_smart_forms_save_form_values",
482        formString:JSON.stringify(formValues),
483        requestUrl:document.URL,
484        nonce:smartFormsSaveNonce
485    };
486
487
488
489    if(this.client_form_options.UsesCaptcha=='y')
490    {
491        if(this.client_form_options.CaptchaVersion=='1')
492            data.captcha={
493                version:1,
494                challenge:this.JQueryForm.find('[name="recaptcha_challenge_field"]').val(),
495                response:this.JQueryForm.find('[name="recaptcha_response_field"]').val()
496            };
497        else{
498            var captchaId="";
499            for(var i=0;i<this.FormElements.length;i++)
500                if(this.FormElements[i].Id=="captcha2")
501                    captchaId=this.FormElements[i].captchaId;
502            data.captcha={
503                version:2,
504                response:grecaptcha.getResponse(captchaId)
505            }
506        }
507
508
509    }
510
511    if(isUsingAFileUploader)
512        this.SendFilesWithForm(data,formValues);
513    else
514    {
515        var self=this;
516        //noinspection JSUnusedLocalSymbols
517        RedNaoEventManager.Publish('FormSubmitted',{Generator:this});
518        rnJQuery.ajax({
519            type:'POST',
520            url:ajaxurl,
521            dataType:"json",
522            data:data,
523            success:function(result){self.SaveCompleted(result,formValues)},
524            error:function(result){
525                rnJQuery('body, input[type="submit"]').removeClass('redNaoWait');
526                self.JQueryForm.find('input[type="submit"],.redNaoMSButton').removeAttr('disabled');
527                alert('An error occurred, please try again later');}
528        });
529    }
530};
531
532smartFormGenerator.prototype.SendFilesWithForm=function(data,formValues)
533{
534    data=JSON.stringify(data);
535    rnJQuery('#sfTemporalIFrame').remove();
536    rnJQuery('body').append('<iframe id="sfTemporalIFrame" name="sfTemporalIFrame"></iframe>');
537    var self=this;
538    RedNaoEventManager.Publish('FormSubmitted',{Generator:this});
539    rnJQuery('#sfTemporalIFrame').on('load',function()
540    {
541        var response;
542        if (this.contentDocument) {
543            response = this.contentDocument.body.innerText;
544        } else {
545            response = this.contentWindow.document.body.innerText;
546        }
547
548        var regex=/{.*}/g;
549        var match=regex.exec(response);
550        if(match!=null)
551            response=match[0];
552
553        self.SaveCompleted(rnJQuery.parseJSON(response),formValues);
554    });
555    this.JQueryForm.attr('method','post');
556    this.JQueryForm.attr('enctype','multipart/form-data');
557    this.JQueryForm.attr('target','sfTemporalIFrame');
558    this.JQueryForm.attr('action',ajaxurl);
559    var dataField=rnJQuery('<input type="hidden" name="data"/> ');
560    dataField.val(data);
561    this.JQueryForm.append(dataField);
562    this.JQueryForm.append('<input type="hidden" name="action" value="rednao_smart_forms_send_files"/>');
563    this.SubmittingThroughIframe=true;
564    this.JQueryForm.submit();
565
566};
567
568//noinspection JSUnusedLocalSymbols
569smartFormGenerator.prototype.SendToSmartDonations=function(formValues,isUsingAFileUploader)
570{
571    this.JQueryForm.find('input[name="return"]').val(this.RedirectUrl);
572    if(RedNaoPathExists(this.client_form_options,'Formulas.DonationFormula'))
573    {
574        //noinspection JSUnresolvedVariable
575        var formula=new RedNaoFormula(null,this.client_form_options.Formulas.DonationFormula);
576        var donationAmount=formula.GetValueFromFormula(RedNaoFormulaManagerVar.Data);
577        var self=this;
578        if(donationAmount instanceof Promise)
579            donationAmount.then(function(result){self.ProcessDonation(formValues,isUsingAFileUploader,result)});
580        else
581            self.ProcessDonation(formValues,isUsingAFileUploader,donationAmount);
582
583
584
585    }
586
587
588
589};
590
591smartFormGenerator.prototype.ProcessDonation=function(formValues,isUsingAFileUploader,donationAmount){
592    if(donationAmount<=0)
593    {
594        this.GetRootContainer().prepend('<p class="redNaoValidationMessage" style="margin:0;padding: 0; font-style: italic; color:red;font-family:Arial,serif;font-size:12px;">*The donation amount should be greater than zero</p>');
595        return;
596    }
597
598    var self=this;
599
600
601    var data={
602        action:"rednao_smart_donations_save_form_values",
603        emailToNotify:this.emailToNotify,
604        formString:JSON.stringify(formValues)
605    };
606
607    var donationFormSaveComplete=function(data){
608        if(data.status=="success")
609        {
610            self.PaypalForm.find('.amountToDonate').val(donationAmount);
611            self.PaypalForm.find('input[name=custom]').val(encodeURI('type=form&campaign_id='+self.client_form_options.Campaign+"&formId="+data.randomString+'&sformid='+self.form_id));
612            if(self.PaypalForm.find('.redNaoRecurrence').length>0&&self.JQueryForm.find('.redNaoRecurrence').find(':selected').val()!='OT')
613            {
614                self.PaypalForm.find('.amountToDonate').attr('name','a3');
615                self.PaypalForm.find('.smartDonationsPaypalCommand').val('_xclick-subscriptions');
616                self.PaypalForm.append('<input type="hidden" class="redNaoRecurrenceField" name="src" value="1"><input type="hidden" class="redNaoRecurrenceField" name="p3" value="1"><input type="hidden" name="t3" value="'+self.JQueryForm.find('.redNaoRecurrence').find(':selected').val()+'">');
617            }
618
619debugger;
620            self.SubmittingRedNaoDonationForm='y';
621            self.PaypalForm.submit();
622
623
624        }else
625        {
626            alert("An error occured, please try again");
627        }
628    };
629
630    RedNaoEventManager.Publish('FormSubmitted',{Generator:this});
631    if(isUsingAFileUploader)
632    {
633        var previousAction=this.JQueryForm.attr('action');
634        var previousEncoding=  this.JQueryForm.attr('enctype');
635        var previousTarget=  this.JQueryForm.attr('target');
636        this.JQueryForm.attr('method','post');
637        this.JQueryForm.attr('enctype','multipart/form-data');
638        this.JQueryForm.attr('target','sfTemporalIFrame');
639        this.JQueryForm.attr('action',ajaxurl);
640        this.JQueryForm.append('<input type="hidden" name="action" value="rednao_smart_donations_save_form_values"/>');
641
642
643        rnJQuery('#sfTemporalIFrame').remove();
644        rnJQuery('body').append('<iframe id="sfTemporalIFrame" name="sfTemporalIFrame"></iframe>');
645        rnJQuery('#sfTemporalIFrame').on('load',function()
646        {
647            self.JQueryForm.attr('action',previousAction);
648            self.JQueryForm.attr('enctype',previousEncoding);
649            self.JQueryForm.attr('target',previousTarget);
650            var response;
651            if (this.contentDocument) {
652                response = this.contentDocument.body.innerHTML;
653            } else {
654                response = this.contentWindow.document.body.innerHTML;
655            }
656
657            try{
658                response=JSON.parse(response);
659            }catch(e){
660
661            }
662            donationFormSaveComplete(response);
663        });
664        var dataField=rnJQuery('<input type="hidden" name="formString"/> ');
665        dataField.val(data.formString);
666        this.JQueryForm.append(dataField);
667
668        this.SubmittingThroughIframe=true;
669        this.JQueryForm.submit();
670    }else
671        rnJQuery.post(ajaxurl,data,donationFormSaveComplete,"json");
672}
673
674smartFormGenerator.prototype.SaveCompleted=function(result,formValues){
675    RedNaoEventManager.Publish('FormSubmittedCompleted',{Generator:this});
676    rnJQuery('body, input[type="submit"]').removeClass('redNaoWait');
677    this.JQueryForm.find('input[type="submit"],.redNaoMSButton').removeAttr('disabled');
678    if(this.RedirectUrl.search('@@formid')>=0)
679        this.RedirectUrl=this.RedirectUrl.replace('@@formid',result.insertedValues._formid);
680
681    if(typeof result.AdditionalActions!='undefined')
682    {
683        for(var i=0;i<result.AdditionalActions.length;i++)
684        {
685            if(result.AdditionalActions[i].Action=="RedirectTo")
686            {
687                window.location=result.AdditionalActions[0].Value;
688                return;
689            }
690
691            if(result.AdditionalActions[i].Action=="ShowMessage")
692            {
693                alert(result.AdditionalActions[i].Value.Message);
694                return;
695            }
696
697
698            var result=RedNaoEventManager.Publish('SubmitAction',{'Action':result.AdditionalActions[i],Generator:this});
699            if(result===false)
700                return;
701
702
703        }
704    }
705
706    if(typeof result.refreshCaptcha!='undefined'&&result.refreshCaptcha=='y')
707    {
708        alert(result.message);
709        Recaptcha.reload();
710        return;
711    }
712
713    if(result.success=='y')
714        this.FireExtensionMethod('FormSubmissionCompleted');
715
716    if((RedNaoGetValueOrEmpty(this.client_form_options.alert_message_cb)!='y'&&RedNaoGetValueOrEmpty(this.client_form_options.redirect_to_cb)!='y')||result.success=='n')
717    {
718        alert(result.message);
719        if(RedNaoGetValueOrEmpty(this.client_form_options.DontClearForm)!='y')
720            this.CreateForm();
721        return;
722    }
723
724    if(RedNaoGetValueOrEmpty(this.client_form_options.alert_message_cb)=='y')
725        alert(this.client_form_options.alert_message);
726
727    if(RedNa
727oGetValueOrEmpty(this.client_form_options.DontClearForm)!='y')
728        this.CreateForm();
729
730    if(RedNaoGetValueOrEmpty(this.client_form_options.redirect_to_cb)=="y")
731    {
732        this.CreateForm();
733        window.location=this.RedirectUrl;
734    }
735
736
737};
738
739smartFormGenerator.prototype.GetUrl=function(redirectOptions,index,formValues){
740    var self=this;
741    return new Promise(function(resolve){
742        if(index>=redirectOptions.length)
743            resolve('');
744
745
746
747        if(redirectOptions[index].RCSettings.Redirect=='always')
748        {
749            resolve(redirectOptions[index].URL);
750        }else{
751
752            var processCalculation=function(calculation){
753                if(calculation)
754                {
755                    resolve(redirectOptions[index].URL);
756                }else{
757                    self.GetUrl(redirectOptions,index+1,formValues).then(function(result){resolve(result)});
758                }
759            };
760
761            var calculation=RedNaoEventManager.Publish('CalculateCondition',{Condition:redirectOptions[index].RCSettings.ConditionSettings ,Values:formValues});
762            if(calculation instanceof Promise)
763            {
764                calculation.then(function(result){
765                    processCalculation(result);
766                });
767            }else
768                processCalculation(calculation);
769
770        }
771
772
773
774    });
775
776};
777
778smartFormGenerator.prototype.ProcessRedirectUrl=function()
779{
780    var self=this;
781    return new Promise(function(resolve){
782        if(self.client_form_options.redirect_to_cb=='n')
783            resolve('');
784        var redirectOptions=self.client_form_options.redirect_to;
785        var formValues=self.GetCurrentData();
786        var i;
787        var url='';
788        var redirectToUse=null;
789
790
791        self.GetUrl(redirectOptions,0,formValues).then(function(url) {
792
793            var regEx = /{([^}]+)}/g;
794            var matches;
795
796            while (matches = regEx.exec(url))
797            {
798                regEx.lastIndex = 0;
799                for (i = 0; i < matches.length; i++)
800                {
801                    if (matches[i][0] == '{')
802                        continue;
803                    var value = '';
804                    if (typeof formValues[matches[i]] != 'undefined')
805                    {
806                        value = formValues[matches[i]].label;
807                        for (var t = 0; t < self.RedNaoFormElements.length; t++)
808                            if (matches[i] == self.RedNaoFormElements[t].Id)
809                                switch(self.RedNaoFormElements[t].Options.ClassName){
810                                    case 'rednaodatepicker':
811                                        value=formValues[matches[i]].value;
812                                        break;
813                                    case "rednaoaddress":
814                                        value=JSON.stringify(formValues[matches[i]].OriginalValues);
815                                        break;
816                                }
817
818                    }
819                    if (matches[i] == '_formid')
820                        url = url.replace('{' + matches[i] + '}', '@@formid');
821                    else
822                        url = url.replace('{' + matches[i] + '}', encodeURIComponent(value));
823                }
824            }
825
826            resolve(url);
827        });
828    });
829};
830
831smartFormGenerator.prototype.GetRootContainer=function()
832{
833    return rnJQuery('#'+this.containerName);
834};
835
836rnJQuery(function(){
837    if( window.smartFormsItemsToLoad)
838        for(var i=0;i< window.smartFormsItemsToLoad.length;i++)
839            smartFormsLoadForm(window.smartFormsItemsToLoad[i]);
840});
841
842
843var smartFormsLoadedItems=[];
844
845function smartFormsLoadForm(options)
846{
847    var form=new smartFormGenerator(options);
848    smartFormsLoadedItems.push(form);
849
850
851}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.