@@ -29,60 +29,59 @@ angular.module('wt.genius', []);
2929 this . config = function ( value ) {
3030 configOptions = value ;
3131 } ;
32- this . $get = [ '$http' , '$document' , '$compile' , '$rootScope' , '$controller' , '$templateCache' , '$q' , '$injector' , '$position' , '$timeout' ,
33- function ( $http , $document , $compile , $rootScope , $controller , $templateCache , $q , $injector , $position , $timeout ) {
34- var result ;
32+ this . $get = [ function ( ) {
33+ var result ;
3534
36- function _notify ( p ) {
37- var options = this . options = angular . extend ( { } , defaults , configOptions , p ) ;
38- var myNotify = new Notify ( options . title , options ) ;
39- if ( Notify . needsPermission ) {
40- Notify . requestPermission ( function ( ) {
41- myNotify . show ( ) ;
42- } ) ;
43- } else {
35+ function _notify ( p ) {
36+ var options = this . options = angular . extend ( { } , defaults , configOptions , p ) ;
37+ var myNotify = new Notify ( options . title , options ) ;
38+ if ( Notify . needsPermission ) {
39+ Notify . requestPermission ( function ( ) {
4440 myNotify . show ( ) ;
45- }
41+ } ) ;
42+ } else {
43+ myNotify . show ( ) ;
4644 }
45+ }
4746
48- result = {
49- notify : function ( p ) {
50- //初始化,默认去验证权限
51- return new _notify ( p ) ;
52- } ,
53- notSetPermission : Notify . permissionLevel == 'default' ,
54- checkPermission : function ( onSuccess , onError , onThen ) {
55- //验证权限,设置开启与禁止
56- var onSuccess = onSuccess || function ( ) {
57- } ;
58- var onError = onError || function ( ) {
59- } ;
60- var onThen = onThen || function ( ) {
61- } ;
62- if ( Notify . needsPermission ) {
63- Notify . requestPermission ( function ( ) {
64- result . permissionLevel = 'granted' ;
65- result . needsPermission = false ;
66- onSuccess ( ) ;
67- } , function ( ) {
68- result . permissionLevel = 'denied' ;
69- result . needsPermission = true ;
70- onError ( ) ;
71- } ) ;
72- } else {
47+ result = {
48+ notify : function ( p ) {
49+ //初始化,默认去验证权限
50+ return new _notify ( p ) ;
51+ } ,
52+ notSetPermission : Notify . permissionLevel == 'default' ,
53+ checkPermission : function ( onSuccess , onError , onThen ) {
54+ //验证权限,设置开启与禁止
55+ var onSuccess = onSuccess || function ( ) {
56+ } ;
57+ var onError = onError || function ( ) {
58+ } ;
59+ var onThen = onThen || function ( ) {
60+ } ;
61+ if ( Notify . needsPermission ) {
62+ Notify . requestPermission ( function ( ) {
7363 result . permissionLevel = 'granted' ;
64+ result . needsPermission = false ;
7465 onSuccess ( ) ;
75- }
76- result . notSetPermission = false ;
77- onThen ( ) ;
78- } ,
79- needsPermission : Notify . needsPermission ,
80- requestPermission : Notify . requestPermission ,
81- isSupported : Notify . isSupported ,
82- permissionLevel : Notify . permissionLevel
83- } ;
84- return result ;
85- }
66+ } , function ( ) {
67+ result . permissionLevel = 'denied' ;
68+ result . needsPermission = true ;
69+ onError ( ) ;
70+ } ) ;
71+ } else {
72+ result . permissionLevel = 'granted' ;
73+ onSuccess ( ) ;
74+ }
75+ result . notSetPermission = false ;
76+ onThen ( ) ;
77+ } ,
78+ needsPermission : Notify . needsPermission ,
79+ requestPermission : Notify . requestPermission ,
80+ isSupported : Notify . isSupported ,
81+ permissionLevel : Notify . permissionLevel
82+ } ;
83+ return result ;
84+ }
8685 ] ;
8786 } ] ) ;
8887} ) ( ) ;
0 commit comments