b73f6ec817e578035a58f8bbb2e411deaf92123c
[Packages/TYPO3.CMS.git] / typo3 / sysext / t3skin / resources / login.js
1 TYPO3BackendLogin = {
2 start: function() {
3 TYPO3BackendLogin.registerEventListeners();
4 TYPO3BackendLogin.setVisibilityOfClearIcon($('t3-username'), $('t3-username-clearIcon'));
5 TYPO3BackendLogin.setVisibilityOfClearIcon($('t3-password'), $('t3-password-clearIcon'));
6 },
7
8 registerEventListeners: function() {
9 Event.observe(
10 $('t3-login-switchToOpenId'),
11 'click',
12 TYPO3BackendLogin.switchToOpenId
13 );
14 Event.observe(
15 $('t3-login-switchToDefault'),
16 'click',
17 TYPO3BackendLogin.switchToDefault
18 );
19
20 $A(['t3-username', 't3-password']).each(function(value) {
21 Event.observe(
22 $(value + '-clearIcon'),
23 'click',
24 function() { TYPO3BackendLogin.clearInputField($(value)); }
25 );
26 TYPO3BackendLogin.observeEvents(
27 $(value),
28 ['focus', 'blur', 'keypress'],
29 function() { TYPO3BackendLogin.setVisibilityOfClearIcon($(value), $(value + '-clearIcon')); }
30 );
31 Event.observe(
32 $(value),
33 'keypress',
34 function(event) { TYPO3BackendLogin.showCapsLockWarning($(value + '-alert-capslock'), event); }
35 );
36 })
37 },
38
39 observeEvents: function(element, events, handler) {
40 events.each(function(event) {
41 Event.observe(
42 element,
43 event,
44 handler
45 );
46 });
47 },
48
49 setVisibilityOfClearIcon: function(formField, clearIcon) {
50 if (formField.value) {
51 clearIcon.show();
52 } else {
53 clearIcon.hide();
54 }
55 },
56
57 showCapsLockWarning: function(alertIcon, event) {
58 if (isCapslock(event)) {
59 alertIcon.show();
60 } else {
61 alertIcon.hide();
62 }
63 },
64
65 clearInputField: function(formField) {
66 formField.value = '';
67 formField.focus();
68 },
69
70 switchToOpenId: function() {
71 $('t3-login-label-username').hide();
72 $('t3-login-label-openId').show();
73 $('t3-login-openIdLogo').show();
74
75 $('t3-login-form-footer-default').hide();
76 $('t3-login-form-footer-openId').show();
77 $('t3-login-password-section').hide();
78
79 if ($('t3-login-interface-section')) {
80 $('t3-login-interface-section').hide();
81 }
82 },
83
84 switchToDefault: function() {
85 $('t3-login-label-username').show();
86 $('t3-login-label-openId').hide();
87 $('t3-login-openIdLogo').hide();
88
89 $('t3-login-form-footer-default').show();
90 $('t3-login-form-footer-openId').hide();
91 $('t3-login-password-section').show();
92
93 if ($('t3-login-interface-section')) {
94 $('t3-login-interface-section').show();
95 }
96 }
97 };
98
99 Event.observe(window, 'load', TYPO3BackendLogin.start);