e7cd71ae19e7d755cc036d3df9ec0621dbff7c5d
Bernd Wurst E-Mail-Modul auf JQuery umg...

Bernd Wurst authored 10 years ago

1) 
2)   function moreForward(e)
3)   {
4)     e.preventDefault();
5)     last = $('div.vmail-forward:last');
6)     last_id = parseInt(last.attr('id').match(/\d+/g));
7)     new_id = ++last_id;
8)  
9)     if (new_id > 50) {
10)       alert("Jetzt wird's merkwürdig. Bitte nutzen Sie eine Mailingliste wenn Sie so viele Empfänger brauchen!");
11)       return;
12)     }
13) 
14) 
15)     var $clone = last.clone();
16)     $clone.attr('id',$clone.attr('id').replace(/\d+$/, function(str) { return parseInt(str) + 1; }) ); 
17) 
18)     // Find all elements in $clone that have an ID, and iterate using each()
19)     $clone.find('[id]').each(function() { 
20)       //Perform the same replace as above
21)       var $th = $(this);
22)       var newID = $th.attr('id').replace(/\d+$/, function(str) { return parseInt(str) + 1; });
23)       $th.attr('id', newID);
24)     });
25)     // Find all elements in $clone that have a name, and iterate using each()
26)     $clone.find('[name]').each(function() { 
27)       //Perform the same replace as above
28)       var $th = $(this);
29)       var newName = $th.attr('name').replace(/\d+$/, function(str) { return parseInt(str) + 1; });
30)       $th.attr('name', newName);
31)     });
32) 
33)     $clone.find('input:first-of-type').val('');
34)     $clone.find('select:first-of-type')
Bernd Wurst attr() zu prop() geändert

Bernd Wurst authored 10 years ago

35)           .find('option:first-of-type').prop('selected', true);
Bernd Wurst E-Mail-Modul auf JQuery umg...

Bernd Wurst authored 10 years ago

36)     $clone.find('.warning').text('');
37)     $clone.find('.warning').hide();
38)     
39)     $clone.find('div.delete_forward').click(removeForward);
40)     $clone.find('input').on("change keyup paste", checkForward);
41)     
42)     last.after($clone);
43)   }
44) 
45)   function removeForward() 
46)   {
47)     div = $(this).closest('div.vmail-forward');
48)     input = div.find('input:first');
49)     input.val('');
50)     select = div.find('select:first');
Bernd Wurst attr() zu prop() geändert

Bernd Wurst authored 10 years ago

51)     select.find('option:first').prop('selected', true);
Bernd Wurst E-Mail-Modul auf JQuery umg...

Bernd Wurst authored 10 years ago

52)     if ($('div.vmail-forward').length > 1) {
53)       div.remove();
54)     }
55)   }
56) 
57) 
58)   function removeUnneededForwards() {
59)     // Alle <div> nach dem Element mit der ID vmail_forward_1...
60)     $('div#vmail_forward_1 ~ div').each( function (el) {
61)       // ... die leere Eingabefelder haben ...
62)       if ($(this).find('input:first').val() == '') {
63)         // ... werden gelöscht
64)         $(this).remove();
65)       }
66)       });
67)   }
68) 
69)   function clearPassword() {
70)     var input = document.getElementById('password');
71)     if (input.value == '**********') {
72)       input.value = '';
73)     }
74)     input.style.color = '#000';
75)     /* FIXME: Keine Ahnung, warum das notwendig ist. Mit dem tut es was es soll.  */
76)     input.focus();
77)   }
78) 
79)   function refillPassword() {
80)     var input = document.getElementById('password');
81)     if (input.value == '') {
82)       input.value = input.defaultValue;
83)     }
84)     if (input.value == '**********') {
85)       input.style.color = '#aaa';
86)     }
87)   }
88) 
89) 
90) function hideOrShowGroup( ev ) {
91)   checkbox = ev.target;
92)   the_id = checkbox.id;
93)   checkbox = $('#'+the_id)
94)   div = $('#'+the_id+'_config')
95)   if (checkbox.is(':checked')) {
96)     div.show(100);
97)   } else {
98)     div.hide(100);
99)   }
100) 
101) }
102) 
103) 
104) function hideUnchecked() {
105)   $('div.option_group').each( function(index) {
106)     the_id = this.id.replace('_config', '');
107)     checkbox = $('#'+the_id)
108)     div = $('#'+the_id+'_config')
109)     if (checkbox.is(':checked')) {
110)       div.show();
111)     } else {
112)       div.hide();
113)     }
114)   });
115) }
116) 
117) 
118) function checkForwardCallback( result ) {
119)   target = result.target;
120)   type = result.type;
121)   element = null;
122)   $('div.vmail-forward input').each(function () {
123)     if ($(this).val() == target) {
124)       element = $(this).closest('div.vmail-forward');
125)     }
126)   });
127)   if (! element) {
128)     // Der User hat noch weiter getippt
129)     return;
130)   }
131)   if (type == 'critical') {
Bernd Wurst attr() zu prop() geändert

Bernd Wurst authored 10 years ago

132)     element.find('select option[value="delete"]').prop('selected', true);
133)     element.find('select option[value="none"]').prop('disabled', true);
134)     element.find('select option[value="tag"]').prop('disabled', true);
135)     element.find('select option[value="delete"]').prop('disabled', false);
Bernd Wurst E-Mail-Modul auf JQuery umg...

Bernd Wurst authored 10 years ago

