compose_area.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * Copyright © 2016-2018 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 types
  13. import '../../src/threema.d';
  14. // Import dependencies
  15. import config from '../../src/config';
  16. import '../../src/directives';
  17. import '../../src/filters';
  18. import '../../src/services';
  19. export function init() {
  20. console.info('Init UI Test: compose_area');
  21. const app = angular.module('uitest', [
  22. '3ema.directives',
  23. '3ema.filters',
  24. '3ema.services',
  25. 'ngMaterial',
  26. 'pascalprecht.translate',
  27. ]);
  28. app.constant('CONFIG', config);
  29. app.controller('ComposeAreaController', ComposeAreaController);
  30. // Provide mock translations
  31. app.config(function($translateProvider) {
  32. $translateProvider.translations('en', {
  33. messenger: {
  34. COMPOSE_MESSAGE: 'compose_message',
  35. COMPOSE_MESSAGE_DRAGOVER: 'compose_message_dragover',
  36. },
  37. });
  38. $translateProvider.preferredLanguage('en');
  39. });
  40. // Fix paths
  41. app.config(['$httpProvider', ($httpProvider: ng.IHttpProvider) => {
  42. $httpProvider.interceptors.push([() => {
  43. return {
  44. request: (conf) => {
  45. if (conf.url.indexOf('partials/') !== -1 ||
  46. conf.url.indexOf('directives/') !== -1 ||
  47. conf.url.indexOf('components/') !== -1) {
  48. conf.url = '../../src/' + conf.url;
  49. }
  50. return conf;
  51. },
  52. };
  53. }]);
  54. }]);
  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 startTyping() {
  66. // ignore
  67. }
  68. public onTyping() {
  69. // ignore
  70. }
  71. public stopTyping() {
  72. // ignore
  73. }
  74. public onComposeKeyDown() {
  75. return true;
  76. }
  77. public submit(msgtype, data) {
  78. // ignore
  79. }
  80. }