mirror of
https://github.com/moparisthebest/mail
synced 2024-11-27 03:12:23 -05:00
refactor writer to use state scope
This commit is contained in:
parent
28a109bb07
commit
866ebbeac4
@ -40,14 +40,6 @@ define(function(require) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.openWriter = function(replyTo) {
|
|
||||||
$scope.writerReply = !! (replyTo);
|
|
||||||
$scope.writerOpen = true;
|
|
||||||
};
|
|
||||||
$scope.closeWriter = function() {
|
|
||||||
$scope.writerOpen = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.openFolder = function(folder) {
|
$scope.openFolder = function(folder) {
|
||||||
$scope.currentFolder = folder;
|
$scope.currentFolder = folder;
|
||||||
$scope.state.nav.toggle(false);
|
$scope.state.nav.toggle(false);
|
||||||
@ -284,27 +276,27 @@ define(function(require) {
|
|||||||
elm.bind('keydown', function(e) {
|
elm.bind('keydown', function(e) {
|
||||||
var cs = scope.$$childTail;
|
var cs = scope.$$childTail;
|
||||||
|
|
||||||
if (e.keyCode === 78 && !cs.writerOpen) {
|
if (e.keyCode === 78 && !scope.state.writer.open) {
|
||||||
// n -> new mail
|
// n -> new mail
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
cs.openWriter();
|
scope.state.writer.write();
|
||||||
|
|
||||||
} else if (e.keyCode === 82 && !cs.writerOpen && cs.selected) {
|
} else if (e.keyCode === 82 && !scope.state.writer.open && cs.selected) {
|
||||||
// r -> reply
|
// r -> reply
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
cs.openWriter(cs.selected);
|
scope.state.writer.write(cs.selected);
|
||||||
|
|
||||||
} else if (e.keyCode === 27 && cs.writerOpen) {
|
} else if (e.keyCode === 27 && scope.state.writer.open) {
|
||||||
// escape -> close writer
|
// escape -> close writer
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
cs.closeWriter();
|
scope.state.writer.close();
|
||||||
|
|
||||||
} else if (e.keyCode === 27 && cs.accountOpen) {
|
} else if (e.keyCode === 27 && cs.accountOpen) {
|
||||||
// escape -> close account view
|
// escape -> close account view
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
cs.closeAccount();
|
cs.closeAccount();
|
||||||
|
|
||||||
} else if (e.keyCode === 83 && !cs.writerOpen && cs.synchronize) {
|
} else if (e.keyCode === 83 && !scope.state.writer.open && cs.synchronize) {
|
||||||
// s -> sync folder
|
// s -> sync folder
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
cs.synchronize();
|
cs.synchronize();
|
||||||
|
@ -20,14 +20,22 @@ define(function(require) {
|
|||||||
// Init
|
// Init
|
||||||
//
|
//
|
||||||
|
|
||||||
$scope.$watch('writerOpen', function() {
|
$scope.state.writer = {
|
||||||
|
open: false,
|
||||||
|
write: function(replyTo) {
|
||||||
|
this.open = true;
|
||||||
|
|
||||||
resetFields();
|
resetFields();
|
||||||
if ($scope.writerReply) {
|
if (replyTo) {
|
||||||
fillFields($scope.selected);
|
fillFields(replyTo);
|
||||||
$scope.updatePreview();
|
$scope.updatePreview();
|
||||||
}
|
}
|
||||||
$scope.verifyTo();
|
$scope.verifyTo();
|
||||||
});
|
},
|
||||||
|
close: function() {
|
||||||
|
this.open = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function resetFields() {
|
function resetFields() {
|
||||||
$scope.writerTitle = 'New email';
|
$scope.writerTitle = 'New email';
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
</div><!--/.nav-container-->
|
</div><!--/.nav-container-->
|
||||||
|
|
||||||
<!-- lightbox -->
|
<!-- lightbox -->
|
||||||
<div class="lightbox-overlay" ng-class="{'show': writerOpen}">
|
<div class="lightbox-overlay" ng-class="{'show': state.writer.open}">
|
||||||
<div class="lightbox lightbox-effect" ng-include="'tpl/write.html'"></div>
|
<div class="lightbox lightbox-effect" ng-include="'tpl/write.html'"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="lightbox-overlay" ng-class="{'show': accountOpen}">
|
<div class="lightbox-overlay" ng-class="{'show': accountOpen}">
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<div class="controls">
|
<div class="controls">
|
||||||
<button ng-click="remove(selected)" class="btn-icon" title="Delete mail"></button>
|
<button ng-click="remove(selected)" class="btn-icon" title="Delete mail"></button>
|
||||||
<button ng-click="openWriter(selected)" class="btn-icon" title="Reply to"></button>
|
<button ng-click="state.writer.write(selected)" class="btn-icon" title="Reply to"></button>
|
||||||
<button ng-click="openWriter()" class="btn-icon" title="New mail"></button>
|
<button ng-click="state.writer.write()" class="btn-icon" title="New mail"></button>
|
||||||
</div><!--/.controls-->
|
</div><!--/.controls-->
|
||||||
|
|
||||||
<div class="view-read">
|
<div class="view-read">
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<div class="lightbox-body" ng-controller="WriteCtrl">
|
<div class="lightbox-body" ng-controller="WriteCtrl">
|
||||||
<header>
|
<header>
|
||||||
<h2>{{writerTitle}}</h2>
|
<h2>{{writerTitle}}</h2>
|
||||||
<button class="close" ng-click="closeWriter()" data-action="lightbox-close"></button>
|
<button class="close" ng-click="state.writer.close()" data-action="lightbox-close"></button>
|
||||||
</header>
|
</header>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user