136)     element.find('.warning').text('Weiterleitungen zu einigen großen E-Mail-Providern dürfen nur mit aktiviertem Spamfilter eingerichtet werden.');
137)     element.find('.warning').show()
138)   } else if (type == 'local') {
Bernd Wurst attr() zu prop() geändert

Bernd Wurst authored 10 years ago

139)     //element.find('select option[value="none"]').prop('selected', true);
140)     element.find('select option[value="none"]').prop('disabled', false);
141)     element.find('select option[value="tag"]').prop('disabled', false);
142)     element.find('select option[value="delete"]').prop('disabled', false);
Bernd Wurst E-Mail-Modul auf JQuery umg...

Bernd Wurst authored 10 years ago

143)     element.find('.warning').hide()
144)   } else {
Bernd Wurst attr() zu prop() geändert

Bernd Wurst authored 10 years ago

145)     //element.find('select option[value="delete"]').prop('selected', true);
146)     element.find('select option[value="none"]').prop('disabled', false);
147)     element.find('select option[value="tag"]').prop('disabled', false);
148)     element.find('select option[value="delete"]').prop('disabled', false);
Bernd Wurst E-Mail-Modul auf JQuery umg...

Bernd Wurst authored 10 years ago

149)     element.find('.warning').hide()
150)   }
151)   $('#submit').prop('disabled', false);
152) }
153) 
154) function checkForward( ) {
155)   input = $(this);
156)   val = input.val();
157)   atpos = val.indexOf('@');
158)   dot = val.lastIndexOf('.');
159)   if (atpos < 0 || val.length < atpos + 3 || dot < atpos || dot > val.length - 2) {
160)     return;
161)   }
162)   div = input.closest('div.vmail-forward');
163)   $('#submit').prop('disabled', true);
164)   $.getJSON("checkforward?target="+val, checkForwardCallback)
165)     .fail( function () {
166)       $('#submit').prop('disabled', false);
167)       });
168) }
169) 
170) 
171) 
172) $(document).ready(function(){
173)   // Automatisch Sternchen im Passwortfeld eintragen und entfernen
174)   $('#password').on('blur', refillPassword);
175)   $('#password').on('focus',clearPassword);    
176) 
177)   hideUnchecked();
178)   $('input.option_group').change(hideOrShowGroup);
179) 
180)   removeUnneededForwards();
181)   $('div.delete_forward').click(removeForward);
182)   $('#more_forwards').click(moreForward);
183) 
184)   $('div.vmail-forward input').on("change keyup paste", checkForward);
Bernd Wurst Ändere nicht die eingestell...

Bernd Wurst authored 10 years ago

185)   
186)   // trigger setup of warnings
187)   $('div.vmail-forward input').change();
Bernd Wurst Umgestellt auf JQueryUI-Dat...

Bernd Wurst authored 10 years ago

188) 
189) 
190)   $.datepicker.regional['de'] = {clearText: 'löschen', clearStatus: 'aktuelles Datum löschen',
191)                 closeText: 'schließen', closeStatus: 'ohne Änderungen schließen',
192)                 prevText: '< zurück', prevStatus: 'letzten Monat zeigen',
193)                 nextText: 'vor >', nextStatus: 'nächsten Monat zeigen',
194)                 currentText: 'heute', currentStatus: '',
195)                 monthNames: ['Januar','Februar','März','April','Mai','Juni',
196)                 'Juli','August','September','Oktober','November','Dezember'],
197)                 monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
198)                 'Jul','Aug','Sep','Okt','Nov','Dez'],
199)                 monthStatus: 'anderen Monat anzeigen', yearStatus: 'anderes Jahr anzeigen',
200)                 weekHeader: 'Wo', weekStatus: 'Woche des Monats',
201)                 dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
202)                 dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
203)                 dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
204)                 dayStatus: 'Setze DD als ersten Wochentag', dateStatus: 'Wähle D, M d',
205)                 dateFormat: 'dd.mm.yy', firstDay: 1, 
206)                 initStatus: 'Wähle ein Datum', isRTL: false};
207)   $.datepicker.setDefaults( $.datepicker.regional[ "de" ] );
208)   $.datepicker.setDefaults({
209)     dateFormat: 'yy-mm-dd',
210)     minDate: 1,
Bernd Wurst Autoresponder nur noch befr...

Bernd Wurst authored 9 years ago

211)     maxDate: "+2m"
Bernd Wurst Umgestellt auf JQueryUI-Dat...

Bernd Wurst authored 10 years ago

212) 
213)     });
214) 
215)   $('#ar_startdate').datepicker();
216)   $('#ar_startdate').change(function () {
Bernd Wurst attr() zu prop() geändert

Bernd Wurst authored 10 years ago

217)     $('#ar_valid_from_date').prop('checked', true)
Bernd Wurst Autoresponder nur noch befr...

Bernd Wurst authored 9 years ago

218)     mindate = $('#ar_startdate').datepicker("getDate");
219)     mindate.setDate(mindate.getDate()+1);
220)     $('#ar_enddate').datepicker("option", "minDate", mindate);
221)     maxdate = $('#ar_startdate').datepicker("getDate");
222)     maxdate.setDate(maxdate.getDate()+60);
223)     $('#ar_enddate').datepicker("option", "maxDate", maxdate);
Bernd Wurst Umgestellt auf JQueryUI-Dat...

Bernd Wurst authored 10 years ago

224)     });
225) 
226)   $('#ar_enddate').datepicker();
227)   $('#ar_enddate').datepicker("option", "minDate", $('#ar_startdate').val());
228)   $('#ar_enddate').change(function () {
Bernd Wurst attr() zu prop() geändert

Bernd Wurst authored 10 years ago

229)     $('#ar_valid_until_date').prop('checked', true)
Bernd Wurst Umgestellt auf JQueryUI-Dat...

Bernd Wurst authored 10 years ago

230)     });
Bernd Wurst E-Mail-Modul auf JQuery umg...

Bernd Wurst authored 10 years ago

231) });
232)