mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-29 02:07:36 +00:00
@@ -11,7 +11,8 @@
|
||||
var vm = this,
|
||||
defaultWindowTitle = angular.element($window.document).find('title').attr('sg-default') || "SOGo",
|
||||
hotkeys = [],
|
||||
sortLabels;
|
||||
sortLabels,
|
||||
popupWindow = null;
|
||||
|
||||
sortLabels = {
|
||||
subject: 'Subject',
|
||||
@@ -184,15 +185,58 @@
|
||||
return Preferences.defaults.SOGoMailComposeWindowEnabled;
|
||||
};
|
||||
|
||||
this.newMessage = function($event, inPopup) {
|
||||
var message, onCompleteDeferred = $q.defer();
|
||||
this.openInPopup = function(message, action) {
|
||||
var url = [sgSettings.baseURL(),
|
||||
'UIxMailPopupView#!/Mail',
|
||||
this.account.id],
|
||||
wId = this.account.id + '/' + Math.random(0, 1000);
|
||||
if (message) {
|
||||
// The double-encoding is necessary
|
||||
url.push(encodeUriFilter(encodeUriFilter(message.$mailbox.path)));
|
||||
url.push(message.uid);
|
||||
wId = message.$absolutePath();
|
||||
}
|
||||
if (action) {
|
||||
wId += '/' + action;
|
||||
url.push(action);
|
||||
}
|
||||
url = url.join('/');
|
||||
popupWindow = $window.open(url, wId,
|
||||
["width=680",
|
||||
"height=520",
|
||||
"resizable=1",
|
||||
"scrollbars=1",
|
||||
"toolbar=0",
|
||||
"location=0",
|
||||
"directories=0",
|
||||
"status=0",
|
||||
"menubar=0",
|
||||
"copyhistory=0"]
|
||||
.join(','));
|
||||
};
|
||||
|
||||
if (vm.messageDialog === null) {
|
||||
if (inPopup || Preferences.defaults.SOGoMailComposeWindow == 'popup')
|
||||
_newMessageInPopup();
|
||||
else {
|
||||
message = vm.account.$newMessage();
|
||||
vm.messageDialog = $mdDialog
|
||||
this.closePopup = function() {
|
||||
if ($window.document.body.classList.contains('popup'))
|
||||
$window.close();
|
||||
};
|
||||
|
||||
/**
|
||||
* To keep track of the currently active dialog, we share a common variable with the parent controller.
|
||||
*/
|
||||
function _messageDialog() {
|
||||
if ($scope.mailbox) {
|
||||
if (arguments.length > 0)
|
||||
$scope.mailbox.messageDialog = arguments[0];
|
||||
return $scope.mailbox.messageDialog;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function _showMailEditor($event, message) {
|
||||
if (_messageDialog() === null) {
|
||||
var onCompleteDeferred = $q.defer();
|
||||
_messageDialog(
|
||||
$mdDialog
|
||||
.show({
|
||||
parent: angular.element(document.body),
|
||||
targetEvent: $event,
|
||||
@@ -215,34 +259,29 @@
|
||||
})
|
||||
.catch(_.noop) // Cancel
|
||||
.finally(function() {
|
||||
vm.messageDialog = null;
|
||||
});
|
||||
}
|
||||
_messageDialog(null);
|
||||
vm.closePopup();
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
this._showMailEditorInPopup = function(message, action, inPopup) {
|
||||
if (!sgSettings.isPopup &&
|
||||
(Preferences.defaults.SOGoMailComposeWindow == 'popup' || inPopup)) {
|
||||
this.openInPopup(message, action);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
function _newMessageInPopup() {
|
||||
var url = [sgSettings.baseURL(),
|
||||
'UIxMailPopupView#!/Mail',
|
||||
vm.account.id,
|
||||
// The double-encoding is necessary
|
||||
encodeUriFilter(encodeUriFilter(vm.selectedFolder.path)),
|
||||
'new']
|
||||
.join('/'),
|
||||
wId = vm.selectedFolder.$id() + '/' + Math.random(0, 1000);
|
||||
$window.open(url, wId,
|
||||
["width=680",
|
||||
"height=520",
|
||||
"resizable=1",
|
||||
"scrollbars=1",
|
||||
"toolbar=0",
|
||||
"location=0",
|
||||
"directories=0",
|
||||
"status=0",
|
||||
"menubar=0",
|
||||
"copyhistory=0"]
|
||||
.join(','));
|
||||
}
|
||||
this.newMessage = function($event, inPopup) {
|
||||
if (!this._showMailEditorInPopup(null, 'new', inPopup)) {
|
||||
this.account.$newMessage().then(function(message) {
|
||||
_showMailEditor($event, message);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* User has pressed up arrow key
|
||||
@@ -579,6 +618,20 @@
|
||||
}
|
||||
};
|
||||
|
||||
this.forwardSelectedMessages = function($event) {
|
||||
var _this = this,
|
||||
selectedMessages = vm.selectedFolder.selectedMessages();
|
||||
if (_.size(selectedMessages) > 0) {
|
||||
vm.selectedFolder.forwardMessages(selectedMessages).then(function(message) {
|
||||
if (!_this._showMailEditorInPopup(message, 'edit')) {
|
||||
message.$editableContent().then(function() {
|
||||
_showMailEditor($event, message);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
angular
|
||||
|
||||
Reference in New Issue
Block a user