mirror of
https://github.com/moparisthebest/mail
synced 2024-11-26 19:02:20 -05:00
create dialog and start cleanup of controller code using scope chain
This commit is contained in:
parent
f36f664a43
commit
28a109bb07
@ -40,11 +40,17 @@ define(function(require) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.checkForUpdate = function() {
|
self.checkForUpdate = function(callback) {
|
||||||
// check for update and restart app automatically
|
if (!chrome || !chrome.runtime || !chrome.runtime.onUpdateAvailable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for update and restart on confirmation
|
||||||
chrome.runtime.onUpdateAvailable.addListener(function(details) {
|
chrome.runtime.onUpdateAvailable.addListener(function(details) {
|
||||||
console.log("Updating to version " + details.version);
|
callback(function() {
|
||||||
chrome.runtime.reload();
|
console.log("Updating to version " + details.version);
|
||||||
|
chrome.runtime.reload();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
chrome.runtime.requestUpdateCheck(function(status) {
|
chrome.runtime.requestUpdateCheck(function(status) {
|
||||||
if (status === "update_found") {
|
if (status === "update_found") {
|
||||||
|
@ -3,6 +3,7 @@ window.name = 'NG_DEFER_BOOTSTRAP!';
|
|||||||
|
|
||||||
require([
|
require([
|
||||||
'angular',
|
'angular',
|
||||||
|
'js/controller/dialog',
|
||||||
'js/controller/account',
|
'js/controller/account',
|
||||||
'js/controller/login',
|
'js/controller/login',
|
||||||
'js/controller/login-initial',
|
'js/controller/login-initial',
|
||||||
@ -14,7 +15,7 @@ require([
|
|||||||
'js/controller/navigation',
|
'js/controller/navigation',
|
||||||
'angularRoute',
|
'angularRoute',
|
||||||
'angularTouch'
|
'angularTouch'
|
||||||
], function(angular, AccountCtrl, LoginCtrl, LoginInitialCtrl, LoginNewDeviceCtrl, LoginExistingCtrl, MailListCtrl, ReadCtrl, WriteCtrl, NavigationCtrl) {
|
], function(angular, DialogCtrl, AccountCtrl, LoginCtrl, LoginInitialCtrl, LoginNewDeviceCtrl, LoginExistingCtrl, MailListCtrl, ReadCtrl, WriteCtrl, NavigationCtrl) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var app = angular.module('mail', ['ngRoute', 'ngTouch', 'navigation', 'mail-list', 'write', 'read', 'login-new-device']);
|
var app = angular.module('mail', ['ngRoute', 'ngTouch', 'navigation', 'mail-list', 'write', 'read', 'login-new-device']);
|
||||||
@ -51,6 +52,7 @@ require([
|
|||||||
app.controller('WriteCtrl', WriteCtrl);
|
app.controller('WriteCtrl', WriteCtrl);
|
||||||
app.controller('MailListCtrl', MailListCtrl);
|
app.controller('MailListCtrl', MailListCtrl);
|
||||||
app.controller('AccountCtrl', AccountCtrl);
|
app.controller('AccountCtrl', AccountCtrl);
|
||||||
|
app.controller('DialogCtrl', DialogCtrl);
|
||||||
|
|
||||||
// manually bootstrap angular due to require.js
|
// manually bootstrap angular due to require.js
|
||||||
angular.element().ready(function() {
|
angular.element().ready(function() {
|
||||||
|
16
src/js/controller/dialog.js
Normal file
16
src/js/controller/dialog.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
define(function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var DialogCtrl = function($scope) {
|
||||||
|
$scope.confirm = function(ok) {
|
||||||
|
$scope.state.dialog.open = false;
|
||||||
|
|
||||||
|
if ($scope.state.dialog.callback) {
|
||||||
|
$scope.state.dialog.callback(ok);
|
||||||
|
}
|
||||||
|
$scope.state.dialog.callback = undefined;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
return DialogCtrl;
|
||||||
|
});
|
@ -16,8 +16,6 @@ define(function(require) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for app update
|
|
||||||
appController.checkForUpdate();
|
|
||||||
// login to imap
|
// login to imap
|
||||||
initializeUser();
|
initializeUser();
|
||||||
});
|
});
|
||||||
|
@ -145,7 +145,7 @@ define(function(require) {
|
|||||||
function syncImapFolder(options, callback) {
|
function syncImapFolder(options, callback) {
|
||||||
emailDao.unreadMessages(getFolder().path, function(err, unreadCount) {
|
emailDao.unreadMessages(getFolder().path, function(err, unreadCount) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
$scope.onError(err);
|
||||||
updateStatus('Error on sync!');
|
updateStatus('Error on sync!');
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
return;
|
return;
|
||||||
@ -156,7 +156,7 @@ define(function(require) {
|
|||||||
|
|
||||||
emailDao.imapSync(options, function(err) {
|
emailDao.imapSync(options, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
$scope.onError(err);
|
||||||
updateStatus('Error on sync!');
|
updateStatus('Error on sync!');
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
return;
|
return;
|
||||||
@ -171,7 +171,7 @@ define(function(require) {
|
|||||||
firstSelect = true;
|
firstSelect = true;
|
||||||
emailDao.listMessages(options, function(err, emails) {
|
emailDao.listMessages(options, function(err, emails) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
$scope.onError(err);
|
||||||
updateStatus('Error listing cache!');
|
updateStatus('Error listing cache!');
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
return;
|
return;
|
||||||
@ -233,7 +233,7 @@ define(function(require) {
|
|||||||
uid: email.uid
|
uid: email.uid
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
$scope.onError(err);
|
||||||
updateStatus('Error marking read!');
|
updateStatus('Error marking read!');
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
return;
|
return;
|
||||||
|
@ -13,6 +13,7 @@ define(function(require) {
|
|||||||
//
|
//
|
||||||
|
|
||||||
var NavigationCtrl = function($scope) {
|
var NavigationCtrl = function($scope) {
|
||||||
|
$scope.$root.state = {};
|
||||||
$scope.navOpen = false;
|
$scope.navOpen = false;
|
||||||
$scope.writerOpen = false;
|
$scope.writerOpen = false;
|
||||||
$scope.accountOpen = false;
|
$scope.accountOpen = false;
|
||||||
@ -23,11 +24,20 @@ define(function(require) {
|
|||||||
// scope functions
|
// scope functions
|
||||||
//
|
//
|
||||||
|
|
||||||
$scope.openNav = function() {
|
$scope.$root.onError = function(options) {
|
||||||
$scope.navOpen = true;
|
console.error(options);
|
||||||
|
$scope.state.dialog = {
|
||||||
|
open: true,
|
||||||
|
title: options.title || 'Error',
|
||||||
|
message: options.message || options.errMsg
|
||||||
|
};
|
||||||
};
|
};
|
||||||
$scope.closeNav = function() {
|
|
||||||
$scope.navOpen = false;
|
$scope.state.nav = {
|
||||||
|
open: false,
|
||||||
|
toggle: function(to) {
|
||||||
|
this.open = to;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.openWriter = function(replyTo) {
|
$scope.openWriter = function(replyTo) {
|
||||||
@ -40,7 +50,7 @@ define(function(require) {
|
|||||||
|
|
||||||
$scope.openFolder = function(folder) {
|
$scope.openFolder = function(folder) {
|
||||||
$scope.currentFolder = folder;
|
$scope.currentFolder = folder;
|
||||||
$scope.closeNav();
|
$scope.state.nav.toggle(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.openAccount = function() {
|
$scope.openAccount = function() {
|
||||||
@ -188,6 +198,22 @@ define(function(require) {
|
|||||||
// Start
|
// Start
|
||||||
//
|
//
|
||||||
|
|
||||||
|
function onUpdateAvailable(doUpdate) {
|
||||||
|
$scope.state.dialog = {
|
||||||
|
open: true,
|
||||||
|
title: 'Update available',
|
||||||
|
message: 'Would you like to update the application now?',
|
||||||
|
callback: function(confirm) {
|
||||||
|
if (confirm) {
|
||||||
|
doUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// check for app update
|
||||||
|
appController.checkForUpdate(onUpdateAvailable);
|
||||||
|
|
||||||
|
// init folders
|
||||||
initFolders(function(folders) {
|
initFolders(function(folders) {
|
||||||
$scope.folders = folders;
|
$scope.folders = folders;
|
||||||
// select inbox as the current folder on init
|
// select inbox as the current folder on init
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
// Views
|
// Views
|
||||||
@import "views/shared";
|
@import "views/shared";
|
||||||
@import "views/account";
|
@import "views/account";
|
||||||
|
@import "views/dialog";
|
||||||
@import "views/navigation";
|
@import "views/navigation";
|
||||||
@import "views/mail-list";
|
@import "views/mail-list";
|
||||||
@import "views/read";
|
@import "views/read";
|
||||||
|
29
src/sass/views/_dialog.scss
Normal file
29
src/sass/views/_dialog.scss
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
.view-dialog {
|
||||||
|
padding: 0px;
|
||||||
|
color: $color-grey-dark;
|
||||||
|
max-width: 350px;
|
||||||
|
height: auto;
|
||||||
|
top: 30%;
|
||||||
|
|
||||||
|
@include respond-to(mobile) {
|
||||||
|
top: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
text-align: center;
|
||||||
|
max-width: 80%;
|
||||||
|
margin: 50px auto 90px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 15px;
|
||||||
|
right: 15px;
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: 100px;
|
||||||
|
border: 0!important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
<div class="nav-container nav-effect" ng-class="{'nav-menu-open': navOpen}">
|
<div class="nav-container nav-effect" ng-class="{'nav-menu-open': state.nav.open}">
|
||||||
|
|
||||||
<!-- main navigation -->
|
<!-- main navigation -->
|
||||||
<nav class="nav-menu nav-effect" ng-include="'tpl/navigation.html'"></nav>
|
<nav class="nav-menu nav-effect" ng-include="'tpl/navigation.html'"></nav>
|
||||||
|
|
||||||
<!-- content wrapper pushed right -->
|
<!-- content wrapper pushed right -->
|
||||||
<div class="nav-pusher" ng-click="closeNav()">
|
<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': readingMode}">
|
||||||
|
|
||||||
<!-- left column: containing list view and navigation header -->
|
<!-- left column: containing list view and navigation header -->
|
||||||
@ -25,4 +25,7 @@
|
|||||||
<div class="lightbox-overlay" ng-class="{'show': accountOpen}">
|
<div class="lightbox-overlay" ng-class="{'show': accountOpen}">
|
||||||
<div class="lightbox lightbox-effect" ng-include="'tpl/account.html'"></div>
|
<div class="lightbox lightbox-effect" ng-include="'tpl/account.html'"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="lightbox-overlay" ng-class="{'show': state.dialog.open}">
|
||||||
|
<div class="lightbox lightbox-effect view-dialog" ng-include="'tpl/dialog.html'"></div>
|
||||||
|
</div>
|
||||||
<!--/.lightbox-overlay-->
|
<!--/.lightbox-overlay-->
|
13
src/tpl/dialog.html
Normal file
13
src/tpl/dialog.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<div class="lightbox-body" ng-controller="DialogCtrl">
|
||||||
|
<header>
|
||||||
|
<h2>{{state.dialog.title}}</h2>
|
||||||
|
<button class="close" ng-click="confirm(false)" data-action="lightbox-close"></button>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<p>{{state.dialog.message}}</p>
|
||||||
|
<div class="control">
|
||||||
|
<button ng-click="confirm(true)" class="btn">Ok</button>
|
||||||
|
</div>
|
||||||
|
</div><!-- /.content -->
|
||||||
|
</div><!-- /.lightbox-body -->
|
@ -1,6 +1,6 @@
|
|||||||
<div class="view-mail-list">
|
<div class="view-mail-list">
|
||||||
<!-- nav controll and section headline -->
|
<!-- nav controll and section headline -->
|
||||||
<header data-icon="" ng-click="openNav(); $event.stopPropagation()">
|
<header data-icon="" ng-click="state.nav.toggle(true); $event.stopPropagation()">
|
||||||
<h2>{{currentFolder.type}}</h2>
|
<h2>{{currentFolder.type}}</h2>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user