Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ChatSubmitButtonInjector.ts « ts - github.com/nextcloud/jsxc.nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 45f5b5751d976a7678b58402b8336283ca0785f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import Storage from './Storage';

export function addChatSubmitButton(formElement: JQuery<any>, translate: (key: string) => string) {
   let storage = Storage.get();
   let submitWrapperElement = $('<div>');
   submitWrapperElement.attr('id', 'jsxc-submit-wrapper');

   let submitElement = $('<input>');
   submitElement.attr({
      type: 'button',
   });
   submitElement.addClass('login primary jsxc-submit');

   let submitElementWithout = submitElement.clone();
   submitElementWithout.val(translate('Log_in_without_chat'));
   submitElementWithout.click(function() {
      storage.setItem('loginForm:disable', true);

      formElement.submit();
   });

   let submitElementWith = submitElement.clone();
   submitElementWith.val(translate('Log_in_with_chat'));
   submitElementWith.click(function() {
      storage.setItem('loginForm:disable', false);

      formElement.submit();
   });

   submitWrapperElement.append(submitElementWithout);
   submitWrapperElement.append(submitElementWith);

   if (formElement.find('.login-additional').length > 0) {
      formElement.find('.login-additional').prepend(submitWrapperElement);
   } else {
      formElement.find('#submit-wrapper').after(submitWrapperElement);
   }

   $('#lost-password').mouseup(function(ev) {
      ev.preventDefault();

      submitWrapperElement.slideUp().fadeOut();
   });
   $('#lost-password-back').mouseup(function(ev) {
      ev.preventDefault();

      submitWrapperElement.slideDown().fadeIn();
   });
}