compose_area.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * Copyright © 2016-2019 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. }
  54. class ComposeAreaController {
  55. public static $inject = [];
  56. public initialData: threema.InitialConversationData;
  57. constructor() {
  58. this.initialData = {
  59. draft: '',
  60. initialText: '',
  61. };
  62. }
  63. public startTyping() {
  64. // ignore
  65. }
  66. public onTyping() {
  67. // ignore
  68. }
  69. public stopTyping() {
  70. // ignore
  71. }
  72. public onComposeKeyDown() {
  73. return true;
  74. }
  75. public submit(msgtype, data) {
  76. // ignore
  77. }
  78. }