1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-23 09:22:23 -05:00

refactor read conrtoller to use global state

This commit is contained in:
Tankred Hase 2013-11-08 22:05:08 +01:00
parent 866ebbeac4
commit a82c2ca20a
5 changed files with 13 additions and 15 deletions

View File

@ -218,7 +218,7 @@ define(function(require) {
return; return;
} }
$scope.openReadMode(); $scope.state.read.toggle(true);
if (!window.chrome || !chrome.socket) { if (!window.chrome || !chrome.socket) {
return; return;
} }

View File

@ -14,8 +14,6 @@ define(function(require) {
var NavigationCtrl = function($scope) { var NavigationCtrl = function($scope) {
$scope.$root.state = {}; $scope.$root.state = {};
$scope.navOpen = false;
$scope.writerOpen = false;
$scope.accountOpen = false; $scope.accountOpen = false;
emailDao = appController._emailDao; emailDao = appController._emailDao;
@ -52,13 +50,6 @@ define(function(require) {
$scope.accountOpen = false; $scope.accountOpen = false;
}; };
$scope.openReadMode = function() {
$scope.readingMode = true;
};
$scope.closeReadMode = function() {
$scope.readingMode = false;
};
$scope.remove = function(email) { $scope.remove = function(email) {
if (!email) { if (!email) {
return; return;

View File

@ -7,7 +7,14 @@ define(function(require) {
// Controller // Controller
// //
var ReadCtrl = function() {}; var ReadCtrl = function($scope) {
$scope.state.read = {
open: false,
toggle: function(to) {
this.open = to;
}
};
};
// //
// Directives // Directives

View File

@ -5,13 +5,13 @@
<!-- content wrapper pushed right --> <!-- content wrapper pushed right -->
<div class="nav-pusher" ng-click="state.nav.toggle(false)"> <div class="nav-pusher" ng-click="state.nav.toggle(false)">
<section class="content main-content" ng-class="{'shift-right': readingMode}"> <section class="content main-content" ng-class="{'shift-right': state.read.open}">
<!-- left column: containing list view and navigation header --> <!-- left column: containing list view and navigation header -->
<div class="column column-left" ng-include="'tpl/mail-list.html'" ng-controller="MailListCtrl"></div> <div class="column column-left" ng-include="'tpl/mail-list.html'" ng-controller="MailListCtrl"></div>
<!-- right column: containing list read view --> <!-- right column: containing list read view -->
<div class="column" ng-include="'tpl/read.html'" ng-controller="ReadCtrl"></div> <div class="column" ng-include="'tpl/read.html'"></div>
</section> </section>
</div><!--/.nav-pusher--> </div><!--/.nav-pusher-->

View File

@ -4,9 +4,9 @@
<button ng-click="state.writer.write()" class="btn-icon" title="New mail">&#xe006;</button> <button ng-click="state.writer.write()" class="btn-icon" title="New mail">&#xe006;</button>
</div><!--/.controls--> </div><!--/.controls-->
<div class="view-read"> <div class="view-read" ng-controller="ReadCtrl">
<div class="headers"> <div class="headers">
<p class="subject" ng-click="closeReadMode()">{{selected.subject || 'No subject'}}</p> <p class="subject" ng-click="state.read.toggle(false)">{{selected.subject || 'No subject'}}</p>
<p class="date">{{selected.sentDate | date:'EEEE, MMM d, yyyy h:mm a'}}</p> <p class="date">{{selected.sentDate | date:'EEEE, MMM d, yyyy h:mm a'}}</p>
<p class="address">From: <span class="label" data-icon-append="&#xe009;">{{selected.from[0].name || selected.from[0].address}}</span></p> <p class="address">From: <span class="label" data-icon-append="&#xe009;">{{selected.from[0].name || selected.from[0].address}}</span></p>
<p class="address">To: <span class="label" data-icon-append="&#xe009;" ng-repeat="t in selected.to">{{t.address}} </span></p> <p class="address">To: <span class="label" data-icon-append="&#xe009;" ng-repeat="t in selected.to">{{t.address}} </span></p>