1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-23 07:48:48 -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;
}
$scope.openReadMode();
$scope.state.read.toggle(true);
if (!window.chrome || !chrome.socket) {
return;
}

View File

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

View File

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

View File

@ -5,13 +5,13 @@
<!-- content wrapper pushed right -->
<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 -->
<div class="column column-left" ng-include="'tpl/mail-list.html'" ng-controller="MailListCtrl"></div>
<!-- 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>
</div><!--/.nav-pusher-->

View File

@ -4,9 +4,9 @@
<button ng-click="state.writer.write()" class="btn-icon" title="New mail">&#xe006;</button>
</div><!--/.controls-->
<div class="view-read">
<div class="view-read" ng-controller="ReadCtrl">
<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="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>