compose_area.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. } else if (conf.url.indexOf('css/') !== -1 ||
  50. conf.url.indexOf('fonts/') !== -1 ||
  51. conf.url.indexOf('i18n/') !== -1 ||
  52. conf.url.indexOf('img/') !== -1 ||
  53. conf.url.indexOf('libs/') !== -1 ||
  54. conf.url.indexOf('sounds/') !== -1) {
  55. conf.url = '../../public/' + conf.url;
  56. }
  57. return conf;
  58. },
  59. };
  60. }]);
  61. }]);
  62. }
  63. export class ComposeAreaController {
  64. public static $inject = [];
  65. public initialData: threema.InitialConversationData;
  66. constructor() {
  67. this.initialData = {
  68. draft: '',
  69. initialText: '',
  70. };
  71. }
  72. public startTyping() {
  73. // ignore
  74. }
  75. public onTyping() {
  76. // ignore
  77. }
  78. public stopTyping() {
  79. // ignore
  80. }
  81. public onComposeKeyDown() {
  82. return true;
  83. }
  84. public submit(msgtype, data) {
  85. // ignore
  86. }
  87. }