diff --git a/modules/chat/client/controllers/chat.client.controller.js b/modules/chat/client/controllers/chat.client.controller.js index 3b7bb2a0..6c1a36f0 100644 --- a/modules/chat/client/controllers/chat.client.controller.js +++ b/modules/chat/client/controllers/chat.client.controller.js @@ -34,7 +34,6 @@ // Add an event listener to the 'chatMessage' event Socket.on('chatMessage', function (message) { - var e = angular.element('#chat-body'); vm.messages.push(message); }); @@ -70,6 +69,20 @@ $scope.$watch('vm.messages.length', function (newValue, oldValue) { //console.log('vm.messages changed'); }); + $scope.$watch('vm.fontStyleBold', function (newValue, oldValue) { + if (newValue) { + angular.element('#messageText').css('font-weight', 'bold'); + } else { + angular.element('#messageText').css('font-weight', 'normal'); + } + }); + $scope.$watch('vm.fontStyleItalic', function (newValue, oldValue) { + if (newValue) { + angular.element('#messageText').css('font-style', 'italic'); + } else { + angular.element('#messageText').css('font-style', 'normal'); + } + }); /** * onMessageRepeatDone @@ -101,11 +114,27 @@ vm.messageText = ''; }; + /** + * sanitizeHTML + * @param msg + * @param white + * @param black + * @returns {*} + */ function sanitizeHTML(msg, white, black) { - if (!white) white = 'b|i|p|u|img';//allowed tags + if (!white) white = 'b|i|p|u';//allowed tags if (!black) black = 'script|object|embed';//complete remove tags var e = new RegExp('(<(' + black + ')[^>]*>.*|(?!<[/]?(' + white + ')(\\s[^<]*>|[/]>|>))<[^<>]*>|(?!<[^<>\\s]+)\\s[^]+(?=[/>]))', 'gi'); - return msg.replace(e, ''); + msg = msg.replace(e, ''); + + if (vm.fontStyleBold) { + msg = '' + msg + ''; + } + if (vm.fontStyleItalic) { + msg = '' + msg + ''; + } + + return msg; } /** @@ -244,5 +273,22 @@ vm.messageText += atu; angular.element('#messageText').trigger('focus'); } + + /** + * onCleanClicked + */ + vm.onCleanClicked = function () { + vm.messages = []; + + var m = {}; + m.type = 'status'; + m.text = $translate.instant('CHAT_MESSAGE_ALREADY_CLEAN'); + m.created = Date.now(); + m.profileImageURL = vm.user.profileImageURL; + m.username = vm.user.username; + m.displayName = vm.user.displayName; + + vm.messages.push(m); + } } }()); diff --git a/modules/chat/client/less/chat.less b/modules/chat/client/less/chat.less index e2621bc5..065adcb1 100644 --- a/modules/chat/client/less/chat.less +++ b/modules/chat/client/less/chat.less @@ -194,6 +194,25 @@ height: 40px; border-bottom: solid 1px lighten(@gray-light, 45%); background-color: lighten(@gray-light, 48%); + .glyphicon { + color: @mt-base-color; + margin: 10px 2px; + cursor: pointer; + &:hover { + color: darken(@mt-base-color, 10%); + } + } + .font-style-list { + label { + cursor: pointer; + font-weight: normal; + font-size: 12px; + margin-top: 10px; + &:not(:last-child) { + margin-right: 10px; + } + } + } } .footer-input { textarea { diff --git a/modules/chat/client/views/chat.client.view.html b/modules/chat/client/views/chat.client.view.html index 06ff1120..fdcde46c 100644 --- a/modules/chat/client/views/chat.client.view.html +++ b/modules/chat/client/views/chat.client.view.html @@ -32,7 +32,18 @@