From 4fc4b02c267a299c9c1b981d97faa141e2cb11cf Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Thu, 8 May 2014 16:25:20 +0200 Subject: [PATCH 1/3] Fix development mode for ui work --- src/js/controller/mail-list.js | 106 +++++++++++++++++---------------- 1 file changed, 55 insertions(+), 51 deletions(-) diff --git a/src/js/controller/mail-list.js b/src/js/controller/mail-list.js index 7eab938..b386e9e 100644 --- a/src/js/controller/mail-list.js +++ b/src/js/controller/mail-list.js @@ -17,57 +17,6 @@ define(function(require) { outboxBo = appController._outboxBo; emailSync = appController._emailSync; - emailDao.onNeedsSync = function(error, folder) { - if (error) { - $scope.onError(error); - return; - } - - $scope.synchronize({ - folder: folder - }); - }; - - emailSync.onIncomingMessage = function(msgs) { - var popupId, popupTitle, popupMessage, unreadMsgs; - - unreadMsgs = msgs.filter(function(msg) { - return msg.unread; - }); - - if (unreadMsgs.length === 0) { - return; - } - - popupId = '' + unreadMsgs[0].uid; - if (unreadMsgs.length > 1) { - popupTitle = unreadMsgs.length + ' new messages'; - popupMessage = _.pluck(unreadMsgs, 'subject').join('\n'); - } else { - popupTitle = unreadMsgs[0].from[0].name || unreadMsgs[0].from[0].address; - popupMessage = unreadMsgs[0].subject; - } - - notification.create({ - id: popupId, - title: popupTitle, - message: popupMessage - }); - }; - - notification.setOnClickedListener(function(uidString) { - var uid = parseInt(uidString, 10); - - if (isNaN(uid)) { - return; - } - - $scope.select(_.findWhere(currentFolder().messages, { - uid: uid - })); - }); - - // // scope functions // @@ -294,6 +243,60 @@ define(function(require) { function currentFolder() { return $scope.state.nav.currentFolder; } + + if (!emailDao || !emailSync) { + return; // development mode + } + + emailDao.onNeedsSync = function(error, folder) { + if (error) { + $scope.onError(error); + return; + } + + $scope.synchronize({ + folder: folder + }); + }; + + emailSync.onIncomingMessage = function(msgs) { + var popupId, popupTitle, popupMessage, unreadMsgs; + + unreadMsgs = msgs.filter(function(msg) { + return msg.unread; + }); + + if (unreadMsgs.length === 0) { + return; + } + + popupId = '' + unreadMsgs[0].uid; + if (unreadMsgs.length > 1) { + popupTitle = unreadMsgs.length + ' new messages'; + popupMessage = _.pluck(unreadMsgs, 'subject').join('\n'); + } else { + popupTitle = unreadMsgs[0].from[0].name || unreadMsgs[0].from[0].address; + popupMessage = unreadMsgs[0].subject; + } + + notification.create({ + id: popupId, + title: popupTitle, + message: popupMessage + }); + }; + + notification.setOnClickedListener(function(uidString) { + var uid = parseInt(uidString, 10); + + if (isNaN(uid)) { + return; + } + + $scope.select(_.findWhere(currentFolder().messages, { + uid: uid + })); + }); }; function createDummyMails() { @@ -415,6 +418,7 @@ define(function(require) { '>> from 0.7.0.1\n' + '>>\n' + '>> God speed!'; // plaintext body + this.html = '

HTML content

'; this.encrypted = true; this.decrypted = true; }; From c272b4f9371e3681fd19fdf48cc4447069fb5a31 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Thu, 8 May 2014 16:32:46 +0200 Subject: [PATCH 2/3] [WO-323] Render HTML content in sandboxed iframe --- src/js/controller/read.js | 14 +++++++++----- src/sass/views/_read.scss | 27 +++++++++++++++++---------- src/tpl/read.html | 37 +++++++++++++++++++++++-------------- 3 files changed, 49 insertions(+), 29 deletions(-) diff --git a/src/js/controller/read.js b/src/js/controller/read.js index 8a054ab..da173fb 100644 --- a/src/js/controller/read.js +++ b/src/js/controller/read.js @@ -330,11 +330,15 @@ define(function(require) { }; }); - ngModule.directive('frameLoad', function() { - return function(scope, elm) { - elm.bind('load', function() { - var frame = elm[0]; - frame.height = frame.contentWindow.document.body.scrollHeight + 'px'; + ngModule.directive('frameLoad', function($parse, $sce, $timeout) { + return function(scope, elm, attrs) { + scope.$watch(attrs.frameLoad, function(value) { + scope.html = undefined; + if (value) { + $timeout(function() { + scope.html = $sce.trustAsHtml(value); + }); + } }); }; }); diff --git a/src/sass/views/_read.scss b/src/sass/views/_read.scss index 7ebb8de..d9694c5 100644 --- a/src/sass/views/_read.scss +++ b/src/sass/views/_read.scss @@ -87,13 +87,9 @@ } } - .body { + .working-wrapper { flex-grow: 1; position: relative; - margin-top: 1.75em; - line-height: 1.5em; - overflow-y: scroll; - user-select: text; .working { @include scut-vcenter-tt; @@ -106,6 +102,22 @@ vertical-align: middle; } } + } + + iframe { + flex-grow: 1; + margin-top: 1.75em; + width: 100%; + height: 100%; + border: none; + } + + .body { + flex-grow: 1; + margin-top: 1.75em; + line-height: 1.5em; + overflow-y: scroll; + user-select: text; .line { cursor: text; @@ -147,11 +159,6 @@ } } - iframe { - flex-grow: 1; - width: 100%; - } - .reply-selection { .popover-content { padding: 0; diff --git a/src/tpl/read.html b/src/tpl/read.html index ce0dcba..f3d7862 100644 --- a/src/tpl/read.html +++ b/src/tpl/read.html @@ -1,4 +1,5 @@
+
@@ -43,21 +44,28 @@
-
-
- - -
-
- -
-
+ +
+
- +
+
+ + + + + +
+
+
@@ -74,4 +82,5 @@
  • -
    + +
    \ No newline at end of file From 36c08cdbb156e9b6af814db2c3bcbd27b5e2b9b4 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Fri, 9 May 2014 10:19:35 +0200 Subject: [PATCH 3/3] Remove $parse from frameLoad directive --- src/js/controller/read.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/controller/read.js b/src/js/controller/read.js index da173fb..6dc3258 100644 --- a/src/js/controller/read.js +++ b/src/js/controller/read.js @@ -330,7 +330,7 @@ define(function(require) { }; }); - ngModule.directive('frameLoad', function($parse, $sce, $timeout) { + ngModule.directive('frameLoad', function($sce, $timeout) { return function(scope, elm, attrs) { scope.$watch(attrs.frameLoad, function(value) { scope.html = undefined; @@ -353,4 +353,4 @@ define(function(require) { }); return ReadCtrl; -}); \ No newline at end of file +});