PageSourceSearch

https://www.linassimonis.lt/wp-content/plugins/smart-forms/js/formBuilder/formelements.js?ver=19

js linassimonis.lt collected 2026-10-10 00:32:57 UTC 162,250 bytes, 4,446 lines download raw bytes

1"use strict";
2
3function SmartFormsIsIE8OrEarlier()
4{
5    return navigator.appVersion.indexOf("MSIE 7.")!=-1||navigator.appVersion.indexOf("MSIE 8.")!=-1||navigator.appVersion.indexOf("MSIE 9.")!=-1;
6}
7/************************************************************************************* Formula Methods ***************************************************************************************************/
8var SmartFormsStyleScopeField=1;
9var SmartFormsStyleScopeType=2;
10var SmartFormsStyleScopeAll=3;
11
12//used in an string that is evaluated as function
13//noinspection JSUnusedGlobalSymbols
14function RedNaoGetValueFromArray(array)
15{
16    var value=0;
17
18    for(var i=0;i<array.length;i++)
19    {
20        var aux=parseFloat(array[i].amount);
21        if(isNaN(aux))
22           aux=0;
23        value+=aux;
24    }
25
26    return value;
27}
28
29
30function RedNaoListContainsValue(options,value)
31{
32    var arrayOfValues;
33    if(value!=null&&typeof value.selectedValues !='undefined')
34        arrayOfValues=value.selectedValues;
35    else
36    {
37        arrayOfValues=[];
38        arrayOfValues.push(value);
39    }
40
41    for(var i=0;i<arrayOfValues.length;i++)
42    {
43        for(var h=0;h<options.length;h++)
44            if(rnJQuery.trim(options[h].toLowerCase())==rnJQuery.trim(arrayOfValues[i].label.toLowerCase()))
45                return true;
46    }
47
48    return false;
49}
50
51
52/************************************************************************************* End or formula methods ***************************************************************************************************/
53
54
55
56
57function RedNaoFormElementEscape(property)
58{
59    return property.replace(' ','_');
60}
61
62function sfRedNaoCreateFormElementByName(elementName,options,serverOptions)
63{
64    if(elementName=='rednaotextinput')
65        return new sfTextInputElement(options,serverOptions);
66    if(elementName=='rednaoprependedtext')
67        return new sfPrependTexElement(options,serverOptions);
68    if(elementName=='rednaoappendedtext')
69        return new sfAppendedTexElement(options,serverOptions);
70    if(elementName=='rednaoprependedcheckbox')
71        return new sfPrependCheckBoxElement(options,serverOptions);
72    if(elementName=='rednaoappendedcheckbox')
73        return new sfAppendCheckBoxElement(options,serverOptions);
74    if(elementName=='rednaobuttondropdown')
75        return 'rednaobuttondropdown';
76    if(elementName=='tabradioscheckboxes')
77        return 'tabradioscheckboxes';
78    if(elementName=='rednaomultiplecheckboxes')
79        return new sfMultipleCheckBoxElement(options,serverOptions);
80    if(elementName=='rednaoselectbasic')
81        return new sfSelectBasicElement(options,serverOptions);
82    if(elementName=='rednaofilebutton')
83        return 'rednaofilebutton';
84    if(elementName=='rednaosinglebutton')
85        return 'rednaosinglebutton';
86    if(elementName=='rednaodoublebutton')
87        return 'rednaodoublebutton';
88    if(elementName=='rednaotitle')
89        return new sfTitleElement(options,serverOptions);
90    if(elementName=='rednaotextarea')
91        return  new sfTextAreaElement(options,serverOptions);
92    if(elementName=='rednaomultipleradios')
93        return new sfMultipleRadioElement(options,serverOptions);
94    if(elementName=='rednaodonationbutton')
95        return new sfDonationButtonElement(options,serverOptions);
96    if(elementName=='rednaodonationrecurrence')
97        return new sfRecurrenceElement(options,serverOptions);
98    if(elementName=='rednaosubmissionbutton')
99        return new sfRedNaoSubmissionButton(options,serverOptions);
100
101    if(elementName=='rednaodatepicker')
102        return new sfRedNaoDatePicker(options,serverOptions);
103    if(elementName=='rednaoname')
104        return new sfRedNaoName(options,serverOptions);
105    if(elementName=='rednaoaddress')
106        return new sfRedNaoAddress(options,serverOptions);
107    if(elementName=='rednaophone')
108        return new sfRedNaoPhone(options,serverOptions);
109    if(elementName=='rednaoemail')
110        return new sfRedNaoEmail(options,serverOptions);
111    if(elementName=='rednaonumber')
112        return new sfRedNaoNumber(options,serverOptions);
113    if(elementName=='rednaocaptcha')
114        return new sfRedNaoCaptcha(options,serverOptions);
115    if(elementName=='rednaohtml')
116        return new sfHtmlElement(options,serverOptions);
117    if(elementName=='rednaosearchablelist')
118        return new sfSearchableList(options,serverOptions);
119    if(elementName=='rednaosurveytable')
120        return new sfSurveyTable(options,serverOptions);
121    if(elementName=='rednaorating')
122        return new sfRating(options,serverOptions);
123    if(elementName=='rednaolineseparator')
124        return new sfLineSeparator(options,serverOptions);
125
126    for(var i=0;i<sfFormElementBase.Extensions.length;i++)
127        if(sfFormElementBase.Extensions[i].Name==elementName)
128            return sfFormElementBase.Extensions[i].Create(options,serverOptions);
129
130    var formId=0;
131    if(options!=null&&typeof options.FormId!='undefined')
132        formId=options.FormId;
133
134    var smartFormsAdditionalFields=window['smartFormsAdditionalFields'+formId];
135
136    if(typeof smartFormsAdditionalFields!='undefined')
137    {
138        for (var i = 0; i < smartFormsAdditionalFields.length; i++)
139        {
140            if (smartFormsAdditionalFields[i].id == elementName)
141                return new SmartFormsFields[smartFormsAdditionalFields[i].id](options, serverOptions);
142        }
143    }
144    console.log('The field '+elementName+' was not found');
145    throw 'Element Type Not Found';
146}
147
148/************************************************************************************* Base Class  ***************************************************************************************************/
149function sfFormElementBase(options,serverOptions)
150{
151    //Variable declared in another javascript;
152    //noinspection JSUnresolvedVariable
153    this.Translations=SmartFormsElementsTranslation;
154    this.StyleTags={};
155    this.Fields=[];
156    this.IsFieldContainer=false;
157    this.HandleFieldsInternally=false;
158    this.FieldContainer=null;
159    this._ignore=false;
160    this.IsInternal=false;
161    this.Generator=null;
162    this.Errors={};
163    this.ShowRequests=[];
164    this.Container=null;
165    if(options==null)
166    {
167        this.Options={};
168        this.ServerOptions={};
169        this.Options._id=++sfFormElementBase.FieldId;
170        this.Options.ClassName="";
171        this.Options.IsRequired='n';
172        this.Options.Formulas={};
173        this.Options.Styles={};
174        this.Options.ContainerOptions={
175            Id:0,
176            Type:'single',
177            Width:-1
178        };
179
180        sfFormElementBase.IdCounter++;
181        this.Id='rnField'+sfFormElementBase.IdCounter;
182        while(!SmartFormsFieldIsAvailable(this.Id))
183        {
184            sfFormElementBase.IdCounter++;
185            this.Id='rnField'+sfFormElementBase.IdCounter;
186        }
187
188        this.Options.Id=this.Id;
189        this.IsNew=true;
190        this.GenerateDefaultStyle();
191    }
192    else
193    {
194        this.Id=options.Id;
195        this.IsNew=false;
196        if(serverOptions=='undefined')
197            this.ServerOptions={};
198        else
199            this.ServerOptions=serverOptions;
200
201        if(typeof options._id =='undefined')
202            options._id=++sfFormElementBase.FieldId;
203        else
204            sfFormElementBase.FieldId=Math.max(sfFormElementBase.FieldId,options._id);
205        if(typeof options.IsRequired=='undefined')
206            options.IsRequired='n';
207        this.Options=options;
208        if(typeof this.Options.ContainerOptions=='undefined')
209            this.Options.ContainerOptions={
210                Id:0,
211                Type:'single',
212                Width:-1
213            };
214        if(typeof this.Options.Styles=='undefined')
215            this.Options.Styles={};
216        if(typeof this.Options.Formulas=='undefined')
217            this.Options.Formulas={};
218        else{
219            if(typeof RedNaoFormulaManagerVar!='undefined')
220                for(var property in this.Options.Formulas)
221                {
222                    RedNaoFormulaManagerVar.AddFormula(this,this.Options.Formulas[property]);
223                }
224        }
225
226
227    }
228    this._id=this.Options._id;
229    this.FormId=0;
230    this.Properties=null;
231    this.amount=0;
232    this.SetGlobalProperties();
233}
234sfFormElementBase.Extensions=[];
235sfFormElementBase.IdCounter=0;
236sfFormElementBase.FieldId=0;
237
238sfFormElementBase.prototype.InitializeFieldLinking=function(listOfFields){
239    if(this.IsFieldContainer)
240        for(var i=0;i<listOfFields.length;i++)
241            if(listOfFields[i].Options._parentId==this.Options._id)
242                this.AddField(listOfFields[i],this.Fields.length);
243
244};
245
246sfFormElementBase.prototype.AddField=function(field,index)
247{
248    if(field.FieldContainer!=null)
249        field.FieldContainer.RemoveField(field);
250    this.Fields.splice(index,0,field);
251    if(this.HandleFieldsInternally)
252        this.Options.FieldOptions.splice(index,0,field.Options);
253    field.FieldContainer=this;
254    field.Options._parentId=this._id;
255};
256
257
258
259sfFormElementBase.prototype.RemoveField=function(field)
260{
261    this.Fields.splice(this.Fields.indexOf(field),1);
262    if(this.HandleFieldsInternally)
263        this.Options.FieldOptions.splice(this.Options.FieldOptions.indexOf(field.Options),1);
264    field.FieldContainer=null;
265    field.Options._parentId=null;
266};
267
268
269sfFormElementBase.prototype.GetContainer=function()
270{
271    if(this.Container==null)
272        this.Container=SmartFormsModules.ContainerManager.CreateOrUpdateContainer(this);
273
274    return this.Container;
275};
276
277sfFormElementBase.prototype.GetFormId=function()
278{
279    if(typeof this.FormId=='undefined')
280        return 0;
281
282    return this.FormId;
283};
284
285
286sfFormElementBase.prototype.AddError=function(id,errorMessage)
287{
288    this.Errors[id]=errorMessage;
289};
290
291sfFormElementBase.prototype.RemoveError=function(id)
292{
293    if(typeof this.Errors[id]!='undefined')
294        delete this.Errors[id];
295};
296
297
298sfFormElementBase.prototype.GetStepOptions=function()
299{
300    if(this.Generator==null||this.Generator.MultipleStepsManager==null||typeof this.Generator.MultipleStepsManager.StepCatalog[this.GetStepId()]=='undefined')
301        return null;
302    return this.Generator.MultipleStepsManager.StepCatalog[this.GetStepId()];
303};
304
305
306sfFormElementBase.prototype.GetFirstError=function()
307{
308    for(var errorId in this.Errors)
309        return this.Errors[errorId];
310
311    return null;
312};
313
314
315sfFormElementBase.prototype.ShowLoadingBox=function()
316{
317    var $controlBox=this.JQueryElement.find('.redNaoControls ');
318    $controlBox.append('<div class="rnLoadingbBox" style="z-index: 10000000;display: flex;justify-content: center;align-items: center; background-color: white;position: absolute;width:100%;height:100%;left:0;opacity: .6;top:0;"><i style="font-size: 20px;line-height: 20px;height: 20px;" class="fa fa-spinner fa-spin" aria-hidden="true"></i></div>')
319};
320
321sfFormElementBase.prototype.HideLoadingBox=function()
322{
323    this.JQueryElement.find('.rnLoadingbBox').remove();
324};
325
326sfFormElementBase.prototype.SetGlobalProperties=function()
327{
328    if(this.IsNew)
329        this.Options.Spacing='col-sm-12';
330    else
331        this.SetDefaultIfUndefined('Spacing','col-sm-12');
332};
333
334sfFormElementBase.prototype.SetData=function(data)
335{
336
337};
338
339sfFormElementBase.prototype.Ignore=function()
340{
341    if(this._ignore===true)
342        return;
343    this._ignore=true;
344    this.FirePropertyChanged();
345};
346
347sfFormElementBase.prototype.GetStepId=function()
348{
349    if(typeof this.Options.StepId=='undefined')
350        return '';
351
352    return this.Options.StepId;
353};
354
355sfFormElementBase.prototype.SetStepId=function(stepId)
356{
357    this.Options.StepId=stepId;
358};
359
360sfFormElementBase.prototype.Hide=function(requestId)
361{
362    if(this.ShowRequests.indexOf(requestId)>=0)
363        this.ShowRequests.splice(this.ShowRequests.indexOf(requestId),1);
364
365    if(this.ShowRequests.length<=0)
366    {
367        var me=this;
368        this.JQueryElement.slideUp(400,function(){me.JQueryElement.css('display','none')});
369        this.Ignore();
370    }
371};
372
373sfFormElementBase.prototype.Show=function(requestId)
374{
375    if(this.ShowRequests.indexOf(requestId)<0)
376        this.ShowRequests.push(requestId);
377
378    this.JQueryElement.slideDown();
379    this.UnIgnore();
380};
381
382sfFormElementBase.prototype.UnIgnore=function()
383{
384    if(this._ignore===false)
385        return;
386    this._ignore=false;
387    this.FirePropertyChanged();
388};
389
390sfFormElementBase.prototype.IsIgnored=function()
391{
392
393    var stepOptions=this.GetStepOptions();
394    if(stepOptions!=null&&stepOptions.IsIgnored)
395        return true;
396    if(this.FieldContainer==null)
397        return this._ignore;
398    if(this.FieldContainer.IsIgnored())
399        return true;
400    return this._ignore;
401};
402
403
404sfFormElementBase.prototype.FirePropertyChanged=function(subField){
405
406    if(typeof subField==='undefined')
407        subField='';
408    this.DestroyPopOver();
409    RedNaoEventManager.Publish('formPropertyChanged',{Field:this,FieldName:this.Id, Value:this.GetValueString(),FormId:this.FormId,SubField:subField});
410
411};
412
413sfFormElementBase.prototype.DestroyPopOver=function()
414{
415    this.JQueryElement.popover('destroy');
416};
417
418sfFormElementBase.prototype.SetDefaultIfUndefined=function(propertyName,defaultValue)
419{
420    if(typeof this.Options[propertyName]=='undefined')
421        this.Options[propertyName]=defaultValue;
422};
423
424
425sfFormElementBase.prototype.GenerateDefaultStyle=function()
426{
427};
428
429sfFormElementBase.prototype.GetRootContainer=function()
430{
431    return rnJQuery("#"+this.Id);
432};
433
434sfFormElementBase.prototype.GetElementByClassName=function(className)
435{
436    return this.GetRootContainer().find("."+className);
437};
438
439sfFormElementBase.prototype.RefreshElement=function(propertyChanged,previousValue)
440{
441    if(propertyChanged!=null)
442    {
443        if(this.HandleRefresh(propertyChanged,previousValue))
444            return;
445    }
446    var element=this.JQueryElement;
447   // var labelWidth=element.find('.rednao_label_container').width();
448    //var controlWidth=element.find('.redNaoControls').width();
449    var i;
450    var generatedElement;
451    if(this.IsFieldContainer)
452    {
453        var $fieldList=element.find('.fieldContainerOfFields').detach();
454        var $actions=element.find('.smartFormsActionMenu').detach();
455        element.empty();
456        generatedElement = rnJQuery(this.GenerateInlineElement(propertyChanged));
457        if($actions.length>0)
458            element.append($actions);
459        element.append(generatedElement);
460        element.find('.fieldContainerOfFields').replaceWith($fieldList);
461
462
463    }else
464    {
465        element.find(".rednao_label_container, .redNaoControls").remove();
466        element.find(".redNaoOneColumn").remove();
467        generatedElement = rnJQuery(this.GenerateInlineElement(propertyChanged));
468        element.append(generatedElement);
469        //noinspection JSUnusedGlobalSymbols
470    }
471    this.JQueryElement = element;
472
473
474    this.GenerationCompleted(element);
475    if(!smartFormsDesignMode)
476    {
477    //    element.find('.rednao_label_container').width(labelWidth);
478    //    element.find('.redNaoControls').width(controlWidth);
479    }
480    return element;
481};
482
483sfFormElementBase.prototype.HandleRefresh=function(propertyChanges){
484    return false;
485};
486
487sfFormElementBase.prototype.GenerateHtml=function(jqueryElement,animate)
488{
489    var newElement=this.GetContainer().ReplaceWithJQueryElement(jqueryElement,animate);
490 //   var newElement=rnJQuery('<div class="'+this.GetElementClasses()+'" id="'+this.Id+'" >'+this.GenerateInlineElement()+'</div>');
491   // jqueryElement.replaceWith(newElement );
492    //noinspection JSUnusedGlobalSymbols
493    this.JQueryElement=newElement;
494    this.GenerationCompleted(newElement);
495    this.ApplyAllStyles();
496    return newElement;
497
498};
499
500sfFormElementBase.prototype.MoveField=function(fieldToMove,position,animate)
501{
502    return this.GetContainer().MoveField(this,fieldToMove,position,animate);
503};
504
505sfFormElementBase.prototype.InsertField=function(fieldToInsert,position,animate)
506{
507    return this.GetContainer().InsertField(this,fieldToInsert,position,animate);
508};
509
510
511
512
513sfFormElementBase.prototype.SetContainer=function(container)
514{
515    this.Container=container;
516    this.Options.ContainerOptions.Id=container.Options.Id;
517    this.Options.ContainerOptions.Type=container.Options.Type;
518};
519
520sfFormElementBase.prototype.AppendElementToContainer=function(jqueryElement,animate)
521{
522
523    var JQueryElement=this.GetContainer().AppendJQueryElementToUI(this,jqueryElement,animate);
524    //var JQueryElement=rnJQuery( '<div class="'+this.GetElementClasses()+'" id="'+this.Id+'">'+this.GenerateInlineElement()+'</div>');
525    //jqueryElement.append(JQueryElement);
526    //noinspection JSUnusedGlobalSymbols
527    if(this.FieldContainer!=null&&!jqueryElement.hasClass('fieldContainerOfFields'))
528        this.JQueryElement = JQueryElement;
529    else{
530        this.JQueryElement = JQueryElement;
531        if(this.IsFieldContainer&&this.HandleFieldsInternally)
532            this.InitializeField();
533        this.GenerationCompleted(JQueryElement);
534        this.ApplyAllStyles();
535    }
536
537
538};
539
540sfFormElementBase.prototype.GetElementClasses=function()
541{
542    var isRequired='';
543    if(typeof this.Options.IsRequired!='undefined'&&this.Options.IsRequired=='y')
544        isRequired='sfRequired';
545    var spacing=this.Options.Spacing;
546    if(this.Options.ContainerOptions.Width!=-1)
547        spacing='sfContainedField sfFieldWidth'+this.Options.ContainerOptions.Width;
548
549    var fieldWithFields='';
550    if(this.IsFieldContainer)
551        fieldWithFields='sfFieldWithFields';
552
553    return 'rnintid_'+this.Options._id+' rednao-control-group form-group row '+this.Options.ClassName+' '+spacing+' '+fieldWithFields+' '+ isRequired+' '+this.Options.CustomCSS;
554};
555
556sfFormElementBase.prototype.GetFriendlyName=function()
557{
558    if(this.Options.Label.trim()=='')
559        return this.Options.Id;
560    return this.Options.Label;
561};
562
563sfFormElementBase.prototype.StoresInformation=function()
564{
565    return true;
566};
567sfFormElementBase.prototype.IsHandledByAnotherField=function()
568{
569    return this.FieldContainer!=null&&this.FieldContainer.HandleFieldsInternally;
570};
571
572sfFormElementBase.prototype.CreateProperties=function()
573{
574    throw 'Abstract method';
575};
576
577sfFormElementBase.prototype.GenerateInlineElement=function()
578{
579    throw 'Abstract method';
580};
581
582sfFormElementBase.prototype.GetProperties=function()
583{
584    if(this.Properties==null)
585    {
586        this.Properties=[];
587        this.CreateProperties();
588        if(SmartFormsEnableGDPR=='y'&&this.StoresInformation())
589        {
590            this.Properties.push(new PropertyContainer('gdpr','GDPR').AddProperties([
591                new CheckBoxProperty(this,this.Options,"DoNotSave","Do not save this field in the database",{ManipulatorType:'basic'}),
592            ]));
593        }
594        this.CreateGlobalProperties();
595    }
596
597    return this.Properties;
598};
599
600sfFormElementBase.prototype.CreateGlobalProperties=function()
601{
602    for(var i=0;i<this.Properties.length;i++)
603    {
604        if(typeof this.Properties[i].Id!='undefined'&&this.Properties[i].Id=='advanced')
605        {
606            var self=this;
607            this.Properties[i].AddProperty(
608                new ComboBoxProperty(this,this.Options,"Spacing","Spacing",{ManipulatorType:'basic',Values:[
609                {label:'Fill entire row (12 Columns)',value:'col-sm-12'},
610                {label:'Use 11 columns',value:'col-sm-11'},
611                {label:'Use 10 columns',value:'col-sm-10'},
612                {label:'Use 9 columns',value:'col-sm-9'},
613                {label:'Use 8 columns',value:'col-sm-8'},
614                {label:'Use 7 columns',value:'col-sm-7'},
615                {label:'Use 6 columns',value:'col-sm-6'},
616                {label:'Use 5 columns',value:'col-sm-5'},
617                {label:'Use 4 columns',value:'col-sm-4'},
618                {label:'Use 3 columns',value:'col-sm-3'},
619                {label:'Use 2 columns',value:'col-sm-2'},
620                {label:'Use 1 columns',value:'col-sm-1'}
621            ],
622                ChangeCallBack:function()
623                {
624                    var previousClasses=self.JQueryElement.attr('class');
625                    var newClasses=self.GetElementClasses();
626                    if(previousClasses.indexOf('SmartFormsElementSelected')>=0)
627                        newClasses+=' SmartFormsElementSelected';
628                    self.JQueryElement.attr('class',newClasses);
629                },
630                ToolTip:{Text:"Space that the field will occupy.\r\nNote: All rows have a capacity of 12 columns and will be filled with as much fields as possible, for example, if you sequentially have tw
630o fields that use 6 columns each they will be placed in the same row",
631                    Width:'400px'}
632            }));
633
634            break;
635        }
636    }
637
638};
639
640sfFormElementBase.prototype.GetPropertyName=function()
641{
642    return '';
643};
644
645sfFormElementBase.prototype.RegisterForFocusEvent=function($element)
646{
647    $element.focus(function(){
648        $element.closest('.form-group').addClass('is-focused');
649    });
650
651    $element.focusout(function(){
652        $element.closest('.form-group').removeClass('is-focused');
653    });
654
655};
656
657sfFormElementBase.prototype.GeneratePropertiesHtml=function(jQueryObject)
658{
659    var properties=this.GetProperties();
660
661    for(var i=0;i<properties.length;i++)
662    {
663        properties[i].CreateProperty(jQueryObject);
664    }
665
666    jQueryObject.append('<div style="clear:both;"></div>')
667};
668
669
670sfFormElementBase.prototype.GetValueString=function()
671{
672    return '';
673};
674
675sfFormElementBase.prototype.GenerationCompleted=function(jQueryElement)
676{
677
678};
679
680sfFormElementBase.prototype.IsValid=function()
681{
682    return true;
683};
684
685sfFormElementBase.prototype.InternalIsValid=function()
686{
687    var firstError=this.GetFirstError();
688    if(firstError==null)
689    {
690        this.JQueryElement.removeClass('has-error');
691        this.JQueryElement.popover('destroy');
692        return true;
693    }
694    this.JQueryElement.addClass('has-error');
695    var tooltipPosition=this.ClientOptions.ToolTipPosition;
696    if(this.ClientOptions.DocumentWidth<=768)
697        tooltipPosition='bottom';
698
699    var trigger='click';
700    if(tooltipPosition=='bottom')
701        trigger='manual';
702
703
704    if(tooltipPosition=='bottom'&&this.JQueryElement.data('bs.popover')!=null&&this.JQueryElement.data('bs.popover').$tip!=null)
705{
706    if(this.JQueryElement.data('bs.popover').$tip.find('.popover-content').text()==firstError)
707        return;
708    else
709        this.DestroyPopOver();
710}
711
712    var container=this.JQueryElement;
713
714    if(this.ClientOptions.ToolTipPosition!='none')
715        this.JQueryElement.popover({
716            html : true,
717            content :firstError,
718            'trigger':trigger,
719            placement:tooltipPosition,
720            'container':container,
721            template:'<div class="popover invalid" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
722        });
723
724    this.JQueryElement.on('show.bs.popover',function(e,args){
725        if(tooltipPosition=='bottom')
726        {
727            args.popoverInstance.tip().addClass('sfPopHidden');
728
729        }
730    });
731
732    this.JQueryElement.on('shown.bs.popover',function(e,args){
733        if(tooltipPosition=='bottom')
734        {
735            var $popover=args.popoverInstance.tip();
736            var height=$popover.find('.popover-content').outerHeight()+4;
737
738            $popover.css('top',parseInt($popover.css('top'), 10)-5);
739            $popover.removeClass('sfPopHidden');
740            $popover.addClass('in');
741            $popover.velocity({'height':height},"easeIn",300);
742
743        }
744    });
745
746    this.JQueryElement.on('hide.bs.popover',function(e,args){
747        if(tooltipPosition=='bottom')
748        {
749            var $popover=args.popoverInstance.tip();
750            $popover.velocity({'height':0},"easeInExp",300,function(){
751                $popover.addClass('sfPopHidden');
752                $popover.removeClass('in');
753
754            });
755        }
756    });
757
758    if(this.IsIgnored())
759        return true;
760
761
762    this.JQueryElement.popover('show');
763    return false;
764
765
766};
767
768sfFormElementBase.prototype.ClearInvalidStyle=function()
769{
770
771};
772
773sfFormElementBase.prototype.Clone=function()
774{
775   var newObject=  rnJQuery.extend(true, {}, this);
776    sfFormElementBase.IdCounter++;
777    newObject.Id='rnField'+sfFormElementBase.IdCounter;
778    newObject._id=++sfFormElementBase.FieldId;
779    newObject.Options.Id=newObject.Id;
780    newObject.Properties=null;
781    newObject.Options.ContainerOptions={
782        Id:0,
783        Type:'single',
784        Width:-1
785    };
786    newObject.Container=null;
787
788    return newObject;
789};
790
791sfFormElementBase.prototype.GetValuePath=function()
792{
793    return '';
794};
795
796sfFormElementBase.prototype.GetDataStore=function()
797{
798    return new SmartFormBasicDataStore('value');
799};
800
801sfFormElementBase.prototype.GetLabelPath=function()
802{
803    return 'formData.'+this.Id+'.label';
804};
805
806sfFormElementBase.prototype.GetNumericalValuePath=function()
807{
808    return 'formData.'+this.Id+'.numericalValue';
809};
810
811sfFormElementBase.prototype.GetStyleTagForElement=function(elementName)
812{
813    if(typeof this.StyleTags[elementName]=='undefined')
814    {
815        this.StyleTags[elementName]=rnJQuery("<style type='text/css'></style>");
816        rnJQuery("head").append(this.StyleTags[elementName]);
817    }
818
819    return this.StyleTags[elementName];
820};
821
822sfFormElementBase.prototype.ApplyAllStyles=function()
823{
824    for(var elements in this.Options.Styles)
825        this.ApplyTagStyleForElement(elements);
826};
827
828sfFormElementBase.prototype.ApplyTagStyleForElement=function(elementName)
829{
830    if(typeof this.Options.Styles[elementName]=='undefined'||SmartFormsIsIE8OrEarlier())
831        return;
832
833    var style="";
834    var elementProperties=this.Options.Styles[elementName];
835    if(typeof elementProperties.Properties !='undefined')
836        for(var styleName in elementProperties.Properties)
837        {
838            //noinspection JSUnfilteredForInLoop
839            style+=styleName+":"+elementProperties.Properties[styleName]+" !important;";
840        }
841
842    if(typeof elementProperties.CustomCSS!='undefined')
843        style+=elementProperties.CustomCSS.CSS;
844
845    //noinspection JSUnresolvedVariable
846    var selector=this.GetSelectorByScope(elementProperties.Scope,elementName);
847
848    var tag=this.GetStyleTagForElement(elementName);
849    tag.empty();
850    tag.append( selector+' {'+style+'}')
851
852
853};
854
855sfFormElementBase.prototype.GetSelectorByScope=function(scope,elementName)
856{
857    if(scope==SmartFormsStyleScopeField)
858        return '#'+this.Id + " ."+elementName;
859
860    if(scope==SmartFormsStyleScopeType)
861        return '.'+this.Options.ClassName+' .'+elementName;
862
863    if(scope==SmartFormsStyleScopeAll)
864        return '.'+elementName;
865
866    throw ("Undefined scope");
867};
868
869
870sfFormElementBase.prototype.LoadPlaceHolderIcon=function($element,$offsetLeft,$offsetRight,options)
871{
872    rnJQuery.RNLoadLibrary([smartFormsPath+'js/utilities/rnPlaceHolderIcons.js'],null,function(){
873        SfLoadPlaceHolderIcon($element,$offsetLeft,$offsetRight,options);
874    });
875};
876
877/************************************************************************************* Title Element ***************************************************************************************************/
878
879function sfTitleElement(options,serverOptions)
880{
881    sfFormElementBase.call(this,options,serverOptions);
882    this.Title="Title";
883    if(this.IsNew)
884    {
885        this.Options.ClassName="rednaotitle";
886        this.Options.Title="Title";
887        this.Options.CustomCSS='';
888    }else{
889        this.SetDefaultIfUndefined('CustomCSS','');
890    }
891}
892sfTitleElement.prototype=Object.create(sfFormElementBase.prototype);
893
894sfTitleElement.prototype.GetFriendlyName=function()
895{
896    return this.Options.Title;
897};
898
899
900sfTitleElement.prototype.CreateProperties=function()
901{
902
903    this.Properties.push(new PropertyContainer('general','General').AddProperties([
904        new SimpleTextProperty(this,this.Options,"Title","Title",{ManipulatorType:'basic'}),
905
906    ]));
907
908    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
909
910    ]));
911
912};
913
914sfTitleElement.prototype.GenerateInlineElement=function()
915{
916    return '<div class="col-sm-12 redNaoControls"><legend class="redNaoLegend redNaoOneColumn">'+RedNaoEscapeHtml(this.Options.Title)+'</legend></div>';
917};
918
919
920
921
922sfTitleElement.prototype.GetValueString=function()
923{
924    return '';
925
926};
927
928sfTitleElement.prototype.StoresInformation=function()
929{
930    return false;
931};
932
933
934/************************************************************************************* Line separator Element ***************************************************************************************************/
935
936function sfLineSeparator(options,serverOptions)
937{
938    sfFormElementBase.call(this,options,serverOptions);
939    this.Title="Title";
940    if(this.IsNew)
941    {
942        this.Options.ClassName="rednaolineseparator";
943        this.Options.CustomCSS='';
944    }else{
945        this.SetDefaultIfUndefined('CustomCSS','');
946    }
947}
948sfLineSeparator.prototype=Object.create(sfFormElementBase.prototype);
949
950sfLineSeparator.prototype.GetFriendlyName=function()
951{
952    return this.Options.Title;
953};
954
955
956sfLineSeparator.prototype.CreateProperties=function()
957{
958
959    this.Properties.push(new CustomCSSProperty(this,this.Options));
960};
961
962sfLineSeparator.prototype.GenerateInlineElement=function()
963{
964    return '<div class="col-sm-12"><hr/></div>';
965};
966
967
968
969
970sfLineSeparator.prototype.GetValueString=function()
971{
972    return '';
973
974};
975
976sfLineSeparator.prototype.StoresInformation=function()
977{
978    return false;
979};
980
981sfLineSeparator.prototype.GenerationCompleted=function(jQueryElement)
982{
983    if(this.JQueryElement.parent().hasClass('component'))
984        this.JQueryElement.find('div').prepend('<span style="color:#aaaaaa">&lt;&lt;Horizontal Line Separator&gt;&gt;</span>')
985};
986
987
988/************************************************************************************* Text Element ***************************************************************************************************/
989
990function sfTextInputElement(options,serverOptions)
991{
992    sfFormElementBase.call(this,options,serverOptions);
993    this.Title="Text Input";
994    if(this.IsNew)
995    {
996        this.Options.ClassName="rednaotextinput";
997        this.Options.Label="Text Input";
998        this.Options.Placeholder="";
999        this.Options.Value="";
1000        this.Options.ReadOnly='n';
1001        this.Options.Width="";
1002        this.Options.Icon={ClassName:''};
1003        this.Options.CustomCSS='';
1004        this.Options.Placeholder_Icon={ClassName:'',Orientation:''};
1005    }else{
1006        this.SetDefaultIfUndefined('Value','');
1007        this.SetDefaultIfUndefined('ReadOnly','n');
1008        this.SetDefaultIfUndefined('Width','');
1009        this.SetDefaultIfUndefined('Icon',{ClassName:''});
1010        this.SetDefaultIfUndefined('CustomCSS','');
1011        this.SetDefaultIfUndefined('Placeholder_Icon',{ClassName:''});
1012    }
1013
1014
1015
1016
1017
1018}
1019
1020sfTextInputElement.prototype=Object.create(sfFormElementBase.prototype);
1021
1022sfTextInputElement.prototype.CreateProperties=function()
1023{
1024    this.Properties.push(new PropertyContainer('general','Common').AddProperties([
1025        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
1026        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}),
1027        new SimpleTextProperty(this,this.Options,"Value","Default Value",{ManipulatorType:'basic',RefreshFormData:true}).SetEnableFormula()
1028    ]));
1029
1030    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
1031        new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic',IconOptions:{Type:'leftAndRight'}}),
1032        new SimpleNumericProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}),
1033        new IconProperty(this,this.Options,'Icon','Icon',{ManipulatorType:'basic'})
1034    ]));
1035
1036
1037    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
1038        new CheckBoxProperty(this,this.Options,"ReadOnly","Read Only",{ManipulatorType:'basic'}),
1039        new IdProperty(this,this.Options),
1040        new CustomCSSProperty(this,this.Options)
1041    ]));
1042
1043};
1044
1045sfTextInputElement.prototype.GenerateInlineElement=function()
1046{
1047    var additionalStyle='';
1048    if(!isNaN(parseFloat(this.Options.Width)))
1049        additionalStyle='max-width:'+this.Options.Width+'px'+' !important;';
1050
1051    var startOfInput='';
1052    var endOfInput='';
1053
1054    if(this.Options.Icon.ClassName!='')
1055    {
1056        startOfInput='<div class="rednao-input-prepend input-group"><span class="redNaoPrepend input-group-addon prefix '+RedNaoEscapeHtml(this.Options.Icon.ClassName)+' "></span>';
1057        endOfInput='</div>';
1058    }
1059
1060    return '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label" >'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>'+
1061                '<div class="redNaoControls col-sm-9">'+
1062                     startOfInput+
1063                    '<input '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+' style="'+additionalStyle+'" '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'" type="text" placeholder="'+RedNaoEscapeHtml(this.Options.Placeholder)+'" class="form-control redNaoInputText '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'" value="'+RedNaoEscapeHtml(this.Options.Value)+'">'+
1064                    endOfInput+
1065                '</div>';
1066};
1067
1068
1069sfTextInputElement.prototype.GetValueString=function()
1070{
1071    if(this.IsIgnored())
1072        return {value:''};
1073    return {value:this.JQueryElement.find('.redNaoInputText').val()};
1074};
1075
1076sfTextInputElement.prototype.SetData=function(data)
1077{
1078    this.JQueryElement.find('.redNaoInputText').val(data.value);
1079};
1080
1081sfTextInputElement.prototype.GetValuePath=function()
1082{
1083    return 'formData.'+this.Id+'.value';
1084};
1085
1086
1087sfTextInputElement.prototype.IsValid=function()
1088{
1089    if(this.JQueryElement.find('.redNaoInputText').val()==""&&this.Options.IsRequired=='y')
1090        this.AddError('root',this.InvalidInputMessage);
1091    else
1092        this.RemoveError('root');
1093    return this.InternalIsValid();
1094};
1095
1096//noinspection JSUnusedLocalSymbols
1097sfTextInputElement.prototype.GenerationCompleted=function(jQueryElement)
1098{
1099    var self=this;
1100    this.JQueryElement.find( '.redNaoInputText').change(function(){self.FirePropertyChanged();});
1101 
1102    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoInputText'));
1103    if(this.Options.Placeholder_Icon.ClassName!='')
1104    {
1105        this.LoadPlaceHolderIcon(jQueryElement.find('.redNaoInputText'),null,null,this.Options.Placeholder_Icon);
1106    }
1107
1108
1109};
1110
1111/************************************************************************************* Prepend Text Element ***************************************************************************************************/
1112
1113function sfPrependTexElement(options,serverOptions)
1114{
1115    sfFormElementBase.call(this,options,serverOptions);
1116    this.Title="Prepend Text";
1117
1118    if(this.IsNew)
1119    {
1120        this.Options.Label="Prepend Text";
1121        this.Options.ClassName="rednaoprependedtext";
1122        this.Options.Placeholder="";
1123        this.Options.Prepend="Prepend";
1124        this.Options.Value='';
1125        this.Options.Checked='y';
1126        this.Options.Width='';
1127        this.Options.Icon={ClassName:''};
1128        this.Options.CustomCSS='';
1129        this.Options.ReadOnly='n';
1130        this.Options.Placeholder_Icon={ClassName:'',Orientation:''};
1131    }else{
1132        this.SetDefaultIfUndefined('Value','');
1133        this.SetDefaultIfUndefined('Width','');
1134        this.SetDefaultIfUndefined('Icon',{ClassName:''});
1135        this.SetDefaultIfUndefined('CustomCSS','');
1136        this.SetDefaultIfUndefined('Placeholder_Icon',{ClassName:''});
1137        this.SetDefaultIfUndefined('ReadOnly','n');
1138
1139    }
1140
1141
1142
1143}
1144
1145sfPrependTexElement.prototype=Object.create(sfFormElementBase.prototype);
1146
1147sfPrependTexElement.prototype.CreateProperties=function()
1148{
1149
1150    this.Properties.push(new PropertyContainer('general','General').AddProperties([
1151        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
1152        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}),
1153        new SimpleTextProperty(this,this.Options,"Prepend","Prepend Text",{ManipulatorType:'basic'}),
1154        new SimpleTextProperty(this,this.Options,"Value","Default Value",{ManipulatorType:'basic',RefreshFormData:true}).SetEnableFormula()
1155    ]));
1156
1157    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
1158        new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic',IconOptions:{Type:'leftAndRight'}}),
1159        new SimpleNumericProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}),
1160        new IconProperty(this,this.Options,'Icon','Icon',{ManipulatorType:'basic'})
1161    ]));
1162
1163
1164    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
1165        new CheckBoxProperty(this,this.Options,"ReadOnly","Read Only",{ManipulatorType:'basic'}),
1166        new IdProperty(this,this.Options),
1167        new CustomCSSProperty(this,this.Options)
1168    ]));
1169
1170
1171};
1172
1173sfPrependTexElement.prototype.GenerateInlineElement=function()
1174{
1175    var additionalStyle='';
1176    if(!isNaN(parseFloat(this.Options.Width)))
1177        additionalStyle='width:'+this.Options.Width+'px'+' !important;';
1178
1179
1180
1181    return '<div class="rednao_label_container col-sm-3">'+
1182            '<label class="rednao_control_label" for="prependedtext">'+RedNaoEscapeHtml(this.Options.Label)+'</label>' +
1183            '</div>'+
1184            '<div class="redNaoControls col-sm-9">'+
1185               '<div class="rednao-input-prepend input-group">'+
1186                    (this.Options.Icon.ClassName!=''?'<span class="redNaoPrepend input-group-addon prefix '+RedNaoEscapeHtml(this.Options.Icon.ClassName)+' "></span>'
1187                                                            :'<span class="redNaoPrepend input-group-addon prefix">'+RedNaoEscapeHtml(this.Options.Prepend)+'</span>')+
1188                    '<input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  style="'+additionalStyle+'"  name="prependedtext" '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' class="redNaoInputText form-control" placeholder="'+RedNaoEscapeHtml(this.Options.Placeholder)+'" type="text" value="'+RedNaoEscapeHtml(this.Options.Value)+'">'+
1189                '</div>'+
1190            '</div>';
1191};
1192
1193
1194
1195
1196sfPrependTexElement.prototype.GetValueString=function()
1197{
1198    if(this.IsIgnored())
1199        return {value:''};
1200    return {value:this.JQueryElement.find('.redNaoInputText').val()};
1201};
1202
1203sfPrependTexElement.prototype.SetData=function(data)
1204{
1205    this.JQueryElement.find('.redNaoInputText').val(data.value);
1206};
1207
1208
1209sfPrependTexElement.prototype.GetValuePath=function()
1210{
1211    return 'formData.'+this.Id+'.value';
1212};
1213
1214
1215sfPrependTexElement.prototype.IsValid=function()
1216{
1217    if(this.JQueryElement.find('.redNaoInputText').val()==""&&this.Options.IsRequired=='y')
1218    {
1219        this.JQueryElement.addClass('has-error');
1220        this.AddError('root',this.InvalidInputMessage);
1221    }
1222    else
1223        this.RemoveError('root');
1224
1225    return this.InternalIsValid();
1226};
1227
1228//noinspection JSUnusedLocalSymbols
1229sfPrependTexElement.prototype.GenerationCompleted=function(jQueryElement)
1230{
1231    var self=this;
1232    this.JQueryElement.find('.redNaoInputText').change(function(){self.FirePropertyChanged();});
1233    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoInputText'));
1234    if(this.Options.Placeholder_Icon.ClassName!='')
1235    {
1236        this.LoadPlaceHolderIcon(jQueryElement.find('.redNaoInputText'),jQueryElement.find('.redNaoPrepend'),null,this.Options.Placeholder_Icon);
1237    }
1238};
1239
1240/************************************************************************************* Appended Text Element ***************************************************************************************************/
1241
1242function sfAppendedTexElement(options,serverOptions)
1243{
1244    sfFormElementBase.call(this,options,serverOptions);
1245    this.Title="Appended Text";
1246
1247    if(this.IsNew)
1248    {
1249        this.Options.Label="Appended Text";
1250        this.Options.ClassName="rednaoappendedtext";
1251        this.Options.Placeholder="";
1252        this.Options.Append="Append";
1253        this.Options.Value="";
1254        this.Options.Width='';
1255        this.Options.Icon={ClassName:''};
1256        this.Options.CustomCSS='';
1257        this.Options.ReadOnly='n';
1258
1259        this.Options.Placeholder_Icon={ClassName:'',Orientation:''};
1260    }else{
1261        this.SetDefaultIfUndefined('Value','');
1262        this.SetDefaultIfUndefined('Width','');
1263        this.SetDefaultIfUndefined('Icon',{ClassName:""});
1264        this.SetDefaultIfUndefined('CustomCSS','');
1265        this.SetDefaultIfUndefined('Placeholder_Icon',{ClassName:''});
1266        this.SetDefaultIfUndefined('ReadOnly','n');
1267
1268    }
1269}
1270
1271sfAppendedTexElement.prototype=Object.create(sfFormElementBase.prototype);
1272
1273sfAppendedTexElement.prototype.CreateProperties=function()
1274{
1275    this.Properties.push(new PropertyContainer('general','General').AddProperties([
1276        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
1277        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}),
1278        new SimpleTextProperty(this,this.Options,"Append","Append Text",{ManipulatorType:'basic'}),
1279        new SimpleTextProperty(this,this.Options,"Value","Default Value",{ManipulatorType:'basic',RefreshFormData:true}).SetEnableFormula()
1280
1281    ]));
1282
1283    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
1284        new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic',IconOptions:{Type:'leftAndRight'}}),
1285        new SimpleNumericProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}),
1286        new IconProperty(this,this.Options,'Icon','Icon',{ManipulatorType:'basic'})
1287    ]));
1288
1289
1290    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
1291        new CheckBoxProperty(this,this.Options,"ReadOnly","Read Only",{ManipulatorType:'basic'}),
1292        new IdProperty(this,this.Options),
1293        new CustomCSSProperty(this,this.Options)
1294    ]));
1295
1296};
1297
1298sfAppendedTexElement.prototype.GenerateInlineElement=function()
1299{
1300    var additionalStyle='';
1301    if(!isNaN(parseFloat(this.Options.Width)))
1302        additionalStyle='width:'+this.Options.Width+'px'+' !important;';
1303
1304
1305    return '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label" for="appendedtext">'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>'+
1306            '<div class="redNaoControls col-sm-9 ">'+
1307                '<div class="rednao-input-append input-group">'+
1308                    '<input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  style="'+additionalStyle+'" name="appendedtext" '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+'  placeholder="'+RedNaoEscapeHtml(this.Options.Placeholder)+'" type="text" class="redNaoInputText form-control" value="'+RedNaoEscapeHtml(this.Options.Value)+'">'+
1309                    (this.Options.Icon.ClassName!=''?'<span class="redNaoAppend input-group-addon '+RedNaoEscapeHtml(this.Options.Icon.ClassName)+' "></span>'
1310                                                            :'<span class="redNaoAppend input-group-addon">'+RedNaoEscapeHtml(this.Options.Append)+'</span>')+
1311                '</div>'+
1312            '</div>';
1313
1314
1315};
1316
1317
1318
1319
1320sfAppendedTexElement.prototype.GetValueString=function()
1321{
1322    if(this.IsIgnored())
1323        return {value:''};
1324    return  {value:this.JQueryElement.find('.redNaoInputText').val()};
1325};
1326
1327sfAppendedTexElement.prototype.SetData=function(data)
1328{
1329    this.JQueryElement.find('.redNaoInputText').val(data.value);
1330};
1331
1332
1333
1334sfAppendedTexElement.prototype.GetValuePath=function()
1335{
1336    return 'formData.'+this.Id+'.value';
1337};
1338
1339sfAppendedTexElement.prototype.IsValid=function()
1340{
1341    if(this.JQueryElement.find('.redNaoInputText').val()==""&&this.Options.IsRequired=='y')
1342    {
1343        this.JQueryElement.addClass('has-error');
1344        this.AddError('root',this.InvalidInputMessage);
1345    }else
1346        this.RemoveError('root');
1347
1348    return this.InternalIsValid();
1349};
1350
1351//noinspection JSUnusedLocalSymbols
1352sfAppendedTexElement.prototype.GenerationCompleted=function(jQueryElement)
1353{
1354    var self=this;
1355    this.JQueryElement.find('.redNaoInputText').change(function(){self.FirePropertyChanged();});
1356    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoInputText'));
1357    if(this.Options.Placeholder_Icon.ClassName!='')
1358    {
1359        this.LoadPlaceHolderIcon(jQueryElement.find('.redNaoInputText'),null,jQueryElement.find('.redNaoAppend'),this.Options.Placeholder_Icon);
1360    }
1361};
1362
1363
1364/************************************************************************************* Prepend Checkbox Element ***************************************************************************************************/
1365
1366function sfPrependCheckBoxElement(options,serverOptions)
1367{
1368    sfFormElementBase.call(this,options,serverOptions);
1369    this.Title="Prepend Checkbox";
1370
1371    if(this.IsNew)
1372    {
1373        this.Options.Label="Prepend Checkbox";
1374        this.Options.ClassName="rednaoprependedcheckbox";
1375        this.Options.Placeholder="";
1376        this.Options.IsChecked='n';
1377        this.Options.Value="";
1378        this.Options.Width='';
1379        this.Options.CustomCSS='';
1380        this.Options.Placeholder_Icon={ClassName:'',Orientation:''};
1381    }else{
1382        this.SetDefaultIfUndefined('Value','');
1383        this.SetDefaultIfUndefined('Width','');
1384        this.SetDefaultIfUndefined('CustomCSS','');
1385        this.SetDefaultIfUndefined('Placeholder_Icon',{ClassName:''});
1386
1387    }
1388}
1389
1390sfPrependCheckBoxElement.prototype=Object.create(sfFormElementBase.prototype);
1391
1392sfPrependCheckBoxElement.prototype.CreateProperties=function()
1393{
1394
1395    this.Properties.push(new PropertyContainer('general','General').AddProperties([
1396        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
1397        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}),
1398        new SimpleTextProperty(this,this.Options,"Value","Default Value",{ManipulatorType:'basic',RefreshFormData:true}).SetEnableFormula()
1399    ]));
1400
1401    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
1402        new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic',IconOptions:{Type:'leftAndRight'}}),
1403        new SimpleNumericProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}),
1404        new CheckBoxProperty(this,this.Options,"IsChecked","Is Checked",{ManipulatorType:'basic'})
1405    ]));
1406
1407
1408    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
1409        new IdProperty(this,this.Options),
1410        new CustomCSSProperty(this,this.Options)
1411    ]));
1412
1413};
1414
1415sfPrependCheckBoxElement.prototype.GenerateInlineElement=function()
1416{
1417    var additionalStyle='';
1418    if(!isNaN(parseFloat(this.Options.Width)))
1419        additionalStyle='width:'+this.Options.Width+'px'+' !important;';
1420
1421
1422    return '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label" for="prependedcheckbox">'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>\
1423                <div class="redNaoControls col-sm-9">\
1424                    <div class="input-prepend input-group">\
1425                        <span class="redNaoPrepend input-group-addon">\
1426                                <input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  type="checkbox" class="redNaoRealCheckBox "  '+(this.Options.IsChecked=='y'? 'checked="checked"':'')+'/>\
1427                        </span>\
1428                        <input style="'+additionalStyle+'" id="prependedcheckbox" name="prependedcheckbox"  class="redNaoInputText form-control" type="text" placeholder="'+RedNaoEscapeHtml(this.Options.Placeholder)+'" value="'+RedNaoEscapeHtml(this.Options.Value)+'"/>\
1429                    </div>\
1430                </div>';
1431
1432
1433};
1434
1435
1436
1437sfPrependCheckBoxElement.prototype.GetValueString=function()
1438{
1439    if(this.IsIgnored())
1440        return {checked:'n',value:''};
1441    return  {checked:(this.JQueryElement.find('.redNaoRealCheckBox').is(':checked')?'Yes':'No'),value:this.JQueryElement.find('.redNaoInputText').val()};
1442};
1443
1444sfPrependCheckBoxElement.prototype.SetData=function(data)
1445{
1446    if(data.checked=='Yes')
1447        this.JQueryElement.find('.redNaoRealCheckBox').attr('checked','checked');
1448    else
1449        this.JQueryElement.find('.redNaoRealCheckBox').removeAttr('checked');
1450
1451
1452    this.JQueryElement.find('.redNaoInputText').val(data.value);
1453};
1454
1455
1456
1457sfPrependCheckBoxElement.prototype.GetValuePath=function()
1458{
1459    return 'formData.'+this.Id+'.value';
1460};
1461
1462
1463sfPrependCheckBoxElement.prototype.IsValid=function()
1464{
1465    if(this.JQueryElement.find('.redNaoInputText').val()==""&&this.Options.IsRequired=='y')
1466    {
1467        this.JQueryElement.addClass('has-error');
1468        this.AddError('root',this.InvalidInputMessage);
1469    }else
1470        this.RemoveError('root');
1471
1472    return this.InternalIsValid();
1473
1474};
1475
1476//noinspection JSUnusedLocalSymbols
1477sfPrependCheckBoxElement.prototype.GenerationCompleted=function(jQueryElement)
1478{
1479    var self=this;
1480    this.JQueryElement.find('.redNaoInputText,.redNaoRealCheckBox').change(function(){self.FirePropertyChanged();});
1481    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoInputText'));
1482    if(this.Options.Placeholder_Icon.ClassName!='')
1483    {
1484        this.LoadPlaceHolderIcon(jQueryElement.find('.redNaoInputText'),jQueryElement.find('.redNaoPrepend'),null,this.Options.Placeholder_Icon);
1485    }
1486
1487
1488};
1489/************************************************************************************* Append Checkbox Element ***************************************************************************************************/
1490
1491function sfAppendCheckBoxElement(options,serverOptions)
1492{
1493    sfFormElementBase.call(this,options,serverOptions);
1494    this.Title="Append Checkbox";
1495
1496    if(this.IsNew)
1497    {
1498        this.Options.Label="Append Checkbox";
1499        this.Options.ClassName="rednaoappendedcheckbox";
1500        this.Options.Placeholder="";
1501        this.Options.IsChecked='n';
1502        this.Options.Value="";
1503        this.Options.Width='';
1504        this.Options.CustomCSS='';
1505        this.Options.Placeholder_Icon={ClassName:'',Orientation:''};
1506    }else{
1507        this.SetDefaultIfUndefined('Value','');
1508        this.SetDefaultIfUndefined('Width','');
1509        this.SetDefaultIfUndefined('CustomCSS','');
1510        this.SetDefaultIfUndefined('Placeholder_Icon',{ClassName:''});
1511
1512    }
1513}
1514
1515sfAppendCheckBoxElement.prototype=Object.create(sfFormElementBase.prototype);
1516
1517sfAppendCheckBoxElement.prototype.CreateProperties=function()
1518{
1519
1520    this.Properties.push(new PropertyContainer('general','General').AddProperties([
1521        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
1522        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}),
1523        new SimpleTextProperty(this,this.Options,"Value","Default Value",{ManipulatorType:'basic',RefreshFormData:true}).SetEnableFormula()
1524    ]));
1525
1526    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
1527        new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic',IconOptions:{Type:'leftAndRight'}}),
1528        new SimpleNumericProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}),
1529        new CheckBoxProperty(this,this.Options,"IsChecked","Is Checked",{ManipulatorType:'basic'})
1530    ]));
1531
1532
1533    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
1534        new IdProperty(this,this.Options),
1535        new CustomCSSProperty(this,this.Options)
1536    ]));
1537
1538};
1539
1540sfAppendCheckBoxElement.prototype.GenerateInlineElement=function()
1541{
1542    var additionalStyle='';
1543    if(!isNaN(parseFloat(this.Options.Width)))
1544        additionalStyle='width:'+this.Options.Width+'px'+' !important;';
1545
1546
1547    return '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label" for="appendedcheckbox">'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>\
1548            <div class="redNaoControls col-sm-9">\
1549                <div class="rednao-input-append input-group">\
1550                    <input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  style="'+additionalStyle+'" id="appendedcheckbox" class="form-control redNaoInputText" name="appendedcheckbox" class="form-control span2" type="text" placeholder="'+RedNaoEscapeHtml(this.Options.Placeholder)+'" value="'+RedNaoEscapeHtml(this.Options.Value)+'"/>\
1551                        <span class="redNaoAppend input-group-addon">\
1552                            <input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  type="checkbox" class="redNaoRealCheckBox "   '+(this.Options.IsChecked=='y'? 'checked="checked"':'')+'/>\
1553                        </span>\
1554                </div>\
1555            </div>';
1556
1557
1558};
1559
1560
1561
1562sfAppendCheckBoxElement.prototype.GetValueString=function()
1563{
1564    if(this.IsIgnored())
1565        return {checked:'n',value:''};
1566    return  {checked:(this.JQueryElement.find('.redNaoRealCheckBox').is(':checked')?'Yes':'No'),value:this.JQueryElement.find('.redNaoInputText').val()};
1567};
1568
1569
1570sfAppendCheckBoxElement.prototype.SetData=function(data)
1571{
1572    if(data.checked=='Yes')
1573        this.JQueryElement.find('.redNaoRealCheckBox').attr('checked','checked');
1574    else
1575        this.JQueryElement.find('.redNaoRealCheckBox').removeAttr('checked');
1576
1577
1578    this.JQueryElement.find('.redNaoInputText').val(data.value);
1579};
1580
1581
1582sfAppendCheckBoxElement.prototype.GetValuePath=function()
1583{
1584    return 'formData.'+this.Id+'.value';
1585};
1586
1587sfAppendCheckBoxElement.prototype.IsValid=function()
1588{
1589    if(this.JQueryElement.find('.redNaoInputText').val()==""&&this.Options.IsRequired=='y')
1590    {
1591        this.JQueryElement.addClass('has-error');
1592        this.AddError('root',this.InvalidInputMessage);
1593    }
1594    else
1595        this.RemoveError('root');
1596
1597    return this.InternalIsValid();
1598};
1599
1600//noinspection JSUnusedLocalSymbols
1601sfAppendCheckBoxElement.prototype.GenerationCompleted=function(jQueryElement)
1602{
1603    var self=this;
1604    this.JQueryElement.find('.redNaoInputText,.redNaoRealCheckBox').change(function(){self.FirePropertyChanged();});
1605    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoInputText'));
1606    if(this.Options.Placeholder_Icon.ClassName!='')
1607    {
1608        this.LoadPlaceHolderIcon(jQueryElement.find('.redNaoInputText'),null,jQueryElement.find('.redNaoAppend'),this.Options.Placeholder_Icon);
1609    }
1610
1611
1612};
1613/************************************************************************************* Text Area Element ***************************************************************************************************/
1614
1615function sfTextAreaElement(options,serverOptions)
1616{
1617    sfFormElementBase.call(this,options,serverOptions);
1618    this.Title="Text Area";
1619
1620    if(this.IsNew)
1621    {
1622        this.Options.Label="Text Area";
1623        this.Options.DefaultText="";
1624        this.Options.ClassName="rednaotextarea";
1625        this.Options.Value="";
1626        this.Options.Width='';
1627        this.Options.Height='';
1628        this.Options.Placeholder='';
1629        this.Options.Disabled="n";
1630        this.Options.MaxLength='';
1631        this.Options.CustomCSS='';
1632        this.Options.Placeholder_Icon={ClassName:'',Orientation:''};
1633    }else{
1634        this.SetDefaultIfUndefined('Value','');
1635        this.SetDefaultIfUndefined('Width','');
1636        this.SetDefaultIfUndefined('Height','');
1637        this.SetDefaultIfUndefined('Placeholder','');
1638        this.SetDefaultIfUndefined('Disabled','n');
1639        this.SetDefaultIfUndefined('MaxLength','');
1640        this.SetDefaultIfUndefined('CustomCSS','');
1641        this.SetDefaultIfUndefined('Placeholder_Icon',{ClassName:''});
1642    }
1643
1644    this.MaxLength=parseFloat(this.Options.MaxLength);
1645}
1646
1647sfTextAreaElement.prototype=Object.create(sfFormElementBase.prototype);
1648
1649sfTextAreaElement.prototype.CreateProperties=function()
1650{
1651
1652    this.Properties.push(new PropertyContainer('general','General').AddProperties([
1653        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
1654        new SimpleTextProperty(this,this.Options,"DefaultText","Default Value",{ManipulatorType:'basic',RefreshFormData:true,MultipleLine:true}).SetEnableFormula(),
1655        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'})
1656    ]));
1657
1658    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
1659        new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic',RefreshFormData:true,IconOptions:{Type:'leftAndRight'}}),
1660        new SimpleNumericProperty(this,this.Options,"MaxLength","Max Length",{ManipulatorType:'basic',Placeholder:"No Limit"}),
1661        new SimpleNumericProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}),
1662        new SimpleNumericProperty(this,this.Options,"Height","Height",{ManipulatorType:'basic'})
1663    ]));
1664
1665
1666    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
1667        new CheckBoxProperty(this,this.Options,"Disabled","Read Only",{ManipulatorType:'basic'}),
1668        new IdProperty(this,this.Options),
1669        new CustomCSSProperty(this,this.Options)
1670    ]));
1671};
1672
1673sfTextAreaElement.prototype.GenerateInlineElement=function()
1674{
1675    var additionalStyle='';
1676    if(!isNaN(parseFloat(this.Options.Width)))
1677        additionalStyle='width:'+this.Options.Width+'px'+' !important;';
1678
1679    if(!isNaN(parseFloat(this.Options.Height)))
1680        additionalStyle+='height:'+this.Options.Height+'px'+' !important;';
1681
1682    var disabled="";
1683    if(this.Options.Disabled=='y')
1684        disabled='disabled="disabled"';
1685
1686
1687    var html=  '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label" for="textarea">'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>\
1688                <div class="redNaoControls col-sm-9">\
1689                <textarea '+(!isNaN(this.MaxLength)?'maxlength="'+this.MaxLength.toString()+'"':'')+'  '+disabled+' placeholder="'+RedNaoEscapeHtml(this.Options.Placeholder)+'" style="'+additionalStyle+'" name="textarea" class="form-control redNaoTextAreaInput '+(!isNaN(this.MaxLength)?'redNaoTextAreaInputWordCount':'')+'">'+RedNaoEscapeHtml(this.Options.DefaultText)+'</textarea>';
1690    if(!isNaN(this.MaxLength))
1691        html+='<span class="smartFormsCharacterCount">'+this.MaxLength.toString()+'</span>';
1692    html+='</div>';
1693
1694    return html;
1695};
1696
1697
1698
1699sfTextAreaElement.prototype.GetValueString=function()
1700{
1701    if(this.IsIgnored())
1702        return {value:''};
1703    return  {value:this.JQueryElement.find('.redNaoTextAreaInput').val()};
1704};
1705
1706sfTextAreaElement.prototype.SetData=function(data)
1707{
1708    this.JQueryElement.find('.redNaoTextAreaInput').val(data.value);
1709};
1710
1711sfTextAreaElement.prototype.GetValuePath=function()
1712{
1713    return 'formData.'+this.Id+'.value';
1714};
1715
1716
1717sfTextAreaElement.prototype.IsValid=function()
1718{
1719    if(this.JQueryElement.find('.redNaoTextAreaInput').val()==""&&this.Options.IsRequired=='y')
1720    {
1721        this.JQueryElement.addClass('has-error');
1722        this.AddError('root',this.InvalidInputMessage);
1723    }
1724    else
1725        this.RemoveError('root');
1726    return this.InternalIsValid();
1727};
1728
1729//noinspection JSUnusedLocalSymbols
1730sfTextAreaElement.prototype.GenerationCompleted=function(jQueryElement)
1731{
1732    var self=this;
1733    this.JQueryElement.find('.redNaoTextAreaInput').change(function(){self.FirePropertyChanged();});
1734    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoTextAreaInput'));
1735    if(!isNaN(this.MaxLength))
1736        this.JQueryElement.find(' .redNaoTextAreaInput').bind('keyup keydown',function(){
1737            var length=rnJQuery(this).val().length;
1738            var charactersRemaining=self.MaxLength-length;
1739            var wordCounter=self.GetElementByClassName('smartFormsCharacterCount');
1740            wordCounter.text(charactersRemaining.toString());
1741
1742            if(charactersRemaining<=20)
1743                wordCounter.addClass("smartFormsAlmostFull");
1744            else
1745                wordCounter.removeClass("smartFormsAlmostFull");
1746
1747        });
1748
1749
1750
1751    if(this.Options.Placeholder_Icon.ClassName!='')
1752    {
1753        this.LoadPlaceHolderIcon(jQueryElement.find('.redNaoTextAreaInput'),null,null,this.Options.Placeholder_Icon);
1754    }
1755};
1756
1757/*************************************************************************************Multiple Radio Element ***************************************************************************************************/
1758
1759function sfMultipleRadioElement(options,serverOptions)
1760{
1761    sfFormElementBase.call(this,options,serverOptions);
1762    this.Title="Multiple Radio";
1763    var i=undefined;
1764    if(this.IsNew)
1765    {
1766        this.Options.Label="Multiple Radio";
1767        this.Options.ClassName="rednaomultipleradios";
1768        this.Options.Orientation='v';
1769        this.Options.Options=[{label:'Option 1',value:0,sel:'n'},{label:'Option 2',value:0,sel:'n'},{label:'Option 3',value:0,sel:'n'}];
1770        this.Options.CustomCSS='';
1771    }else
1772    {
1773        this.SetDefaultIfUndefined('CustomCSS','');
1774        if(RedNaoGetValueOrNull(this.Options.Orientation)==null)
1775            this.Options.Orientation='v';
1776        if(this.Options.Options.length>0&&typeof this.Options.Options[0].sel=='undefined')
1777        {
1778            this.Options.Options[0].sel='y';
1779            for(i=1;i<this.Options.Options.length;i++)
1780                this.Options.Options[i].sel='n';
1781        }
1782        if(this.Options.Options.length>0&&typeof this.Options.Options[i]=='string')
1783        {
1784            var aux=[];
1785            for(i=0;i<this.Options.Options.length;i++)
1786            {
1787                aux.push({label:this.Options.Options[i]});
1788            }
1789
1790            this.Options.Options=aux;
1791        }
1792    }
1793
1794
1795}
1796
1797sfMultipleRadioElement.prototype=Object.create(sfFormElementBase.prototype);
1798
1799sfMultipleRadioElement.prototype.CreateProperties=function()
1800{
1801    this.Properties.push(new PropertyContainer('general','General').AddProperties([
1802        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
1803        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}),
1804        new ArrayProperty(this,this.Options,"Options","Options",{ManipulatorType:'basic',SelectorType:'radio'})
1805    ]));
1806
1807    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
1808        new ComboBoxProperty(this,this.Options,"Orientation","Orientation",{ManipulatorType:'basic',Values:[{label:'Vertical',value:'v'},{label:'Horizontal',value:'h'}]})
1809    ]));
1810
1811
1812    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
1813        new IdProperty(this,this.Options),
1814        new CustomCSSProperty(this,this.Options)
1815    ]));
1816
1817
1818};
1819
1820sfMultipleRadioElement.prototype.GenerateInlineElement=function()
1821{
1822    var orientationClass='';
1823    if(this.Options.Orientation=='h')
1824        orientationClass='-inline';
1825
1826    var html=  '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label">'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>\
1827        <div class="redNaoControls col-sm-9">';
1828
1829    var checked='';
1830    for(var i=0;i<this.Options.Options.length;i++)
1831    {
1832        if(this.Options.Options[i].sel=='y')
1833            checked='checked="checked"';
1834        else
1835            checked='';
1836        var itemId=this.Id+"_"+i;
1837        html+='<div class="radio'+orientationClass+'">\
1838                    <input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  id="'+itemId+'" '+checked+' class="redNaoInputRadio" type="radio" name="'+this.Id+'"  value="'+RedNaoEscapeHtml(this.Options.Options[i].value)+'" '+checked+'></input>\
1839                    <label class="redNaoRadio '+orientationClass+'" for="'+itemId+'">'+RedNaoEscapeHtml(rnJQuery.trim(this.Options.Options[i].label))+
1840                '</label></div>';
1841
1842        checked="";
1843
1844    }
1845
1846    html+='</div>';
1847    return html;
1848};
1849
1850
1851
1852
1853
1854sfMultipleRadioElement.prototype.GetValueString=function()
1855{
1856    if(this.IsIgnored())
1857    {
1858        this.amount=0;
1859        return {value:'',amount:0};
1860    }
1861    var jQueryElement=this.JQueryElement.find(':checked');
1862    if(jQueryElement.length>0)
1863        this.amount=parseFloat(jQueryElement.val());
1864    else
1865        this.amount=0;
1866    if(isNaN(this.amount))
1867        this.amount=0;
1868    return  {value:rnJQuery.trim(jQueryElement.parent().find('label').text()),amount:this.amount};
1869};
1870
1871sfMultipleRadioElement.prototype.SetData=function(data)
1872{
1873    if(data.value!='')
1874    {
1875        var labels=this.JQueryElement.find('.redNaoRadio');
1876        for(var i=0;i<labels.length;i++)
1877        {
1878            if (rnJQuery.trim(rnJQuery(labels[i]).text()) == data.value)
1879            {
1880                rnJQuery(labels[i]).parent().find('input:radio').attr('checked','checked').click();
1881            }
1882        }
1883    }
1884};
1885
1886
1887sfMultipleRadioElement.prototype.GetDataStore=function()
1888{
1889    return new SmartFormBasicDataStore('amount');
1890};
1891
1892
1893sfMultipleRadioElement.prototype.GetValuePath=function()
1894{
1895    return 'formData.'+this.Id+'.amount';
1896};
1897
1898
1899sfMultipleRadioElement.prototype.IsValid=function()
1900{
1901    if(this.JQueryElement.find(':checked').length<=0&&this.Options.IsRequired=='y')
1902    {
1903        this.AddError('root',this.InvalidInputMessage);
1904    }
1905    else
1906        this.RemoveError('root');
1907
1908    return this.InternalIsValid();
1909};
1910
1911sfMultipleRadioElement.prototype.ClearInvalidStyle=function()
1912{
1913
1914};
1915
1916
1917//noinspection JSUnusedLocalSymbols
1918sfMultipleRadioElement.prototype.GenerationCompleted=function(jQueryElement)
1919{
1920    var self=this;
1921    jQueryElement.find('.redNaoInputRadio').change(function(){self.FirePropertyChanged();});
1922};
1923
1924/*************************************************************************************Multiple Checkbox Element ***************************************************************************************************/
1925
1926function sfMultipleCheckBoxElement(options,serverOptions)
1927{
1928    sfFormElementBase.call(this,options,serverOptions);
1929    this.Title="Multiple Checkboxes";
1930    var i=undefined;
1931    if(this.IsNew)
1932    {
1933        this.Options.Label="Multiple Checkbox";
1934        this.Options.ClassName="rednaomultiplecheckboxes";
1935        this.Options.Orientation='v';
1936        this.Options.Options=[{label:'Check 1',value:0,sel:'n'},{label:'Check 2',value:0,sel:'n'},{label:'Check 3',value:0,sel:'n'}];
1937        this.Options.CustomCSS='';
1938    }else
1939    {
1940        this.SetDefaultIfUndefined('CustomCSS','');
1941        if(RedNaoGetValueOrNull(this.Options.Orientation)==null)
1942            this.Options.Orientation='v';
1943        if(this.Options.Options.length>0&&typeof this.Options.Options[0].sel=='undefined')
1944        {
1945            for(i=0;i<this.Options.Options.length;i++)
1946                this.Options.Options[i].sel='n';
1947        }
1948
1949        if(this.Options.Options.length>0&&typeof this.Options.Options[i]=='string')
1950        {
1951            var aux=[];
1952            for(i=0;i<this.Options.Options.length;i++)
1953            {
1954                aux.push({label:this.Options.Options[i]});
1955            }
1956
1957            this.Options.Options=aux;
1958        }
1959    }
1960
1961
1962}
1963
1964sfMultipleCheckBoxElement.prototype=Object.create(sfFormElementBase.prototype);
1965
1966sfMultipleCheckBoxElement.prototype.CreateProperties=function()
1967{
1968
1969    this.Properties.push(new PropertyContainer('general','General').AddProperties([
1970        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
1971        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}),
1972        new ArrayProperty(this,this.Options,"Options","Options",{ManipulatorType:'basic'})
1973    ]));
1974
1975    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
1976        new ComboBoxProperty(this,this.Options,"Orientation","Orientation",{ManipulatorType:'basic',Values:[{label:'Vertical',value:'v'},{label:'Horizontal',value:'h'}]})
1977    ]));
1978
1979
1980    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
1981        new IdProperty(this,this.Options),
1982        new CustomCSSProperty(this,this.Options)
1983    ]));
1984};
1985
1986sfMultipleCheckBoxElement.prototype.GenerateInlineElement=function()
1987{
1988    var orientationClass='';
1989    if(this.Options.Orientation=='h')
1990        orientationClass='-inline';
1991
1992    var html='';
1993    if(this.Options.Label.trim()!='')
1994      html+=  '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label">'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>';
1995
1996    html+='<div class="redNaoControls col-sm-9">';
1997
1998    var checked='';
1999    for(var i=0;i<this.Options.Options.length;i++)
2000    {
2001        if(this.Options.Options[i].sel=='y')
2002            checked='checked="checked"';
2003        else
2004            checked='';
2005        var itemId=this.Id+"_"+i;
2006        html+='<div class="checkbox'+orientationClass+'">\
2007                    <input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  type="checkbox" class="redNaoInputCheckBox" id="'+itemId+'" name="'+this.Id+'"  value="'+RedNaoEscapeHtml(this.Options.Options[i].value)+'" '+checked+'/>\
2008                    <label class="redNaoCheckBox redNaoCheckBox'+orientationClass+'" for="'+itemId+'">'+RedNaoEscapeHtml(this.Options.Options[i].label)+'\
2009                </label></div>';
2010
2011        checked="";
2012
2013    }
2014
2015    html+='</div>';
2016    return html;
2017};
2018
2019
2020
2021
2022
2023
2024sfMultipleCheckBoxElement.prototype.GetValueString=function()
2025{
2026    this.amount=0;
2027    if(this.IsIgnored())
2028        return {selectedValues:[]};
2029    var jQueryElement=this.JQueryElement.find(':checked');
2030    var data={};
2031    data.selectedValues=[];
2032    if(jQueryElement.length>0)
2033    {
2034        for(var i=0;i<jQueryElement.length;i++)
2035        {
2036            if(jQueryElement.length>0)
2037                this.amount=parseFloat(rnJQuery(jQueryElement[i]).val());
2038            if(isNaN(this.amount))
2039                this.amount=0;
2040            data.selectedValues.push({value:rnJQuery.trim(rnJQuery(jQueryElement[i]).parent().find('label').text()),amount:this.amount,label:rnJQuery.trim(rnJQuery(jQueryElement[i]).parent().find('label').text())});
2041        }
2042    }
2043
2044
2045    return data;
2046
2047};
2048
2049
2050sfMultipleCheckBoxElement.prototype.SetData=function(data)
2051{
2052    if(typeof data.selectedValues=='undefined')
2053        return;
2054
2055    this.JQueryElement.find('input:checkbox').removeAttr('checked');
2056
2057    var labels=this.JQueryElement.find('.redNaoCheckBox');
2058    for(var i=0;i<data.selectedValues.length;i++)
2059    {
2060        for(var t=0;t<labels.length;t++)
2061        {
2062            if (rnJQuery.trim(rnJQuery(labels[t]).text()) == data.selectedValues[i].value)
2063            {
2064                rnJQuery(labels[t]).parent().find('input:checkbox').attr('checked','checked').click();
2065            }
2066        }
2067    }
2068};
2069
2070
2071
2072sfMultipleCheckBoxElement.prototype.GetDataStore=function()
2073{
2074    return new SmartFormMultipleItemsDataStore();
2075};
2076
2077
2078
2079sfMultipleCheckBoxElement.prototype.GetValuePath=function()
2080{
2081    return 'RedNaoGetValueFromArray(formData.'+this.Id+'.selectedValues)';
2082};
2083
2084
2085sfMultipleCheckBoxElement.prototype.IsValid=function()
2086{
2087    if(this.JQueryElement.find(':checked').length<=0&&this.Options.IsRequired=='y')
2088    {
2089        this.AddError('root',this.InvalidInputMessage);
2090    }else
2091        this.RemoveError('root');
2092    return this.InternalIsValid();
2093};
2094
2095sfMultipleCheckBoxElement.prototype.ClearInvalidStyle=function()
2096{
2097
2098};
2099
2100
2101
2102//noinspection JSUnusedLocalSymbols
2103sfMultipleCheckBoxElement.prototype.GenerationCompleted=function(jQueryElement)
2104{
2105    var self=this;
2106    jQueryElement.find('.redNaoInputCheckBox').change(function(){
2107        self.FirePropertyChanged();
2108    });
2109};
2110
2111
2112/*************************************************************************************Select Basic Element ***************************************************************************************************/
2113
2114function sfSelectBasicElement(options,serverOptions)
2115{
2116    sfFormElementBase.call(this,options,serverOptions);
2117    this.Title="Select Basic";
2118    var i=undefined;
2119    if(this.IsNew)
2120    {
2121        this.Options.Label="Select Basic";
2122        this.Options.ClassName="rednaoselectbasic";
2123        this.Options.DefaultText="Select a value";
2124        this.Options.Options=[{label:'Option 1',value:0,sel:'n'},{label:'Option 2',value:0,sel:'n'},{label:'Option',value:0,sel:'n'}];
2125        this.SetDefaultIfUndefined('Width','');
2126        this.Options.CustomCSS='';
2127        this.Options.DefaultText_Icon={ClassName:'',Orientation:''};
2128
2129    }else
2130    {
2131        this.SetDefaultIfUndefined('CustomCSS','');
2132        this.SetDefaultIfUndefined('Width','');
2133        this.SetDefaultIfUndefined("DefaultText","");
2134        this.SetDefaultIfUndefined('DefaultText_Icon',{ClassName:''});
2135        if(this.Options.Options.length>0&&typeof this.Options.Options[0].sel=='undefined')
2136        {
2137            this.Options.Options[0].sel='y';
2138            for(i=1;i<this.Options.Options.length;i++)
2139                this.Options.Options[i].sel='n';
2140        }
2141        if(this.Options.Options.length>0&&typeof this.Options.Options[i]=='string')
2142        {
2143            var aux=[];
2144            for(i=0;i<this.Options.Options.length;i++)
2145            {
2146                aux.push({label:this.Options.Options[i]});
2147            }
2148
2149            this.Options.Options=aux;
2150        }
2151    }
2152
2153
2154}
2155
2156sfSelectBasicElement.prototype=Object.create(sfFormElementBase.prototype);
2157
2158sfSelectBasicElement.prototype.CreateProperties=function()
2159{
2160
2161    this.Properties.push(new PropertyContainer('general','General').AddProperties([
2162        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
2163        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}),
2164        new ArrayProperty(this,this.Options,"Options","Options",{ManipulatorType:'basic',SelectorType:'radio'})
2165    ]));
2166
2167    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
2168        new SimpleTextProperty(this,this.Options,"DefaultText","Default text",{ManipulatorType:'basic',IconOptions:{Type:'leftAndRight'}}),
2169        new SimpleNumericProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'})
2170    ]));
2171
2172
2173    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
2174        new IdProperty(this,this.Options),
2175        new CustomCSSProperty(this,this.Options)
2176
2177    ]));
2178};
2179
2180sfSelectBasicElement.prototype.GenerateInlineElement=function()
2181{
2182    var additionalStyle='';
2183    if(!isNaN(parseFloat(this.Options.Width)))
2184        additionalStyle='width:'+this.Options.Width+'px'+' !important;';
2185
2186
2187    var html=  '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label">'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>\
2188        <div class="redNaoControls col-sm-9">\
2189        <select style="'+additionalStyle+'" name="'+this.GetPropertyName()+'" class="redNaoSelect form-control">';
2190
2191    var selected='';
2192    var i=undefined;
2193    if(this.Options.DefaultText!="")
2194    {
2195        selected='selected="selected"';
2196        for(i=0;i<this.Options.Options.length;i++)
2197        {
2198            if(this.Options.Options[i].sel=='y')
2199                selected='';
2200        }
2201        html+='<option   value="redNaoNone" '+selected+'>'+RedNaoEscapeHtml(this.Options.DefaultText)+'</opton>';
2202    }
2203
2204
2205
2206    selected='';
2207    for(i=0;i<this.Options.Options.length;i++)
2208    {
2209        if(this.Options.Options[i].sel=='y')
2210            selected='selected="selected"';
2211        else
2212            selected='';
2213
2214        html+='<option   value="'+RedNaoEscapeHtml(this.Options.Options[i].value)+'" '+selected+'>'+RedNaoEscapeHtml(this.Options.Options[i].label)+'</opton>';
2215
2216        selected="";
2217
2218    }
2219    html+='</select></div>';
2220    return html;
2221};
2222
2223
2224
2225sfSelectBasicElement.prototype.GetValueString=function()
2226{
2227    if(this.IsIgnored())
2228    {
2229        this.amount=0;
2230        return {value:'',amount:0};
2231    }
2232    var jQueryElement=this.JQueryElement.find('.redNaoSelect option:selected');
2233    if(jQueryElement.length>0)
2234        this.amount=parseFloat(jQueryElement.val());
2235    if(isNaN(this.amount))
2236        this.amount=0;
2237
2238    if(jQueryElement.text()==this.Options.DefaultText)
2239    {
2240        this.amount=0;
2241        return {value:'',amount:0};
2242    }
2243    return  {value:jQueryElement.text(),amount:this.amount,optionVal:jQueryElement.val()};
2244};
2245
2246sfSelectBasicElement.prototype.SetData=function(data)
2247{
2248    var options=this.JQueryElement.find('option');
2249    for(var i=0;i<options.length;i++)
2250    {
2251        var $option=rnJQuery(options[i]);
2252        $option.removeAttr('selected');
2253        if($option.text()==data.value)
2254            $option.attr('selected','selected');
2255    }
2256};
2257
2258
2259sfSelectBasicElement.prototype.GetDataStore=function()
2260{
2261    return new SmartFormBasicDataStore('amount');
2262};
2263
2264
2265
2266sfSelectBasicElement.prototype.GetValuePath=function()
2267{
2268    return 'formData.'+this.Id+'.amount';
2269};
2270
2271
2272sfSelectBasicElement.prototype.IsValid=function()
2273{
2274    if(this.Options.IsRequired=='y'&&(this.GetValueString().value==''||this.JQueryElement.find('.redNaoSelect option:selected').length==0))
2275    {
2276        this.JQueryElement.addClass('has-error');
2277        this.AddError('root',this.InvalidInputMessage);
2278    }
2279    else
2280        this.RemoveError('root');
2281
2282    return this.InternalIsValid();
2283};
2284
2285
2286//noinspection JSUnusedLocalSymbols
2287sfSelectBasicElement.prototype.GenerationCompleted=function(jQueryElement)
2288{
2289    var self=this;
2290    this.JQueryElement.find('.redNaoSelect').change(function(){self.FirePropertyChanged();});
2291    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoSelect'));
2292    if(this.Options.DefaultText_Icon.ClassName!='')
2293    {
2294        this.LoadPlaceHolderIcon(jQueryElement.find('.redNaoSelect'),null,null,this.Options.DefaultText_Icon);
2295    }
2296
2297
2298
2299};
2300
2301/*************************************************************************************Donation Button***************************************************************************************************/
2302
2303
2304
2305function sfDonationButtonElement(options,serverOptions)
2306{
2307    sfFormElementBase.call(this,options,serverOptions);
2308    this.Title="Donation Button";
2309
2310    if(this.IsNew)
2311    {
2312        this.Options.Label="Donation Button";
2313        this.Options.ClassName="rednaodonationbutton";
2314        this.Options.Image='https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif';
2315        this.Options.CustomCSS='';
2316    }else
2317    {
2318        this.SetDefaultIfUndefined('CustomCSS','');
2319        if(typeof this.Options.Image=='undefined')
2320            this.Options.Image='https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif';
2321    }
2322
2323
2324}
2325
2326sfDonationButtonElement.prototype=Object.create(sfFormElementBase.prototype);
2327
2328sfDonationButtonElement.prototype.CreateProperties=function()
2329{
2330    this.Properties.push(new PropertyContainer('general','General').AddProperties([
2331        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'})
2332    ]));
2333
2334    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
2335        new SimpleTextProperty(this,this.Options,"Image","Image Url",{ManipulatorType:'basic'})
2336    ]));
2337
2338
2339    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
2340        new IdProperty(this,this.Options),
2341        new CustomCSSProperty(this,this.Options)
2342    ]));
2343
2344
2345};
2346
2347sfDonationButtonElement.prototype.GenerateInlineElement=function()
2348{
2349    return '<div class="rednao_label_container col-sm-3"></div>'+
2350            '<div class="redNaoControls col-sm-9">' +
2351                '<input type="image" class="redNaoDonationButton" src="'+this.Options.Image+'" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">' +
2352           '</div>';
2353};
2354
2355
2356sfDonationButtonElement.prototype.GetValueString=function()
2357{
2358    return '';
2359
2360};
2361
2362sfDonationButtonElement.prototype.StoresInformation=function()
2363{
2364    return false;
2365};
2366
2367
2368/************************************************************************************* Recurrence Element  ***************************************************************************************************/
2369
2370
2371
2372function sfRecurrenceElement(options,serverOptions)
2373{
2374    sfFormElementBase.call(this,options,serverOptions);
2375    this.Title="Donation Button";
2376
2377    if(this.IsNew)
2378    {
2379        this.Options.Label="Recurrence";
2380        this.Options.ClassName="rednaodonationrecurrence";
2381        this.Options.ShowOneTime='y';
2382        this.Options.ShowDaily='y';
2383        this.Options.ShowWeekly='y';
2384        this.Options.ShowMonthly='y';
2385        this.Options.ShowYearly='y';
2386        this.Options.CustomCSS='';
2387    }else
2388    {
2389        this.SetDefaultIfUndefined('CustomCSS','');
2390    }
2391
2392
2393}
2394
2395sfRecurrenceElement.prototype=Object.create(sfFormElementBase.prototype);
2396
2397sfRecurrenceElement.prototype.CreateProperties=function()
2398{
2399
2400    this.Properties.push(new PropertyContainer('general','General').AddProperties([
2401        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'})
2402
2403    ]));
2404
2405    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
2406        new CheckBoxProperty(this,this.Options,"ShowOneTime","Show one time option",{ManipulatorType:'basic'}),
2407        new CheckBoxProperty(this,this.Options,"ShowDaily","Show daily option",{ManipulatorType:'basic'}),
2408        new CheckBoxProperty(this,this.Options,"ShowWeekly","Show weekly option",{ManipulatorType:'basic'}),
2409        new CheckBoxProperty(this,this.Options,"ShowMonthly","Show monthly option",{ManipulatorType:'basic'}),
2410            new CheckBoxProperty(this,this.Options,"ShowYearly","Show yearly option",{ManipulatorType:'basic'})
2411    ]));
2412
2413
2414    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
2415        new IdProperty(this,this.Options),
2416        new CustomCSSProperty(this,this.Options)
2417    ]));
2418};
2419
2420sfRecurrenceElement.prototype.GenerateInlineElement=function()
2421{
2422    var html= '<div class="rednao_label_container col-sm-3">' +
2423                    '<label class="rednao_control_label">'+RedNaoEscapeHtml(this.Options.Label)+'</label>' +
2424                    '</div>' +
2425              '<div class="redNaoControls col-sm-9">' +
2426              '<select class="redNaoSelect redNaoRecurrence">';
2427    var selected='selected="selected"';
2428
2429    if(this.Options.ShowOneTime=='y')
2430    {
2431         html+='<option value="OT" '+selected+'>
2431One Time</option>';
2432        selected='';
2433    }
2434
2435    if(this.Options.ShowDaily=='y')
2436    {
2437        html+='<option value="D" '+selected+'>Daily</option>';
2438        selected='';
2439    }
2440
2441    if(this.Options.ShowWeekly=='y')
2442    {
2443        html+='<option value="W" '+selected+'>Weekly</option>';
2444        selected='';
2445    }
2446
2447    if(this.Options.ShowMonthly=='y')
2448    {
2449        html+='<option value="M" '+selected+'>Monthly</option>';
2450        selected='';
2451    }
2452
2453    if(this.Options.ShowYearly=='y')
2454    {
2455        html+='<option value="Y" '+selected+'>Yearly</option>';
2456        selected='';
2457    }
2458
2459    html+='</select></div>';
2460
2461    return html;
2462};
2463
2464
2465
2466sfRecurrenceElement.prototype.GetValueString=function()
2467{
2468    if(this.IsIgnored())
2469        return {value:''};
2470    var jQueryElement=this.JQueryElement.find('.redNaoSelect option:selected');
2471    return {value:jQueryElement.val()};
2472
2473};
2474
2475sfRecurrenceElement.prototype.SetData=function(data)
2476{
2477   this.JQueryElement.find('.redNaoSelect').val(data.value);
2478};
2479
2480
2481sfRecurrenceElement.prototype.GetValuePath=function()
2482{
2483    return 'formData.'+this.Id+'.value';
2484};
2485
2486
2487//noinspection JSUnusedLocalSymbols
2488sfRecurrenceElement.prototype.GenerationCompleted=function(jQueryElement)
2489{
2490    var self=this;
2491    this.JQueryElement.find('.redNaoSelect').change(function(){self.FirePropertyChanged();});
2492    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoSelect'));
2493};
2494
2495
2496/************************************************************************************* Submission Button ***************************************************************************************************/
2497
2498
2499
2500function sfRedNaoSubmissionButton(options,serverOptions)
2501{
2502    sfFormElementBase.call(this,options,serverOptions);
2503    this.Title="Submit Button";
2504
2505    if(this.IsNew)
2506    {
2507        this.Options.ClassName="rednaosubmissionbutton";
2508        this.Options.ButtonText="Submit";
2509        this.Options.CustomCSS='';
2510        this.Options.Icon={ClassName:''};
2511        this.Options.Animated='y';
2512        this.Options.Action='submit';
2513
2514    }else{
2515        this.SetDefaultIfUndefined('CustomCSS','');
2516        this.SetDefaultIfUndefined('Icon',{ClassName:''});
2517        this.SetDefaultIfUndefined('Animated','n');
2518        this.SetDefaultIfUndefined('Action','submit');
2519    }
2520
2521    this.RegisterForSubmitEvents();
2522
2523}
2524
2525sfRedNaoSubmissionButton.prototype=Object.create(sfFormElementBase.prototype);
2526
2527sfRedNaoSubmissionButton.prototype.RegisterForSubmitEvents=function()
2528{
2529
2530    var self=this;
2531    RedNaoEventManager.Subscribe('FormSubmitted',function(data)
2532    {
2533        if(data.Generator.form_id!=self.FormId)
2534            return;
2535
2536
2537        if(self.Options.Animated=='y')
2538            self.JQueryElement.find('button').RNWait('start');
2539        else
2540            self.JQueryElement.find('button').attr('disabled','disabled');
2541    });
2542
2543    RedNaoEventManager.Subscribe('FormSubmittedCompleted',function(data)
2544    {
2545        if(data.Generator.form_id!=self.FormId)
2546            return;
2547
2548
2549        if(self.Options.Animated=='y')
2550            self.JQueryElement.find('button').RNWait('stop');
2551        else
2552            self.JQueryElement.find('button').removeAttr('disabled','disabled');
2553    });
2554};
2555
2556sfRedNaoSubmissionButton.prototype.GetFriendlyName=function()
2557{
2558    return this.Options.ButtonText;
2559};
2560
2561sfRedNaoSubmissionButton.prototype.CreateProperties=function()
2562{
2563    this.Properties.push(new PropertyContainer('general','General').AddProperties([
2564        new SimpleTextProperty(this,this.Options,"ButtonText","Button Text",{ManipulatorType:'basic'}),
2565        new ComboBoxProperty(this,this.Options,"Action","Action",{ManipulatorType:'basic',Values:[{label:'Submit',value:'submit'},{label:'Clear form (no submission)',value:'clear'}]})
2566    ]));
2567
2568    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
2569        new IconProperty(this,this.Options,'Icon','Icon',{ManipulatorType:'basic'}),
2570        new CheckBoxProperty(this,this.Options,"Animated","Animate Button Click",{ManipulatorType:'basic'})
2571    ]));
2572
2573
2574    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
2575        new IdProperty(this,this.Options),
2576        new CustomCSSProperty(this,this.Options)
2577    ]));
2578
2579};
2580
2581sfRedNaoSubmissionButton.prototype.GenerateInlineElement=function()
2582{
2583    var icon='';
2584    if(this.Options.Icon.ClassName!='')
2585        icon='<span class="'+RedNaoEscapeHtml(this.Options.Icon.ClassName)+' "></span>';
2586
2587    return '<div class="rednao_label_container col-sm-3"></div>
2587<div class="redNaoControls col-sm-9"><button class="redNaoSubmitButton btn btn-normal ladda-button" >'+
2588                icon+
2589                '<span class="ladda-label">'+RedNaoEscapeHtml(this.Options.ButtonText)+'</span>'+
2590            '</button></div>';
2591};
2592
2593sfRedNaoSubmissionButton.prototype.GenerationCompleted=function(jQueryElement)
2594{
2595
2596    if(this.Options.Action=='clear')
2597    {
2598        var me=this;
2599        this.JQueryElement.find('button').click(function(e){
2600            e.preventDefault();
2601            me.Generator.CreateForm();
2602            if(window.localStorage!=null)
2603                window.localStorage.removeItem('sfAutoSave'+me.Generator.form_id);
2604        });
2605    }
2606};
2607
2608
2609
2610sfRedNaoSubmissionButton.prototype.GetValueString=function()
2611{
2612    return '';
2613
2614};
2615
2616sfRedNaoSubmissionButton.prototype.StoresInformation=function()
2617{
2618    return false;
2619};
2620
2621
2622
2623/************************************************************************************* Date Picker ***************************************************************************************************/
2624
2625
2626
2627function sfRedNaoDatePicker(options,serverOptions)
2628{
2629    sfFormElementBase.call(this,options,serverOptions);
2630    this.Title="Date Picker";
2631
2632    if(this.IsNew)
2633    {
2634        this.Options.ClassName="rednaodatepicker";
2635        this.Options.Label="Date";
2636        this.Options.DateFormat="MM-dd-yy";
2637        this.Options.Value='';
2638        this.Options.Icon={ClassName:''};
2639        this.Options.ReadOnly='n';
2640        this.Options.Value='';
2641        this.Options.CustomCSS='';
2642        this.Options.IsRequired='n';
2643        this.Options.ShowMonthPicker='n';
2644        this.Options.ShowYearPicker='n';
2645        this.Options.Placeholder="";
2646        this.Options.Placeholder_Icon={ClassName:'',Orientation:''};
2647        this.Options.MaximumDate='';
2648        this.Options.MinimumDate='';
2649    }else{
2650        this.SetDefaultIfUndefined('Icon',{ClassName:''});
2651        this.SetDefaultIfUndefined('ReadOnly','n');
2652        this.SetDefaultIfUndefined('Value','');
2653        this.SetDefaultIfUndefined('CustomCSS','');
2654        this.SetDefaultIfUndefined('IsRequired','n');
2655        this.SetDefaultIfUndefined('ShowMonthPicker','n');
2656        this.SetDefaultIfUndefined('ShowYearPicker','n');
2657        this.SetDefaultIfUndefined('Placeholder','');
2658        this.SetDefaultIfUndefined('Placeholder_Icon',{ClassName:''});
2659        this.SetDefaultIfUndefined('MaximumDate','');
2660        this.SetDefaultIfUndefined('MinimumDate','');
2661    }
2662
2663    this.SelectedDate=this.Options.Value;
2664}
2665
2666
2667sfRedNaoDatePicker.prototype=Object.create(sfFormElementBase.prototype);
2668sfRedNaoDatePicker.prototype.GetDataStore=function()
2669{
2670    return new SmartFormDateDataStore('value');
2671};
2672
2673
2674sfRedNaoDatePicker.prototype.CreateProperties=function()
2675{
2676    this.Properties.push(new PropertyContainer('general','General').AddProperties([
2677        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
2678        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}),
2679        new SimpleTextProperty(this,this.Options,"Value","Default Value",{ManipulatorType:'basic',RefreshFormData:true}).SetEnableFormula()
2680    ]));
2681
2682    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
2683        new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic',IconOptions:{Type:'leftAndRight'}}),
2684        new SimpleTextProperty(this,this.Options,"DateFormat","Date Format",{ManipulatorType:'basic'}),
2685        new DatePickerProperty(this,this.Options,"MinimumDate","Minimum Date",{ManipulatorType:'basic',RefreshFormData:true}).SetEnableFormula().SetAllowRelativeDates(),
2686        new DatePickerProperty(this,this.Options,"MaximumDate","Maximum Date",{ManipulatorType:'basic',RefreshFormData:true}).SetEnableFormula().SetAllowRelativeDates(),
2687        new CheckBoxProperty(this,this.Options,"ShowMonthPicker","Show Month Picker",{ManipulatorType:'basic'}),
2688        new CheckBoxProperty(this,this.Options,"ShowYearPicker","Show Year Picker",{ManipulatorType:'basic'}),
2689        new IconProperty(this,this.Options,'Icon','Icon',{ManipulatorType:'basic'})
2690    ]));
2691
2692
2693    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
2694        new CheckBoxProperty(this,this.Options,"ReadOnly","Read Only",{ManipulatorType:'basic'}),
2695        new IdProperty(this,this.Options),
2696        new CustomCSSProperty(this,this.Options)
2697    ]));
2698
2699};
2700
2701sfRedNaoDatePicker.prototype.GenerateInlineElement=function()
2702{
2703    var startOfInput='';
2704    var endOfInput='';
2705
2706    if(this.Options.Icon.ClassName!='')
2707    {
2708        startOfInput='<div class="rednao-input-prepend input-group"><span class="redNaoPrepend input-group-addon prefix '+RedNaoEscapeHtml(this.Options.Icon.ClassName)+' "></span>';
2709        endOfInput='</div>';
2710    }
2711
2712
2713    return '<div class="rednao_label_container col-sm-3">' +
2714                '<label class="rednao_control_label ">'+RedNaoEscapeHtml(this.Options.Label)+'</label>' +
2715            '</div>' +
2716            '<div class="redNaoControls col-sm-9">' +
2717                startOfInput+
2718                '<input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  type="text" class="form-control redNaoDatePicker" placeholder="'+RedNaoEscapeHtml(this.Options.Placeholder)+'"  />' +
2719                endOfInput+
2720            '</div>';
2721
2722};
2723
2724
2725sfRedNaoDatePicker.prototype.GetValueString=function()
2726{
2727    if(this.IsIgnored())
2728        return {value:'',formattedValue:''};
2729    var selectedDate= this.JQueryElement.find('.redNaoDatePicker').datepicker('getDate');
2730    var dateLabel='';
2731    var numericalValues=0;
2732    if(selectedDate==null)
2733        selectedDate ="";
2734    else
2735    {
2736        numericalValues=selectedDate.getTime();
2737        var month=selectedDate.getMonth()+1;
2738        var day=selectedDate.getDate();
2739
2740        selectedDate=selectedDate.getFullYear()+'-'+(month<10?'0':'')+month+'-'+(day<10?'0':'')+day;
2741        dateLabel=this.JQueryElement.find('.redNaoDatePicker').datepicker({dateFormat: this.Options.DateFormat}).val();
2742
2743    }
2744    return {value:selectedDate,formattedValue:dateLabel,format: this.Options.DateFormat,numericalValue:numericalValues};
2745
2746};
2747
2748
2749
2750sfRedNaoDatePicker.prototype.SetData=function(data)
2751{
2752    this.JQueryElement.find('.redNaoDatePicker').datepicker('setDate',data.formattedValue);
2753};
2754
2755
2756sfRedNaoDatePicker.prototype.GetValuePath=function()
2757{
2758    return 'formData.'+this.Id+'.value';
2759};
2760
2761
2762
2763sfRedNaoDatePicker.prototype.StoresInformation=function()
2764{
2765    return true;
2766};
2767
2768//noinspection JSUnusedLocalSymbols
2769sfRedNaoDatePicker.prototype.GenerationCompleted=function(jQueryElement)
2770{
2771    var minDate=this.ParseDate(this.Options.MinimumDate);
2772    var maxDate=this.ParseDate(this.Options.MaximumDate);
2773    var self=this;
2774    var datePickerOptions={
2775        dateFormat:this.Options.DateFormat,
2776        beforeShow: function() {
2777            rnJQuery('#ui-datepicker-div').wrap('<div class="smartFormsSlider"></div>');
2778            self.JQueryElement.addClass('is-focused');
2779        },
2780        onClose: function() {
2781            rnJQuery('#ui-datepicker-div').unwrap();
2782            self.JQueryElement.removeClass('is-focused');
2783        },
2784        changeMonth:self.Options.ShowMonthPicker=="y",
2785        changeYear:self.Options.ShowYearPicker=="y"
2786    };
2787
2788    if(minDate!=null)
2789        datePickerOptions.minDate=minDate;
2790    if(maxDate!=null)
2791        datePickerOptions.maxDate=maxDate;
2792
2793    datePickerOptions.yearRange='-100:+100';
2794
2795    this.JQueryElement.find('.redNaoDatePicker').datepicker(datePickerOptions);
2796    rnJQuery('#ui-datepicker-div').css('display','none');
2797
2798    if(this.SelectedDate instanceof Date||rnJQuery.trim(this.SelectedDate)!='')
2799        this.JQueryElement.find('.redNaoDatePicker').datepicker('setDate',this.SelectedDate);
2800
2801
2802    if(this.Options.ReadOnly=='y')
2803        this.JQueryElement.find('.redNaoDatePicker').datepicker('disable');
2804
2805    var self=this;
2806    this.JQueryElement.change(function(){
2807        self.SelectedDate=self.JQueryElement.find('.redNaoDatePicker').datepicker('getDate')
2808        self.FirePropertyChanged();
2809    });
2810    if(this.Options.Placeholder_Icon.ClassName!='')
2811    {
2812        this.LoadPlaceHolderIcon(jQueryElement.find('.redNaoDatePicker'),null,null,this.Options.Placeholder_Icon);
2813    }
2814
2815};
2816
2817sfRedNaoDatePicker.prototype.ParseDate=function(date)
2818{
2819    var dateToReturn=date;
2820    if(date instanceof SmartFormDateDataStore)
2821        dateToReturn =date.GetTime();
2822    if(dateToReturn=='0'||dateToReturn=='')
2823        return null;
2824    if(!isNaN(Number(dateToReturn))&&((date instanceof SmartFormDateDataStore)||parseInt(dateToReturn)>100000000))
2825        return new Date(Number(dateToReturn));
2826    return dateToReturn;
2827};
2828
2829sfRedNaoDatePicker.prototype.IsValid=function()
2830{
2831    var selectedDate= this.JQueryElement.find('.redNaoDatePicker').datepicker('getDate');
2832    if(selectedDate==null&&this.Options.IsRequired=='y')
2833        this.AddError('root',this.InvalidInputMessage);
2834    else
2835        this.RemoveError('root');
2836
2837    return this.InternalIsValid();
2838};
2839
2840/************************************************************************************* Name ***************************************************************************************************/
2841
2842function sfRedNaoName(options,serverOptions)
2843{
2844    sfFormElementBase.call(this,options,serverOptions);
2845    this.Title="Text Input";
2846    if(this.IsNew)
2847    {
2848        this.Options.ClassName="rednaoname";
2849        this.Options.Label="Name";
2850        this.Options.FirstNamePlaceholder="First Name";
2851        this.Options.LastNamePlaceholder="Last Name";
2852        this.Options.FirstNameValue="";
2853        this.Options.LastNameValue="";
2854        this.Options.ReadOnly='n';
2855        this.Options.Icon={ClassName:''};
2856        this.Options.CustomCSS='';
2857        this.Options.IsRequired='n';
2858        this.Options.FirstNamePlaceholder_Icon={ClassName:'',Orientation:''};
2859    }else
2860    {
2861        this.SetDefaultIfUndefined('Icon',{ClassName:''});
2862        this.SetDefaultIfUndefined('CustomCSS','');
2863        this.SetDefaultIfUndefined('IsRequired','n');
2864        this.SetDefaultIfUndefined('IsRequired','n');
2865        this.SetDefaultIfUndefined('FirstNamePlaceholder_Icon',{ClassName:''});
2866    }
2867
2868
2869
2870
2871
2872}
2873
2874sfRedNaoName.prototype=Object.create(sfFormElementBase.prototype);
2875
2876sfRedNaoName.prototype.CreateProperties=function()
2877{
2878    this.Properties.push(new PropertyContainer('general','General').AddProperties([
2879        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
2880        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'})
2881    ]));
2882
2883    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
2884        new SimpleTextProperty(this,this.Options,"FirstNamePlaceholder","First name placeholder",{ManipulatorType:'basic',IconOptions:{Type:'leftAndRight'}}),
2885        new SimpleTextProperty(this,this.Options,"LastNamePlaceholder","Last name placeholder",{ManipulatorType:'basic'}),
2886        new IconProperty(this,this.Options,'Icon','Icon',{ManipulatorType:'basic'})
2887    ]));
2888
2889
2890    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
2891        new CheckBoxProperty(this,this.Options,"ReadOnly","Read Only",{ManipulatorType:'basic'}),
2892        new IdProperty(this,this.Options),
2893        new CustomCSSProperty(this,this.Options)
2894
2895    ]));
2896
2897};
2898
2899sfRedNaoName.prototype.GenerateInlineElement=function()
2900{
2901
2902    var startOfInput='';
2903    var endOfInput='';
2904
2905    if(this.Options.Icon.ClassName!='')
2906    {
2907        startOfInput='<div class="rednao-input-prepend input-group"><span class="redNaoPrepend input-group-addon prefix '+RedNaoEscapeHtml(this.Options.Icon.ClassName)+' "></span>';
2908        endOfInput='</div>';
2909    }
2910
2911    var firstNameLabel='';
2912    var lastNameLabel='';
2913
2914    if(this.Options.FirstNamePlaceholder!='')
2915        firstNameLabel='<br/><label class="redNaoHelper">'+this.Options.FirstNamePlaceholder+'</label>';
2916    if(this.Options.LastNamePlaceholder!='')
2917        lastNameLabel='<br/><label class="redNaoHelper">'+this.Options.LastNamePlaceholder+'</label>';
2918
2919    return '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label" >'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>'+
2920                 '<div class="redNaoControls col-sm-9">'+
2921                    '<div class="form-inline firstAndLastName">'+
2922                        '<div class="redNaoFirstNameDiv redNaoTwoColumnsDiv form-group col-sm-6">'+
2923                            startOfInput+
2924                            '<input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_firstname" type="text" placeholder="'+RedNaoEscapeHtml(this.Options.FirstNamePlaceholder)+'" class="form-control redNaoInputText redNaoTwoColumns redNaoInputFirstName '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'"/>'+
2925                            endOfInput+ /*firstNameLabel+*/
2926                        '</div>    '+
2927                        '<div class="redNaoLastNameDiv redNaoTwoColumnsDiv form-group col-sm-6">'+
2928                            '<input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_lastname" type="text" placeholder="'+RedNaoEscapeHtml(this.Options.LastNamePlaceholder)+'" class="form-control redNaoInputText redNaoTwoColumns redNaoInputLastName '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'">'+ /*lastNameLabel+*/
2929                        '</div>'+
2930                     '</div>   '+
2931               '<div>     '+
2932    '</div>';
2933};
2934
2935
2936sfRedNaoName.prototype.GetValueString=function()
2937{
2938    if(this.IsIgnored())
2939        return {firstName:'',lastName:''};
2940    return {
2941        firstName:this.JQueryElement.find('.redNaoInputFirstName').val(),
2942        lastName:this.JQueryElement.find('.redNaoInputLastName').val()
2943
2944    };
2945
2946
2947};
2948
2949
2950sfRedNaoName.prototype.SetData=function(data)
2951{
2952    this.JQueryElement.find('.redNaoInputFirstName').val(data.firstName);
2953    this.JQueryElement.find('.redNaoInputLastName').val(data.lastName);
2954};
2955
2956
2957
2958sfRedNaoName.prototype.GetValuePath=function()
2959{
2960    return 'formData.'+this.Id+'.firstName+" "'+'formData.'+this.Id+'.lastName';
2961};
2962
2963
2964sfRedNaoName.prototype.IsValid=function()
2965{
2966    if(this.Options.IsRequired=='y'&&(this.JQueryElement.find('.redNaoInputFirstName').val()==""||this.JQueryElement.find('.redNaoInputLastName').val()==""))
2967    {
2968        var firstNameJQuery=this.JQueryElement.find('.redNaoInputFirstName');
2969        var lastNameJQuery=this.JQueryElement.find('.redNaoInputLastName');
2970
2971        if(firstNameJQuery.val()=="")
2972            firstNameJQuery.parent().addClass('has-error');
2973
2974        if(lastNameJQuery.val()=="")
2975            lastNameJQuery.parent().addClass('has-error');
2976
2977        this.AddError('root',this.InvalidInputMessage);
2978    }
2979    else
2980        this.RemoveError('root');
2981
2982    return this.InternalIsValid();
2983};
2984
2985//noinspection JSUnusedLocalSymbols
2986sfRedNaoName.prototype.GenerationCompleted=function(jQueryElement)
2987{
2988    var self=this;
2989    this.JQueryElement.find('.redNaoInputFirstName,.redNaoInputLastName').change(function(){self.FirePropertyChanged();});
2990    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoInputFirstName'));
2991    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoInputLastName'));
2992    if(this.Options.FirstNamePlaceholder_Icon.ClassName!='')
2993    {
2994        this.LoadPlaceHolderIcon(jQueryElement.find('.redNaoInputFirstName'),null,null,this.Options.FirstNamePlaceholder_Icon);
2995    }
2996};
2997
2998
2999
3000/************************************************************************************* Address ***************************************************************************************************/
3001
3002function sfRedNaoAddress(options,serverOptions)
3003{
3004    sfFormElementBase.call(this,options,serverOptions);
3005    this.Title="Text Input";
3006    this.Countries=["Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burma", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo, Democratic Republic", "Congo, Republic of the", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Greece", "Greenland", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "
3006Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Mongolia", "Morocco", "Monaco", "Mozambique", "Namibia", "Nauru", "Nepal", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Samoa", "San Marino", " Sao Tome", "Saudi Arabia", "Senegal", "Serbia","Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe"];
3007    if(this.IsNew)
3008    {
3009        this.Options.ClassName="rednaoaddress";
3010        this.Options.Label="Address";
3011        this.Options.StreetAddress1Label="Street Address";
3012        this.Options.StreetAddress2Label="Street Address 2";
3013        this.Options.CityLabel="City";
3014        this.Options.StateLabel="State";
3015        this.Options.ZipLabel='Zip';
3016        this.Options.CountryLabel='Country';
3017        this.Options.DefaultCountry="United States";
3018
3019        this.Options.ShowStreetAddress1="y";
3020        this.Options.ShowStreetAddress2="y";
3021        this.Options.ShowCity="y";
3022        this.Options.ShowState="y";
3023        this.Options.ShowZip='y';
3024        this.Options.ShowCountry='y';
3025        this.Options.Icon={ClassName:''};
3026        this.Options.CustomCSS='';
3027    }else
3028    {
3029        this.SetDefaultIfUndefined("DefaultCountry","United States");
3030        this.SetDefaultIfUndefined('Icon',{ClassName:''});
3031        this.SetDefaultIfUndefined('CustomCSS','');
3032    }
3033}
3034
3035sfRedNaoAddress.prototype=Object.create(sfFormElementBase.prototype);
3036
3037sfRedNaoAddress.prototype.GetCountriesForPropertyConfiguration = function () {
3038    var countriesToReturn=new Array(this.Countries.length);
3039    for(var i=0;i<this.Countries.length;i++)
3040    {
3041        countriesToReturn[i]={value:this.Countries[i],label:this.Countries[i]};
3042    }
3043
3044    return countriesToReturn;
3045};
3046sfRedNaoAddress.prototype.CreateProperties=function()
3047{
3048
3049    this.Properties.push(new PropertyContainer('general','General').AddProperties([
3050        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
3051        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'})
3052    ]));
3053
3054    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
3055        new SimpleTextProperty(this,this.Options,"StreetAddress1Label","St Addr Placeholder",{ManipulatorType:'basic'}),
3056        new SimpleTextProperty(this,this.Options,"StreetAddress2Label","St Addr 2 Placeholder",{ManipulatorType:'basic'}),
3057        new SimpleTextProperty(this,this.Options,"CityLabel","City Placeholder",{ManipulatorType:'basic'}),
3058        new SimpleTextProperty(this,this.Options,"StateLabel","State Placeholder",{ManipulatorType:'basic'}),
3059        new SimpleTextProperty(this,this.Options,"ZipLabel","Zip Placeholder",{ManipulatorType:'basic'}),
3060        new SimpleTextProperty(this,this.Options,"CountryLabel","Country Placeholder",{ManipulatorType:'basic'}),
3061        new CheckBoxProperty(this,this.Options,"ShowStreetAddress1","Show Street Address",{ManipulatorType:'basic'}),
3062        new CheckBoxProperty(this,this.Options,"ShowStreetAddress2","Show Street Address 2",{ManipulatorType:'basic'}),
3063        new CheckBoxProperty(this,this.Options,"ShowCity","Show City",{ManipulatorType:'basic'}),
3064        new CheckBoxProperty(this,this.Options,"ShowState","Show State",{ManipulatorType:'basic'}),
3065        new CheckBoxProperty(this,this.Options,"ShowZip","Show Zip",{ManipulatorType:'basic'}),
3066        new CheckBoxProperty(this,this.Options,"ShowCountry","Show Country",{ManipulatorType:'basic'}),
3067        new ComboBoxProperty(this,this.Options,"DefaultCountry",this.Translations.DefaultCountry,{ManipulatorType:'basic',Values:this.GetCountriesForPropertyConfiguration()}),
3068        new IconProperty(this,this.Options,'Icon','Icon',{ManipulatorType:'basic'})
3069    ]));
3070
3071
3072    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
3073        new IdProperty(this,this.Options),
3074        new CustomCSSProperty(this,this.Options)
3075    ]));
3076
3077};
3078
3079sfRedNaoAddress.prototype.GenerateInlineElement=function()
3080{
3081    var StreetAddress1Label='';
3082    var StreetAddress2Label='';
3083    var CityLabel='';
3084    var StateLabel='';
3085    var ZipLabel='';
3086    var CountryLabel='';
3087    var isFirstElement=true;
3088
3089    var startOfInput='';
3090    var endOfInput='';
3091    if(this.Options.Icon.ClassName!='')
3092    {
3093        startOfInput='<div class="rednao-input-prepend input-group"><span class="redNaoPrepend input-group-addon prefix '+RedNaoEscapeHtml(this.Options.Icon.ClassName)+' "></span>';
3094        endOfInput='</div>';
3095    }
3096
3097
3098    if(this.Options.StreetAddress1Label!='')
3099        StreetAddress1Label='<label class="redNaoHelper">'+RedNaoEscapeHtml(this.Options.StreetAddress1Label)+'</label>';
3100
3101    if(this.Options.StreetAddress2Label!='')
3102        StreetAddress2Label='<label class="redNaoHelper">'+RedNaoEscapeHtml(this.Options.StreetAddress2Label)+'</label>';
3103
3104    if(this.Options.CityLabel!='')
3105        CityLabel='<br/><label class="redNaoHelper">'+RedNaoEscapeHtml(this.Options.CityLabel)+'</label>';
3106
3107    if(this.Options.StateLabel!='')
3108        StateLabel='<br/><label class="redNaoHelper">'+RedNaoEscapeHtml(this.Options.StateLabel)+'</label>';
3109
3110    if(this.Options.ZipLabel!='')
3111        ZipLabel='<br/><label class="redNaoHelper">'+RedNaoEscapeHtml(this.Options.ZipLabel)+'</label>';
3112
3113    if(this.Options.CountryLabel!='')
3114        CountryLabel='<br/><label class="redNaoHelper">'+RedNaoEscapeHtml(this.Options.CountryLabel)+'</label>';
3115
3116
3117
3118
3119    var html= '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label" >'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>\
3120                <div class="redNaoControls col-sm-9">';
3121                if(this.Options.ShowStreetAddress1=='y')
3122                    html+='<div class="redNaoStreetAddress1Div form-group">'+
3123                        startOfInput+'<input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_streetaddress1" type="text" placeholder="'+RedNaoEscapeHtml(this.Options.StreetAddress1Label)+'" class="form-control redNaoInputText redNaoOneColumn redNaoStreetAddress1 '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'"/>'+endOfInput+ /* StreetAddress1Label+'\*/
3124                    '</div>';
3125                if(this.Options.ShowStreetAddress2=='y')
3126                    html+='<div class="redNaoStreetAddress2Div form-group">\
3127                        <input '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_streetaddress2" type="text" placeholder="'+RedNaoEscapeHtml(this.Options.StreetAddress2Label)+'" class="form-control redNaoInputText redNaoOneColumn redNaoStreetAddress2 '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'"/>'+/*+StreetAddress2Label+'\*/
3128                    '</div>';
3129
3130                html+="<div><div class='form-inline cityAndState'>";
3131                if(this.Options.ShowCity=='y')
3132                    html+='<div class="form-group col-sm-6">\
3133                        <input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_city" type="text" placeholder="'+RedNaoEscapeHtml(this.Options.CityLabel)+'" class="form-control redNaoInputText redNaoTwoColumns redNaoCity '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'"/>'+/*'+CityLabel+'\*/
3134                    '</div>';
3135                if(this.Options.ShowState=='y')
3136                    html+='<div class="form-group col-sm-6">\
3137                          <input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'state" type="text" placeholder="'+RedNaoEscapeHtml(this.Options.StateLabel)+'" class="form-control redNaoInputText redNaoTwoColumns redNaoState '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'"/>'+/*+StateLabel+'\*/
3138                    '</div>';
3139                html+='</div></div>';
3140
3141                html+="<div class='form-inline zipAndCountry'>";
3142                if(this.Options.ShowZip=='y')
3143                    html+='<div class="form-group col-sm-6">\
3144                                    <input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'zip" type="text" placeholder="'+RedNaoEscapeHtml(this.Options.ZipLabel)+'" class="form-control redNaoInputText redNaoTwoColumns redNaoZip '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'"/>'+/*+ZipLabel+'\*/
3145                                '</div>';
3146
3147                if(this.Options.ShowCountry=='y')
3148                {
3149                    html+='<div class="form-group col-sm-6">\
3150                        <select '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_country"  class="form-control redNaoSelect redNaoCountry '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'">';
3151                        for(var i=0;i<this.Countries.length;i++)
3152                        {
3153                            html+='<option '+((this.Countries[i]==this.Options.DefaultCountry)?'selected="selected"':'')+'  value="'+RedNaoEscapeHtml(this.Countries[i])+'">'+RedNaoEscapeHtml(this.Countries[i])+'</option>';
3154                            isFirstElement=false;
3155                        }
3156                html+="</select>"+/*CountryLabel+'\*/
3157                    "</div>";
3158                }
3159
3160    html+='</div></div>';
3161    return html;
3162};
3163
3164
3165sfRedNaoAddress.prototype.GetValueString=function()
3166{
3167    if(this.IsIgnored())
3168        return {streetAddress1:'',
3169                streetAddress2:'',
3170                city:'',
3171                state:'',
3172                zip:'',
3173                country:''
3174        };
3175    return {
3176        streetAddress1:this.JQueryElement.find('.redNaoStreetAddress1').val(),
3177        streetAddress2:this.JQueryElement.find('.redNaoStreetAddress2').val(),
3178        city:this.JQueryElement.find('.redNaoCity').val(),
3179        state:this.JQueryElement.find('.redNaoState').val(),
3180        zip:this.JQueryElement.find('.redNaoZip').val(),
3181        country:this.JQueryElement.find('.redNaoCountry').val()
3182
3183    };
3184
3185
3186};
3187
3188
3189sfRedNaoAddress.prototype.SetData=function(data)
3190{
3191    this.JQueryElement.find('.redNaoStreetAddress1').val(data.streetAddress1);
3192    this.JQueryElement.find('.redNaoStreetAddress2').val(data.streetAddress2);
3193    this.JQueryElement.find('.redNaoCity').val(data.city);
3194    this.JQueryElement.find('.redNaoState').val(data.state);
3195    this.JQueryElement.find('.redNaoZip').val(data.zip);
3196    this.JQueryElement.find('.redNaoCountry').val(data.country);
3197};
3198
3199sfRedNaoAddress.prototype.GetValuePath=function()
3200{
3201    return  "formData."+this.Id+'.streetAddress1'+
3202            " "+'formData.'+this.Id+'.streetAddress2'+
3203            " "+'formData.'+this.Id+'.city'+
3204            " "+'formData.'+this.Id+'.state'+
3205            " "+'formData.'+this.Id+'.zip'+
3206            " "+'formData.'+this.Id+'.country';
3207};
3208
3209
3210sfRedNaoAddress.prototype.IsValid=function()
3211{
3212    if(this.Options.IsRequired=='n')
3213        return true;
3214
3215
3216
3217    var streetAddress1JQuery=this.JQueryElement.find('.redNaoStreetAddress1');
3218    var streetAddress2JQuery=this.JQueryElement.find('.redNaoStreetAddress2');
3219    var cityJQuery=this.JQueryElement.find('.redNaoCity');
3220    var stateJQuery=this.JQueryElement.find('.redNaoState');
3221    var zipJQuery=this.JQueryElement.find('.redNaoZip');
3222    var countryJQuery=this.JQueryElement.find('.redNaoCountry');
3223
3224    var isValid=true;
3225    if(this.Options.ShowStreetAddress1&&streetAddress1JQuery.val()=='')
3226    {
3227        isValid=false;
3228        streetAddress1JQuery.parent().addClass('has-error');
3229    }
3230
3231
3232
3233    if(this.Options.ShowCity&&cityJQuery.val()=='')
3234    {
3235        isValid=false;
3236        cityJQuery.parent().addClass('has-error');
3237    }
3238
3239    if(this.Options.ShowState&&stateJQuery.val()=='')
3240    {
3241        isValid=false;
3242        stateJQuery.parent().addClass('has-error');
3243    }
3244
3245    if(this.Options.ShowZip&&zipJQuery.val()=='')
3246    {
3247        isValid=false;
3248        zipJQuery.parent().addClass('has-error');
3249    }
3250
3251    if(this.Options.ShowCountry&&countryJQuery.val()=='')
3252    {
3253        isValid=false;
3254        countryJQuery.parent().addClass('has-error');
3255    }
3256
3257    if(!isValid)
3258        this.AddError('root',this.InvalidInputMessage);
3259    else
3260        this.RemoveError('root');
3261
3262
3263    return this.InternalIsValid();
3264
3265};
3266
3267//noinspection JSUnusedLocalSymbols
3268sfRedNaoAddress.prototype.GenerationCompleted=function(jQueryElement)
3269{
3270    var self=this;
3271    this.JQueryElement.find('.redNaoStreetAddress1,.redNaoStreetAddress2,.redNaoCity,.redNaoState,.redNaoZip,.redNaoCountry').change(function(){self.FirePropertyChanged();});
3272    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoStreetAddress1'));
3273    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoStreetAddress2'));
3274    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoCity'));
3275    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoState'));
3276    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoZip'));
3277    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoCountry'));
3278};
3279
3280
3281/************************************************************************************* Phone ***************************************************************************************************/
3282
3283function sfRedNaoPhone(options,serverOptions)
3284{
3285    sfFormElementBase.call(this,options,serverOptions);
3286    this.Title="Phone";
3287    if(this.IsNew)
3288    {
3289        this.Options.ClassName="rednaophone";
3290        this.Options.Label="Phone";
3291        this.Options.AreaLabel="Area";
3292        this.Options.PhoneLabel="Phone";
3293        this.Options.Icon={ClassName:''};
3294        this.Options.CustomCSS='';
3295    }else{
3296        this.SetDefaultIfUndefined('Icon',{ClassName:''});
3297        this.SetDefaultIfUndefined('CustomCSS','');
3298    }
3299}
3300
3301sfRedNaoPhone.prototype=Object.create(sfFormElementBase.prototype);
3302
3303sfRedNaoPhone.prototype.CreateProperties=function()
3304{
3305    this.Properties.push(new PropertyContainer('general','General').AddProperties([
3306        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
3307        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'})
3308    ]));
3309
3310    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
3311        new SimpleTextProperty(this,this.Options,"AreaLabel","Area Placeholder",{ManipulatorType:'basic'}),
3312        new SimpleTextProperty(this,this.Options,"PhoneLabel","Phone Placeholder",{ManipulatorType:'basic'}),
3313        new IconProperty(this,this.Options,'Icon','Icon',{ManipulatorType:'basic'})
3314    ]));
3315
3316
3317    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
3318        new IdProperty(this,this.Options),
3319        new CustomCSSProperty(this,this.Options)
3320    ]));
3321
3322
3323};
3324
3325sfRedNaoPhone.prototype.GenerateInlineElement=function()
3326{
3327    var startOfInput='';
3328    var endOfInput='';
3329    if(this.Options.Icon.ClassName!='')
3330    {
3331        startOfInput='<div class="rednao-input-prepend input-group"><span class="redNaoPrepend input-group-addon prefix '+RedNaoEscapeHtml(this.Options.Icon.ClassName)+' "></span>';
3332        endOfInput='</div>';
3333    }
3334
3335    var areaLabel='';
3336    var phoneLabel='';
3337
3338    if(this.Options.AreaLabel!='')
3339        areaLabel='<br/><label class="redNaoHelper">'+RedNaoEscapeHtml(this.Options.AreaLabel)+'</label>';
3340    if(this.Options.PhoneLabel!='')
3341        phoneLabel='<br/><label class="redNaoHelper">'+RedNaoEscapeHtml(this.Options.PhoneLabel)+'</label>';
3342
3343    return '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label" >'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>'+
3344                '<div class="redNaoControls col-sm-9">'+
3345                    '<div class="form-inline">'+
3346                        '<div class="form-group col-sm-3">'+
3347                            startOfInput+'<input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_area" type="text" placeholder="'+RedNaoEscapeHtml(this.Options.AreaLabel)+'" class="form-control redNaoInputText redNaoTwoColumns redNaoInputArea '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'"/>'+endOfInput+ /*areaLabel+''+*/
3348                        '</div>    '+
3349                        '<div class="form-group col-sm-6">'+
3350                            '<input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_phone" type="text" placeholder="'+RedNaoEscapeHtml(this.Options.PhoneLabel)+'" class="form-control redNaoInputText redNaoTwoColumns redNaoInputPhone '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'">'+ /*phoneLabel+''+*/
3351                        '</div>'+
3352                    '</div>'+
3353               '<div>     '+
3354    '</div>';
3355};
3356
3357
3358sfRedNaoPhone.prototype.GetValueString=function()
3359{
3360    if(this.IsIgnored())
3361        return {area:'',phone:''};
3362    return {
3363        area:this.JQueryElement.find('.redNaoInputArea').val(),
3364        phone:this.JQueryElement.find('.redNaoInputPhone').val()
3365
3366    };
3367
3368
3369};
3370
3371sfRedNaoPhone.prototype.SetData=function(data)
3372{
3373    this.JQueryElement.find('.redNaoInputArea').val(data.area);
3374    this.JQueryElement.find('.redNaoInputPhone').val(data.phone);
3375};
3376
3377sfRedNaoPhone.prototype.GetValuePath=function()
3378{
3379    return 'formData.'+this.Id+'.area+" "'+'formData.'+this.Id+'.phone';
3380};
3381
3382
3383sfRedNaoPhone.prototype.IsValid=function()
3384{
3385
3386
3387    if(this.Options.IsRequired=='y'&&(this.JQueryElement.find('.redNaoInputArea').val()==""||this.JQueryElement.find('.redNaoInputPhone').val()==""))
3388    {
3389        var areaJQuery=this.JQueryElement.find('.redNaoInputArea');
3390        var phoneJQuery=this.JQueryElement.find('.redNaoInputPhone');
3391
3392        if(areaJQuery.val()=="")
3393            areaJQuery.parent().addClass('has-error');
3394
3395        if(phoneJQuery.val()=="")
3396            phoneJQuery.parent().addClass('has-error');
3397
3398        this.AddError('root',this.InvalidInputMessage);
3399    }
3400    else
3401        this.RemoveError('root');
3402
3403    return this.InternalIsValid();
3404};
3405
3406
3407//noinspection JSUnusedLocalSymbols
3408sfRedNaoPhone.prototype.GenerationCompleted=function(jQueryElement)
3409{
3410    var self=this;
3411    this.JQueryElement.find('.redNaoInputArea,.redNaoInputPhone').change(function(){
3412        self.FirePropertyChanged();
3413    });
3414
3415    this.JQueryElement.find('.redNaoInputArea,.redNaoInputPhone').ForceNumericOnly();
3416    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoInputArea'));
3417    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoInputPhone'));
3418
3419};
3420
3421
3422/************************************************************************************* Email Element ***************************************************************************************************/
3423
3424function sfRedNaoEmail(options,serverOptions)
3425{
3426    sfFormElementBase.call(this,options,serverOptions);
3427    this.Title="Text Input";
3428    if(this.IsNew)
3429    {
3430        this.Options.ClassName="rednaoemail";
3431        this.Options.Label="Email";
3432        this.Options.Placeholder="";
3433        this.Options.Icon={ClassName:''};
3434        this.Options.CustomCSS='';
3435        this.Options.Placeholder_Icon={ClassName:'',Orientation:''};
3436        this.Options.Value='';
3437        this.Options.ReadOnly='n';
3438    }else{
3439        this.SetDefaultIfUndefined('Icon',{ClassName:''});
3440        this.SetDefaultIfUndefined('ReadOnly','n');
3441        this.SetDefaultIfUndefined('CustomCSS','');
3442        this.SetDefaultIfUndefined('Placeholder_Icon',{ClassName:''});
3443        this.SetDefaultIfUndefined('Value','');
3444    }
3445}
3446
3447sfRedNaoEmail.prototype=Object.create(sfFormElementBase.prototype);
3448
3449sfRedNaoEmail.prototype.CreateProperties=function()
3450{
3451    this.Properties.push(new PropertyContainer('general','General').AddProperties([
3452        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
3453        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}),
3454        new SimpleTextProperty(this,this.Options,"Value","Default Value",{ManipulatorType:'basic',RefreshFormData:true}).SetEnableFormula()
3455    ]));
3456
3457    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
3458        new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic',IconOptions:{Type:'leftAndRight'}}),
3459        new IconProperty(this,this.Options,'Icon','Icon',{ManipulatorType:'basic'})
3460    ]));
3461
3462
3463    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
3464        new CheckBoxProperty(this,this.Options,"ReadOnly","Read Only",{ManipulatorType:'basic'}),
3465        new IdProperty(this,this.Options),
3466        new CustomCSSProperty(this,this.Options)
3467    ]));
3468
3469};
3470
3471sfRedNaoEmail.prototype.GenerateInlineElement=function()
3472{
3473    var startOfInput='';
3474    var endOfInput='';
3475    if(this.Options.Icon.ClassName!='')
3476    {
3477        startOfInput='<div class="rednao-input-prepend input-group"><span class="redNaoPrepend input-group-addon prefix '+RedNaoEscapeHtml(this.Options.Icon.ClassName)+' "></span>';
3478        endOfInput='</div>';
3479    }
3480
3481
3482    return '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label " >'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>'+
3483                '<div class="redNaoControls col-sm-9">'+
3484                    startOfInput+'<input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+'  value="'+RedNaoEscapeHtml(this.Options.Value)+'"  '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'" type="text" placeholder="'+RedNaoEscapeHtml(this.Options.Placeholder)+'" class="form-control redNaoInputText redNaoEmail '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'">'+endOfInput+
3485    '</div>';
3486};
3487
3488
3489sfRedNaoEmail.prototype.GetValueString=function()
3490{
3491    if(this.IsIgnored())
3492        return {value:''};
3493    return {value:this.JQueryElement.find('.redNaoEmail').val()};
3494};
3495
3496sfRedNaoEmail.prototype.SetData=function(data)
3497{
3498    this.JQueryElement.find('.redNaoEmail').val(data.value);
3499};
3500
3501
3502sfRedNaoEmail.prototype.GetValuePath=function()
3503{
3504    return 'formData.'+this.Id+'.value';
3505};
3506
3507
3508sfRedNaoEmail.prototype.IsValid=function()
3509{
3510    var email=this.JQueryElement.find('.redNaoEmail').val();
3511    if(email==""&&this.Options.IsRequired=='y')
3512    {
3513        this.JQueryElement.addClass('has-error');
3514        this.AddError('root',this.InvalidInputMessage);
3515    }else
3516        if(email!=''&&!this.EmailIsValid(email))
3517        {
3518            this.JQueryElement.addClass('has-error');
3519            this.AddError('root',this.InvalidInputMessage);
3520        }
3521        else
3522            this.RemoveError('root');
3523    return this.InternalIsValid();
3524};
3525
3526sfRedNaoEmail.prototype.EmailIsValid=function(email)
3527{
3528    var reg=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
3529    return reg.test(email);
3530};
3531
3532//noinspection JSUnusedLocalSymbols
3533sfRedNaoEmail.prototype.GenerationCompleted=function(jQueryElement)
3534{
3535    var self=this;
3536    this.JQueryElement.find('.redNaoEmail').change(function(){self.FirePropertyChanged();});
3537    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoEmail'));
3538    if(this.Options.Placeholder_Icon.ClassName!='')
3539    {
3540        this.LoadPlaceHolderIcon(jQueryElement.find('.redNaoInputText'),null,null,this.Options.Placeholder_Icon);
3541    }
3542
3543};
3544
3545
3546/************************************************************************************* Number Element ***************************************************************************************************/
3547
3548function sfRedNaoNumber(options,serverOptions)
3549{
3550    sfFormElementBase.call(this,options,serverOptions);
3551    this.Title="Text Input";
3552    if(this.IsNew)
3553    {
3554        this.Options.ClassName="rednaonumber";
3555        this.Options.Label="Number";
3556        this.Options.Placeholder="";
3557        this.Options.NumberOfDecimals=0;
3558        this.Options.MaximumValue="";
3559        this.Options.MinimumValue="";
3560        this.Options.Decimals=0;
3561        this.Options.Icon={ClassName:''};
3562        this.Options.CustomCSS='';
3563        this.Options.Width="";
3564        this.Options.Placeholder_Icon={ClassName:'',Orientation:''};
3565        this.Options.Value='';
3566        this.Options.ShowArrows='n';
3567        this.Options.ReadOnly='n';
3568    }else
3569    {
3570        this.SetDefaultIfUndefined("MaximumValue","");
3571        this.SetDefaultIfUndefined("MinimumValue","");
3572        this.SetDefaultIfUndefined('Width','');
3573        this.SetDefaultIfUndefined('Icon',{ClassName:''});
3574        this.SetDefaultIfUndefined('Decimals',0);
3575        this.SetDefaultIfUndefined('CustomCSS','');
3576        this.SetDefaultIfUndefined('Placeholder_Icon',{ClassName:''});
3577        this.SetDefaultIfUndefined('Value','');
3578        this.SetDefaultIfUndefined('ShowArrows','n');
3579        this.SetDefaultIfUndefined('ReadOnly','n');
3580
3581
3582    }
3583}
3584
3585sfRedNaoNumber.prototype=Object.create(sfFormElementBase.prototype);
3586
3587sfRedNaoNumber.prototype.CreateProperties=function()
3588{
3589    this.Properties.push(new PropertyContainer('general','General').AddProperties([
3590        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
3591        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}),
3592        new CheckBoxProperty(this,this.Options,"ShowArrows","Show Arrows",{ManipulatorType:'basic'}),
3593        new SimpleTextProperty(this,this.Options,"Value","Default Value",{ManipulatorType:'basic',RefreshFormData:true}).SetEnableFormula()
3594
3595    ]));
3596
3597    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
3598        new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic',IconOptions:{Type:'leftAndRight'}}),
3599        new SimpleNumericProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}),
3600        new SimpleNumericProperty(this,this.Options,"MinimumValue","Minimum Value",{ManipulatorType:'basic',Placeholder:'No Minimum'}).SetEnableFormula(),
3601        new SimpleNumericProperty(this,this.Options,"MaximumValue","Maximum Value",{ManipulatorType:'basic',Placeholder:'No Maximum'}).SetEnableFormula(),
3602        new SimpleNumericProperty(this,this.Options,"Decimals","Decimals",{ManipulatorType:'basic'}),
3603        new IconProperty(this,this.Options,'Icon','Icon',{ManipulatorType:'basic'})
3604    ]));
3605
3606
3607    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
3608        new CheckBoxProperty(this,this.Options,"ReadOnly","Read Only",{ManipulatorType:'basic'}),
3609        new IdProperty(this,this.Options),
3610        new CustomCSSProperty(this,this.Options)
3611    ]));
3612
3613
3614};
3615
3616sfRedNaoNumber.prototype.GenerateInlineElement=function()
3617{
3618    var additionalStyle='';
3619    if(!isNaN(parseFloat(this.Options.Width)))
3620        additionalStyle='width:'+this.Options.Width+'px'+' !important;';
3621    var inputClassNames='';
3622    if(this.Options.ShowArrows=='n')
3623    {
3624        inputClassNames='rnNumericWithOutArrows';
3625    }
3626    var startOfInput='';
3627    var endOfInput='';
3628    if(this.Options.Icon.ClassName!='')
3629    {
3630        startOfInput='<div class="rednao-input-prepend input-group"><span class="redNaoPrepend input-group-addon prefix '+RedNaoEscapeHtml(this.Options.Icon.ClassName)+' "></span>';
3631        endOfInput='</div>';
3632    }
3633
3634
3635
3636    return '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label" >'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>'+
3637                '<div class="redNaoControls col-sm-9">'+
3638                    startOfInput+'<input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  step="any" style="'+additionalStyle+'"  value="'+RedNaoEscapeHtml(this.Options.Value)+'" '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'" type="number" placeholder="'+this.Options.Placeholder+'" class="form-control redNaoInputText redNaoNumber '+inputClassNames+' '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'">'+endOfInput+
3639    '</div>';
3640};
3641
3642
3643sfRedNaoNumber.prototype.GetValueString=function()
3644{
3645    if(this.IsIgnored())
3646        return {value:''};
3647
3648    var number=parseFloat(this.JQueryElement.find('.redNaoNumber').val());
3649    if(isNaN(number))
3650        number=null;
3651    return {value:this.JQueryElement.find('.redNaoNumber').val(),numericalValue:number};
3652};
3653
3654sfRedNaoNumber.prototype.SetData=function(data)
3655{
3656    this.JQueryElement.find('.redNaoNumber').val(data.value);
3657};
3658
3659sfRedNaoNumber.prototype.GetValuePath=function()
3660{
3661    return 'formData.'+this.Id+'.value';
3662};
3663
3664
3665sfRedNaoNumber.prototype.IsValid=function()
3666{
3667    var number=this.JQueryElement.find('.redNaoNumber').val();
3668    if(number==""&&this.Options.IsRequired=='y')
3669    {
3670        this.JQueryElement.addClass('has-error');
3671        this.AddError('root',this.InvalidInputMessage);
3672    }
3673    else
3674        this.RemoveError('root');
3675
3676    return this.InternalIsValid();
3677};
3678
3679sfRedNaoNumber.prototype.InputIsValid=function()
3680{
3681    var inputText=this.JQueryElement.find('.redNaoNumber').val();
3682
3683    if(isNaN(inputText))
3684        return false;
3685
3686    var inputNumber=parseFloat(inputText);
3687    if(!isNaN(parseInt(this.Options.MaximumValue)))
3688    {
3689        var maximumValue=parseFloat(this.Options.MaximumValue);
3690        if(inputNumber>maximumValue)
3691            return false;
3692    }
3693
3694    if(!isNaN(parseInt(this.Options.MinimumValue)))
3695    {
3696        var minimumValue=parseFloat(this.Options.MinimumValue);
3697        if(inputNumber<minimumValue)
3698            return false;
3699    }
3700    return true;
3701};
3702
3703//noinspection JSUnusedLocalSymbols
3704sfRedNaoNumber.prototype.GenerationCompleted=function(jQueryElement)
3705{
3706    var self=this;
3707    this.JQueryElement.find('.redNaoNumber').change(function(){
3708        var decimals=self.Options.Decimals;
3709        var number=parseFloat(rnJQuery(this).val());
3710
3711        if(!isNaN(decimals)&&!isNaN(number)&&decimals>=0)
3712        {
3713            var formattedNumber=number.toFixed(decimals);
3714            if(formattedNumber!=number)
3715                rnJQuery('#'+self.Id+ ' .redNaoNumber').val(formattedNumber);
3716
3717        }
3718
3719
3720        if(!self.InputIsValid())
3721            rnJQuery('#'+self.Id+ ' .redNaoNumber').val('');
3722
3723        self.FirePropertyChanged();});
3724    this.JQueryElement.find('.redNaoNumber').ForceNumericOnly(this.Options.Decimals);
3725    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoNumber'));
3726    if(this.Options.Placeholder_Icon.ClassName!='')
3727    {
3728        this.LoadPlaceHolderIcon(jQueryElement.find('.redNaoInputText'),null,null,this.Options.Placeholder_Icon);
3729    }
3730};
3731
3732
3733/************************************************************************************* Recaptcha Element ***************************************************************************************************/
3734
3735function sfRedNaoCaptcha(options,serverOptions)
3736{
3737    sfFormElementBase.call(this,options,serverOptions);
3738    this.Title="captcha";
3739    if(this.IsNew)
3740    {
3741        this.Options.ClassName="rednaocaptcha";
3742        this.Options.Label="Captcha";
3743        this.Options.Theme="red";
3744        this.Options.CustomCSS='';
3745    }else{
3746        this.SetDefaultIfUndefined('CustomCSS','');
3747    }
3748
3749    this.Options.Id="captcha";
3750    this.Id="captcha";
3751}
3752
3753sfRedNaoCaptcha.prototype=Object.create(sfFormElementBase.prototype);
3754
3755sfRedNaoCaptcha.prototype.CreateProperties=function()
3756{
3757    this.Properties.push(new PropertyContainer('general','General').AddProperties([
3758        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'})
3759    ]));
3760
3761
3762
3763    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
3764        new CustomCSSProperty(this,this.Options)
3765    ]));
3766
3767};
3768
3769sfRedNaoCaptcha.prototype.GenerateInlineElement=function()
3770{
3771
3772    return '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label" >'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>\
3773                <div class="redNaoControls row redNaoCaptcha col-sm-9" id="captchaComponent">\
3774    </div>';
3775};
3776sfRedNaoCaptcha.prototype.StoresInformation=function()
3777{
3778    return false;
3779};
3780
3781
3782//noinspection JSUnusedLocalSymbols
3783sfRedNaoCaptcha.prototype.GenerationCompleted=function(jQueryElement)
3784{
3785    var url='';
3786    if(location.protocol == 'https:')
3787        url="https://www.google.com/recaptcha/api/js/recaptcha_ajax.js";
3788    else
3789        url="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js";
3790
3791    rnJQuery.getScript(url, function(){
3792        //noinspection JSUnresolvedVariable
3793        Recaptcha.create("6Lf2J-wSAAAAACCijq50oACQRuvrsmNt9DeUsE-7",
3794            'captchaComponent',
3795            {
3796                theme: "red"
3797            }
3798        );
3799    });
3800};
3801
3802/************************************************************************************* Html Element ***************************************************************************************************/
3803
3804function sfHtmlElement(options,serverOptions)
3805{
3806    sfFormElementBase.call(this,options,serverOptions);
3807    this.Title="HTML Element";
3808
3809    if(this.IsNew)
3810    {
3811        this.Options.ClassName="rednaohtml";
3812        this.Options.Label="Html";
3813        this.Options.HTML='';
3814        this.Options.CustomCSS='';
3815    }else{
3816        this.SetDefaultIfUndefined('CustomCSS','');
3817    }
3818}
3819sfHtmlElement.prototype=Object.create(sfFormElementBase.prototype);
3820
3821sfHtmlElement.prototype.CreateProperties=function()
3822{
3823
3824    this.Properties.push(new PropertyContainer('general','General').AddProperties([
3825        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
3826        new SimpleTextProperty(this,this.Options,"HTML","HTML",{ManipulatorType:'basic',RefreshFormData:true,MultipleLine:true})
3827    ]));
3828
3829
3830
3831    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
3832        new IdProperty(this,this.Options),
3833        new CustomCSSProperty(this,this.Options)
3834    ]));
3835
3836};
3837
3838sfHtmlElement.prototype.StoresInformation=function()
3839{
3840    return false;
3841};
3842
3843sfHtmlElement.prototype.GenerateInlineElement=function()
3844{
3845
3846    if(this.Options.Label!='')
3847    {
3848        return  '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label" for="textarea">'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>'+
3849            '<div class="redNaoControls col-sm-9">'+
3850            this.Options.HTML+
3851            '</div>';
3852    }else{
3853        return '<div class="redNaoControls col-sm-12">'+
3854        this.Options.HTML+
3855        '</div>'
3856    }
3857
3858
3859
3860};
3861
3862
3863/*************************************************************************************Searchable list ***************************************************************************************************/
3864
3865function sfSearchableList(options,serverOptions)
3866{
3867    sfFormElementBase.call(this,options,serverOptions);
3868    this.Title="Searchable List";
3869    this.DataToLoad=null;
3870    if(this.IsNew)
3871    {
3872        this.Options.Label="Searchable List";
3873        this.Options.ClassName="rednaosearchablelist";
3874        this.Options.DefaultText="Select a value";
3875        this.Options.Options=[{label:'Option 1',value:0,sel:'n',url:''},{label:'Option 2',value:0,sel:'n',url:''},{label:'Option',value:0,sel:'n',url:''}];
3876        this.Options.Multiple='n';
3877        this.Options.CustomCSS='';
3878        this.Options.NoMatchesFound='No matches found';
3879    }else{
3880        this.SetDefaultIfUndefined('CustomCSS','');
3881        this.SetDefaultIfUndefined('NoMatchesFound','No matches found');
3882    }
3883}
3884
3885sfSearchableList.prototype=Object.create(sfFormElementBase.prototype);
3886
3887sfSearchableList.prototype.CreateProperties=function()
3888{
3889    this.OptionsProperty=new ArrayProperty(this,this.Options,"Options","Options",{ManipulatorType:'basic',SelectorType:(this.Options.Multiple=='n'?'radio':'checkbox'),AllowImages:true});
3890    var self=this;
3891    this.Properties.push(new PropertyContainer('general','General').AddProperties([
3892        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
3893        new SimpleTextProperty(this,this.Options,"NoMatchesFound","No matches found label",{ManipulatorType:'basic'}),
3894        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}),
3895        new CheckBoxProperty(this,this.Options,"Multiple","Multiple Items",{ManipulatorType:'basic',ChangeCallBack:function(newValue,oldValue){
3896            if(newValue=='y')
3897                self.OptionsProperty.AdditionalInformation.SelectorType='checkbox';
3898            else
3899                self.OptionsProperty.AdditionalInformation.SelectorType='radio';
3900
3901            self.OptionsProperty.RefreshProperty();
3902        }}).SetTooltip("Define if multiple options can be selected or only one"),
3903        this.OptionsProperty
3904
3905    ]));
3906
3907    this.Properties.push(new PropertyContainer('icons','Icons and Tweaks').AddProperties([
3908        new SimpleTextProperty(this,this.Options,"DefaultText","Default text",{ManipulatorType:'basic'})
3909    ]));
3910
3911
3912    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
3913        new IdProperty(this,this.Options),
3914        new CustomCSSProperty(this,this.Options)
3915    ]));
3916
3917
3918
3919
3920
3921
3922};
3923
3924sfSearchableList.prototype.GenerateInlineElement=function()
3925{
3926    var additionalStyle='';
3927    if(!isNaN(parseFloat(this.Options.Width)))
3928        additionalStyle='width:'+this.Options.Width+'px'+' !important;';
3929
3930    var multiple='';
3931    if(this.Options.Multiple=='y')
3932        multiple='multiple="multiple"';
3933
3934    var html=  '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label">'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>\
3935        <div class="redNaoControls col-sm-9">\
3936        <select data-placeholder="'+RedNaoEscapeHtml(this.Options.DefaultText)+'" style="'+additionalStyle+'" name="'+this.GetPropertyName()+'" class="redNaoSelect" '+multiple+'>';
3937
3938    var selected='';
3939
3940
3941
3942    if(this.Options.Multiple=='n')
3943        html+='<option></option>';
3944
3945
3946    for(var i=0;i<this.Options.Options.length;i++)
3947    {
3948        if(this.Options.Options[i].sel=='y')
3949            selected='selected="selected"';
3950        else
3951            selected='';
3952
3953        var imgSrc='';
3954        if(typeof this.Options.Options[i].url!='undefined')
3955            imgSrc=rnJQuery.trim(this.Options.Options[i].url);
3956        html+='<option  data-imgsrc="'+imgSrc+'"   value="'+i+'" '+selected+'>'+RedNaoEscapeHtml(this.Options.Options[i].label)+'</opton>';
3957
3958        selected="";
3959
3960    }
3961    html+='</select></div>';
3962    return html;
3963};
3964
3965sfSearchableList.prototype.GetSelectedValuesFromNormalSelect=function()
3966{
3967    var selectedOptionIndexes=[];
3968    var $selectedOptions=this.GetRootContainer().find('.redNaoSelect option:selected');
3969
3970    for(var i=0;i<$selectedOptions.length;i++)
3971    {
3972        var optionIndex=parseInt(rnJQuery($selectedOptions[i]).val());
3973        if(!isNaN(optionIndex))
3974            selectedOptionIndexes.push(optionIndex);
3975    }
3976
3977    return selectedOptionIndexes;
3978};
3979
3980sfSearchableList.prototype.GetValueString=function()
3981{
3982    this.amount=0;
3983    if(this.IsIgnored())
3984        return {selectedValues:[]};
3985    var data={};
3986    data.selectedValues=[];
3987    var select2SelectedValues;
3988    if(this.Select2.hasClass('select2-offscreen'))
3989    {
3990        select2SelectedValues = this.Select2.select2('val');
3991        if(select2SelectedValues==null)
3992            select2SelectedValues=[];
3993        if(!rnJQuery.isArray(select2SelectedValues))
3994        {
3995            var aux=select2SelectedValues;
3996            select2SelectedValues=[];
3997            if(rnJQuery.trim(aux)!="")
3998                select2SelectedValues.push(aux);
3999        }
4000    }
4001    else
4002        select2SelectedValues=this.GetSelectedValuesFromNormalSelect();
4003
4004
4005
4006    for(var i=0;i<select2SelectedValues.length;i++)
4007    {
4008        var option=this.Options.Options[select2SelectedValues[i]];
4009        this.amount=parseFloat(option.value);
4010        if(isNaN(this.amount))
4011            this.amount=0;
4012
4013        data.selectedValues.push(
4014            {
4015                value:option.label,
4016                amount:this.amount,
4017                label:rnJQuery.trim(option.label)
4018            }
4019        );
4020    }
4021
4022    return data;
4023};
4024
4025sfSearchableList.prototype.SetData=function(data)
4026{
4027    var values=[];
4028
4029
4030    for(var i=0;i<data.selectedValues.length;i++)
4031    {
4032        for(var t=0;t<this.Options.Options.length;t++)
4033        {
4034            if(data.selectedValues[i].value==rnJQuery.trim(this.Options.Options[t].label))
4035            {
4036                values.push(t);
4037                break;
4038            }
4039
4040        }
4041    }
4042    if(typeof this.Select2.select2=='undefined')
4043        this.DataToLoad=values;
4044    else
4045        this.Select2.select2('val',values);
4046};
4047
4048sfSearchableList.prototype.GetDataStore=function()
4049{
4050    return new SmartFormMultipleItemsDataStore();
4051};
4052
4053
4054
4055
4056sfSearchableList.prototype.GetValuePath=function()
4057{
4058    return 'RedNaoGetValueFromArray(formData.'+this.Id+'.selectedValues)';
4059};
4060
4061
4062sfSearchableList.prototype.IsValid=function()
4063{
4064    if(this.Options.IsRequired=='y'&&(this.GetValueString().selectedValues.length==0))
4065    {
4066        this.JQueryElement.addClass('has-error');
4067        this.AddError('root',this.InvalidInputMessage);
4068    }
4069    else
4070        this.RemoveError('root');
4071    return this.InternalIsValid();
4072};
4073
4074
4075//noinspection JSUnusedLocalSymbols
4076sfSearchableList.prototype.GenerationCompleted=function(jQueryElement)
4077{
4078    var self=this;
4079    this.Select2=this.JQueryElement.find('.redNaoSelect');
4080    rnJQuery.RNLoadLibrary([smartFormsPath+'js/utilities/select2/select2.js'],[smartFormsPath+'js/utilities/select2/select2.css'],function(){self.LoadSelect2()});
4081    this.JQueryElement.find('.redNaoSelect').change(function(){self.FirePropertyChanged();});
4082};
4083
4084sfSearchableList.prototype.LoadSelect2=function()
4085{
4086    var me=this;
4087    this.Select2.select2({
4088        width:'100%',
4089        formatResult:sfFormatResult,
4090        formatSelection:sfFormatSelection,
4091        formatNoMatches:function (params) {
4092            return me.Options.NoMatchesFound;
4093        }
4094
4095    });
4096
4097    if(this.DataToLoad!=null)
4098    {
4099        this.Select2.select2('val', this.DataToLoad);
4100        this.DataToLoad=null;
4101        this.FirePropertyChanged();
4102    }
4103
4104};
4105
4106function sfFormatResult(state)
4107{
4108    var imageSrc=rnJQuery(state.element).data('imgsrc').toString();
4109    if(imageSrc!='')
4110        return '<img style="vertical-align:middle" src="'+imageSrc+'"/><span style="margin-left:2px;vertical-align:middle">'+RedNaoEscapeHtml(state.text)+'</span>';
4111    return '<span>'+RedNaoEscapeHtml(state.text)+'</span>';
4112}
4113
4114function sfFormatSelection(state)
4115{
4116    var imageSrc=rnJQuery(state.element).data('imgsrc').toString();
4117    if(imageSrc!='')
4118        return '<img style="vertical-align:middle;max-height:19px;display:inline;" src="'+imageSrc+'"/><span style="margin-left:2px;vertical-align:middle">'+RedNaoEscapeHtml(state.text)+'</span>';
4119    return '<span>'+RedNaoEscapeHtml(state.text)+'</span>';
4120}
4121
4122/*
4123function SmartFormBasicDataStore(defaultValue)
4124{
4125    this.defaultValue='value';
4126    if(typeof defaultValue!=null)
4127        this.defaultValue=defaultValue;
4128}
4129
4130SmartFormBasicDataStore.prototype.toString=function(){
4131    return this[this.defaultValue];
4132};
4133
4134
4135
4136
4137
4138function SmartFormMultipleItemsDataStore()
4139{
4140    SmartFormBasicDataStore.call(this,'');
4141}
4142SmartFormMultipleItemsDataStore.prototype=Object.create(SmartFormBasicDataStore.prototype);
4143
4144SmartFormMultipleItemsDataStore.prototype.toString=function(){
4145    return RedNaoGetValueFromArray(this.selectedValues);
4146};
4147
4148SmartFormMultipleItemsDataStore.prototype.IsSelected=function(label){
4149    for(var i=0;i<this.selectedValues.length;i++)
4150    {
4151        if(this.selectedValues[i].label==label)
4152            return true;
4153    }
4154
4155    return false;
4156
4157};
4158*/
4159
4160
4161
4162
4163/************************************************************************************* Survey Table***************************************************************************************************/
4164
4165function sfSurveyTable(options,serverOptions)
4166{
4167    sfFormElementBase.call(this,options,serverOptions);
4168    this.Title="Survey Table";
4169    if(this.IsNew)
4170    {
4171        this.Options.ClassName="rednaosurveytable";
4172        this.Options.Questions=[];
4173        this.Options.Label="How satisfied are you with the following items";
4174        this.Options.Columns=[{'label':'Very Satisfied',value:0},{'label':'Satisfied',value:0},{'label':'Neutral',value:0},{'label':'Unsatisfied',value:0},{'label':'Very Unsatisfied',value:0}];
4175        this.Options.Rows=[{'label':'Support',value:0},{'label':'Price',value:0},{'label':'Quality',value:0},{'label':'Variety',value:0}];
4176        this.Options.CustomCSS="";
4177        this.Options.IsRequired='n';
4178    }
4179}
4180
4181sfSurveyTable.prototype=Object.create(sfFormElementBase.prototype);
4182
4183sfSurveyTable.prototype.CreateProperties=function()
4184{
4185    this.Properties.push(new PropertyContainer('general','General').AddProperties([
4186        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
4187        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}),
4188        new ArrayProperty(this,this.Options,"Columns","Columns",{ManipulatorType:'basic',SelectorType:'radio'}),
4189        new ArrayProperty(this,this.Options,"Rows","Rows",{ManipulatorType:'basic',SelectorType:'radio'})
4190    ]));
4191
4192
4193
4194    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
4195        new IdProperty(this,this.Options),
4196        new CustomCSSProperty(this,this.Options)
4197    ]));
4198
4199
4200};
4201
4202sfSurveyTable.prototype.GenerateInlineElement=function()
4203{
4204
4205    var table= '<div class="rednao_label_container col-sm-12"><label class="rednao_control_label" >'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>';
4206    table+='<div class="redNaoControls"><table class="table table-striped"> <thead> <tr> <th  class="redNaoSurveyColumn"></th>';
4207    for(var i=0;i<this.Options.Columns.length;i++)
4208    {
4209        table+='<th class="redNaoSurveyColumn">'+this.Options.Columns[i].label+'</th>';
4210    }
4211    table+='</tr> </thead> <tbody>';
4212
4213    for(i=0;i<this.Options.Rows.length;i++)
4214    {
4215        var id=this.Id+'_'+i;
4216        table+='<tr class="redNaoSurveyRow"> <th class="redNaoSurveyQuestion">'+RedNaoEscapeHtml(this.Options.Rows[i].label)+'</th>';
4217        for(var t=0;t<this.Options.Columns.length;t++)
4218        {
4219            table+='<td><input  '+(this.Options.IsRequired=='y'?'aria-required="true"':"")+'  type="radio" class="redNaoSurveyRadio" name="'+id+'"/></td>';
4220        }
4221
4222        table+='</tr>';
4223    }
4224
4225    table+="</tbody></div></table>";
4226
4227
4228    return table;
4229};
4230
4231
4232sfSurveyTable.prototype.GetValueString=function()
4233{
4234    var result={values:[]};
4235    result.label=this.Options.Label;
4236    if(this.IsIgnored())
4237        return result;
4238
4239    var $rows=this.JQueryElement.find('.redNaoSurveyRow');
4240    var total=0;
4241    for(var i=0;i<$rows.length;i++)
4242    {
4243        var $processingRow=rnJQuery($rows[i]);
4244        var selectedItem=$processingRow.find('input[type="radio"]:checked');
4245        var index=selectedItem.parent().index()-1;
4246        if(selectedItem.length==0)
4247            continue;
4248        total+=parseFloat(this.Options.Columns[index].value);
4249        result.values.push({
4250            QuestionLabel:$processingRow.find('.redNaoSurveyQuestion').text(),
4251            ValueLabel:this.Options.Columns[index].label,
4252            ValueAmount:this.Options.Columns[index].value
4253        });
4254    }
4255    result.value=total;
4256
4257    return result;
4258};
4259
4260sfSurveyTable.prototype.SetData=function(data)
4261{
4262    for(var i=0;i<data.values.length;i++)
4263    {
4264        var columnIndex=-1;
4265        for(var t=0;t<this.Options.Columns.length;t++)
4266            if(this.Options.Columns[t].label==data.values[i].ValueLabel)
4267                columnIndex=t;
4268
4269        var rowIndex=-1;
4270        for(var t=0;t<this.Options.Rows.length;t++)
4271            if(this.Options.Rows[t].label==data.values[i].QuestionLabel)
4272                rowIndex=t;
4273
4274        if(rowIndex>=0&&columnIndex>=0)
4275            this.JQueryElement.find('.redNaoSurveyRow').eq(rowIndex).find('.redNaoSurveyRadio').eq(columnIndex).attr('checked','checked');
4276    }
4277
4278
4279};
4280
4281sfSurveyTable.prototype.GetValuePath=function()
4282{
4283    return 'formData.'+this.Id+'.value';
4284};
4285
4286
4287sfSurveyTable.prototype.IsValid=function()
4288{
4289    var isValid=true;
4290    if(this.Options.IsRequired=='y')
4291    {
4292        var $rows=this.JQueryElement.find('.redNaoSurveyRow');
4293        for(var i=0;i<$rows.length;i++)
4294        {
4295            if(rnJQuery($rows[i]).find('input[type="radio"]:checked').length==0)
4296            {
4297                isValid=false;
4298                rnJQuery($rows[i]).addClass('redNaoInvalid');
4299            }
4300        }
4301    }
4302
4303    if(!isValid)
4304        this.AddError('root',this.InvalidInputMessage);
4305    else
4306        this.RemoveError('root');
4307    return this.InternalIsValid();
4308};
4309
4310//noinspection JSUnusedLocalSymbols
4311sfSurveyTable.prototype.GenerationCompleted=function(jQueryElement)
4312{
4313    var self=this;
4314    this.JQueryElement.find( '.redNaoSurveyRadio').change(function(){self.FirePropertyChanged();});
4315    this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoSurveyRadio'));
4316
4317
4318};
4319
4320
4321
4322/************************************************************************************* Rating***************************************************************************************************/
4323
4324function sfRating(options,serverOptions)
4325{
4326    sfFormElementBase.call(this,options,serverOptions);
4327    this.Title="Rating";
4328    this.LibraryLoaded=false;
4329    if(this.IsNew)
4330    {
4331        this.Options.ClassName="rednaorating";
4332        this.Options.Label="Rating";
4333        this.Options.Value="5";
4334        this.Options.CustomCSS="";
4335        this.Options.IsRequired='n';
4336    }
4337}
4338
4339sfRating.prototype=Object.create(sfFormElementBase.prototype);
4340
4341sfRating.prototype.CreateProperties=function()
4342{
4343    this.Properties.push(new PropertyContainer('general','General').AddProperties([
4344        new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}),
4345        new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}),
4346        new SimpleTextProperty(this,this.Options,"Value","Default Value",{ManipulatorType:'basic',RefreshFormData:true}).SetEnableFormula()
4347    ]));
4348
4349
4350
4351
4352    this.Properties.push(new PropertyContainer('advanced','Advanced').AddProperties([
4353        new IdProperty(this,this.Options),
4354        new CustomCSSProperty(this,this.Options)
4355    ]));
4356
4357};
4358
4359sfRating.prototype.GenerateInlineElement=function()
4360{
4361
4362    var rating= '<div class="rednao_label_container col-sm-3"><label class="rednao_control_label" >'+RedNaoEscapeHtml(this.Options.Label)+'</label></div>';
4363    rating+='<div class="redNaoControls col-sm-9"><div class="sfRating"></div></div>';
4364
4365
4366    return rating;
4367};
4368
4369
4370sfRating.prototype.GetValueString=function()
4371{
4372    if(this.IsIgnored())
4373        return {value:''};
4374
4375    if(!this.LibraryLoaded)
4376        return {value:this.Options.Value};
4377    return {value:this.JQueryElement.find('.sfRating').rateYo('rating')};
4378};
4379
4380sfRating.prototype.SetData=function(data)
4381{
4382    if(this.LibraryLoaded)
4383        this.JQueryElement.find('.sfRating').rateYo('rating',data.value);
4384    else
4385        this.Options.Value=data.value;
4386};
4387
4388sfRating.prototype.GetValuePath=function()
4389{
4390    return 'formData.'+this.Id+'.value';
4391};
4392
4393
4394sfRating.prototype.IsValid=function()
4395{
4396    var rating=this.JQueryElement.find('.sfRating').rateYo('rating');
4397    var isValid=true;
4398
4399
4400    if(this.Options.IsRequired=='y')
4401    {
4402        if(rating==0||rating=="")
4403        {
4404            isValid = false;
4405        }
4406    }
4407
4408    if(!isValid)
4409    {
4410        this.AddError('root', this.InvalidInputMessage);
4411        this.JQueryElement.find('svg').attr('stroke','#a94442');
4412        this.JQueryElement.find('svg').attr('stroke-width','20');
4413    }
4414    else
4415    {
4416        this.RemoveError('root');
4417        this.JQueryElement.find('svg').removeAttr('stroke');
4418        this.JQueryElement.find('svg').removeAttr('stroke-width');
4419    }
4420    return this.InternalIsValid();
4421};
4422
4423//noinspection JSUnusedLocalSymbols
4424sfRating.prototype.GenerationCompleted=function(jQueryElement)
4425{
4426    var self=this;
4427    rnJQuery.RNLoadLibrary(
4428        [smartFormsPath+'js/utilities/rateyo/jquery.rateyo.min.js'],[smartFormsPath+'js/utilities/rateyo/jquery.rateyo.min.css'],function(){
4429            self.LibraryLoaded=true;
4430            self.JQueryElement.find('.sfRating').rateYo(
4431                {
4432                    rating:self.Options.Value,
4433                    halfStar:true
4434
4435                }
4436            );
4437
4438            self.JQueryElement.find('.sfRating').on('rateyo.set',function(e,data){
4439                self.FirePropertyChanged();
4440            });
4441        });
4442
4443    //this.RegisterForFocusEvent(this.JQueryElement.find( '.redNaoSurveyRadio'));
4444
4445
4446};

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.