Bug 23901: Fix sms_input is null in opac-messaging.tt

When sms messaging is disabled, JavaScript breaks in opac-messaging.tt.
Bug introduced in Bug 22862.

To test:
1. Enable EnhancedMessagingPreferences system preference
2. Disable sms messaging by unsetting SMSSendDriver system preference
3. Go to OPAC -> your messaging
4. Observe JavaScript error "sms_input is null" in your browser console
5. Apply patch
6. Refresh page and observe the error is gone

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Lari Taskula 2019-10-25 13:36:11 +00:00 committed by Martin Renvoize
parent 4c853b0034
commit 7b8780daa1
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 2 additions and 0 deletions

View File

@ -193,6 +193,7 @@ function normalizeSMS(value){
var sms_input = document.getElementById('SMSnumber');
if (typeof sms_input !== 'undefined' && sms_input !== null) {
sms_input.addEventListener('keyup', function(){
var field = sms_input.value;
sms_input.value = normalizeSMS(field);
@ -204,6 +205,7 @@ sms_input.addEventListener('paste', function(event) {
sms_input.value = normalizeSMS(paste);
}, 100);
});
}
//]]>
</script>