compose_area.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /**
  2. * Copyright © 2016-2020 Threema GmbH (https://threema.ch/).
  3. *
  4. * This file is part of Threema Web.
  5. */
  6. // tslint:disable:no-console
  7. // tslint:disable:no-reference
  8. // Import AngularJS
  9. import * as angular from 'angular';
  10. import 'angular-material';
  11. import 'angular-translate';
  12. // Import dependencies
  13. import config from '../../src/config';
  14. import '../../src/directives';
  15. import '../../src/filters';
  16. import '../../src/services';
  17. export function init() {
  18. console.info('Init UI Test: compose_area');
  19. const app = angular.module('uitest', [
  20. '3ema.directives',
  21. '3ema.filters',
  22. '3ema.services',
  23. 'ngMaterial',
  24. 'pascalprecht.translate',
  25. ]);
  26. app.constant('CONFIG', config);
  27. app.controller('ComposeAreaController', ComposeAreaController);
  28. // Provide mock translations
  29. app.config(function($translateProvider) {
  30. $translateProvider.translations('en', {
  31. messenger: {
  32. COMPOSE_MESSAGE: 'compose_message',
  33. COMPOSE_MESSAGE_DRAGOVER: 'compose_message_dragover',
  34. },
  35. });
  36. $translateProvider.preferredLanguage('en');
  37. });
  38. // Fix paths
  39. app.config(['$httpProvider', ($httpProvider: ng.IHttpProvider) => {
  40. $httpProvider.interceptors.push([() => {
  41. return {
  42. request: (conf) => {
  43. if (conf.url.indexOf('partials/') !== -1 ||
  44. conf.url.indexOf('directives/') !== -1 ||
  45. conf.url.indexOf('components/') !== -1) {
  46. conf.url = '../../src/' + conf.url;
  47. }
  48. return conf;
  49. },
  50. };
  51. }]);
  52. }]);
  53. // Bootstrap application
  54. angular.bootstrap(document, ['uitest']);
  55. }
  56. class ComposeAreaController {
  57. public static $inject = [];
  58. public initialData: threema.InitialConversationData;
  59. constructor() {
  60. this.initialData = {
  61. draft: '',
  62. initialText: '',
  63. };
  64. }
  65. public onInit(composeArea) {
  66. // tslint:disable-next-line:no-string-literal
  67. window['composeArea'] = composeArea;
  68. }
  69. public startTyping() {
  70. // ignore
  71. }
  72. public onTyping() {
  73. // ignore
  74. }
  75. public stopTyping() {
  76. // ignore
  77. }
  78. public onComposeKeyDown() {
  79. return true;
  80. }
  81. public submit(msgtype, data) {
  82. // ignore
  83. }
  84. }