2015-01-09 21:58:11 +01:00
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/ * *
* The common SOGo UI , app module
*
* @ type { angular . Module }
* /
2015-01-27 04:01:24 +01:00
( function ( ) {
2015-01-09 21:58:11 +01:00
'use strict' ;
2015-03-09 19:09:26 +01:00
2015-03-23 15:53:17 +01:00
angular . module ( 'SOGo.UI' , [ 'ngMaterial' , 'ngAnimate' ] )
2015-03-19 08:40:46 +01:00
// md break-points values are hard-coded in angular-material/src/core/util/constant.js
// $mdMedia has a built-in support for those values but can also evaluate others
// For some reasons, angular-material's break-points don't match the specs
// Here we define values according to specs
. constant ( 'sgConstant' , {
'sm' : '(max-width: 600px)' ,
'gt-sm' : '(min-width: 600px)' ,
'md' : '(min-width: 600px) and (max-width: 1024px)' ,
'gt-md' : '(min-width: 1025px)' ,
'lg' : '(min-width: 1024px) and (max-width: 1280px)' ,
'gt-lg' : '(min-width: 1280px)'
} )
2015-01-17 05:22:59 +01:00
2015-03-09 19:09:26 +01:00
. config ( [ '$mdThemingProvider' , function ( $mdThemingProvider ) {
2015-01-27 21:50:19 +01:00
2015-03-09 19:09:26 +01:00
$mdThemingProvider . definePalette ( 'sogo-green' , {
'50' : 'eaf5e9' ,
'100' : 'cbe5c8' ,
'200' : 'aad6a5' ,
'300' : '88c781' ,
'400' : '66b86a' ,
'500' : '56b04c' ,
'600' : '4da143' ,
'700' : '388e3c' ,
'800' : '367d2e' ,
'900' : '225e1b' ,
'A100' : 'b9f6ca' ,
'A200' : '69f0ae' ,
'A400' : '00e676' ,
'A700' : '00c853' ,
'contrastDefaultColor' : 'dark' ,
2015-03-14 01:35:27 +01:00
'contrastDarkColors' : '50 100 200' ,
'contrastLightColors' : '300 400 500 600 700 800 900'
2015-03-09 19:09:26 +01:00
} ) ;
2015-03-14 01:35:27 +01:00
$mdThemingProvider . definePalette ( 'sogo-blue' , {
2015-03-09 19:09:26 +01:00
'50' : 'f0faf9' ,
'100' : 'e1f5f3' ,
'200' : 'ceebe8' ,
'300' : 'bfe0dd' ,
'400' : 'b2d6d3' ,
'500' : 'a1ccc8' ,
'600' : '8ebfbb' ,
'700' : '7db3b0' ,
'800' : '639997' ,
'900' : '4d8080' ,
'A100' : 'd4f7fa' ,
'A200' : 'c3f5fa' ,
'A400' : '53e3f0' ,
'A700' : '00b0c0' ,
'contrastDefaultColor' : 'light' ,
'contrastDarkColors' : [ '50' , '100' , '200' ] ,
'contrastLightColors' : [ '300' , '400' , '500' , '600' , '700' , '800' , '900' , 'A100' , 'A200' , 'A400' , 'A700' ]
} ) ;
2015-03-14 01:35:27 +01:00
$mdThemingProvider . definePalette ( 'sogo-paper' , {
2015-03-09 19:09:26 +01:00
'50' : 'fcf7f8' ,
'100' : 'f7f1dc' ,
'200' : 'ede5ca' ,
'300' : 'e6d8ba' ,
'400' : 'e2d2a3' ,
'500' : 'd6c48d' ,
'600' : 'baa870' ,
'700' : '857545' ,
'800' : '524517' ,
'900' : '433809' ,
'1000' : '000000' ,
'A100' : 'ffffff' ,
'A200' : 'eeeeee' ,
'A400' : 'bdbdbd' ,
'A700' : '616161' ,
'contrastDefaultColor' : 'dark' ,
'contrastLightColors' : '800 900'
} ) ;
// Default theme definition
// .primaryColor will soon be deprecated in favor of primaryPalette (already on dev builds https://groups.google.com/forum/m/#!topic/ngmaterial/-sXR8CYBMPg)
$mdThemingProvider . theme ( 'default' )
2015-03-14 01:35:27 +01:00
. primaryPalette ( 'sogo-blue' , {
2015-03-09 19:09:26 +01:00
'default' : '300' ,
'hue-1' : '100' ,
'hue-2' : '400' ,
'hue-3' : 'A700'
} )
2015-03-14 01:35:27 +01:00
. accentPalette ( 'sogo-green' , {
2015-03-26 14:58:09 +01:00
'default' : '500' ,
2015-03-14 01:35:27 +01:00
'hue-1' : '200' ,
2015-03-26 14:58:09 +01:00
'hue-2' : '300' ,
2015-03-14 01:35:27 +01:00
'hue-3' : 'A700'
} )
. backgroundPalette ( 'sogo-paper' , {
2015-04-15 04:19:51 +02:00
'default' : '100' ,
2015-03-09 19:09:26 +01:00
'hue-1' : '200' ,
'hue-2' : '50' ,
2015-04-15 04:19:51 +02:00
'hue-3' : '500'
2015-01-27 05:33:47 +01:00
} ) ;
2015-03-09 19:09:26 +01:00
} ] )
2015-01-27 04:01:24 +01:00
2015-03-09 19:09:26 +01:00
. filter ( 'encodeUri' , function ( $window ) {
return $window . encodeURIComponent ;
} )
2015-01-27 04:01:24 +01:00
2015-03-09 19:09:26 +01:00
. filter ( 'decodeUri' , function ( $window ) {
return $window . decodeURIComponent ;
} )
2015-01-27 04:01:24 +01:00
2015-03-09 19:09:26 +01:00
. filter ( 'loc' , function ( ) {
return l ;
} )
2015-01-09 21:58:11 +01:00
2015-03-26 13:52:48 +01:00
. controller ( 'navController' , [ '$scope' , '$timeout' , '$interval' , '$http' , '$mdSidenav' , '$mdBottomSheet' , '$mdMedia' , '$log' , 'sgConstant' , function ( $scope , $timeout , $interval , $http , $mdSidenav , $mdBottomSheet , $mdMedia , $log , sgConstant ) {
2015-03-26 19:39:44 +01:00
2015-03-26 13:52:48 +01:00
// Show current day in top bar
$scope . currentDay = window . currentDay ;
$timeout ( function ( ) {
// Update date when day ends
$interval ( function ( ) {
$http . get ( '../date' ) . success ( function ( data ) {
$scope . currentDay = data ;
} ) ;
} , 24 * 3600 * 1000 ) ;
} , window . secondsBeforeTomorrow * 1000 ) ;
2015-03-19 08:40:46 +01:00
2015-03-09 19:09:26 +01:00
$scope . toggleLeft = function ( ) {
$mdSidenav ( 'left' ) . toggle ( )
. then ( function ( ) {
$log . debug ( "toggle left is done" ) ;
} ) ;
} ;
$scope . toggleRight = function ( ) {
$mdSidenav ( 'right' ) . toggle ( )
. then ( function ( ) {
$log . debug ( "toggle RIGHT is done" ) ;
} ) ;
} ;
2015-03-14 01:35:27 +01:00
$scope . openBottomSheet = function ( ) {
$mdBottomSheet . show ( {
parent : angular . element ( document . getElementById ( 'left-sidenav' ) ) ,
templateUrl : 'bottomSheetTemplate.html'
} ) ;
} ;
2015-03-26 14:58:09 +01:00
$scope . toggleDetailView = function ( ) {
2015-03-26 19:39:44 +01:00
var detail = angular . element ( document . getElementById ( 'detailView' ) ) ;
detail . toggleClass ( 'sg-close' ) ;
2015-03-26 14:58:09 +01:00
} ;
2015-03-19 08:40:46 +01:00
$scope . $watch ( function ( ) {
return $mdMedia ( sgConstant [ 'gt-md' ] ) ;
} ,
function ( newVal ) {
$scope . isGtMedium = newVal ;
} ) ;
2015-03-09 19:09:26 +01:00
} ] ) ;
2015-01-09 21:58:11 +01:00
} ) ( ) ;