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')
35) .find('option:first-of-type').attr('selected', true);
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');
51) select.find('option:first').attr('selected', true);
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') {
132) element.find('select option[value="delete"]').attr('selected', true);
133) element.find('select option[value="none"]').attr('disabled', true);
134) element.find('select option[value="tag"]').attr('disabled', true);
135) element.find('select option[value="delete"]').attr('disabled', false);
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') {
139) element.find('select option[value="none"]').attr('selected', true);
140) element.find('select option[value="none"]').attr('disabled', false);
141) element.find('select option[value="tag"]').attr('disabled', false);
142) element.find('select option[value="delete"]').attr('disabled', false);
143) element.find('.warning').hide()
144) } else {
145) element.find('select option[value="delete"]').attr('selected', true);
146) element.find('select option[value="none"]').attr('disabled', false);
147) element.find('select option[value="tag"]').attr('disabled', false);
148) element.find('select option[value="delete"]').attr('disabled', false);
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);
|
Umgestellt auf JQueryUI-Dat...
Bernd Wurst authored 10 years ago
|
185)
186)
187) $.datepicker.regional['de'] = {clearText: 'löschen', clearStatus: 'aktuelles Datum löschen',
188) closeText: 'schließen', closeStatus: 'ohne Änderungen schließen',
189) prevText: '< zurück', prevStatus: 'letzten Monat zeigen',
190) nextText: 'vor >', nextStatus: 'nächsten Monat zeigen',
191) currentText: 'heute', currentStatus: '',
192) monthNames: ['Januar','Februar','März','April','Mai','Juni',
193) 'Juli','August','September','Oktober','November','Dezember'],
194) monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
195) 'Jul','Aug','Sep','Okt','Nov','Dez'],
196) monthStatus: 'anderen Monat anzeigen', yearStatus: 'anderes Jahr anzeigen',
197) weekHeader: 'Wo', weekStatus: 'Woche des Monats',
198) dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
199) dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
200) dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
201) dayStatus: 'Setze DD als ersten Wochentag', dateStatus: 'Wähle D, M d',
202) dateFormat: 'dd.mm.yy', firstDay: 1,
203) initStatus: 'Wähle ein Datum', isRTL: false};
204) $.datepicker.setDefaults( $.datepicker.regional[ "de" ] );
205) $.datepicker.setDefaults({
206) dateFormat: 'yy-mm-dd',
207) minDate: 1,
208) maxDate: "+3y"
209)
210) });
211)
212) $('#ar_startdate').datepicker();
213) $('#ar_startdate').change(function () {
214) $('#ar_valid_from_date').attr('checked', true)
215) $('#ar_enddate').datepicker("option", "minDate", $('#ar_startdate').val());
216) });
217)
218) $('#ar_enddate').datepicker();
219) $('#ar_enddate').datepicker("option", "minDate", $('#ar_startdate').val());
220) $('#ar_enddate').change(function () {
221) $('#ar_valid_until_date').attr('checked', true)
222) });
|