mirror of
https://github.com/moparisthebest/mail
synced 2024-12-04 06:42:17 -05:00
refactor read to use own controller logic and fix edit bug in live encryption
This commit is contained in:
parent
8c632fb885
commit
038b5a1d62
@ -5,11 +5,12 @@ require([
|
|||||||
'angular',
|
'angular',
|
||||||
'js/controller/login',
|
'js/controller/login',
|
||||||
'js/controller/mail-list',
|
'js/controller/mail-list',
|
||||||
|
'js/controller/read',
|
||||||
'js/controller/write',
|
'js/controller/write',
|
||||||
'js/controller/navigation',
|
'js/controller/navigation',
|
||||||
'angularRoute',
|
'angularRoute',
|
||||||
'angularTouch'
|
'angularTouch'
|
||||||
], function(angular, LoginCtrl, MailListCtrl, WriteCtrl, NavigationCtrl) {
|
], function(angular, LoginCtrl, MailListCtrl, ReadCtrl, WriteCtrl, NavigationCtrl) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var app = angular.module('mail', ['ngRoute', 'ngTouch', 'write', 'read']);
|
var app = angular.module('mail', ['ngRoute', 'ngTouch', 'write', 'read']);
|
||||||
@ -34,6 +35,7 @@ require([
|
|||||||
});
|
});
|
||||||
|
|
||||||
// inject controllers from ng-included view templates
|
// inject controllers from ng-included view templates
|
||||||
|
app.controller('ReadCtrl', ReadCtrl);
|
||||||
app.controller('MailListCtrl', MailListCtrl);
|
app.controller('MailListCtrl', MailListCtrl);
|
||||||
|
|
||||||
// manually bootstrap angular due to require.js
|
// manually bootstrap angular due to require.js
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
define(function(require) {
|
define(function(require) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var angular = require('angular'),
|
var folders = require('js/app-config').config.gmail.folders;
|
||||||
folders = require('js/app-config').config.gmail.folders;
|
|
||||||
|
|
||||||
var NavigationCtrl = function($scope) {
|
var NavigationCtrl = function($scope) {
|
||||||
$scope.navOpen = false;
|
$scope.navOpen = false;
|
||||||
@ -41,20 +40,5 @@ define(function(require) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
|
||||||
// Directives
|
|
||||||
//
|
|
||||||
|
|
||||||
var ngModule = angular.module('read', []);
|
|
||||||
ngModule.directive('frameLoad', function() {
|
|
||||||
return function(scope, elm) {
|
|
||||||
var frame;
|
|
||||||
elm.bind('load', function() {
|
|
||||||
frame = elm[0];
|
|
||||||
frame.height = frame.contentWindow.document.body.scrollHeight + 'px';
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return NavigationCtrl;
|
return NavigationCtrl;
|
||||||
});
|
});
|
27
src/js/controller/read.js
Normal file
27
src/js/controller/read.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
define(function(require) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var angular = require('angular');
|
||||||
|
|
||||||
|
//
|
||||||
|
// Controller
|
||||||
|
//
|
||||||
|
|
||||||
|
var ReadCtrl = function() {};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Directives
|
||||||
|
//
|
||||||
|
|
||||||
|
var ngModule = angular.module('read', []);
|
||||||
|
ngModule.directive('frameLoad', function() {
|
||||||
|
return function(scope, elm) {
|
||||||
|
elm.bind('load', function() {
|
||||||
|
var frame = elm[0];
|
||||||
|
frame.height = frame.contentWindow.document.body.scrollHeight + 'px';
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return ReadCtrl;
|
||||||
|
});
|
@ -36,9 +36,9 @@ define(function(require) {
|
|||||||
// remove generated html from body
|
// remove generated html from body
|
||||||
body = parseBody(body);
|
body = parseBody(body);
|
||||||
|
|
||||||
// Although this does encrypt live using AES, this is just for show. The plaintext is encrypted seperately using before sending the email.
|
// Although this does encrypt live using AES, this is just for show. The plaintext is encrypted seperately before sending the email.
|
||||||
var plaintext = ($scope.subject) ? $scope.subject + body : body;
|
var plaintext = ($scope.subject) ? $scope.subject + body : body;
|
||||||
$scope.ciphertextPreview = aes.encrypt(plaintext, key, iv);
|
$scope.ciphertextPreview = (plaintext) ? aes.encrypt(plaintext, key, iv) : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.sendEmail = function() {
|
$scope.sendEmail = function() {
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<div class="column view-mail-list" ng-include="'tpl/mail-list.html'" ng-controller="MailListCtrl"></div>
|
<div class="column view-mail-list" 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'"></div>
|
<div class="column" ng-include="'tpl/read.html'" ng-controller="ReadCtrl"></div>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
</div><!--/.nav-pusher-->
|
</div><!--/.nav-pusher-->
|
||||||
|
Loading…
Reference in New Issue
Block a user