PluginProbe
Smart Forms – when you need more than just a contact form / 0.6
Smart Forms – when you need more than just a contact form v0.6
trunk 0.5 0.5.5 0.6 0.7 0.8 0.8.5 0.9.1
smart-forms / js / formBuilder / formelements.js

formelements.js in Smart Forms – when you need more than just a contact form 0.6, at js/formBuilder/formelements.js

2,234 lines 77.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2
3
4 /************************************************************************************* Formula Methods ***************************************************************************************************/
5
6 function RedNaoGetValueFromArray(array)
7 {
8 var value=0;
9
10 for(var i=0;i<array.length;i++)
11 {
12 var aux=parseFloat(array[i].amount);
13 if(isNaN(aux))
14 aux=0;
15 value+=aux;
16 }
17
18 return value;
19 }
20
21
22
23
24
25 /************************************************************************************* End or formula methods ***************************************************************************************************/
26
27
28
29
30 function RedNaoFormElementEscape(property)
31 {
32 return property.replace(' ','_');
33 }
34
35 function RedNaoCreateFormElementByName(elementName,options)
36 {
37 if(elementName=='rednaotextinput')
38 return new TextInputElement(options);
39 if(elementName=='rednaodonationamount')
40 return new DonationAmountElement(options);
41 if(elementName=='rednaoprependedtext')
42 return new PrependTexElement(options);
43 if(elementName=='rednaoappendedtext')
44 return new AppendedTexElement(options);
45 if(elementName=='rednaoprependedcheckbox')
46 return new PrependCheckBoxElement(options);
47 if(elementName=='rednaoappendedcheckbox')
48 return new AppendCheckBoxElement(options);
49 if(elementName=='rednaobuttondropdown')
50 return 'rednaobuttondropdown';
51 if(elementName=='tabradioscheckboxes')
52 return 'tabradioscheckboxes';
53 if(elementName=='rednaomultiplecheckboxes')
54 return new MultipleCheckBoxElement(options);
55 if(elementName=='rednaoselectbasic')
56 return new SelectBasicElement(options);
57
58 if(elementName=='rednaofilebutton')
59 return 'rednaofilebutton';
60 if(elementName=='rednaosinglebutton')
61 return 'rednaosinglebutton';
62 if(elementName=='rednaodoublebutton')
63 return 'rednaodoublebutton';
64 if(elementName=='rednaotitle')
65 return new TitleElement(options);
66 if(elementName=='rednaotextarea')
67 return new TextAreaElement(options);
68 if(elementName=='rednaomultipleradios')
69 return new MultipleRadioElement(options);
70 if(elementName=='rednaodonationbutton')
71 return new DonationButtonElement(options);
72 if(elementName=='rednaodonationrecurrence')
73 return new RecurrenceElement(options);
74 if(elementName=='rednaosubmissionbutton')
75 return new RedNaoSubmissionButton(options);
76
77 if(elementName=='rednaodatepicker')
78 return new RedNaoDatePicker(options);
79 if(elementName=='rednaoname')
80 return new RedNaoName(options);
81 if(elementName=='rednaoaddress')
82 return new RedNaoAddress(options);
83 if(elementName=='rednaophone')
84 return new RedNaoPhone(options);
85 if(elementName=='rednaoemail')
86 return new RedNaoEmail(options);
87 if(elementName=='rednaonumber')
88 return new RedNaoNumber(options);
89 if(elementName=='rednaocaptcha')
90 return new RedNaoCaptcha(options);
91
92
93 }
94
95
96
97 function RedNaoCreateFormElementByOptions(options)
98 {
99 var element=RedNaoCreateFormElementByName(options.ClassName,options);
100 return element;
101
102 }
103
104
105
106 /************************************************************************************* Base Class ***************************************************************************************************/
107 function FormElementBase(options)
108 {
109 if(options==null)
110 {
111 this.Options=new Object();
112 this.Options.ClassName="";
113 this.Options.IsRequired='n';
114 this.Options.Formulas={};
115
116 FormElementBase.IdCounter++;
117 this.Id='rnField'+FormElementBase.IdCounter;
118 while(!SmartFormsFieldIsAvailable(this.Id))
119 {
120 FormElementBase.IdCounter++;
121 this.Id='rnField'+FormElementBase.IdCounter;
122 }
123
124 this.Options.Id=this.Id;
125 this.IsNew=true;
126 this.GenerateDefaultStyle();
127 }
128 else
129 {
130 this.Id=options.Id;
131 this.IsNew=false;
132 if(typeof options.IsRequired=='undefined')
133 options.IsRequired='n';
134 this.Options=options;
135 if(typeof this.Options.Formulas=='undefined')
136 this.Options.Formulas={};
137 else{
138 if(typeof RedNaoFormulaManagerVar!='undefined')
139 for(var property in this.Options.Formulas)
140 {
141 RedNaoFormulaManagerVar.AddFormula(this,this.Options.Formulas[property]);
142 }
143 }
144
145
146 }
147 this.Properties=null;
148 this.amount=0;
149 }
150
151 FormElementBase.IdCounter=0;
152
153 FormElementBase.prototype.FirePropertyChanged=function(val){
154
155 RedNaoEventManager.Publish('formPropertyChanged',{FieldName:this.Id, Value:val});
156
157 }
158
159 FormElementBase.prototype.SetDefaultIfUndefined=function(propertyName,defaultValue)
160 {
161 if(typeof this.Options[propertyName]=='undefined')
162 this.Options[propertyName]=defaultValue;
163 }
164
165
166 FormElementBase.prototype.GenerateDefaultStyle=function()
167 {
168 }
169
170 FormElementBase.prototype.RefreshElement=function()
171 {
172 var element=rnJQuery("#"+this.Id);
173 var labelWidth=element.find('.rednao_label_container').width();
174 var controlWidth=element.find('.redNaoControls').width();
175 element.find(".rednao_label_container, .redNaoControls").remove();
176 element.find(".redNaoOneColumn").remove();
177 element.append(this.GenerateInlineElement());
178 this.GenerationCompleted();
179 element.find('.rednao_label_container').width(labelWidth);
180 element.find('.redNaoControls').width(controlWidth);
181 return element;
182 }
183 FormElementBase.prototype.GenerateHtml=function(jqueryElement)
184 {
185 var newElement=rnJQuery('<div class="rednao-control-group '+this.Options.ClassName+'" id="'+this.Id+'" style="margin-bottom:15px;clear:both;">'+this.GenerateInlineElement()+'</div>')
186 jqueryElement.replaceWith(newElement );
187 this.GenerationCompleted();
188 return newElement;
189
190 }
191
192 FormElementBase.prototype.AppendElementToContainer=function(jqueryElement)
193 {
194 this.JQueryElement=rnJQuery( '<div class="rednao-control-group '+this.Options.ClassName+'" id="'+this.Id+'" style="margin-bottom:15px;">'+this.GenerateInlineElement()+'</div>');
195 jqueryElement.append(this.JQueryElement);
196 this.GenerationCompleted();
197
198 }
199
200 FormElementBase.prototype.StoresInformation=function()
201 {
202 return true;
203 }
204
205
206 FormElementBase.prototype.CreateProperties=function()
207 {
208 throw 'Abstract method';
209 }
210
211 FormElementBase.prototype.GenerateInlineElement=function()
212 {
213 throw 'Abstract method';
214 }
215
216 FormElementBase.prototype.GetProperties=function()
217 {
218 if(this.Properties==null)
219 {
220 this.Properties=new Array();
221 this.CreateProperties();
222 }
223
224 return this.Properties;
225 }
226
227
228 FormElementBase.prototype.UpdateProperties=function()
229 {
230 if(this.Properties!=null)
231 {
232 for(var i=0;i<this.Properties.length;i++)
233 {
234 this.Properties[i].UpdateProperty();
235 }
236 }
237 }
238
239 FormElementBase.prototype.GetPropertyName=function()
240 {
241 return RedNaoFormElementEscape(this.Options.Label);
242 }
243
244
245 FormElementBase.prototype.GeneratePropertiesHtml=function(jQueryObject)
246 {
247 var properties=this.GetProperties();
248
249 for(var i=0;i<properties.length;i++)
250 {
251 properties[i].CreateProperty(jQueryObject);
252 }
253 }
254
255
256 FormElementBase.prototype.GetValueString=function()
257 {
258
259 }
260
261 FormElementBase.prototype.GenerationCompleted=function()
262 {
263
264 }
265
266 FormElementBase.prototype.IsValid=function()
267 {
268 return true;
269 }
270
271 FormElementBase.prototype.Clone=function()
272 {
273 var newObject= jQuery.extend(true, {}, this);
274 FormElementBase.IdCounter++;
275 newObject.Id='rnField'+FormElementBase.IdCounter;
276
277 newObject.Properties=[];
278 newObject.CreateProperties();
279
280 return newObject;
281 }
282
283 FormElementBase.prototype.GetValuePath=function()
284 {
285 return '';
286 }
287
288 /************************************************************************************* Title Element ***************************************************************************************************/
289
290 function TitleElement(options)
291 {
292 FormElementBase.call(this,options);
293
294
295
296 this.Title="Title";
297
298 if(this.IsNew)
299 {
300 this.Options.ClassName="rednaotitle";
301 this.Options.Title="Title";
302 }
303 }
304
305 TitleElement.prototype=Object.create(FormElementBase.prototype);
306
307 TitleElement.prototype.CreateProperties=function()
308 {
309
310 this.Properties.push(new SimpleTextProperty(this,this.Options,"Title","Title",{ManipulatorType:'basic'}));
311 }
312
313 TitleElement.prototype.GenerateInlineElement=function()
314 {
315 return '<legend class="redNaoLegend redNaoOneColumn">'+this.Options.Title+'</legend>';
316 }
317
318
319
320
321 TitleElement.prototype.GetValueString=function()
322 {
323 return '';
324
325 }
326
327 TitleElement.prototype.StoresInformation=function()
328 {
329 return false;
330 }
331
332 /************************************************************************************* Text Element ***************************************************************************************************/
333
334 function TextInputElement(options)
335 {
336 FormElementBase.call(this,options);
337 this.Title="Text Input";
338 if(this.IsNew)
339 {
340 this.Options.ClassName="rednaotextinput";
341 this.Options.Label="Text Input";
342 this.Options.Placeholder="Placeholder";
343 this.Options.Value="";
344 this.Options.ReadOnly='n'
345 this.Options.Width="";
346 }else{
347 this.SetDefaultIfUndefined('Value','');
348 this.SetDefaultIfUndefined('ReadOnly','n');
349 this.SetDefaultIfUndefined('Width','');
350 }
351
352
353
354
355
356 }
357
358 TextInputElement.prototype=Object.create(FormElementBase.prototype);
359
360 TextInputElement.prototype.CreateProperties=function()
361 {
362 this.Properties.push(new IdProperty(this,this.Options));
363 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
364 this.Properties.push(new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic'}));
365 this.Properties.push(new SimpleTextProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}));
366 this.Properties.push(new SimpleTextProperty(this,this.Options,"Value","Value",{ManipulatorType:'basic',RefreshFormData:true}));
367 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
368 this.Properties.push(new CheckBoxProperty(this,this.Options,"ReadOnly","Read Only",{ManipulatorType:'basic'}));
369
370 }
371
372 TextInputElement.prototype.GenerateInlineElement=function()
373 {
374 var additionalStyle='';
375 if(!isNaN(parseFloat(this.Options.Width)))
376 additionalStyle='width:'+this.Options.Width+'px'+' !important;'
377
378 return '<div class="rednao_label_container"><label class="rednao_control_label" >'+this.Options.Label+'</label></div>\
379 <div class="redNaoControls">\
380 <input style="'+additionalStyle+'" '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'" type="text" placeholder="'+this.Options.Placeholder+'" class="redNaoInputText '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'" value="'+this.Options.Value+'">'
381 '</div>';
382 }
383
384
385 TextInputElement.prototype.GetValueString=function()
386 {
387 return {value:rnJQuery('#'+this.Id+ ' .redNaoInputText').val()};
388 }
389
390 TextInputElement.prototype.GetValuePath=function()
391 {
392 return 'formData.'+this.Id+'.value';
393 }
394
395
396 TextInputElement.prototype.IsValid=function()
397 {
398 if(rnJQuery('#'+this.Id+ ' .redNaoInputText').val()==""&&this.Options.IsRequired=='y')
399 {
400 rnJQuery('#'+this.Id).find('.redNaoInputText,.redNaoRealCheckBox,.redNaoInputRadio,.redNaoInputCheckBox,.redNaoSelect,.redNaoTextArea').addClass('redNaoInvalid');
401 return false;
402 }
403
404 return true;
405 }
406
407 TextInputElement.prototype.GenerationCompleted=function()
408 {
409 var self=this;
410 rnJQuery('#'+this.Id+ ' .redNaoInputText').change(function(){self.FirePropertyChanged(self.GetValueString());});
411 }
412
413 /************************************************************************************* Donation Amount ***************************************************************************************************/
414
415 function DonationAmountElement(options)
416 {
417 FormElementBase.call(this,options);
418 this.Title="Donation Amount";
419
420 if(this.IsNew)
421 {
422 this.Options.ClassName="rednaodonationamount";
423 this.Options.Label="Donation Amount";
424 this.Options.Placeholder="Amount";
425 this.Options.DefaultValue=0;
426 this.Options.Disabled='n';
427 }
428
429 if(typeof this.Options.DefaultValue=='undefined')
430 this.Options.DefaultValue=0;
431
432
433
434
435
436 }
437
438 DonationAmountElement.prototype=Object.create(FormElementBase.prototype);
439
440 DonationAmountElement.prototype.CreateProperties=function()
441 {
442 this.Properties.push(new IdProperty(this,this.Options));
443 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
444 this.Properties.push(new SimpleTextProperty(this,this.Options,"DefaultValue","Default Value",{ManipulatorType:'basic'}));
445
446 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
447 this.Properties.push(new CheckBoxProperty(this,this.Options,"Disabled","Read Only",{ManipulatorType:'basic'}));
448
449
450
451 }
452
453 DonationAmountElement.prototype.GenerateInlineElement=function()
454 {
455
456 return '<div class="rednao_label_container"><label class="rednao_control_label" >'+this.Options.Label+'</label></div>\
457 <div class="redNaoControls">\
458 <input type="text" placeholder="'+this.Options.Placeholder+'" class="redNaoInputText" value="'+this.Options.DefaultValue+'" >'+
459 '</div>';
460 }
461
462
463
464 DonationAmountElement.prototype.GetValueString=function()
465 {
466 try
467 {
468 this.amount=parseFloat(rnJQuery('#'+this.Id+ ' .redNaoInputText').val());
469 }catch(exception)
470 {
471
472 }
473
474 return encodeURI(this.Options.Label)+"="+encodeURI(rnJQuery('#'+this.Id+ ' .redNaoInputText').val());
475 }
476
477 DonationAmountElement.prototype.GenerationCompleted=function()
478 {
479 if(this.Options.Disabled=='y')
480 {
481 rnJQuery('#'+this.Id).find('.redNaoInputText').attr('readonly','readonly').css('background-color','#eeeeee');
482 }
483 }
484
485 DonationAmountElement.prototype.IsValid=function()
486 {
487 try{
488 var number=parseFloat(rnJQuery('#'+this.Id+ ' .redNaoInputText').val());
489 return number>0;
490 }catch(exception)
491 {
492 return false;
493 }
494 }
495
496 /************************************************************************************* Prepend Text Element ***************************************************************************************************/
497
498 function PrependTexElement(options)
499 {
500 FormElementBase.call(this,options);
501 this.Title="Prepend Text";
502
503 if(this.IsNew)
504 {
505 this.Options.Label="Prepend Text";
506 this.Options.ClassName="rednaoprependedtext";
507 this.Options.Placeholder="Placeholder";
508 this.Options.Prepend="Prepend";
509 this.Options.Value='';
510 this.Options.Checked='y';
511 this.Options.Width='';
512 }else{
513 this.SetDefaultIfUndefined('Value','');
514 this.SetDefaultIfUndefined('Width','');
515
516 }
517
518
519
520 }
521
522 PrependTexElement.prototype=Object.create(FormElementBase.prototype);
523
524 PrependTexElement.prototype.CreateProperties=function()
525 {
526 this.Properties.push(new IdProperty(this,this.Options));
527 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
528 this.Properties.push(new SimpleTextProperty(this,this.Options,"Prepend","Prepend",{ManipulatorType:'basic'}));
529 this.Properties.push(new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic'}));
530 this.Properties.push(new SimpleTextProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}));
531 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
532 this.Properties.push(new SimpleTextProperty(this,this.Options,"Value","Value",{ManipulatorType:'basic',RefreshFormData:true}));
533
534 }
535
536 PrependTexElement.prototype.GenerateInlineElement=function()
537 {
538 var additionalStyle='';
539 if(!isNaN(parseFloat(this.Options.Width)))
540 additionalStyle='width:'+this.Options.Width+'px'+' !important;'
541
542
543 return '<div class="rednao_label_container"><label class="rednao_control_label" for="prependedtext">'+this.Options.Label+'</label></div>\
544 <div class="redNaoControls">\
545 <div class="rednao-input-prepend">\
546 <span class="redNaoPrepend">'+this.Options.Prepend+'</span>\
547 <input style="'+additionalStyle+'" id="prependedtext" name="prependedtext" class="redNaoInputText" placeholder="'+this.Options.Placeholder+'" type="text" value="'+this.Options.Value+'">\
548 </div>\
549 </div>';
550 }
551
552
553
554
555 PrependTexElement.prototype.GetValueString=function()
556 {
557 return {value:rnJQuery('#'+this.Id+ ' .redNaoInputText').val()};
558 }
559
560 PrependTexElement.prototype.GetValuePath=function()
561 {
562 return 'formData.'+this.Id+'.value';
563 }
564
565
566 PrependTexElement.prototype.IsValid=function()
567 {
568 if(rnJQuery('#'+this.Id+ ' .redNaoInputText').val()==""&&this.Options.IsRequired=='y')
569 {
570 rnJQuery('#'+this.Id).find('.redNaoInputText,.redNaoRealCheckBox,.redNaoInputRadio,.redNaoInputCheckBox,.redNaoSelect,.redNaoTextArea').addClass('redNaoInvalid');
571 return false;
572 }
573 return true;
574 }
575
576 PrependTexElement.prototype.GenerationCompleted=function()
577 {
578 var self=this;
579 rnJQuery('#'+this.Id+ ' .redNaoInputText').change(function(){self.FirePropertyChanged(self.GetValueString());});
580 }
581
582 /************************************************************************************* Appended Text Element ***************************************************************************************************/
583
584 function AppendedTexElement(options)
585 {
586 FormElementBase.call(this,options);
587 this.Title="Appended Text";
588
589 if(this.IsNew)
590 {
591 this.Options.Label="Appended Text";
592 this.Options.ClassName="rednaoappendedtext";
593 this.Options.Placeholder="Placeholder";
594 this.Options.Append="Append";
595 this.Options.Value="";
596 this.Options.Width='';
597 }else{
598 this.SetDefaultIfUndefined('Value','');
599 this.SetDefaultIfUndefined('Width','');
600
601 }
602
603
604
605
606 }
607
608 AppendedTexElement.prototype=Object.create(FormElementBase.prototype);
609
610 AppendedTexElement.prototype.CreateProperties=function()
611 {
612 this.Properties.push(new IdProperty(this,this.Options));
613 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
614 this.Properties.push(new SimpleTextProperty(this,this.Options,"Append","Append",{ManipulatorType:'basic'}));
615 this.Properties.push(new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic'}));
616 this.Properties.push(new SimpleTextProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}));
617 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
618 this.Properties.push(new SimpleTextProperty(this,this.Options,"Value","Value",{ManipulatorType:'basic',RefreshFormData:true}));
619
620 }
621
622 AppendedTexElement.prototype.GenerateInlineElement=function()
623 {
624 var additionalStyle='';
625 if(!isNaN(parseFloat(this.Options.Width)))
626 additionalStyle='width:'+this.Options.Width+'px'+' !important;'
627
628
629 return '<div class="rednao_label_container"><label class="rednao_control_label" for="appendedtext">'+this.Options.Label+'</label></div>\
630 <div class="redNaoControls">\
631 <div class="rednao-input-append">\
632 <input style="'+additionalStyle+'" id="appendedtext" name="appendedtext" placeholder="'+this.Options.Placeholder+'" type="text" class="redNaoInputText" value="'+this.Options.Value+'">\
633 <span class="redNaoAppend">'+this.Options.Append+'</span>\
634 </div>\
635 </div>';
636
637
638 }
639
640
641
642
643 AppendedTexElement.prototype.GetValueString=function()
644 {
645 return {value:rnJQuery('#'+this.Id+ ' .redNaoInputText').val()};
646 }
647
648 AppendedTexElement.prototype.GetValuePath=function()
649 {
650 return 'formData.'+this.Id+'.value';
651 }
652
653 AppendedTexElement.prototype.IsValid=function()
654 {
655 if(rnJQuery('#'+this.Id+ ' .redNaoInputText').val()==""&&this.Options.IsRequired=='y')
656 {
657 rnJQuery('#'+this.Id).find('.redNaoInputText,.redNaoRealCheckBox,.redNaoInputRadio,.redNaoInputCheckBox,.redNaoSelect,.redNaoTextArea').addClass('redNaoInvalid');
658 return false;
659 }
660 return true;
661 }
662
663 PrependTexElement.prototype.GenerationCompleted=function()
664 {
665 var self=this;
666 rnJQuery('#'+this.Id+ ' .redNaoInputText').change(function(){self.FirePropertyChanged(self.GetValueString());});
667 }
668
669
670 /************************************************************************************* Prepend Checkbox Element ***************************************************************************************************/
671
672 function PrependCheckBoxElement(options)
673 {
674 FormElementBase.call(this,options);
675 this.Title="Prepend Checkbox";
676
677 if(this.IsNew)
678 {
679 this.Options.Label="Prepend Checkbox";
680 this.Options.ClassName="rednaoprependedcheckbox";
681 this.Options.Placeholder="Placeholder";
682 this.Options.IsChecked='n';
683 this.Options.Value="";
684 this.Options.Width='';
685 }else{
686 this.SetDefaultIfUndefined('Value','');
687 this.SetDefaultIfUndefined('Width','');
688
689 }
690
691
692
693 }
694
695 PrependCheckBoxElement.prototype=Object.create(FormElementBase.prototype);
696
697 PrependCheckBoxElement.prototype.CreateProperties=function()
698 {
699 this.Properties.push(new IdProperty(this,this.Options));
700 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
701 this.Properties.push(new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic'}));
702 this.Properties.push(new SimpleTextProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}));
703 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsChecked","Is Checked",{ManipulatorType:'basic'}));
704 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
705 this.Properties.push(new SimpleTextProperty(this,this.Options,"Value","Value",{ManipulatorType:'basic',RefreshFormData:true}));
706
707 }
708
709 PrependCheckBoxElement.prototype.GenerateInlineElement=function()
710 {
711 var additionalStyle='';
712 if(!isNaN(parseFloat(this.Options.Width)))
713 additionalStyle='width:'+this.Options.Width+'px'+' !important;'
714
715
716 return '<div class="rednao_label_container"><label class="rednao_control_label" for="prependedcheckbox">'+this.Options.Label+'</label></div>\
717 <div class="redNaoControls">\
718 <div class="input-prepend">\
719 <span class="redNaoPrepend">\
720 <label class="rednao_checkbox">\
721 <input type="checkbox" class="redNaoRealCheckBox" '+(this.Options.IsChecked=='y'? 'checked="checked"':'')+'/>\
722 </label>\
723 </span>\
724 <input style="'+additionalStyle+'" id="prependedcheckbox" name="prependedcheckbox" class="redNaoInputText" type="text" placeholder="'+this.Options.Placeholder+'" value="'+this.Options.Value+'"/>\
725 </div>\
726 </div>';
727
728
729 }
730
731
732
733 PrependCheckBoxElement.prototype.GetValueString=function()
734 {
735 return {checked:(rnJQuery('#'+this.Id).find('.redNaoRealCheckBox').is(':checked')?'Yes':'No'),value:rnJQuery('#'+this.Id+ ' .redNaoInputText').val()};
736 }
737
738 PrependCheckBoxElement.prototype.GetValuePath=function()
739 {
740 return 'formData.'+this.Id+'.value';
741 }
742
743
744 PrependCheckBoxElement.prototype.IsValid=function()
745 {
746 if(rnJQuery('#'+this.Id+ ' .redNaoInputText').val()==""&&this.Options.IsRequired=='y')
747 {
748 rnJQuery('#'+this.Id).find('.redNaoInputText,.redNaoRealCheckBox,.redNaoInputRadio,.redNaoInputCheckBox,.redNaoSelect,.redNaoTextArea').addClass('redNaoInvalid');
749 return false;
750 }
751 return true;
752 }
753
754 PrependCheckBoxElement.prototype.GenerationCompleted=function()
755 {
756 var self=this;
757 rnJQuery('#'+this.Id+ ' .redNaoInputText','#'+this.Id+' .redNaoRealCheckBox').change(function(){self.FirePropertyChanged(self.GetValueString());});
758 }
759 /************************************************************************************* Append Checkbox Element ***************************************************************************************************/
760
761 function AppendCheckBoxElement(options)
762 {
763 FormElementBase.call(this,options);
764 this.Title="Append Checkbox";
765
766 if(this.IsNew)
767 {
768 this.Options.Label="Append Checkbox";
769 this.Options.ClassName="rednaoappendedcheckbox";
770 this.Options.Placeholder="Placeholder";
771 this.Options.IsChecked='n';
772 this.Options.Value="";
773 this.Options.Width='';
774 }else{
775 this.SetDefaultIfUndefined('Value','');
776 this.SetDefaultIfUndefined('Width','');
777
778 }
779
780
781
782 }
783
784 AppendCheckBoxElement.prototype=Object.create(FormElementBase.prototype);
785
786 AppendCheckBoxElement.prototype.CreateProperties=function()
787 {
788 this.Properties.push(new IdProperty(this,this.Options));
789 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
790 this.Properties.push(new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic'}));
791 this.Properties.push(new SimpleTextProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}));
792 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsChecked","Is Checked",{ManipulatorType:'basic'}));
793 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
794 this.Properties.push(new SimpleTextProperty(this,this.Options,"Value","Value",{ManipulatorType:'basic',RefreshFormData:true}));
795
796 }
797
798 AppendCheckBoxElement.prototype.GenerateInlineElement=function()
799 {
800 var additionalStyle='';
801 if(!isNaN(parseFloat(this.Options.Width)))
802 additionalStyle='width:'+this.Options.Width+'px'+' !important;'
803
804
805 return '<div class="rednao_label_container"><label class="rednao_control_label" for="appendedcheckbox">'+this.Options.Label+'</label></div>\
806 <div class="redNaoControls">\
807 <div class="rednao-input-append">\
808 <input style="'+additionalStyle+'" id="appendedcheckbox" class="redNaoInputText" name="appendedcheckbox" class="span2" type="text" placeholder="'+this.Options.Placeholder+'" value="'+this.Options.Value+'"/>\
809 <span class="redNaoAppend">\
810 <input type="checkbox" class="redNaoRealCheckBox" '+(this.Options.IsChecked=='y'? 'checked="checked"':'')+'/>\
811 </span>\
812 </div>\
813 </div>';
814
815
816 }
817
818
819
820 AppendCheckBoxElement.prototype.GetValueString=function()
821 {
822 return {checked:(rnJQuery('#'+this.Id).find('.redNaoRealCheckBox').is(':checked')?'Yes':'No'),value:rnJQuery('#'+this.Id+ ' .redNaoInputText').val()};
823 }
824
825 AppendCheckBoxElement.prototype.GetValuePath=function()
826 {
827 return 'formData.'+this.Id+'.value';
828 }
829
830 AppendCheckBoxElement.prototype.IsValid=function()
831 {
832 if(rnJQuery('#'+this.Id+ ' .redNaoInputText').val()==""&&this.Options.IsRequired=='y')
833 {
834 rnJQuery('#'+this.Id).find('.redNaoInputText,.redNaoRealCheckBox,.redNaoInputRadio,.redNaoInputCheckBox,.redNaoSelect,.redNaoTextArea').addClass('redNaoInvalid');
835 return false;
836 }
837 return true;
838 }
839
840 AppendCheckBoxElement.prototype.GenerationCompleted=function()
841 {
842 var self=this;
843 rnJQuery('#'+this.Id+ ' .redNaoInputText','#'+this.Id+' .redNaoRealCheckBox').change(function(){self.FirePropertyChanged(self.GetValueString());});
844 }
845 /************************************************************************************* Text Area Element ***************************************************************************************************/
846
847 function TextAreaElement(options)
848 {
849 FormElementBase.call(this,options);
850 this.Title="Text Area";
851
852 if(this.IsNew)
853 {
854 this.Options.Label="Text Area";
855 this.Options.DefaultText="Default Text";
856 this.Options.ClassName="rednaotextarea";
857 this.Options.Value="";
858 this.Options.Width='';
859 this.Options.Height=''
860 }else{
861 this.SetDefaultIfUndefined('Value','');
862 this.SetDefaultIfUndefined('Width','');
863 this.SetDefaultIfUndefined('Height','');
864
865 }
866
867
868 }
869
870 TextAreaElement.prototype=Object.create(FormElementBase.prototype);
871
872 TextAreaElement.prototype.CreateProperties=function()
873 {
874 this.Properties.push(new IdProperty(this,this.Options));
875 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
876 this.Properties.push(new SimpleTextProperty(this,this.Options,"DefaultText","Value",{ManipulatorType:'basic',RefreshFormData:true}));
877 this.Properties.push(new SimpleTextProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}));
878 this.Properties.push(new SimpleTextProperty(this,this.Options,"Height","Height",{ManipulatorType:'basic'}));
879 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
880
881
882
883 }
884
885 TextAreaElement.prototype.GenerateInlineElement=function()
886 {
887 var additionalStyle='';
888 if(!isNaN(parseFloat(this.Options.Width)))
889 additionalStyle='width:'+this.Options.Width+'px'+' !important;'
890
891 if(!isNaN(parseFloat(this.Options.Height)))
892 additionalStyle+='height:'+this.Options.Height+'px'+' !important;'
893
894
895 return '<div class="rednao_label_container"><label class="rednao_control_label" for="textarea">'+this.Options.Label+'</label></div>\
896 <div class="redNaoControls">\
897 <textarea style="'+additionalStyle+'" name="textarea" class="redNaoTextArea">'+this.Options.DefaultText+'</textarea>\
898 </div>';
899 }
900
901
902
903 TextAreaElement.prototype.GetValueString=function()
904 {
905 return {value:rnJQuery('#'+this.Id+ ' .redNaoTextArea').val()};
906 }
907
908 TextAreaElement.prototype.GetValuePath=function()
909 {
910 return 'formData.'+this.Id+'.value';
911 }
912
913
914 TextAreaElement.prototype.IsValid=function()
915 {
916 if(rnJQuery('#'+this.Id+ ' .redNaoTextArea').val()==this.Options.DefaultText&&this.Options.IsRequired=='y')
917 {
918 rnJQuery('#'+this.Id).find('.redNaoInputText,.redNaoRealCheckBox,.redNaoInputRadio,.redNaoInputCheckBox,.redNaoSelect,.redNaoTextArea').addClass('redNaoInvalid');
919 return false;
920 }
921 return true;
922 }
923
924 TextAreaElement.prototype.GenerationCompleted=function()
925 {
926 var self=this;
927 rnJQuery('#'+this.Id+ ' .redNaoTextArea').change(function(){self.FirePropertyChanged(self.GetValueString());});
928 }
929
930 /*************************************************************************************Multiple Radio Element ***************************************************************************************************/
931
932 function MultipleRadioElement(options)
933 {
934 FormElementBase.call(this,options);
935 this.Title="Multiple Radio";
936
937 if(this.IsNew)
938 {
939 this.Options.Label="Multiple Radio";
940 this.Options.ClassName="rednaomultipleradios";
941 this.Options.Options=new Array({label:'Option 1',value:0},{label:'Option 2',value:0},{label:'Option 3',value:0});
942 }else
943 {
944 if(this.Options.Options.length>0&&typeof this.Options.Options[i]=='string')
945 {
946 var aux=new Array();
947 for(var i=0;i<this.Options.Options.length;i++)
948 {
949 aux.push({label:this.Options.Options[i]});
950 }
951
952 this.Options.Options=aux;
953 }
954 }
955
956
957 }
958
959 MultipleRadioElement.prototype=Object.create(FormElementBase.prototype);
960
961 MultipleRadioElement.prototype.CreateProperties=function()
962 {
963 this.Properties.push(new IdProperty(this,this.Options));
964 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
965 this.Properties.push(new ArrayProperty(this,this.Options,"Options","Options",{ManipulatorType:'basic'}));
966 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
967
968
969
970 }
971
972 MultipleRadioElement.prototype.GenerateInlineElement=function()
973 {
974
975 var html= '<div class="rednao_label_container"><label class="rednao_control_label">'+this.Options.Label+'</label></div>\
976 <div class="redNaoControls">';
977
978 var checked='checked="checked"';
979 for(var i=0;i<this.Options.Options.length;i++)
980 {
981 html+='<label class="redNaoRadio" for="radios-0">\
982 <input class="redNaoInputRadio" type="radio" name="'+this.GetPropertyName()+'" value="'+this.Options.Options[i].value+'" '+checked+'>'+rnJQuery.trim(this.Options.Options[i].label)+'</input>\
983 </label>';
984
985 checked="";
986
987 }
988
989 html+='</div>';
990 return html;
991 }
992
993
994
995
996
997 MultipleRadioElement.prototype.GetValueString=function()
998 {
999 var jQueryElement=rnJQuery('#'+this.Id).find(':checked');
1000 if(jQueryElement.length>0)
1001 this.amount=parseFloat(jQueryElement.val());
1002 if(isNaN(this.amount))
1003 this.amount=0;
1004 return {value:rnJQuery.trim(jQueryElement.parent().text()),amount:this.amount};
1005 }
1006
1007
1008 MultipleRadioElement.prototype.GetValuePath=function()
1009 {
1010 return 'formData.'+this.Id+'.amount';
1011 }
1012
1013
1014 MultipleRadioElement.prototype.IsValid=function()
1015 {
1016 if(rnJQuery('#'+this.Id).find(':checked').length>0&&this.Options.IsRequired=='y')
1017 {
1018 rnJQuery('#'+this.Id).find('.redNaoInputText,.redNaoRealCheckBox,.redNaoInputRadio,.redNaoInputCheckBox,.redNaoSelect,.redNaoTextArea').addClass('redNaoInvalid');
1019 return false;
1020 }
1021
1022 return true;
1023 }
1024
1025 MultipleRadioElement.prototype.GenerationCompleted=function()
1026 {
1027 var self=this;
1028 rnJQuery('#'+this.Id+ ' .redNaoInputRadio').change(function(){self.FirePropertyChanged(self.GetValueString());});
1029 }
1030
1031 /*************************************************************************************Multiple Checkbox Element ***************************************************************************************************/
1032
1033 function MultipleCheckBoxElement(options)
1034 {
1035 FormElementBase.call(this,options);
1036 this.Title="Multiple Checkboxes";
1037
1038 if(this.IsNew)
1039 {
1040 this.Options.Label="Multiple Checkbox";
1041 this.Options.ClassName="rednaomultiplecheckboxes";
1042 this.Options.Options=new Array({label:'Check 1',value:0},{label:'Check 2',value:0},{label:'Check 3',value:0});
1043 }else
1044 {
1045 if(this.Options.Options.length>0&&typeof this.Options.Options[i]=='string')
1046 {
1047 var aux=new Array();
1048 for(var i=0;i<this.Options.Options.length;i++)
1049 {
1050 aux.push({label:this.Options.Options[i]});
1051 }
1052
1053 this.Options.Options=aux;
1054 }
1055 }
1056
1057
1058 }
1059
1060 MultipleCheckBoxElement.prototype=Object.create(FormElementBase.prototype);
1061
1062 MultipleCheckBoxElement.prototype.CreateProperties=function()
1063 {
1064 this.Properties.push(new IdProperty(this,this.Options));
1065 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
1066 this.Properties.push(new ArrayProperty(this,this.Options,"Options","Options",{ManipulatorType:'basic'}));
1067 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
1068
1069
1070 }
1071
1072 MultipleCheckBoxElement.prototype.GenerateInlineElement=function()
1073 {
1074
1075 var html= '<div class="rednao_label_container"><label class="rednao_control_label">'+this.Options.Label+'</label></div>\
1076 <div class="redNaoControls">';
1077
1078 var checked='checked=checked';
1079 for(var i=0;i<this.Options.Options.length;i++)
1080 {
1081 html+='<label class="redNaoCheckBox" for="radios-0">\
1082 <input type="checkbox" class="redNaoInputCheckBox" name="'+this.GetPropertyName()+'" value="'+this.Options.Options[i].value+'" '+checked+'/>'+this.Options.Options[i].label+'\
1083 </label>';
1084
1085 checked="";
1086
1087 }
1088
1089 html+='</div>';
1090 return html;
1091 }
1092
1093
1094
1095
1096
1097
1098 MultipleCheckBoxElement.prototype.GetValueString=function()
1099 {
1100 var valueString="";
1101 var me=this;
1102 this.amount=0;
1103 var jQueryElement=rnJQuery('#'+this.Id).find(':checked');
1104 var data={};
1105 data.selectedValues=[];
1106 if(jQueryElement.length>0)
1107 {
1108 for(var i=0;i<jQueryElement.length;i++)
1109 {
1110 if(jQueryElement.length>0)
1111 this.amount=parseFloat(rnJQuery(jQueryElement[i]).val());
1112 if(isNaN(this.amount))
1113 this.amount=0;
1114 data.selectedValues.push({value:rnJQuery(jQueryElement[i]).parent().text(),amount:this.amount})
1115 }
1116 }
1117
1118 return data;
1119
1120 }
1121
1122
1123 MultipleCheckBoxElement.prototype.GetValuePath=function()
1124 {
1125 return 'RedNaoGetValueFromArray(formData.'+this.Id+'.selectedValues)';
1126 }
1127
1128
1129 MultipleCheckBoxElement.prototype.IsValid=function()
1130 {
1131 if(rnJQuery('#'+this.Id).find(':checked').length>0&&this.Options.IsRequired=='y')
1132 {
1133 rnJQuery('#'+this.Id).find('.redNaoInputText,.redNaoRealCheckBox,.redNaoInputRadio,.redNaoInputCheckBox,.redNaoSelect,.redNaoTextArea').addClass('redNaoInvalid');
1134 return false;
1135 }
1136 return true;
1137 }
1138
1139 MultipleCheckBoxElement.prototype.GenerationCompleted=function()
1140 {
1141 var self=this;
1142 rnJQuery('#'+this.Id+ ' .redNaoInputCheckBox').change(function(){self.FirePropertyChanged(self.GetValueString());});
1143 }
1144
1145
1146 /*************************************************************************************Select Basic Element ***************************************************************************************************/
1147
1148 function SelectBasicElement(options)
1149 {
1150 FormElementBase.call(this,options);
1151 this.Title="Select Basic";
1152
1153 if(this.IsNew)
1154 {
1155 this.Options.Label="Select Basic";
1156 this.Options.ClassName="rednaoselectbasic";
1157 this.Options.Options=new Array({label:'Option 1',value:0},{label:'Option 2',value:0},{label:'Option',value:0});
1158 this.SetDefaultIfUndefined('Width','');
1159
1160 }else
1161 {
1162 this.SetDefaultIfUndefined('Width','');
1163
1164 if(this.Options.Options.length>0&&typeof this.Options.Options[i]=='string')
1165 {
1166 var aux=new Array();
1167 for(var i=0;i<this.Options.Options.length;i++)
1168 {
1169 aux.push({label:this.Options.Options[i]});
1170 }
1171
1172 this.Options.Options=aux;
1173 }
1174 }
1175
1176
1177 }
1178
1179 SelectBasicElement.prototype=Object.create(FormElementBase.prototype);
1180
1181 SelectBasicElement.prototype.CreateProperties=function()
1182 {
1183 this.Properties.push(new IdProperty(this,this.Options));
1184 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
1185 this.Properties.push(new ArrayProperty(this,this.Options,"Options","Options",{ManipulatorType:'basic'}));
1186 this.Properties.push(new SimpleTextProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}));
1187 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
1188
1189
1190
1191 }
1192
1193 SelectBasicElement.prototype.GenerateInlineElement=function()
1194 {
1195 var additionalStyle='';
1196 if(!isNaN(parseFloat(this.Options.Width)))
1197 additionalStyle='width:'+this.Options.Width+'px'+' !important;'
1198
1199
1200 var html= '<div class="rednao_label_container"><label class="rednao_control_label">'+this.Options.Label+'</label></div>\
1201 <div class="redNaoControls">\
1202 <select style="'+additionalStyle+'" name="'+this.GetPropertyName()+'" class="redNaoSelect">';
1203
1204 var selected='selected="selected"';
1205 for(var i=0;i<this.Options.Options.length;i++)
1206 {
1207 html+='<option value="'+this.Options.Options[i].value+'" '+selected+'>'+this.Options.Options[i].label+'</opton>'
1208
1209 selected="";
1210
1211 }
1212 html+='</select></div>';
1213 return html;
1214 }
1215
1216
1217
1218 SelectBasicElement.prototype.GetValueString=function()
1219 {
1220 var jQueryElement=rnJQuery('#'+this.Id+ ' .redNaoSelect option:selected');
1221 if(jQueryElement.length>0)
1222 this.amount=parseFloat(jQueryElement.val());
1223 if(isNaN(this.amount))
1224 this.amount=0;
1225 return {value:jQueryElement.text(),amount:this.amount};
1226 }
1227
1228 SelectBasicElement.prototype.GetValuePath=function()
1229 {
1230 return 'formData.'+this.Id+'.amount';
1231 }
1232
1233
1234 SelectBasicElement.prototype.IsValid=function()
1235 {
1236 if(rnJQuery('#'+this.Id+ ' .redNaoSelect option:selected').length>0&&this.Options.IsRequired=='y')
1237 {
1238 rnJQuery('#'+this.Id).find('.redNaoInputText,.redNaoRealCheckBox,.redNaoInputRadio,.redNaoInputCheckBox,.redNaoSelect,.redNaoTextArea').addClass('redNaoInvalid');
1239 return false;
1240 }
1241 return true;
1242 }
1243
1244
1245 SelectBasicElement.prototype.GenerationCompleted=function()
1246 {
1247 var self=this;
1248 rnJQuery('#'+this.Id+ ' .redNaoSelect').change(function(){self.FirePropertyChanged(self.GetValueString());});
1249 }
1250
1251 /*************************************************************************************Donation Button***************************************************************************************************/
1252
1253
1254
1255 function DonationButtonElement(options)
1256 {
1257 FormElementBase.call(this,options);
1258 this.Title="Donation Button";
1259
1260 if(this.IsNew)
1261 {
1262 this.Options.Label="Donation Button";
1263 this.Options.ClassName="rednaodonationbutton";
1264 this.Options.Image='https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif';
1265 }else
1266 {
1267 if(typeof this.Options.Image=='undefined')
1268 this.Options.Image='https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif';
1269 }
1270
1271
1272 }
1273
1274 DonationButtonElement.prototype=Object.create(FormElementBase.prototype);
1275
1276 DonationButtonElement.prototype.CreateProperties=function()
1277 {
1278 this.Properties.push(new IdProperty(this,this.Options));
1279 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
1280 this.Properties.push(new SimpleTextProperty(this,this.Options,"Image","Image Url",{ManipulatorType:'basic'}));
1281 }
1282
1283 DonationButtonElement.prototype.GenerateInlineElement=function()
1284 {
1285 return '<div class="redNaoControls"><input type="image" class="redNaoDonationButton" src="'+this.Options.Image+'" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"></div>';
1286 }
1287
1288
1289 DonationButtonElement.prototype.GetValueString=function()
1290 {
1291 return '';
1292
1293 }
1294
1295 DonationButtonElement.prototype.StoresInformation=function()
1296 {
1297 return false;
1298 }
1299
1300
1301 /************************************************************************************* Recurrence Element ***************************************************************************************************/
1302
1303
1304
1305 function RecurrenceElement(options)
1306 {
1307 FormElementBase.call(this,options);
1308 this.Title="Donation Button";
1309
1310 if(this.IsNew)
1311 {
1312 this.Options.Label="Recurrence";
1313 this.Options.ClassName="rednaodonationrecurrence";
1314 this.Options.ShowOneTime='y';
1315 this.Options.ShowDaily='y';
1316 this.Options.ShowWeekly='y';
1317 this.Options.ShowMonthly='y';
1318 this.Options.ShowYearly='y';
1319
1320 }
1321
1322
1323 }
1324
1325 RecurrenceElement.prototype=Object.create(FormElementBase.prototype);
1326
1327 RecurrenceElement.prototype.CreateProperties=function()
1328 {
1329 this.Properties.push(new IdProperty(this,this.Options));
1330 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
1331 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowOneTime","Show one time option",{ManipulatorType:'basic'}));
1332 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowDaily","Show daily option",{ManipulatorType:'basic'}));
1333 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowWeekly","Show weekly option",{ManipulatorType:'basic'}));
1334 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowMonthly","Show monthly option",{ManipulatorType:'basic'}));
1335 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowYearly","Show yearly option",{ManipulatorType:'basic'}));
1336 }
1337
1338 RecurrenceElement.prototype.GenerateInlineElement=function()
1339 {
1340 var html= '<div class="rednao_label_container"><label class="rednao_control_label">'+this.Options.Label+'</label></div>\<div class="redNaoControls"><select class="redNaoSelect redNaoRecurrence">';
1341 var selected='selected="selected"';
1342
1343 if(this.Options.ShowOneTime=='y')
1344 {
1345 html+='<option value="OT" '+selected+'>One Time</option>';
1346 selected='';
1347 }
1348
1349 if(this.Options.ShowDaily=='y')
1350 {
1351 html+='<option value="D" '+selected+'>Daily</option>';
1352 selected='';
1353 }
1354
1355 if(this.Options.ShowWeekly=='y')
1356 {
1357 html+='<option value="W" '+selected+'>Weekly</option>';
1358 selected='';
1359 }
1360
1361 if(this.Options.ShowMonthly=='y')
1362 {
1363 html+='<option value="M" '+selected+'>Monthly</option>';
1364 selected='';
1365 }
1366
1367 if(this.Options.ShowYearly=='y')
1368 {
1369 html+='<option value="Y" '+selected+'>Yearly</option>';
1370 selected='';
1371 }
1372
1373 html+='</select></div>';
1374
1375 return html;
1376 }
1377
1378
1379
1380 RecurrenceElement.prototype.GetValueString=function()
1381 {
1382 var jQueryElement=rnJQuery('#'+this.Id+ ' .redNaoSelect option:selected');
1383 return encodeURI(this.Options.Label)+"="+encodeURI(jQueryElement.text());
1384
1385 }
1386
1387
1388
1389
1390 /************************************************************************************* Submission Button ***************************************************************************************************/
1391
1392
1393
1394 function RedNaoSubmissionButton(options)
1395 {
1396 FormElementBase.call(this,options);
1397 this.Title="Submit Button";
1398
1399 if(this.IsNew)
1400 {
1401 this.Options.ClassName="rednaosubmissionbutton";
1402 this.Options.ButtonText="Submit";
1403
1404
1405 }
1406 }
1407
1408 RedNaoSubmissionButton.prototype=Object.create(FormElementBase.prototype);
1409
1410 RedNaoSubmissionButton.prototype.CreateProperties=function()
1411 {
1412 this.Properties.push(new SimpleTextProperty(this,this.Options,"ButtonText","Button Text",{ManipulatorType:'basic'}));
1413 }
1414
1415 RedNaoSubmissionButton.prototype.GenerateInlineElement=function()
1416 {
1417 return '<div class="rednao_label_container"></div><div class="redNaoControls"><input type="submit" class="redNaoSubmitButton" value="'+this.Options.ButtonText+'" /></div>';
1418 }
1419
1420
1421 RedNaoSubmissionButton.prototype.GetValueString=function()
1422 {
1423 return '';
1424
1425 }
1426
1427 RedNaoSubmissionButton.prototype.StoresInformation=function()
1428 {
1429 return false;
1430 }
1431
1432
1433
1434 /************************************************************************************* Date Picker ***************************************************************************************************/
1435
1436
1437
1438 function RedNaoDatePicker(options)
1439 {
1440 FormElementBase.call(this,options);
1441 this.Title="Date Picker";
1442
1443 if(this.IsNew)
1444 {
1445 this.Options.ClassName="rednaodatepicker";
1446 this.Options.Label="Date";
1447 this.Options.DateFormat="MM-dd-yy";
1448 this.Options.Value='';
1449 }
1450
1451 }
1452
1453 RedNaoDatePicker.prototype=Object.create(FormElementBase.prototype);
1454
1455 RedNaoDatePicker.prototype.CreateProperties=function()
1456 {
1457 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
1458 this.Properties.push(new SimpleTextProperty(this,this.Options,"DateFormat","Date Format",{ManipulatorType:'basic'}));
1459
1460 }
1461
1462 RedNaoDatePicker.prototype.GenerateInlineElement=function()
1463 {
1464 return '<div class="rednao_label_container"><label class="rednao_control_label">'+this.Options.Label+'</label></div><div class="redNaoControls"><input type="text" class="redNaoDatePicker" /></div>';
1465
1466 }
1467
1468
1469 RedNaoDatePicker.prototype.GetValueString=function()
1470 {
1471 var selectedDate= rnJQuery('#'+this.Id).find('.redNaoDatePicker').datepicker('getDate');
1472 if(selectedDate==null)
1473 selectedDate ="";
1474 else
1475 selectedDate=selectedDate.getFullYear()+'-'+(selectedDate.getMonth()+1)+'-'+selectedDate.getDate();
1476 return {value:selectedDate};
1477
1478 }
1479
1480 RedNaoDatePicker.prototype.GetValuePath=function()
1481 {
1482 return 'formData.'+this.Id+'.value';
1483 }
1484
1485
1486
1487 RedNaoDatePicker.prototype.StoresInformation=function()
1488 {
1489 return true;
1490 }
1491
1492 RedNaoDatePicker.prototype.GenerationCompleted=function()
1493 {
1494 rnJQuery('#'+this.Id).find('.redNaoDatePicker').datepicker({
1495 dateFormat:this.Options.DateFormat,
1496 beforeShow: function() {
1497 rnJQuery('#ui-datepicker-div').wrap('<div class="smartFormsSlider"></div>')
1498 },
1499 onClose: function() {
1500 rnJQuery('#ui-datepicker-div').unwrap();
1501 }
1502 });
1503
1504 var self=this;
1505 rnJQuery('#'+this.Id+ ' .redNaoDatePicker').change(function(){self.FirePropertyChanged(self.GetValueString());});
1506
1507
1508 }
1509
1510 RedNaoDatePicker.prototype.IsValid=function()
1511 {
1512 return true;
1513 }
1514
1515 /************************************************************************************* Name ***************************************************************************************************/
1516
1517 function RedNaoName(options)
1518 {
1519 FormElementBase.call(this,options);
1520 this.Title="Text Input";
1521 if(this.IsNew)
1522 {
1523 this.Options.ClassName="rednaoname";
1524 this.Options.Label="Name";
1525 this.Options.FirstNamePlaceholder="First Name";
1526 this.Options.LastNamePlaceholder="Last Name";
1527 this.Options.FirstNameValue="";
1528 this.Options.LastNameValue="";
1529 this.Options.ReadOnly='n'
1530 }
1531
1532
1533
1534
1535
1536 }
1537
1538 RedNaoName.prototype=Object.create(FormElementBase.prototype);
1539
1540 RedNaoName.prototype.CreateProperties=function()
1541 {
1542 this.Properties.push(new IdProperty(this,this.Options));
1543 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
1544 this.Properties.push(new SimpleTextProperty(this,this.Options,"FirstNamePlaceholder","First name placeholder",{ManipulatorType:'basic'}));
1545 this.Properties.push(new SimpleTextProperty(this,this.Options,"LastNamePlaceholder","Last name placeholder",{ManipulatorType:'basic'}));
1546 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
1547 this.Properties.push(new CheckBoxProperty(this,this.Options,"ReadOnly","Read Only",{ManipulatorType:'basic'}));
1548
1549 }
1550
1551 RedNaoName.prototype.GenerateInlineElement=function()
1552 {
1553 var firstNameLabel='';
1554 var lastNameLabel='';
1555
1556 if(this.Options.FirstNamePlaceholder!='')
1557 firstNameLabel='<label class="redNaoHelper">'+this.Options.FirstNamePlaceholder+'</label>';
1558 if(this.Options.LastNamePlaceholder!='')
1559 lastNameLabel='<label class="redNaoHelper">'+this.Options.LastNamePlaceholder+'</label>';
1560
1561 return '<div class="rednao_label_container"><label class="rednao_control_label" >'+this.Options.Label+'</label></div>\
1562 <div class="redNaoControls">\
1563 <div class="redNaoFirstNameDiv redNaoTwoColumnsDiv">\
1564 <input '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_firstname" type="text" placeholder="'+this.Options.FirstNamePlaceholder+'" class="redNaoInputText redNaoTwoColumns redNaoInputFirstName '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'"/>\
1565 '+firstNameLabel+'\
1566 </div> \
1567 <div class="redNaoLastNameDiv redNaoTwoColumnsDiv">\
1568 <input '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_lastname" type="text" placeholder="'+this.Options.LastNamePlaceholder+'" class="redNaoInputText redNaoTwoColumns redNaoInputLastName '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'">\
1569 '+lastNameLabel+'\
1570 </div>\
1571 <div> \
1572 </div>';
1573 }
1574
1575
1576 RedNaoName.prototype.GetValueString=function()
1577 {
1578 return {
1579 firstName:rnJQuery('#'+this.Id+ ' .redNaoInputFirstName').val(),
1580 lastName:rnJQuery('#'+this.Id+ ' .redNaoInputLastName').val()
1581
1582 };
1583
1584
1585 }
1586
1587
1588 RedNaoName.prototype.GetValuePath=function()
1589 {
1590 return 'formData.'+this.Id+'.firstName+" "'+'formData.'+this.Id+'.lastName';
1591 }
1592
1593
1594 RedNaoName.prototype.IsValid=function()
1595 {
1596 if(this.Options.IsRequired=='y'&&(rnJQuery('#'+this.Id+ ' .redNaoInputFirstName').val()==""||rnJQuery('#'+this.Id+ ' .redNaoInputLastName').val()==""))
1597 {
1598 var firstNameJQuery=rnJQuery('#'+this.Id+ ' .redNaoInputFirstName');
1599 var lastNameJQuery=rnJQuery('#'+this.Id+ ' .redNaoInputLastName');
1600
1601 if(firstNameJQuery.val()=="")
1602 firstNameJQuery.addClass('redNaoInvalid');
1603
1604 if(lastNameJQuery.val()=="")
1605 lastNameJQuery.addClass('redNaoInvalid');
1606
1607 return false;
1608 }
1609
1610 return true;
1611 }
1612
1613 RedNaoName.prototype.GenerationCompleted=function()
1614 {
1615 var self=this;
1616 rnJQuery('#'+this.Id+ ' .redNaoInputFirstName,#'+this.Id+ ' .redNaoInputLastName').change(function(){self.FirePropertyChanged(self.GetValueString());});
1617 }
1618
1619
1620
1621 /************************************************************************************* Address ***************************************************************************************************/
1622
1623 function RedNaoAddress(options)
1624 {
1625 FormElementBase.call(this,options);
1626 this.Title="Text Input";
1627 this.Countries=new Array("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", "Kyrgyzstan", "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 and 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");
1628 if(this.IsNew)
1629 {
1630 this.Options.ClassName="rednaoaddress";
1631 this.Options.Label="Address";
1632 this.Options.StreetAddress1Label="Street Address";
1633 this.Options.StreetAddress2Label="Street Address 2";
1634 this.Options.CityLabel="City";
1635 this.Options.StateLabel="State";
1636 this.Options.ZipLabel='Zip';
1637 this.Options.CountryLabel='Country';
1638
1639 this.Options.ShowStreetAddress1="y";
1640 this.Options.ShowStreetAddress2="y";
1641 this.Options.ShowCity="y";
1642 this.Options.ShowState="y";
1643 this.Options.ShowZip='y';
1644 this.Options.ShowCountry='y';
1645 }
1646
1647
1648
1649
1650
1651 }
1652
1653 RedNaoAddress.prototype=Object.create(FormElementBase.prototype);
1654
1655 RedNaoAddress.prototype.CreateProperties=function()
1656 {
1657 this.Properties.push(new IdProperty(this,this.Options));
1658 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
1659 this.Properties.push(new SimpleTextProperty(this,this.Options,"StreetAddress1Label","Street Address Label",{ManipulatorType:'basic'}));
1660 this.Properties.push(new SimpleTextProperty(this,this.Options,"StreetAddress2Label","Street Address 2 Label",{ManipulatorType:'basic'}));
1661 this.Properties.push(new SimpleTextProperty(this,this.Options,"CityLabel","City Label",{ManipulatorType:'basic'}));
1662 this.Properties.push(new SimpleTextProperty(this,this.Options,"StateLabel","State Label",{ManipulatorType:'basic'}));
1663 this.Properties.push(new SimpleTextProperty(this,this.Options,"ZipLabel","Zip Label",{ManipulatorType:'basic'}));
1664 this.Properties.push(new SimpleTextProperty(this,this.Options,"CountryLabel","Country Label",{ManipulatorType:'basic'}));
1665
1666 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowStreetAddress1","Show Street Address",{ManipulatorType:'basic'}));
1667 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowStreetAddress2","Show Street Address 2",{ManipulatorType:'basic'}));
1668 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowCity","Show City",{ManipulatorType:'basic'}));
1669 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowState","Show State",{ManipulatorType:'basic'}));
1670 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowZip","Show Zip",{ManipulatorType:'basic'}));
1671 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowCountry","Show Country",{ManipulatorType:'basic'}));
1672 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
1673
1674 }
1675
1676 RedNaoAddress.prototype.GenerateInlineElement=function()
1677 {
1678 var StreetAddress1Label='';
1679 var StreetAddress2Label='';
1680 var CityLabel='';
1681 var StateLabel='';
1682 var ZipLabel='';
1683 var CountryLabel='';
1684 var isFirstElement=true;
1685
1686 if(this.Options.StreetAddress1Label!='')
1687 StreetAddress1Label='<label class="redNaoHelper">'+this.Options.StreetAddress1Label+'</label>';
1688
1689 if(this.Options.StreetAddress2Label!='')
1690 StreetAddress2Label='<label class="redNaoHelper">'+this.Options.StreetAddress2Label+'</label>';
1691
1692 if(this.Options.CityLabel!='')
1693 CityLabel='<label class="redNaoHelper">'+this.Options.CityLabel+'</label>';
1694
1695 if(this.Options.StateLabel!='')
1696 StateLabel='<label class="redNaoHelper">'+this.Options.StateLabel+'</label>';
1697
1698 if(this.Options.ZipLabel!='')
1699 ZipLabel='<label class="redNaoHelper">'+this.Options.ZipLabel+'</label>';
1700
1701 if(this.Options.CountryLabel!='')
1702 CountryLabel='<label class="redNaoHelper">'+this.Options.CountryLabel+'</label>';
1703
1704
1705
1706
1707 var html= '<div class="rednao_label_container"><label class="rednao_control_label" >'+this.Options.Label+'</label></div>\
1708 <div class="redNaoControls">';
1709 if(this.Options.ShowStreetAddress1=='y')
1710 html+='<div class="redNaoStreetAddress1Div">\
1711 <input '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_streetaddress1" type="text" placeholder="'+this.Options.StreetAddress1Label+'" class="redNaoInputText redNaoOneColumn redNaoStreetAddress1 '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'"/>\
1712 '+StreetAddress1Label+'\
1713 </div>';
1714 if(this.Options.ShowStreetAddress2=='y')
1715 html+='<div class="redNaoStreetAddress2Div">\
1716 <input '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_streetaddress2" type="text" placeholder="'+this.Options.StreetAddress2Label+'" class="redNaoInputText redNaoOneColumn redNaoStreetAddress2 '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'"/>\
1717 '+StreetAddress2Label+'\
1718 </div>';
1719
1720 if(this.Options.ShowCity=='y')
1721 html+='<div class="redNaoCityDiv redNaoTwoColumnsDiv">\
1722 <input '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_city" type="text" placeholder="'+this.Options.CityLabel+'" class="redNaoInputText redNaoTwoColumns redNaoCity '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'"/>\
1723 '+CityLabel+'\
1724 </div>';
1725 if(this.Options.ShowState=='y')
1726 html+='<div class="redNaoStateDiv redNaoTwoColumnsDiv">\
1727 <input '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'state" type="text" placeholder="'+this.Options.StateLabel+'" class="redNaoInputText redNaoTwoColumns redNaoState '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'"/>\
1728 '+StateLabel+'\
1729 </div>';
1730 html+='<div class="redNaoClearDiv"></div>';
1731
1732 if(this.Options.ShowZip=='y')
1733 html+='<div class="redNaoZipDiv redNaoTwoColumnsDiv">\
1734 <input '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'zip" type="text" placeholder="'+this.Options.ZipLabel+'" class="redNaoInputText redNaoTwoColumns redNaoZip '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'"/>\
1735 '+ZipLabel+'\
1736 </div>';
1737
1738 if(this.Options.ShowCountry=='y')
1739 html+='<div class="redNaoCountryDiv redNaoTwoColumnsDiv">\
1740 <select '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_country" class="redNaoTwoColumns redNaoSelect redNaoCountry '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'">';
1741 for(var i=0;i<this.Countries.length;i++)
1742 {
1743 html+='<option '+(isFirstElement?'selected="selected"':'')+' value="'+this.Countries[i]+'">'+this.Countries[i]+'</option>';
1744 isFirstElement=false;
1745 }
1746 html+="</select>"+CountryLabel+'\
1747 </div>';
1748 html+='</div>';
1749 return html;
1750 }
1751
1752
1753 RedNaoAddress.prototype.GetValueString=function()
1754 {
1755 return {
1756 streetAddress1:rnJQuery('#'+this.Id+ ' .redNaoStreetAddress1').val(),
1757 streetAddress2:rnJQuery('#'+this.Id+ ' .redNaoStreetAddress2').val(),
1758 city:rnJQuery('#'+this.Id+ ' .redNaoCity').val(),
1759 state:rnJQuery('#'+this.Id+ ' .redNaoState').val(),
1760 zip:rnJQuery('#'+this.Id+ ' .redNaoZip').val(),
1761 country:rnJQuery('#'+this.Id+ ' .redNaoCountry').val()
1762
1763 };
1764
1765
1766 }
1767
1768
1769 RedNaoAddress.prototype.GetValuePath=function()
1770 {
1771 return "formData."+this.Id+'.streetAddress1'
1772 " "+'formData.'+this.Id+'.streetAddress2'+
1773 " "+'formData.'+this.Id+'.city'+
1774 " "+'formData.'+this.Id+'.state'+
1775 " "+'formData.'+this.Id+'.zip'+
1776 " "+'formData.'+this.Id+'.country';
1777 }
1778
1779
1780 RedNaoAddress.prototype.IsValid=function()
1781 {
1782 if(this.Options.IsRequired=='n')
1783 return true;
1784
1785
1786
1787 var streetAddress1JQuery=rnJQuery('#'+this.Id+ ' .redNaoStreetAddress1');
1788 var streetAddress2JQuery=rnJQuery('#'+this.Id+ ' .redNaoStreetAddress2');
1789 var cityJQuery=rnJQuery('#'+this.Id+ ' .redNaoCity');
1790 var stateJQuery=rnJQuery('#'+this.Id+ ' .redNaoState');
1791 var zipJQuery=rnJQuery('#'+this.Id+ ' .redNaoZip');
1792 var countryJQuery=rnJQuery('#'+this.Id+ ' .redNaoCountry');
1793
1794 var isValid=true;
1795 if(this.Options.ShowStreetAddress1&&streetAddress1JQuery.val()=='')
1796 {
1797 isValid=false;
1798 streetAddress1JQuery.addClass('redNaoInvalid');
1799 }
1800
1801 if(this.Options.ShowStreetAddress2&&streetAddress2JQuery.val()=='')
1802 {
1803 isValid=false;
1804 streetAddress2JQuery.addClass('redNaoInvalid');
1805 }
1806
1807 if(this.Options.ShowCity&&cityJQuery.val()=='')
1808 {
1809 isValid=false;
1810 cityJQuery.addClass('redNaoInvalid');
1811 }
1812
1813 if(this.Options.ShowState&&stateJQuery.val()=='')
1814 {
1815 isValid=false;
1816 stateJQuery.addClass('redNaoInvalid');
1817 }
1818
1819 if(this.Options.ShowZip&&zipJQuery.val()=='')
1820 {
1821 isValid=false;
1822 zipJQuery.addClass('redNaoInvalid');
1823 }
1824
1825 if(this.Options.ShowCountry&&countryJQuery.val()=='')
1826 {
1827 isValid=false;
1828 countryJQuery.addClass('redNaoInvalid');
1829 }
1830
1831 return isValid;
1832
1833 }
1834
1835 RedNaoAddress.prototype.GenerationCompleted=function()
1836 {
1837 var self=this;
1838 rnJQuery('#'+this.Id+ ' .redNaoStreetAddress1,#'+this.Id+ ' .redNaoStreetAddress2,#'+this.Id+ ' .redNaoCity,#'+this.Id+ ' .redNaoState,#'+this.Id+ ' .redNaoZip,#'+this.Id+ ' .redNaoCountry').change(function(){self.FirePropertyChanged(self.GetValueString());});
1839 }
1840
1841
1842 /************************************************************************************* Phone ***************************************************************************************************/
1843
1844 function RedNaoPhone(options)
1845 {
1846 FormElementBase.call(this,options);
1847 this.Title="Phone";
1848 if(this.IsNew)
1849 {
1850 this.Options.ClassName="rednaophone";
1851 this.Options.Label="Phone";
1852 this.Options.AreaLabel="Area";
1853 this.Options.PhoneLabel="Phone";
1854 }
1855
1856
1857
1858
1859
1860 }
1861
1862 RedNaoPhone.prototype=Object.create(FormElementBase.prototype);
1863
1864 RedNaoPhone.prototype.CreateProperties=function()
1865 {
1866 this.Properties.push(new IdProperty(this,this.Options));
1867 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
1868 this.Properties.push(new SimpleTextProperty(this,this.Options,"AreaLabel","Area",{ManipulatorType:'basic'}));
1869 this.Properties.push(new SimpleTextProperty(this,this.Options,"PhoneLabel","Phone",{ManipulatorType:'basic'}));
1870 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
1871
1872 }
1873
1874 RedNaoPhone.prototype.GenerateInlineElement=function()
1875 {
1876 var areaLabel='';
1877 var phoneLabel='';
1878
1879 if(this.Options.FirstNamePlaceholder!='')
1880 areaLabel='<label class="redNaoHelper">'+this.Options.AreaLabel+'</label>';
1881 if(this.Options.LastNamePlaceholder!='')
1882 phoneLabel='<label class="redNaoHelper">'+this.Options.PhoneLabel+'</label>';
1883
1884 return '<div class="rednao_label_container"><label class="rednao_control_label" >'+this.Options.Label+'</label></div>\
1885 <div class="redNaoControls">\
1886 <div class="redNaoFirstNameDiv redNaoTwoColumnsDiv">\
1887 <input '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_area" type="text" placeholder="'+this.Options.AreaLabel+'" class="redNaoInputText redNaoTwoColumns redNaoInputArea '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'"/>\
1888 '+areaLabel+'\
1889 </div> \
1890 <div class="redNaoLastNameDiv redNaoTwoColumnsDiv">\
1891 <input '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'_phone" type="text" placeholder="'+this.Options.PhoneLabel+'" class="redNaoInputText redNaoTwoColumns redNaoInputPhone '+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'">\
1892 '+phoneLabel+'\
1893 </div>\
1894 <div> \
1895 </div>';
1896 }
1897
1898
1899 RedNaoPhone.prototype.GetValueString=function()
1900 {
1901 return {
1902 area:rnJQuery('#'+this.Id+ ' .redNaoInputArea').val(),
1903 phone:rnJQuery('#'+this.Id+ ' .redNaoInputPhone').val()
1904
1905 };
1906
1907
1908 }
1909
1910
1911
1912 RedNaoPhone.prototype.GetValuePath=function()
1913 {
1914 return 'formData.'+this.Id+'.area+" "'+'formData.'+this.Id+'.phone';
1915 }
1916
1917
1918 RedNaoPhone.prototype.IsValid=function()
1919 {
1920 if(this.Options.IsRequired=='n')
1921 return true;
1922
1923 if(rnJQuery('#'+this.Id+ ' .redNaoInputArea').val()==""||rnJQuery('#'+this.Id+ ' .redNaoInputPhone').val()=="")
1924 {
1925 var areaJQuery=rnJQuery('#'+this.Id+ ' .redNaoInputArea');
1926 var phoneJQuery=rnJQuery('#'+this.Id+ ' .redNaoInputPhone');
1927
1928 if(areaJQuery.val()=="")
1929 areaJQuery.addClass('redNaoInvalid');
1930
1931 if(phoneJQuery.val()=="")
1932 phoneJQuery.addClass('redNaoInvalid');
1933
1934 return false;
1935 }
1936
1937 return true;
1938 }
1939
1940 RedNaoPhone.prototype.GenerationCompleted=function()
1941 {
1942 var self=this;
1943 rnJQuery('#'+this.Id+ ' .redNaoInputArea,#'+this.Id+ ' .redNaoInputPhone').change(function(){self.FirePropertyChanged(self.GetValueString());});
1944 }
1945
1946 RedNaoPhone.prototype.GenerationCompleted=function()
1947 {
1948 rnJQuery('#'+this.Id+ ' .redNaoInputArea,#'+this.Id+ ' .redNaoInputPhone').change(function(){self.FirePropertyChanged(self.GetValueString());});
1949
1950 rnJQuery('#'+this.Id+ ' .redNaoInputArea,#'+this.Id+ ' .redNaoInputPhone').ForceNumericOnly();
1951
1952 }
1953
1954
1955 /************************************************************************************* Email Element ***************************************************************************************************/
1956
1957 function RedNaoEmail(options)
1958 {
1959 FormElementBase.call(this,options);
1960 this.Title="Text Input";
1961 if(this.IsNew)
1962 {
1963 this.Options.ClassName="rednaoemail";
1964 this.Options.Label="Email";
1965 this.Options.Placeholder="Placeholder"
1966 }
1967
1968
1969
1970
1971
1972 }
1973
1974 RedNaoEmail.prototype=Object.create(FormElementBase.prototype);
1975
1976 RedNaoEmail.prototype.CreateProperties=function()
1977 {
1978 this.Properties.push(new IdProperty(this,this.Options));
1979 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
1980 this.Properties.push(new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic'}));
1981 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
1982
1983 }
1984
1985 RedNaoEmail.prototype.GenerateInlineElement=function()
1986 {
1987
1988 return '<div class="rednao_label_container"><label class="rednao_control_label" >'+this.Options.Label+'</label></div>\
1989 <div class="redNaoControls">\
1990 <input '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'" type="text" placeholder="'+this.Options.Placeholder+'" class="redNaoInputText redNaoEmail'+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'">'
1991 '</div>';
1992 }
1993
1994
1995 RedNaoEmail.prototype.GetValueString=function()
1996 {
1997 return {value:rnJQuery('#'+this.Id+ ' .redNaoEmail').val()};
1998 }
1999
2000 RedNaoEmail.prototype.GetValuePath=function()
2001 {
2002 return 'formData.'+this.Id+'.value';
2003 }
2004
2005
2006 RedNaoEmail.prototype.IsValid=function()
2007 {
2008 var email=rnJQuery('#'+this.Id+ ' .redNaoEmail').val();
2009 if(email==""&&this.Options.IsRequired=='y')
2010 {
2011 rnJQuery('#'+this.Id).find('.redNaoInputText,.redNaoRealCheckBox,.redNaoInputRadio,.redNaoInputCheckBox,.redNaoSelect,.redNaoTextArea').addClass('redNaoInvalid');
2012 return false;
2013 }
2014
2015 var reg=/^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/;
2016 if(email!=''&&!reg.test(email))
2017 {
2018 rnJQuery('#'+this.Id).find('.redNaoInputText,.redNaoRealCheckBox,.redNaoInputRadio,.redNaoInputCheckBox,.redNaoSelect,.redNaoTextArea').addClass('redNaoInvalid');
2019 return false;
2020 }
2021
2022 return true;
2023 }
2024
2025 RedNaoEmail.prototype.GenerationCompleted=function()
2026 {
2027 var self=this;
2028 rnJQuery('#'+this.Id+ ' .redNaoEmail').change(function(){self.FirePropertyChanged(self.GetValueString());});
2029 }
2030
2031
2032 /************************************************************************************* Email Element ***************************************************************************************************/
2033
2034 function RedNaoEmail(options)
2035 {
2036 FormElementBase.call(this,options);
2037 this.Title="Text Input";
2038 if(this.IsNew)
2039 {
2040 this.Options.ClassName="rednaoemail";
2041 this.Options.Label="Email";
2042 this.Options.Placeholder="Placeholder"
2043 }
2044
2045
2046
2047
2048
2049 }
2050
2051 RedNaoEmail.prototype=Object.create(FormElementBase.prototype);
2052
2053 RedNaoEmail.prototype.CreateProperties=function()
2054 {
2055 this.Properties.push(new IdProperty(this,this.Options));
2056 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
2057 this.Properties.push(new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic'}));
2058 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
2059
2060 }
2061
2062 RedNaoEmail.prototype.GenerateInlineElement=function()
2063 {
2064
2065 return '<div class="rednao_label_container"><label class="rednao_control_label" >'+this.Options.Label+'</label></div>\
2066 <div class="redNaoControls">\
2067 <input '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'" type="text" placeholder="'+this.Options.Placeholder+'" class="redNaoInputText redNaoEmail'+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'">'
2068 '</div>';
2069 }
2070
2071
2072 RedNaoEmail.prototype.GetValueString=function()
2073 {
2074 return {value:rnJQuery('#'+this.Id+ ' .redNaoEmail').val()};
2075 }
2076
2077 RedNaoEmail.prototype.GetValuePath=function()
2078 {
2079 return 'formData.'+this.Id+'.value';
2080 }
2081
2082
2083 RedNaoEmail.prototype.IsValid=function()
2084 {
2085 var email=rnJQuery('#'+this.Id+ ' .redNaoEmail').val();
2086 if(email==""&&this.Options.IsRequired=='y')
2087 {
2088 rnJQuery('#'+this.Id).find('.redNaoInputText,.redNaoRealCheckBox,.redNaoInputRadio,.redNaoInputCheckBox,.redNaoSelect,.redNaoTextArea').addClass('redNaoInvalid');
2089 return false;
2090 }
2091
2092 var reg=/^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/;
2093 if(email!=''&&!reg.test(email))
2094 {
2095 rnJQuery('#'+this.Id).find('.redNaoInputText,.redNaoRealCheckBox,.redNaoInputRadio,.redNaoInputCheckBox,.redNaoSelect,.redNaoTextArea').addClass('redNaoInvalid');
2096 return false;
2097 }
2098
2099 return true;
2100 }
2101
2102 RedNaoEmail.prototype.GenerationCompleted=function()
2103 {
2104 var self=this;
2105 rnJQuery('#'+this.Id+ ' .redNaoEmail').change(function(){self.FirePropertyChanged(self.GetValueString());});
2106 }
2107
2108
2109 /************************************************************************************* Number Element ***************************************************************************************************/
2110
2111 function RedNaoNumber(options)
2112 {
2113 FormElementBase.call(this,options);
2114 this.Title="Text Input";
2115 if(this.IsNew)
2116 {
2117 this.Options.ClassName="rednaonumber";
2118 this.Options.Label="Number";
2119 this.Options.Placeholder="Placeholder"
2120 this.Options.NumberOfDecimals=0;
2121 }
2122
2123
2124
2125
2126
2127 }
2128
2129 RedNaoNumber.prototype=Object.create(FormElementBase.prototype);
2130
2131 RedNaoNumber.prototype.CreateProperties=function()
2132 {
2133 this.Properties.push(new IdProperty(this,this.Options));
2134 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
2135 this.Properties.push(new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic'}));
2136 //this.Properties.push(new SimpleTextProperty(this,this.Options,"NumberOfDecimals","Number of decimals",{ManipulatorType:'basic'}));
2137 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
2138
2139 }
2140
2141 RedNaoNumber.prototype.GenerateInlineElement=function()
2142 {
2143
2144 return '<div class="rednao_label_container"><label class="rednao_control_label" >'+this.Options.Label+'</label></div>\
2145 <div class="redNaoControls">\
2146 <input '+(this.Options.ReadOnly=='y'?'disabled="disabled"':"")+' name="'+this.GetPropertyName()+'" type="text" placeholder="'+this.Options.Placeholder+'" class="redNaoInputText redNaoNumber'+(this.Options.ReadOnly=='y'?'redNaoDisabledElement':"")+'">'
2147 '</div>';
2148 }
2149
2150
2151 RedNaoNumber.prototype.GetValueString=function()
2152 {
2153 return {value:rnJQuery('#'+this.Id+ ' .redNaoNumber').val()};
2154 }
2155
2156 RedNaoNumber.prototype.GetValuePath=function()
2157 {
2158 return 'formData.'+this.Id+'.value';
2159 }
2160
2161
2162 RedNaoNumber.prototype.IsValid=function()
2163 {
2164 var number=rnJQuery('#'+this.Id+ ' .redNaoNumber').val();
2165 if(number==""&&this.Options.IsRequired=='y')
2166 {
2167 rnJQuery('#'+this.Id).find('.redNaoInputText,.redNaoRealCheckBox,.redNaoInputRadio,.redNaoInputCheckBox,.redNaoSelect,.redNaoTextArea').addClass('redNaoInvalid');
2168 return false;
2169 }
2170 return true;
2171 }
2172
2173 RedNaoNumber.prototype.GenerationCompleted=function()
2174 {
2175 var self=this;
2176 rnJQuery('#'+this.Id+ ' .redNaoNumber').change(function(){self.FirePropertyChanged(self.GetValueString());});
2177 rnJQuery('#'+this.Id+ ' .redNaoNumber').ForceNumericOnly();
2178 }
2179
2180
2181 /************************************************************************************* Recaptcha Element ***************************************************************************************************/
2182
2183 function RedNaoCaptcha(options)
2184 {
2185 FormElementBase.call(this,options);
2186 this.Title="captcha";
2187 if(this.IsNew)
2188 {
2189 this.Options.ClassName="rednaocaptcha";
2190 this.Options.Label="Captcha";
2191 this.Options.Theme="red";
2192 }
2193
2194 this.Options.Id="captcha";
2195 this.Id="captcha";
2196
2197
2198
2199 }
2200
2201 RedNaoCaptcha.prototype=Object.create(FormElementBase.prototype);
2202
2203 RedNaoCaptcha.prototype.CreateProperties=function()
2204 {
2205 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
2206
2207 }
2208
2209 RedNaoCaptcha.prototype.GenerateInlineElement=function()
2210 {
2211
2212 return '<div class="rednao_label_container"><label class="rednao_control_label" >'+this.Options.Label+'</label></div>\
2213 <div class="redNaoControls redNaoCaptcha" id="captchaComponent">\
2214 </div>';
2215 }
2216 RedNaoCaptcha.prototype.StoresInformation=function()
2217 {
2218 return false;
2219 }
2220
2221
2222 RedNaoCaptcha.prototype.GenerationCompleted=function()
2223 {
2224 var self=this;
2225 rnJQuery.getScript("http://www.google.com/recaptcha/api/js/recaptcha_ajax.js", function(){
2226 Recaptcha.create("6Lf2J-wSAAAAACCijq50oACQRuvrsmNt9DeUsE-7",
2227 'captchaComponent',
2228 {
2229 theme: "red",
2230 callback: Recaptcha.focus_response_field
2231 }
2232 );
2233 });
2234 }