File size: 2,465 Bytes
7f88cfb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
'use strict';
/**
* Module dependencies
*/
var angular = require('angular'),
AppContainer = require('./directives/appContainer');
module.exports = angular
.module('app.main', [
require('../common/libs').name,
require('../common/db').name,
])
.constant('config', {
backdrop : true,
debug : true,
defaultRoute : '/notes',
activeTimerId : 'at',
hrefWhitelist : /^\s*(https?|ftp|mailto|file|tel):/
})
.constant('appVersion', require('../../package.json').version)
.config(function ($compileProvider, $urlRouterProvider, config) {
// set anchor href whitelist
if (config.hrefWhitelist) {
$compileProvider.aHrefSanitizationWhitelist(config.hrefWhitelist);
}
// add default route
if (config.defaultRoute) {
$urlRouterProvider.otherwise(config.defaultRoute);
}
})
.config(function (dbsProvider) {
dbsProvider
.db('notes', {
auto_compaction : true,
adapter : 'websql'
});
})
.directive('appContainer', AppContainer)
.factory('app', require('./services/app'))
.run(function ($log, $rootScope, $ionicBackdrop, $timeout, config) {
$log.debug('app.main module - run');
if (config.debug) {
$rootScope.$on('$stateChangeStart',
function (event, toState) {
$log.debug('$stateChangeStart -', toState.name);
});
$rootScope.$on('$stateChangeSuccess',
function (event, toState) {
$log.debug('$stateChangeSuccess -', toState.name);
});
}
$rootScope.$on('$stateNotFound',
function (event, unfoundState, fromState, fromParams) {
$log.warn('$stateNotFound', {
event : event,
unfoundState : unfoundState,
fromState : fromState,
fromParams : fromParams
});
});
$rootScope.$on('$stateChangeError',
function (event, toState, toParams, fromState, fromParams, error) {
$log.error('$stateChangeError', {
event : event,
toState : toState,
toParams : toParams,
fromState : fromState,
fromParams : fromParams,
error : error
});
if (error) {
throw error;
}
});
// add backdrop if enabled
if (config.backdrop) {
$ionicBackdrop.retain();
$timeout(function () {
$ionicBackdrop.release();
}, 600);
}
});
|