PluginProbe
Smart Forms – when you need more than just a contact form / 0.5
Smart Forms – when you need more than just a contact form v0.5
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.5, at js/formBuilder/formelements.js

1,471 lines 46.1 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
80 }
81
82
83
84 function RedNaoCreateFormElementByOptions(options)
85 {
86 var element=RedNaoCreateFormElementByName(options.ClassName,options);
87 return element;
88
89 }
90
91
92
93 /************************************************************************************* Base Class ***************************************************************************************************/
94 function FormElementBase(options)
95 {
96 if(options==null)
97 {
98 this.Options=new Object();
99 this.Options.Styles=new Object();
100 this.Options.ClassName="";
101 this.Options.IsRequired='n';
102 this.Options.Formulas={};
103
104 FormElementBase.IdCounter++;
105 this.Id='rnField'+FormElementBase.IdCounter;
106 while(!SmartFormsFieldIsAvailable(this.Id))
107 {
108 FormElementBase.IdCounter++;
109 this.Id='rnField'+FormElementBase.IdCounter;
110 }
111
112 this.Options.Id=this.Id;
113 this.IsNew=true;
114 this.GenerateDefaultStyle();
115 }
116 else
117 {
118 this.Id=options.Id;
119 this.IsNew=false;
120 if(typeof options.IsRequired=='undefined')
121 options.IsRequired='n';
122 this.Options=options;
123 if(typeof this.Options.Formulas=='undefined')
124 this.Options.Formulas={};
125 else{
126 if(typeof RedNaoFormulaManagerVar!='undefined')
127 for(var property in this.Options.Formulas)
128 {
129 RedNaoFormulaManagerVar.AddFormula(this,this.Options.Formulas[property]);
130 }
131 }
132
133
134 }
135 this.Properties=null;
136 this.amount=0;
137 }
138
139 FormElementBase.IdCounter=0;
140
141 FormElementBase.prototype.FirePropertyChanged=function(val){
142
143 RedNaoEventManager.Publish('formPropertyChanged',{FieldName:this.Id, Value:val});
144
145 }
146
147 FormElementBase.prototype.SetDefaultIfUndefined=function(propertyName,defaultValue)
148 {
149 if(typeof this.Options[propertyName]=='undefined')
150 this.Options[propertyName]=defaultValue;
151 }
152
153
154 FormElementBase.prototype.GenerateDefaultStyle=function()
155 {
156 }
157
158 FormElementBase.prototype.RefreshElement=function()
159 {
160 var element=rnJQuery("#"+this.Id);
161 var labelWidth=element.find('.rednao_label_container').width();
162 var controlWidth=element.find('.redNaoControls').width();
163 element.find(".rednao_label_container, .redNaoControls").remove();
164 element.append(this.GenerateInlineElement());
165 this.GenerationCompleted();
166 element.find('.rednao_label_container').width(labelWidth);
167 element.find('.redNaoControls').width(controlWidth);
168 return element;
169 }
170 FormElementBase.prototype.GenerateHtml=function(jqueryElement)
171 {
172 var newElement=rnJQuery('<div class="rednao-control-group '+this.Options.ClassName+'" id="'+this.Id+'" style="margin-bottom:15px;clear:both;">'+this.GenerateInlineElement()+'</div>')
173 jqueryElement.replaceWith(newElement );
174 this.ApplyStyle();
175 this.GenerationCompleted();
176 return newElement;
177
178 }
179
180 FormElementBase.prototype.AppendElementToContainer=function(jqueryElement)
181 {
182 this.JQueryElement=rnJQuery( '<div class="rednao-control-group '+this.Options.ClassName+'" id="'+this.Id+'" style="margin-bottom:15px;">'+this.GenerateInlineElement()+'</div>');
183 jqueryElement.append(this.JQueryElement);
184 this.ApplyStyle();
185 this.GenerationCompleted();
186
187 }
188
189 FormElementBase.prototype.StoresInformation=function()
190 {
191 return true;
192 }
193
194
195 FormElementBase.prototype.CreateProperties=function()
196 {
197 throw 'Abstract method';
198 }
199
200 FormElementBase.prototype.GenerateInlineElement=function()
201 {
202 throw 'Abstract method';
203 }
204
205 FormElementBase.prototype.GetProperties=function()
206 {
207 if(this.Properties==null)
208 {
209 this.Properties=new Array();
210 this.CreateProperties();
211 }
212
213 return this.Properties;
214 }
215
216
217 FormElementBase.prototype.UpdateProperties=function()
218 {
219 if(this.Properties!=null)
220 {
221 for(var i=0;i<this.Properties.length;i++)
222 {
223 this.Properties[i].UpdateProperty();
224 }
225 }
226 }
227
228 FormElementBase.prototype.GetPropertyName=function()
229 {
230 return RedNaoFormElementEscape(this.Options.Label);
231 }
232
233
234
235 FormElementBase.prototype.ApplyStyle=function()
236 {
237 if(this.Options.Styles==null)
238 return;
239
240 for(var property in this.Options.Styles)
241 {
242
243 rnJQuery('#'+this.Id + ' .'+property).attr("style",this.Options.Styles[property]);
244 }
245 }
246
247
248 FormElementBase.prototype.GeneratePropertiesHtml=function(jQueryObject)
249 {
250 var properties=this.GetProperties();
251
252 for(var i=0;i<properties.length;i++)
253 {
254 properties[i].CreateProperty(jQueryObject);
255 }
256 }
257
258
259 FormElementBase.prototype.GetValueString=function()
260 {
261
262 }
263
264 FormElementBase.prototype.GenerationCompleted=function()
265 {
266
267 }
268
269 FormElementBase.prototype.IsValid=function()
270 {
271 return true;
272 }
273
274 FormElementBase.prototype.Clone=function()
275 {
276 var newObject= jQuery.extend(true, {}, this);
277 FormElementBase.IdCounter++;
278 newObject.Id='rnField'+FormElementBase.IdCounter;
279
280 newObject.Properties=[];
281 newObject.CreateProperties();
282
283 return newObject;
284 }
285
286 FormElementBase.prototype.GetValuePath=function()
287 {
288 return '';
289 }
290
291 /************************************************************************************* Title Element ***************************************************************************************************/
292
293 function TitleElement(options)
294 {
295 FormElementBase.call(this,options);
296
297
298
299 this.Title="Title";
300
301 if(this.IsNew)
302 {
303 this.Options.ClassName="rednaotitle";
304 this.Options.Title="Title";
305 }
306 }
307
308 TitleElement.prototype=Object.create(FormElementBase.prototype);
309
310 TitleElement.prototype.CreateProperties=function()
311 {
312
313 this.Properties.push(new SimpleTextProperty(this,this.Options,"Title","Title",'basic'));
314 }
315
316 TitleElement.prototype.GenerateInlineElement=function()
317 {
318 return '<legend class="redNaoLegend">'+this.Options.Title+'</legend>';
319 }
320
321
322
323
324 TitleElement.prototype.GetValueString=function()
325 {
326 return '';
327
328 }
329
330 TitleElement.prototype.StoresInformation=function()
331 {
332 return false;
333 }
334
335 /************************************************************************************* Text Element ***************************************************************************************************/
336
337 function TextInputElement(options)
338 {
339 FormElementBase.call(this,options);
340 this.Title="Text Input";
341 if(this.IsNew)
342 {
343 this.Options.ClassName="rednaotextinput";
344 this.Options.Label="Text Input";
345 this.Options.Placeholder="Placeholder";
346 this.Options.Value="";
347 this.Options.ReadOnly='n'
348 this.Options.Width="";
349 }else{
350 this.SetDefaultIfUndefined('Value','');
351 this.SetDefaultIfUndefined('ReadOnly','n');
352 this.SetDefaultIfUndefined('Width','');
353
354 }
355
356
357
358
359
360 }
361
362 TextInputElement.prototype=Object.create(FormElementBase.prototype);
363
364 TextInputElement.prototype.CreateProperties=function()
365 {
366 this.Properties.push(new IdProperty(this,this.Options));
367 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
368 this.Properties.push(new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic'}));
369 this.Properties.push(new SimpleTextProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}));
370 this.Properties.push(new SimpleTextProperty(this,this.Options,"Value","Value",{ManipulatorType:'basic',RefreshFormData:true}));
371 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
372 this.Properties.push(new CheckBoxProperty(this,this.Options,"ReadOnly","Read Only",{ManipulatorType:'basic'}));
373
374 }
375
376 TextInputElement.prototype.GenerateInlineElement=function()
377 {
378 var additionalStyle='';
379 if(!isNaN(parseFloat(this.Options.Width)))
380 additionalStyle='width:'+this.Options.Width+'px'+' !important;'
381
382 return '<div class="rednao_label_container"><label class="rednao_control_label" >'+this.Options.Label+'</label></div>\
383 <div class="redNaoControls">\
384 <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+'">'
385 '</div>';
386 }
387
388
389 TextInputElement.prototype.GetValueString=function()
390 {
391 return {value:rnJQuery('#'+this.Id+ ' .redNaoInputText').val()};
392 }
393
394 TextInputElement.prototype.GetValuePath=function()
395 {
396 return 'formData.'+this.Id+'.value';
397 }
398
399
400 TextInputElement.prototype.IsValid=function()
401 {
402 return rnJQuery('#'+this.Id+ ' .redNaoInputText').val()!="";
403 }
404
405 TextInputElement.prototype.GenerationCompleted=function()
406 {
407 var self=this;
408 rnJQuery('#'+this.Id+ ' .redNaoInputText').change(function(){self.FirePropertyChanged(self.GetValueString());});
409 }
410
411 /************************************************************************************* Donation Amount ***************************************************************************************************/
412
413 function DonationAmountElement(options)
414 {
415 FormElementBase.call(this,options);
416 this.Title="Donation Amount";
417
418 if(this.IsNew)
419 {
420 this.Options.ClassName="rednaodonationamount";
421 this.Options.Label="Donation Amount";
422 this.Options.Placeholder="Amount";
423 this.Options.DefaultValue=0;
424 this.Options.Disabled='n';
425 }
426
427 if(typeof this.Options.DefaultValue=='undefined')
428 this.Options.DefaultValue=0;
429
430
431
432
433
434 }
435
436 DonationAmountElement.prototype=Object.create(FormElementBase.prototype);
437
438 DonationAmountElement.prototype.CreateProperties=function()
439 {
440 this.Properties.push(new IdProperty(this,this.Options));
441 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
442 this.Properties.push(new SimpleTextProperty(this,this.Options,"DefaultValue","Default Value",{ManipulatorType:'basic'}));
443
444 this.Properties.push(new SimpleTextProperty(this,this.Options.Styles,"width","Width",{ManipulatorType:'style',class:'redNaoInputText'}));
445 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
446 this.Properties.push(new CheckBoxProperty(this,this.Options,"Disabled","Read Only",{ManipulatorType:'basic'}));
447
448
449
450 }
451
452 DonationAmountElement.prototype.GenerateInlineElement=function()
453 {
454
455 return '<div class="rednao_label_container"><label class="rednao_control_label" >'+this.Options.Label+'</label></div>\
456 <div class="redNaoControls">\
457 <input type="text" placeholder="'+this.Options.Placeholder+'" class="redNaoInputText" value="'+this.Options.DefaultValue+'" >'+
458 '</div>';
459 }
460
461
462
463 DonationAmountElement.prototype.GetValueString=function()
464 {
465 try
466 {
467 this.amount=parseFloat(rnJQuery('#'+this.Id+ ' .redNaoInputText').val());
468 }catch(exception)
469 {
470
471 }
472
473 return encodeURI(this.Options.Label)+"="+encodeURI(rnJQuery('#'+this.Id+ ' .redNaoInputText').val());
474 }
475
476 DonationAmountElement.prototype.GenerationCompleted=function()
477 {
478 if(this.Options.Disabled=='y')
479 {
480 rnJQuery('#'+this.Id).find('.redNaoInputText').attr('readonly','readonly').css('background-color','#eeeeee');
481 }
482 }
483
484 DonationAmountElement.prototype.IsValid=function()
485 {
486 try{
487 var number=parseFloat(rnJQuery('#'+this.Id+ ' .redNaoInputText').val());
488 return number>0;
489 }catch(exception)
490 {
491 return false;
492 }
493 }
494
495 /************************************************************************************* Prepend Text Element ***************************************************************************************************/
496
497 function PrependTexElement(options)
498 {
499 FormElementBase.call(this,options);
500 this.Title="Prepend Text";
501
502 if(this.IsNew)
503 {
504 this.Options.Label="Prepend Text";
505 this.Options.ClassName="rednaoprependedtext";
506 this.Options.Placeholder="Placeholder";
507 this.Options.Prepend="Prepend";
508 this.Options.Value='';
509 this.Options.Checked='y';
510 this.Options.Width='';
511 }else{
512 this.SetDefaultIfUndefined('Value','');
513 this.SetDefaultIfUndefined('Width','');
514
515 }
516
517
518
519 }
520
521 PrependTexElement.prototype=Object.create(FormElementBase.prototype);
522
523 PrependTexElement.prototype.CreateProperties=function()
524 {
525 this.Properties.push(new IdProperty(this,this.Options));
526 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
527 this.Properties.push(new SimpleTextProperty(this,this.Options,"Prepend","Prepend",{ManipulatorType:'basic'}));
528 this.Properties.push(new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic'}));
529 this.Properties.push(new SimpleTextProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}));
530 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
531 this.Properties.push(new SimpleTextProperty(this,this.Options,"Value","Value",{ManipulatorType:'basic',RefreshFormData:true}));
532
533 }
534
535 PrependTexElement.prototype.GenerateInlineElement=function()
536 {
537 var additionalStyle='';
538 if(!isNaN(parseFloat(this.Options.Width)))
539 additionalStyle='width:'+this.Options.Width+'px'+' !important;'
540
541
542 return '<div class="rednao_label_container"><label class="rednao_control_label" for="prependedtext">'+this.Options.Label+'</label></div>\
543 <div class="redNaoControls">\
544 <div class="rednao-input-prepend">\
545 <span class="redNaoPrepend">'+this.Options.Prepend+'</span>\
546 <input style="'+additionalStyle+'" id="prependedtext" name="prependedtext" class="redNaoInputText" placeholder="'+this.Options.Placeholder+'" type="text" value="'+this.Options.Value+'">\
547 </div>\
548 </div>';
549 }
550
551
552
553
554 PrependTexElement.prototype.GetValueString=function()
555 {
556 return {value:rnJQuery('#'+this.Id+ ' .redNaoInputText').val()};
557 }
558
559 PrependTexElement.prototype.GetValuePath=function()
560 {
561 return 'formData.'+this.Id+'.value';
562 }
563
564
565 PrependTexElement.prototype.IsValid=function()
566 {
567 return rnJQuery('#'+this.Id+ ' .redNaoInputText').val()!="";
568 }
569
570 PrependTexElement.prototype.GenerationCompleted=function()
571 {
572 var self=this;
573 rnJQuery('#'+this.Id+ ' .redNaoInputText').change(function(){self.FirePropertyChanged(self.GetValueString());});
574 }
575
576 /************************************************************************************* Appended Text Element ***************************************************************************************************/
577
578 function AppendedTexElement(options)
579 {
580 FormElementBase.call(this,options);
581 this.Title="Appended Text";
582
583 if(this.IsNew)
584 {
585 this.Options.Label="Appended Text";
586 this.Options.ClassName="rednaoappendedtext";
587 this.Options.Placeholder="Placeholder";
588 this.Options.Append="Append";
589 this.Options.Value="";
590 this.Options.Width='';
591 }else{
592 this.SetDefaultIfUndefined('Value','');
593 this.SetDefaultIfUndefined('Width','');
594
595 }
596
597
598
599
600 }
601
602 AppendedTexElement.prototype=Object.create(FormElementBase.prototype);
603
604 AppendedTexElement.prototype.CreateProperties=function()
605 {
606 this.Properties.push(new IdProperty(this,this.Options));
607 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
608 this.Properties.push(new SimpleTextProperty(this,this.Options,"Append","Append",{ManipulatorType:'basic'}));
609 this.Properties.push(new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic'}));
610 this.Properties.push(new SimpleTextProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}));
611 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
612 this.Properties.push(new SimpleTextProperty(this,this.Options,"Value","Value",{ManipulatorType:'basic',RefreshFormData:true}));
613
614 }
615
616 AppendedTexElement.prototype.GenerateInlineElement=function()
617 {
618 var additionalStyle='';
619 if(!isNaN(parseFloat(this.Options.Width)))
620 additionalStyle='width:'+this.Options.Width+'px'+' !important;'
621
622
623 return '<div class="rednao_label_container"><label class="rednao_control_label" for="appendedtext">'+this.Options.Label+'</label></div>\
624 <div class="redNaoControls">\
625 <div class="rednao-input-append">\
626 <input style="'+additionalStyle+'" id="appendedtext" name="appendedtext" placeholder="'+this.Options.Placeholder+'" type="text" class="redNaoInputText" value="'+this.Options.Value+'">\
627 <span class="redNaoAppend">'+this.Options.Append+'</span>\
628 </div>\
629 </div>';
630
631
632 }
633
634
635
636
637 AppendedTexElement.prototype.GetValueString=function()
638 {
639 return {value:rnJQuery('#'+this.Id+ ' .redNaoInputText').val()};
640 }
641
642 AppendedTexElement.prototype.GetValuePath=function()
643 {
644 return 'formData.'+this.Id+'.value';
645 }
646
647 AppendedTexElement.prototype.IsValid=function()
648 {
649 return rnJQuery('#'+this.Id+ ' .redNaoInputText').val()!="";
650 }
651
652 PrependTexElement.prototype.GenerationCompleted=function()
653 {
654 var self=this;
655 rnJQuery('#'+this.Id+ ' .redNaoInputText').change(function(){self.FirePropertyChanged(self.GetValueString());});
656 }
657
658
659 /************************************************************************************* Prepend Checkbox Element ***************************************************************************************************/
660
661 function PrependCheckBoxElement(options)
662 {
663 FormElementBase.call(this,options);
664 this.Title="Prepend Checkbox";
665
666 if(this.IsNew)
667 {
668 this.Options.Label="Prepend Checkbox";
669 this.Options.ClassName="rednaoprependedcheckbox";
670 this.Options.Placeholder="Placeholder";
671 this.Options.IsChecked='n';
672 this.Options.Value="";
673 this.Options.Width='';
674 }else{
675 this.SetDefaultIfUndefined('Value','');
676 this.SetDefaultIfUndefined('Width','');
677
678 }
679
680
681
682 }
683
684 PrependCheckBoxElement.prototype=Object.create(FormElementBase.prototype);
685
686 PrependCheckBoxElement.prototype.CreateProperties=function()
687 {
688 this.Properties.push(new IdProperty(this,this.Options));
689 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
690 this.Properties.push(new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic'}));
691 this.Properties.push(new SimpleTextProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}));
692 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsChecked","Is Checked",{ManipulatorType:'basic'}));
693 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
694 this.Properties.push(new SimpleTextProperty(this,this.Options,"Value","Value",{ManipulatorType:'basic',RefreshFormData:true}));
695
696 }
697
698 PrependCheckBoxElement.prototype.GenerateInlineElement=function()
699 {
700 var additionalStyle='';
701 if(!isNaN(parseFloat(this.Options.Width)))
702 additionalStyle='width:'+this.Options.Width+'px'+' !important;'
703
704
705 return '<div class="rednao_label_container"><label class="rednao_control_label" for="prependedcheckbox">'+this.Options.Label+'</label></div>\
706 <div class="redNaoControls">\
707 <div class="input-prepend">\
708 <span class="redNaoPrepend">\
709 <label class="rednao_checkbox">\
710 <input type="checkbox" class="redNaoRealCheckBox" '+(this.Options.IsChecked=='y'? 'checked="checked"':'')+'/>\
711 </label>\
712 </span>\
713 <input style="'+additionalStyle+'" id="prependedcheckbox" name="prependedcheckbox" class="redNaoInputText" type="text" placeholder="'+this.Options.Placeholder+'" value="'+this.Options.Value+'"/>\
714 </div>\
715 </div>';
716
717
718 }
719
720
721
722 PrependCheckBoxElement.prototype.GetValueString=function()
723 {
724 return {checked:(rnJQuery('#'+this.Id).find('.redNaoRealCheckBox').is(':checked')?'Yes':'No'),value:rnJQuery('#'+this.Id+ ' .redNaoInputText').val()};
725 }
726
727 PrependCheckBoxElement.prototype.GetValuePath=function()
728 {
729 return 'formData.'+this.Id+'.value';
730 }
731
732
733 PrependCheckBoxElement.prototype.IsValid=function()
734 {
735 return rnJQuery('#'+this.Id+ ' .redNaoInputText').val()!="";
736 }
737
738 PrependCheckBoxElement.prototype.GenerationCompleted=function()
739 {
740 var self=this;
741 rnJQuery('#'+this.Id+ ' .redNaoInputText','#'+this.Id+' .redNaoRealCheckBox').change(function(){self.FirePropertyChanged(self.GetValueString());});
742 }
743 /************************************************************************************* Append Checkbox Element ***************************************************************************************************/
744
745 function AppendCheckBoxElement(options)
746 {
747 FormElementBase.call(this,options);
748 this.Title="Append Checkbox";
749
750 if(this.IsNew)
751 {
752 this.Options.Label="Append Checkbox";
753 this.Options.ClassName="rednaoappendedcheckbox";
754 this.Options.Placeholder="Placeholder";
755 this.Options.IsChecked='n';
756 this.Options.Value="";
757 this.Options.Width='';
758 }else{
759 this.SetDefaultIfUndefined('Value','');
760 this.SetDefaultIfUndefined('Width','');
761
762 }
763
764
765
766 }
767
768 AppendCheckBoxElement.prototype=Object.create(FormElementBase.prototype);
769
770 AppendCheckBoxElement.prototype.CreateProperties=function()
771 {
772 this.Properties.push(new IdProperty(this,this.Options));
773 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
774 this.Properties.push(new SimpleTextProperty(this,this.Options,"Placeholder","Placeholder",{ManipulatorType:'basic'}));
775 this.Properties.push(new SimpleTextProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}));
776 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsChecked","Is Checked",{ManipulatorType:'basic'}));
777 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
778 this.Properties.push(new SimpleTextProperty(this,this.Options,"Value","Value",{ManipulatorType:'basic',RefreshFormData:true}));
779
780 }
781
782 AppendCheckBoxElement.prototype.GenerateInlineElement=function()
783 {
784 var additionalStyle='';
785 if(!isNaN(parseFloat(this.Options.Width)))
786 additionalStyle='width:'+this.Options.Width+'px'+' !important;'
787
788
789 return '<div class="rednao_label_container"><label class="rednao_control_label" for="appendedcheckbox">'+this.Options.Label+'</label></div>\
790 <div class="redNaoControls">\
791 <div class="rednao-input-append">\
792 <input style="'+additionalStyle+'" id="appendedcheckbox" class="redNaoInputText" name="appendedcheckbox" class="span2" type="text" placeholder="'+this.Options.Placeholder+'" value="'+this.Options.Value+'"/>\
793 <span class="redNaoAppend">\
794 <input type="checkbox" class="redNaoRealCheckBox" '+(this.Options.IsChecked=='y'? 'checked="checked"':'')+'/>\
795 </span>\
796 </div>\
797 </div>';
798
799
800 }
801
802
803
804 AppendCheckBoxElement.prototype.GetValueString=function()
805 {
806 return {checked:(rnJQuery('#'+this.Id).find('.redNaoRealCheckBox').is(':checked')?'Yes':'No'),value:rnJQuery('#'+this.Id+ ' .redNaoInputText').val()};
807 }
808
809 AppendCheckBoxElement.prototype.GetValuePath=function()
810 {
811 return 'formData.'+this.Id+'.value';
812 }
813
814 AppendCheckBoxElement.prototype.IsValid=function()
815 {
816 return rnJQuery('#'+this.Id+ ' .redNaoInputText').val()!="";
817 }
818
819 AppendCheckBoxElement.prototype.GenerationCompleted=function()
820 {
821 var self=this;
822 rnJQuery('#'+this.Id+ ' .redNaoInputText','#'+this.Id+' .redNaoRealCheckBox').change(function(){self.FirePropertyChanged(self.GetValueString());});
823 }
824 /************************************************************************************* Text Area Element ***************************************************************************************************/
825
826 function TextAreaElement(options)
827 {
828 FormElementBase.call(this,options);
829 this.Title="Text Area";
830
831 if(this.IsNew)
832 {
833 this.Options.Label="Text Area";
834 this.Options.DefaultText="Default Text";
835 this.Options.ClassName="rednaotextarea";
836 this.Options.Value="";
837 this.Options.Width='';
838 this.Options.Height=''
839 }else{
840 this.SetDefaultIfUndefined('Value','');
841 this.SetDefaultIfUndefined('Width','');
842 this.SetDefaultIfUndefined('Height','');
843
844 }
845
846
847 }
848
849 TextAreaElement.prototype=Object.create(FormElementBase.prototype);
850
851 TextAreaElement.prototype.CreateProperties=function()
852 {
853 this.Properties.push(new IdProperty(this,this.Options));
854 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
855 this.Properties.push(new SimpleTextProperty(this,this.Options,"DefaultText","Value",{ManipulatorType:'basic',RefreshFormData:true}));
856 this.Properties.push(new SimpleTextProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}));
857 this.Properties.push(new SimpleTextProperty(this,this.Options,"Height","Height",{ManipulatorType:'basic'}));
858 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
859
860
861
862 }
863
864 TextAreaElement.prototype.GenerateInlineElement=function()
865 {
866 var additionalStyle='';
867 if(!isNaN(parseFloat(this.Options.Width)))
868 additionalStyle='width:'+this.Options.Width+'px'+' !important;'
869
870 if(!isNaN(parseFloat(this.Options.Height)))
871 additionalStyle+='height:'+this.Options.Height+'px'+' !important;'
872
873
874 return '<div class="rednao_label_container"><label class="rednao_control_label" for="textarea">'+this.Options.Label+'</label></div>\
875 <div class="redNaoControls">\
876 <textarea style="'+additionalStyle+'" name="textarea" class="redNaoTextArea">'+this.Options.DefaultText+'</textarea>\
877 </div>';
878 }
879
880
881
882 TextAreaElement.prototype.GetValueString=function()
883 {
884 return {value:rnJQuery('#'+this.Id+ ' .redNaoTextArea').val()};
885 }
886
887 TextAreaElement.prototype.GetValuePath=function()
888 {
889 return 'formData.'+this.Id+'.value';
890 }
891
892
893 TextAreaElement.prototype.IsValid=function()
894 {
895 return rnJQuery('#'+this.Id+ ' .redNaoTextArea').val()!=this.Options.DefaultText;
896 }
897
898 TextAreaElement.prototype.GenerationCompleted=function()
899 {
900 var self=this;
901 rnJQuery('#'+this.Id+ ' .redNaoTextArea').change(function(){self.FirePropertyChanged(self.GetValueString());});
902 }
903
904 /*************************************************************************************Multiple Radio Element ***************************************************************************************************/
905
906 function MultipleRadioElement(options)
907 {
908 FormElementBase.call(this,options);
909 this.Title="Multiple Radio";
910
911 if(this.IsNew)
912 {
913 this.Options.Label="Multiple Radio";
914 this.Options.ClassName="rednaomultipleradios";
915 this.Options.Options=new Array({label:'Option 1',value:0},{label:'Option 2',value:0},{label:'Option 3',value:0});
916 }else
917 {
918 if(this.Options.Options.length>0&&typeof this.Options.Options[i]=='string')
919 {
920 var aux=new Array();
921 for(var i=0;i<this.Options.Options.length;i++)
922 {
923 aux.push({label:this.Options.Options[i]});
924 }
925
926 this.Options.Options=aux;
927 }
928 }
929
930
931 }
932
933 MultipleRadioElement.prototype=Object.create(FormElementBase.prototype);
934
935 MultipleRadioElement.prototype.CreateProperties=function()
936 {
937 this.Properties.push(new IdProperty(this,this.Options));
938 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
939 this.Properties.push(new ArrayProperty(this,this.Options,"Options","Options",{ManipulatorType:'basic'}));
940 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
941
942
943
944 }
945
946 MultipleRadioElement.prototype.GenerateInlineElement=function()
947 {
948
949 var html= '<div class="rednao_label_container"><label class="rednao_control_label">'+this.Options.Label+'</label></div>\
950 <div class="redNaoControls">';
951
952 var checked='checked="checked"';
953 for(var i=0;i<this.Options.Options.length;i++)
954 {
955 html+='<label class="redNaoRadio" for="radios-0">\
956 <input class="redNaoInputRadio" type="radio" name="'+this.GetPropertyName()+'" value="'+this.Options.Options[i].value+'" '+checked+'>'+rnJQuery.trim(this.Options.Options[i].label)+'</input>\
957 </label>';
958
959 checked="";
960
961 }
962
963 html+='</div>';
964 return html;
965 }
966
967
968
969
970
971 MultipleRadioElement.prototype.GetValueString=function()
972 {
973 var jQueryElement=rnJQuery('#'+this.Id).find(':checked');
974 if(jQueryElement.length>0)
975 this.amount=parseFloat(jQueryElement.val());
976 if(isNaN(this.amount))
977 this.amount=0;
978 return {value:rnJQuery.trim(jQueryElement.parent().text()),amount:this.amount};
979 }
980
981
982 MultipleRadioElement.prototype.GetValuePath=function()
983 {
984 return 'formData.'+this.Id+'.amount';
985 }
986
987
988 MultipleRadioElement.prototype.IsValid=function()
989 {
990 return rnJQuery('#'+this.Id).find(':checked').length>0;
991 }
992
993 MultipleRadioElement.prototype.GenerationCompleted=function()
994 {
995 var self=this;
996 rnJQuery('#'+this.Id+ ' .redNaoInputRadio').change(function(){self.FirePropertyChanged(self.GetValueString());});
997 }
998
999 /*************************************************************************************Multiple Checkbox Element ***************************************************************************************************/
1000
1001 function MultipleCheckBoxElement(options)
1002 {
1003 FormElementBase.call(this,options);
1004 this.Title="Multiple Checkboxes";
1005
1006 if(this.IsNew)
1007 {
1008 this.Options.Label="Multiple Checkbox";
1009 this.Options.ClassName="rednaomultiplecheckboxes";
1010 this.Options.Options=new Array({label:'Check 1',value:0},{label:'Check 2',value:0},{label:'Check 3',value:0});
1011 }else
1012 {
1013 if(this.Options.Options.length>0&&typeof this.Options.Options[i]=='string')
1014 {
1015 var aux=new Array();
1016 for(var i=0;i<this.Options.Options.length;i++)
1017 {
1018 aux.push({label:this.Options.Options[i]});
1019 }
1020
1021 this.Options.Options=aux;
1022 }
1023 }
1024
1025
1026 }
1027
1028 MultipleCheckBoxElement.prototype=Object.create(FormElementBase.prototype);
1029
1030 MultipleCheckBoxElement.prototype.CreateProperties=function()
1031 {
1032 this.Properties.push(new IdProperty(this,this.Options));
1033 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
1034 this.Properties.push(new ArrayProperty(this,this.Options,"Options","Options",{ManipulatorType:'basic'}));
1035 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
1036
1037
1038 }
1039
1040 MultipleCheckBoxElement.prototype.GenerateInlineElement=function()
1041 {
1042
1043 var html= '<div class="rednao_label_container"><label class="rednao_control_label">'+this.Options.Label+'</label></div>\
1044 <div class="redNaoControls">';
1045
1046 var checked='checked=checked';
1047 for(var i=0;i<this.Options.Options.length;i++)
1048 {
1049 html+='<label class="redNaoCheckBox" for="radios-0">\
1050 <input type="checkbox" class="redNaoInputCheckBox" name="'+this.GetPropertyName()+'" value="'+this.Options.Options[i].value+'" '+checked+'/>'+this.Options.Options[i].label+'\
1051 </label>';
1052
1053 checked="";
1054
1055 }
1056
1057 html+='</div>';
1058 return html;
1059 }
1060
1061
1062
1063
1064
1065
1066 MultipleCheckBoxElement.prototype.GetValueString=function()
1067 {
1068 var valueString="";
1069 var me=this;
1070 this.amount=0;
1071 var jQueryElement=rnJQuery('#'+this.Id).find(':checked');
1072 var data={};
1073 data.selectedValues=[];
1074 if(jQueryElement.length>0)
1075 {
1076 for(var i=0;i<jQueryElement.length;i++)
1077 {
1078 if(jQueryElement.length>0)
1079 this.amount=parseFloat(rnJQuery(jQueryElement[i]).val());
1080 if(isNaN(this.amount))
1081 this.amount=0;
1082 data.selectedValues.push({value:rnJQuery(jQueryElement[i]).parent().text(),amount:this.amount})
1083 }
1084 }
1085
1086 return data;
1087
1088 }
1089
1090
1091 MultipleCheckBoxElement.prototype.GetValuePath=function()
1092 {
1093 return 'RedNaoGetValueFromArray(formData.'+this.Id+'.selectedValues)';
1094 }
1095
1096
1097 MultipleCheckBoxElement.prototype.IsValid=function()
1098 {
1099 return rnJQuery('#'+this.Id).find(':checked').length>0;
1100 }
1101
1102 MultipleCheckBoxElement.prototype.GenerationCompleted=function()
1103 {
1104 var self=this;
1105 rnJQuery('#'+this.Id+ ' .redNaoInputCheckBox').change(function(){self.FirePropertyChanged(self.GetValueString());});
1106 }
1107
1108
1109 /*************************************************************************************Select Basic Element ***************************************************************************************************/
1110
1111 function SelectBasicElement(options)
1112 {
1113 FormElementBase.call(this,options);
1114 this.Title="Select Basic";
1115
1116 if(this.IsNew)
1117 {
1118 this.Options.Label="Select Basic";
1119 this.Options.ClassName="rednaoselectbasic";
1120 this.Options.Options=new Array({label:'Option 1',value:0},{label:'Option 2',value:0},{label:'Option',value:0});
1121 this.SetDefaultIfUndefined('Width','');
1122
1123 }else
1124 {
1125 this.SetDefaultIfUndefined('Width','');
1126
1127 if(this.Options.Options.length>0&&typeof this.Options.Options[i]=='string')
1128 {
1129 var aux=new Array();
1130 for(var i=0;i<this.Options.Options.length;i++)
1131 {
1132 aux.push({label:this.Options.Options[i]});
1133 }
1134
1135 this.Options.Options=aux;
1136 }
1137 }
1138
1139
1140 }
1141
1142 SelectBasicElement.prototype=Object.create(FormElementBase.prototype);
1143
1144 SelectBasicElement.prototype.CreateProperties=function()
1145 {
1146 this.Properties.push(new IdProperty(this,this.Options));
1147 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
1148 this.Properties.push(new ArrayProperty(this,this.Options,"Options","Options",{ManipulatorType:'basic'}));
1149 this.Properties.push(new SimpleTextProperty(this,this.Options,"Width","Width",{ManipulatorType:'basic'}));
1150 this.Properties.push(new CheckBoxProperty(this,this.Options,"IsRequired","Required",{ManipulatorType:'basic'}));
1151
1152
1153
1154 }
1155
1156 SelectBasicElement.prototype.GenerateInlineElement=function()
1157 {
1158 var additionalStyle='';
1159 if(!isNaN(parseFloat(this.Options.Width)))
1160 additionalStyle='width:'+this.Options.Width+'px'+' !important;'
1161
1162
1163 var html= '<div class="rednao_label_container"><label class="rednao_control_label">'+this.Options.Label+'</label></div>\
1164 <div class="redNaoControls">\
1165 <select style="'+additionalStyle+'" name="'+this.GetPropertyName()+'" class="redNaoSelect">';
1166
1167 var selected='selected="selected"';
1168 for(var i=0;i<this.Options.Options.length;i++)
1169 {
1170 html+='<option value="'+this.Options.Options[i].value+'" '+selected+'>'+this.Options.Options[i].label+'</opton>'
1171
1172 selected="";
1173
1174 }
1175 html+='</select></div>';
1176 return html;
1177 }
1178
1179
1180
1181 SelectBasicElement.prototype.GetValueString=function()
1182 {
1183 var jQueryElement=rnJQuery('#'+this.Id+ ' .redNaoSelect option:selected');
1184 if(jQueryElement.length>0)
1185 this.amount=parseFloat(jQueryElement.val());
1186 if(isNaN(this.amount))
1187 this.amount=0;
1188 return {value:jQueryElement.text(),amount:this.amount};
1189 }
1190
1191 SelectBasicElement.prototype.GetValuePath=function()
1192 {
1193 return 'formData.'+this.Id+'.amount';
1194 }
1195
1196
1197 SelectBasicElement.prototype.IsValid=function()
1198 {
1199 return rnJQuery('#'+this.Id+ ' .redNaoSelect option:selected').length>0;
1200 }
1201
1202
1203 SelectBasicElement.prototype.GenerationCompleted=function()
1204 {
1205 var self=this;
1206 rnJQuery('#'+this.Id+ ' .redNaoSelect').change(function(){self.FirePropertyChanged(self.GetValueString());});
1207 }
1208
1209 /*************************************************************************************Donation Button***************************************************************************************************/
1210
1211
1212
1213 function DonationButtonElement(options)
1214 {
1215 FormElementBase.call(this,options);
1216 this.Title="Donation Button";
1217
1218 if(this.IsNew)
1219 {
1220 this.Options.Label="Donation Button";
1221 this.Options.ClassName="rednaodonationbutton";
1222 this.Options.Image='https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif';
1223 }else
1224 {
1225 if(typeof this.Options.Image=='undefined')
1226 this.Options.Image='https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif';
1227 }
1228
1229
1230 }
1231
1232 DonationButtonElement.prototype=Object.create(FormElementBase.prototype);
1233
1234 DonationButtonElement.prototype.CreateProperties=function()
1235 {
1236 this.Properties.push(new IdProperty(this,this.Options));
1237 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
1238 this.Properties.push(new SimpleTextProperty(this,this.Options.Styles,"margin-left","Spacing",{ManipulatorType:'style',class:'redNaoDonationButton'}));
1239 this.Properties.push(new SimpleTextProperty(this,this.Options.Styles,"width","Width",{ManipulatorType:'style',class:'redNaoDonationButton',default:'auto'}));
1240 this.Properties.push(new SimpleTextProperty(this,this.Options.Styles,"height","Height",{ManipulatorType:'style',class:'redNaoDonationButton',default:'auto'}));
1241 this.Properties.push(new SimpleTextProperty(this,this.Options,"Image","Image Url",{ManipulatorType:'basic'}));
1242 }
1243
1244 DonationButtonElement.prototype.GenerateInlineElement=function()
1245 {
1246 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>';
1247 }
1248
1249
1250 DonationButtonElement.prototype.GetValueString=function()
1251 {
1252 return '';
1253
1254 }
1255
1256 DonationButtonElement.prototype.StoresInformation=function()
1257 {
1258 return false;
1259 }
1260
1261
1262 /************************************************************************************* Recurrence Element ***************************************************************************************************/
1263
1264
1265
1266 function RecurrenceElement(options)
1267 {
1268 FormElementBase.call(this,options);
1269 this.Title="Donation Button";
1270
1271 if(this.IsNew)
1272 {
1273 this.Options.Label="Recurrence";
1274 this.Options.ClassName="rednaodonationrecurrence";
1275 this.Options.ShowOneTime='y';
1276 this.Options.ShowDaily='y';
1277 this.Options.ShowWeekly='y';
1278 this.Options.ShowMonthly='y';
1279 this.Options.ShowYearly='y';
1280
1281 }
1282
1283
1284 }
1285
1286 RecurrenceElement.prototype=Object.create(FormElementBase.prototype);
1287
1288 RecurrenceElement.prototype.CreateProperties=function()
1289 {
1290 this.Properties.push(new IdProperty(this,this.Options));
1291 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
1292 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowOneTime","Show one time option",{ManipulatorType:'basic'}));
1293 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowDaily","Show daily option",{ManipulatorType:'basic'}));
1294 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowWeekly","Show weekly option",{ManipulatorType:'basic'}));
1295 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowMonthly","Show monthly option",{ManipulatorType:'basic'}));
1296 this.Properties.push(new CheckBoxProperty(this,this.Options,"ShowYearly","Show yearly option",{ManipulatorType:'basic'}));
1297 }
1298
1299 RecurrenceElement.prototype.GenerateInlineElement=function()
1300 {
1301 var html= '<div class="rednao_label_container"><label class="rednao_control_label">'+this.Options.Label+'</label></div>\<div class="redNaoControls"><select class="redNaoSelect redNaoRecurrence">';
1302 var selected='selected="selected"';
1303
1304 if(this.Options.ShowOneTime=='y')
1305 {
1306 html+='<option value="OT" '+selected+'>One Time</option>';
1307 selected='';
1308 }
1309
1310 if(this.Options.ShowDaily=='y')
1311 {
1312 html+='<option value="D" '+selected+'>Daily</option>';
1313 selected='';
1314 }
1315
1316 if(this.Options.ShowWeekly=='y')
1317 {
1318 html+='<option value="W" '+selected+'>Weekly</option>';
1319 selected='';
1320 }
1321
1322 if(this.Options.ShowMonthly=='y')
1323 {
1324 html+='<option value="M" '+selected+'>Monthly</option>';
1325 selected='';
1326 }
1327
1328 if(this.Options.ShowYearly=='y')
1329 {
1330 html+='<option value="Y" '+selected+'>Yearly</option>';
1331 selected='';
1332 }
1333
1334 html+='</select></div>';
1335
1336 return html;
1337 }
1338
1339
1340
1341 RecurrenceElement.prototype.GetValueString=function()
1342 {
1343 var jQueryElement=rnJQuery('#'+this.Id+ ' .redNaoSelect option:selected');
1344 return encodeURI(this.Options.Label)+"="+encodeURI(jQueryElement.text());
1345
1346 }
1347
1348
1349
1350
1351 /************************************************************************************* Submission Button ***************************************************************************************************/
1352
1353
1354
1355 function RedNaoSubmissionButton(options)
1356 {
1357 FormElementBase.call(this,options);
1358 this.Title="Submit Button";
1359
1360 if(this.IsNew)
1361 {
1362 this.Options.ClassName="rednaosubmissionbutton";
1363 this.Options.ButtonText="Submit";
1364
1365
1366 }
1367 }
1368
1369 RedNaoSubmissionButton.prototype=Object.create(FormElementBase.prototype);
1370
1371 RedNaoSubmissionButton.prototype.CreateProperties=function()
1372 {
1373 this.Properties.push(new SimpleTextProperty(this,this.Options,"ButtonText","Button Text",{ManipulatorType:'basic'}));
1374 }
1375
1376 RedNaoSubmissionButton.prototype.GenerateInlineElement=function()
1377 {
1378 return '<div class="rednao_label_container"></div><div class="redNaoControls"><input type="submit" class="redNaoSubmitButton" value="'+this.Options.ButtonText+'" /></div>';
1379 }
1380
1381
1382 RedNaoSubmissionButton.prototype.GetValueString=function()
1383 {
1384 return '';
1385
1386 }
1387
1388 RedNaoSubmissionButton.prototype.StoresInformation=function()
1389 {
1390 return false;
1391 }
1392
1393
1394
1395 /************************************************************************************* Date Picker ***************************************************************************************************/
1396
1397
1398
1399 function RedNaoDatePicker(options)
1400 {
1401 FormElementBase.call(this,options);
1402 this.Title="Date Picker";
1403
1404 if(this.IsNew)
1405 {
1406 this.Options.ClassName="rednaodatepicker";
1407 this.Options.Label="Date";
1408 this.Options.DateFormat="MM-dd-yy";
1409 this.Options.Value='';
1410 }
1411
1412 }
1413
1414 RedNaoDatePicker.prototype=Object.create(FormElementBase.prototype);
1415
1416 RedNaoDatePicker.prototype.CreateProperties=function()
1417 {
1418 this.Properties.push(new SimpleTextProperty(this,this.Options,"Label","Label",{ManipulatorType:'basic'}));
1419 this.Properties.push(new SimpleTextProperty(this,this.Options,"DateFormat","Date Format",{ManipulatorType:'basic'}));
1420
1421 }
1422
1423 RedNaoDatePicker.prototype.GenerateInlineElement=function()
1424 {
1425 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>';
1426
1427 }
1428
1429
1430 RedNaoDatePicker.prototype.GetValueString=function()
1431 {
1432 var selectedDate= rnJQuery('#'+this.Id).find('.redNaoDatePicker').datepicker('getDate');
1433 if(selectedDate==null)
1434 selectedDate ="";
1435 else
1436 selectedDate=selectedDate.getFullYear()+'-'+(selectedDate.getMonth()+1)+'-'+selectedDate.getDate();
1437 return {value:selectedDate};
1438
1439 }
1440
1441 RedNaoDatePicker.prototype.GetValuePath=function()
1442 {
1443 return 'formData.'+this.Id+'.value';
1444 }
1445
1446
1447
1448 RedNaoDatePicker.prototype.StoresInformation=function()
1449 {
1450 return true;
1451 }
1452
1453 RedNaoDatePicker.prototype.GenerationCompleted=function()
1454 {
1455 rnJQuery('#'+this.Id).find('.redNaoDatePicker').datepicker({
1456 dateFormat:this.Options.DateFormat,
1457 beforeShow: function() {
1458 rnJQuery('#ui-datepicker-div').wrap('<div class="smartFormsSlider"></div>')
1459 },
1460 onClose: function() {
1461 rnJQuery('#ui-datepicker-div').unwrap();
1462 }
1463 });
1464
1465 var self=this;
1466 rnJQuery('#'+this.Id+ ' .redNaoDatePicker').change(function(){self.FirePropertyChanged(self.GetValueString());});
1467
1468
1469 }
1470
1471