This repository has been archived by the owner on Nov 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1301 from owncloud/reply-button-placement
fix placement of reply button, ref #900
- Loading branch information
Showing
5 changed files
with
85 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* later. See the COPYING file. | ||
* | ||
* @author Christoph Wurst <[email protected]> | ||
* @copyright Christoph Wurst 2015 | ||
* @copyright Christoph Wurst 2016 | ||
*/ | ||
|
||
define(function(require) { | ||
|
@@ -37,6 +37,7 @@ define(function(require) { | |
autosized: false, | ||
events: { | ||
'click .submit-message': 'submitMessage', | ||
'click .submit-message-wrapper-inside': 'submitMessageWrapperInside', | ||
'keypress .message-body': 'handleKeyPress', | ||
'input .to': 'onInputChanged', | ||
'paste .to': 'onInputChanged', | ||
|
@@ -246,6 +247,43 @@ define(function(require) { | |
|
||
return message; | ||
}, | ||
submitMessageWrapperInside: function(e) { | ||
// http://stackoverflow.com/questions/487073/check-if-element-is-visible-after-scrolling | ||
if (this._isVisible()) { | ||
this.$('.submit-message').click(); | ||
} else { | ||
$('#mail-message').animate({ | ||
scrollTop: this.$el.offset().top | ||
}, 1000); | ||
this.$('.submit-message-wrapper-inside').hide(); | ||
// This function is needed because $('.message-body').focus does not focus the first line | ||
this._setCaretToPos(this.$('.message-body')[0], 0); | ||
} | ||
}, | ||
_setSelectionRange: function(input, selectionStart, selectionEnd) { | ||
if (input.setSelectionRange) { | ||
input.focus(); | ||
input.setSelectionRange(selectionStart, selectionEnd); | ||
} else if (input.createTextRange) { | ||
var range = input.createTextRange(); | ||
range.collapse(true); | ||
range.moveEnd('character', selectionEnd); | ||
range.moveStart('character', selectionStart); | ||
range.select(); | ||
} | ||
}, | ||
_setCaretToPos: function(input, pos) { | ||
this._setSelectionRange(input, pos, pos); | ||
}, | ||
_isVisible: function() { | ||
var $elem = this.$el; | ||
var $window = $(window); | ||
var docViewTop = $window.scrollTop(); | ||
var docViewBottom = docViewTop + $window.height(); | ||
var elemTop = $elem.offset().top; | ||
|
||
return elemTop <= docViewBottom; | ||
}, | ||
submitMessage: function() { | ||
clearTimeout(this.draftTimer); | ||
// | ||
|
@@ -276,7 +314,8 @@ define(function(require) { | |
|
||
// if available get account from drop-down list | ||
if (this.$('.mail-account').length > 0) { | ||
this.account = this.accounts.get(this.$('.mail-account').find(':selected').val()); | ||
this.account = this.accounts.get(this.$('.mail-account'). | ||
find(':selected').val()); | ||
} | ||
|
||
// send the mail | ||
|
@@ -303,7 +342,8 @@ define(function(require) { | |
if (_this.draftUID !== null) { | ||
// the sent message was a draft | ||
if (!_.isUndefined(Radio.ui.request('messagesview:collection'))) { | ||
Radio.ui.request('messagesview:collection').remove({id: _this.draftUID}); | ||
Radio.ui.request('messagesview:collection'). | ||
remove({id: _this.draftUID}); | ||
} | ||
_this.draftUID = null; | ||
} | ||
|
@@ -327,7 +367,8 @@ define(function(require) { | |
cc.prop('disabled', false); | ||
bcc.prop('disabled', false); | ||
subject.prop('disabled', false); | ||
_this.$('.new-message-attachments-action').css('display', 'inline-block'); | ||
_this.$('.new-message-attachments-action'). | ||
css('display', 'inline-block'); | ||
_this.$('#mail_new_attachment').prop('disabled', false); | ||
newMessageBody.prop('disabled', false); | ||
newMessageSend.prop('disabled', false); | ||
|
@@ -337,7 +378,7 @@ define(function(require) { | |
|
||
if (this.isReply()) { | ||
options.messageId = this.messageId; | ||
options.folderId = this.folderId; | ||
options.folder = this.account.get('folders').get(this.folderId); | ||
} | ||
|
||
this.submitCallback(this.account, this.getMessage(), options); | ||
|
@@ -354,14 +395,14 @@ define(function(require) { | |
|
||
// if available get account from drop-down list | ||
if (this.$('.mail-account').length > 0) { | ||
this.account = this.accounts.get(this.$('.mail-account').find(':selected').val()); | ||
this.account = this.accounts.get(this.$('.mail-account'). | ||
find(':selected').val()); | ||
} | ||
|
||
// send the mail | ||
var _this = this; | ||
this.draftCallback(this.account, this.getMessage(), { | ||
account: this.account, | ||
folderId: this.folderId, | ||
folder: this.account.get('folders').get(this.folderId), | ||
messageId: this.messageId, | ||
draftUID: this.draftUID, | ||
success: function(data) { | ||
|
@@ -411,7 +452,8 @@ define(function(require) { | |
function extractLast(term) { | ||
return split(term).pop(); | ||
} | ||
if (!$(this).data('autocomplete')) { // If the autocomplete wasn't called yet: | ||
if (!$(this). | ||
data('autocomplete')) { // If the autocomplete wasn't called yet: | ||
// don't navigate away from the field on tab when selecting an item | ||
$(this).bind('keydown', function(event) { | ||
if (event.keyCode === $.ui.keyCode.TAB && | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* later. See the COPYING file. | ||
* | ||
* @author Christoph Wurst <[email protected]> | ||
* @copyright Christoph Wurst 2015 | ||
* @copyright Christoph Wurst 2016 | ||
*/ | ||
|
||
define(function(require) { | ||
|
@@ -136,14 +136,19 @@ define(function(require) { | |
}); | ||
}); | ||
|
||
// TODO: add folder/account reference to message | ||
var account = require('state').accounts.get(this.message.get('accountId')); | ||
var folderId = this.message.get('folderId'); | ||
|
||
// setup reply composer view | ||
|
||
this.replyComposer.show(new ComposerView({ | ||
//el: this.$('#reply-composer'), | ||
type: 'reply', | ||
onSubmit: require('communication').sendMessage, | ||
onDraft: require('communication').saveDraft, | ||
accountId: this.message.get('accountId'), | ||
folderId: this.message.get('folderId'), | ||
account: account, | ||
folderId: folderId, | ||
messageId: this.message.get('messageId') | ||
})); | ||
this.replyComposer.currentView.render({ | ||
|