send button

pull/7748/head
Guilherme Gazzo 8 years ago
parent b1fbdd1b68
commit c3ec2ec28b
  1. 2
      packages/rocketchat-lib/client/MessageAction.js
  2. 3
      packages/rocketchat-theme/client/imports/general/base_old.css
  3. 11
      packages/rocketchat-ui-message/client/messageBox.html
  4. 61
      packages/rocketchat-ui-message/client/messageBox.js
  5. 6
      packages/rocketchat-ui/client/lib/chatMessages.js

@ -115,6 +115,7 @@ Meteor.startup(function() {
} }
input.value += text; input.value += text;
input.focus(); input.focus();
$(input).trigger('change').trigger('input');
return RocketChat.MessageAction.hideDropDown(); return RocketChat.MessageAction.hideDropDown();
}, },
validation(message) { validation(message) {
@ -282,6 +283,7 @@ Meteor.startup(function() {
} }
input.value += text; input.value += text;
input.focus(); input.focus();
$(input).trigger('change').trigger('input');
return RocketChat.MessageAction.hideDropDown(); return RocketChat.MessageAction.hideDropDown();
}, },
validation(message) { validation(message) {

@ -2061,7 +2061,6 @@
} }
& .footer { & .footer {
border-width: 1px 0 0;
flex-shrink: 0; flex-shrink: 0;
} }
@ -2413,7 +2412,7 @@
float: right; float: right;
} }
.rc-old .messages-box { .messages-box {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
flex-grow: 1; flex-grow: 1;

@ -28,6 +28,13 @@
</svg> </svg>
</div> </div>
<textarea autofocus dir="auto" name="msg" maxlength="{{maxMessageLength}}" placeholder="{{_ 'Message'}}" rows="1" class="rc-message-box__textarea js-input-message autogrow-short"></textarea> <textarea autofocus dir="auto" name="msg" maxlength="{{maxMessageLength}}" placeholder="{{_ 'Message'}}" rows="1" class="rc-message-box__textarea js-input-message autogrow-short"></textarea>
{{# if sendIcon}}
<div class="rc-message-box__icon js-send">
<svg class="rc-input__icon-svg rc-input__icon-svg--smile">
<use href="#icon-send"></use>
</svg>
</div>
{{else}}
<label class="rc-message-box__action-label" for="rc-message-box__action-input" data-popover="label"> <label class="rc-message-box__action-label" for="rc-message-box__action-input" data-popover="label">
<input id="rc-message-box__action-input" type="checkbox" class="rc-popover-anchor" data-popover="anchor"> <input id="rc-message-box__action-input" type="checkbox" class="rc-popover-anchor" data-popover="anchor">
<div class="rc-popover js-message-actions" data-popover="popover"> <div class="rc-popover js-message-actions" data-popover="popover">
@ -61,8 +68,8 @@
<svg class="rc-input__icon-svg rc-input__icon-svg--plus"> <svg class="rc-input__icon-svg rc-input__icon-svg--plus">
<use href="#icon-plus"></use> <use href="#icon-plus"></use>
</svg> </svg>
</div> </div></label>
</label> {{/if}}
</div> </div>
<div class="rc-message-box__toolbar-markdown"> <div class="rc-message-box__toolbar-markdown">
<!-- {{#if allowedToSend}} <!-- {{#if allowedToSend}}

@ -306,6 +306,9 @@ Template.messageBox.helpers({
}, },
anonymousWrite() { anonymousWrite() {
return (Meteor.userId() == null) && RocketChat.settings.get('Accounts_AllowAnonymousRead') === true && RocketChat.settings.get('Accounts_AllowAnonymousWrite') === true; return (Meteor.userId() == null) && RocketChat.settings.get('Accounts_AllowAnonymousRead') === true && RocketChat.settings.get('Accounts_AllowAnonymousWrite') === true;
},
sendIcon() {
return Template.instance().sendIcon.get();
} }
}); });
@ -397,7 +400,7 @@ Template.messageBox.events({
KonchatNotification.removeRoomNotification(this._id); KonchatNotification.removeRoomNotification(this._id);
chatMessages[this._id].input = instance.find('.js-input-message'); chatMessages[this._id].input = instance.find('.js-input-message');
}, },
'click .send-button'(event, instance) { 'click .js-send'(event, instance) {
const input = instance.find('.js-input-message'); const input = instance.find('.js-input-message');
chatMessages[this._id].send(this._id, input, () => { chatMessages[this._id].send(this._id, input, () => {
// fixes https://github.com/RocketChat/Rocket.Chat/issues/3037 // fixes https://github.com/RocketChat/Rocket.Chat/issues/3037
@ -444,7 +447,8 @@ Template.messageBox.events({
} }
return chatMessages[this._id].keydown(this._id, event, Template.instance()); return chatMessages[this._id].keydown(this._id, event, Template.instance());
}), }),
'input .js-input-message'(event) { 'input .js-input-message'(event, instance) {
instance.sendIcon.set(event.target.value !== '');
return chatMessages[this._id].valueChanged(this._id, event, Template.instance()); return chatMessages[this._id].valueChanged(this._id, event, Template.instance());
}, },
'propertychange .js-input-message'(event) { 'propertychange .js-input-message'(event) {
@ -480,56 +484,6 @@ Template.messageBox.events({
t.$('.share-items').toggleClass('hidden'); t.$('.share-items').toggleClass('hidden');
return t.$('.message-buttons.share').toggleClass('active'); return t.$('.message-buttons.share').toggleClass('active');
}, },
'click .message-form .message-buttons.location-button'() {
const roomId = this._id;
const position = RocketChat.Geolocation.get();
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;
const text = `<div class="location-preview">\n <img style="height: 250px; width: 250px;" src="https://maps.googleapis.com/maps/api/staticmap?zoom=14&size=250x250&markers=color:gray%7Clabel:%7C${ latitude },${ longitude }&key=${ RocketChat.settings.get('MapView_GMapsAPIKey') }" />\n</div>`;
return swal({
title: t('Share_Location_Title'),
text,
showCancelButton: true,
closeOnConfirm: true,
closeOnCancel: true,
html: true
}, function(isConfirm) {
if (isConfirm !== true) {
return;
}
return Meteor.call('sendMessage', {
_id: Random.id(),
rid: roomId,
msg: '',
location: {
type: 'Point',
coordinates: [longitude, latitude]
}
});
});
},
'click .message-form .mic'(e, t) {
return AudioRecorder.start(function() {
t.$('.stop-mic').removeClass('hidden');
return t.$('.mic').addClass('hidden');
});
},
'click .message-form .video-button'(e) {
return VRecDialog.opened ? VRecDialog.close() : VRecDialog.open(e.currentTarget);
},
'click .message-form .stop-mic'(e, t) {
AudioRecorder.stop(function(blob) {
return fileUpload([
{
file: blob,
type: 'audio',
name: `${ TAPi18n.__('Audio record') }.wav`
}
]);
});
t.$('.stop-mic').addClass('hidden');
return t.$('.mic').removeClass('hidden');
},
'click .sandstorm-offer'() { 'click .sandstorm-offer'() {
const roomId = this._id; const roomId = this._id;
return RocketChat.Sandstorm.request('uiView', (err, data) => { return RocketChat.Sandstorm.request('uiView', (err, data) => {
@ -575,6 +529,9 @@ Template.messageBox.onCreated(function() {
this.isMessageFieldEmpty = new ReactiveVar(true); this.isMessageFieldEmpty = new ReactiveVar(true);
this.showMicButton = new ReactiveVar(false); this.showMicButton = new ReactiveVar(false);
this.showVideoRec = new ReactiveVar(false); this.showVideoRec = new ReactiveVar(false);
this.showVideoRec = new ReactiveVar(false);
this.sendIcon = new ReactiveVar(false);
return this.autorun(() => { return this.autorun(() => {
const videoRegex = /video\/webm|video\/\*/i; const videoRegex = /video\/webm|video\/\*/i;
const videoEnabled = !RocketChat.settings.get('FileUpload_MediaTypeWhiteList') || RocketChat.settings.get('FileUpload_MediaTypeWhiteList').match(videoRegex); const videoEnabled = !RocketChat.settings.get('FileUpload_MediaTypeWhiteList') || RocketChat.settings.get('FileUpload_MediaTypeWhiteList').match(videoRegex);

@ -137,7 +137,7 @@ this.ChatMessages = class ChatMessages {
} else { } else {
this.input.value = msg; this.input.value = msg;
} }
$(this.input).change(); $(this.input).trigger('change').trigger('input');
const cursor_pos = editingNext ? 0 : -1; const cursor_pos = editingNext ? 0 : -1;
this.$input.setCursorPosition(cursor_pos); this.$input.setCursorPosition(cursor_pos);
@ -159,6 +159,7 @@ this.ChatMessages = class ChatMessages {
delete this.editing.index; delete this.editing.index;
this.input.value = this.editing.saved || ''; this.input.value = this.editing.saved || '';
$(this.input).trigger('change').trigger('input');
const cursor_pos = this.editing.savedCursor != null ? this.editing.savedCursor : -1; const cursor_pos = this.editing.savedCursor != null ? this.editing.savedCursor : -1;
this.$input.setCursorPosition(cursor_pos); this.$input.setCursorPosition(cursor_pos);
@ -189,6 +190,7 @@ this.ChatMessages = class ChatMessages {
const lastMessage = ChatMessage.findOne({rid}, { fields: { ts: 1 }, sort: { ts: -1 }}); const lastMessage = ChatMessage.findOne({rid}, { fields: { ts: 1 }, sort: { ts: -1 }});
Meteor.call('setReaction', reaction, lastMessage._id); Meteor.call('setReaction', reaction, lastMessage._id);
input.value = ''; input.value = '';
$(input).trigger('change').trigger('input');
return; return;
} }
} }
@ -209,6 +211,8 @@ this.ChatMessages = class ChatMessages {
KonchatNotification.removeRoomNotification(rid); KonchatNotification.removeRoomNotification(rid);
input.value = ''; input.value = '';
$(input).trigger('change').trigger('input');
if (typeof input.updateAutogrow === 'function') { if (typeof input.updateAutogrow === 'function') {
input.updateAutogrow(); input.updateAutogrow();
} }

Loading…
Cancel
Save