Skip to content

Commit e3a2d1d

Browse files
committed
use gulp-umd
1 parent 8e285c4 commit e3a2d1d

File tree

5 files changed

+174
-149
lines changed

5 files changed

+174
-149
lines changed

dist/angular-wt-genius-min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-wt-genius.js

Lines changed: 81 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
;(function(root, factory) {
2+
if (typeof define === 'function' && define.amd) {
3+
define(['Notify'], factory);
4+
} else if (typeof exports === 'object') {
5+
module.exports = factory(require('Notify'));
6+
} else {
7+
root.$wtNotify = factory(root.Notify);
8+
}
9+
}(this, function(Notify) {
110
angular.module('wt.genius', []);
211
/**
312
* $wtNotify
@@ -6,85 +15,82 @@ angular.module('wt.genius', []);
615
* Version: 1.0.0 - 2015-08-25
716
* Anthor: zhenshuai
817
*/
9-
(function () {
10-
'use strict';
11-
angular.module('wt.genius')
12-
.provider('$wtNotify', [function () {
13-
var defaults = {
14-
title : 'Hey, 我在这里!',
15-
body : '',
16-
icon : '',
17-
tag : '',
18-
lang : 'en',
19-
timeout : 2,
20-
notifyShow : function () {
21-
},
22-
notifyClose: function () {
23-
},
24-
notifyClick: function () {
25-
},
26-
notifyError: function () {
18+
angular.module('wt.genius')
19+
.provider('$wtNotify', [function () {
20+
var defaults = {
21+
title : 'Hey, 我在这里!',
22+
body : '',
23+
icon : '',
24+
tag : '',
25+
lang : 'en',
26+
timeout : 2,
27+
notifyShow : function () {
28+
},
29+
notifyClose: function () {
30+
},
31+
notifyClick: function () {
32+
},
33+
notifyError: function () {
34+
}
35+
};
36+
var configOptions = {};
37+
this.config = function (value) {
38+
configOptions = value;
39+
};
40+
this.$get = [function () {
41+
var result;
42+
var notify = Notify.default;
43+
44+
function _notify(p) {
45+
var options = this.options = angular.extend({}, defaults, configOptions, p);
46+
var myNotify = new Notify.default(options.title, options);
47+
if (notify.needsPermission) {
48+
notify.requestPermission(function () {
49+
myNotify.show();
50+
});
51+
} else {
52+
myNotify.show();
2753
}
28-
};
29-
var configOptions = {};
30-
this.config = function (value) {
31-
configOptions = value;
32-
};
33-
this.$get = [function () {
34-
var result;
35-
var notify = Notify.default;
54+
}
3655

37-
function _notify(p) {
38-
var options = this.options = angular.extend({}, defaults, configOptions, p);
39-
var myNotify = new Notify.default(options.title, options);
56+
result = {
57+
notify : function (p) {
58+
//初始化,默认去验证权限
59+
return new _notify(p);
60+
},
61+
notSetPermission : notify.permissionLevel == 'default',
62+
checkPermission : function (onSuccess, onError, onThen) {
63+
//验证权限,设置开启与禁止
4064
if (notify.needsPermission) {
65+
if (!notify.isSupported()) {
66+
return;
67+
}
4168
notify.requestPermission(function () {
42-
myNotify.show();
69+
result.permissionLevel = 'granted';
70+
result.needsPermission = false;
71+
onSuccess && onSuccess();
72+
}, function () {
73+
result.permissionLevel = 'denied';
74+
result.needsPermission = true;
75+
onError && onError();
76+
}, function () {
77+
result.notSetPermission = true;
4378
});
4479
} else {
45-
myNotify.show();
80+
result.permissionLevel = 'granted';
81+
onSuccess && onSuccess();
4682
}
47-
}
48-
49-
result = {
50-
notify : function (p) {
51-
//初始化,默认去验证权限
52-
return new _notify(p);
53-
},
54-
notSetPermission : notify.permissionLevel == 'default',
55-
checkPermission : function (onSuccess, onError, onThen) {
56-
//验证权限,设置开启与禁止
57-
if (notify.needsPermission) {
58-
if (!notify.isSupported()) {
59-
return;
60-
}
61-
notify.requestPermission(function () {
62-
result.permissionLevel = 'granted';
63-
result.needsPermission = false;
64-
onSuccess && onSuccess();
65-
}, function () {
66-
result.permissionLevel = 'denied';
67-
result.needsPermission = true;
68-
onError && onError();
69-
}, function () {
70-
result.notSetPermission = true;
71-
});
72-
} else {
73-
result.permissionLevel = 'granted';
74-
onSuccess && onSuccess();
75-
}
76-
result.notSetPermission = false;
77-
onThen && onThen();
78-
},
79-
needsPermission : notify.needsPermission,
80-
requestPermission: notify.requestPermission,
81-
isSupported : notify.isSupported,
82-
permissionLevel : notify.permissionLevel
83-
};
84-
return result;
85-
}];
86-
}]);
87-
})();
83+
result.notSetPermission = false;
84+
onThen && onThen();
85+
},
86+
needsPermission : notify.needsPermission,
87+
requestPermission: notify.requestPermission,
88+
isSupported : notify.isSupported,
89+
permissionLevel : notify.permissionLevel
90+
};
91+
return result;
92+
}];
93+
}]);
8894
/**
8995
* $wtRetina
9096
*
@@ -121,4 +127,6 @@ angular.module('wt.genius', []);
121127
}
122128
];
123129
}]);
124-
})();
130+
})();
131+
return $wtNotify;
132+
}));

gulpfile.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var autoprefixer = require('gulp-autoprefixer');
66
var concat = require('gulp-concat');
77
var uglify = require('gulp-uglify');
88
var plumber = require('gulp-plumber');
9+
var umd = require('gulp-umd');
910
//var del = require('del');
1011

1112

@@ -32,6 +33,25 @@ gulp.task('js', function () {
3233
return gulp.src(['./src/main.js', './src/*/*.js'])
3334
.pipe(plumber({errorHandler: error}))
3435
.pipe(concat('angular-wt-genius.js'))
36+
.pipe(umd({
37+
exports: function(file) {
38+
return '$wtNotify';
39+
},
40+
namespace: function(file) {
41+
return '$wtNotify';
42+
},
43+
dependencies: function(file) {
44+
return [
45+
{
46+
name: 'Notify',
47+
amd: 'Notify',
48+
cjs: 'Notify',
49+
global: 'Notify',
50+
param: 'Notify'
51+
}
52+
];
53+
}
54+
}))
3555
.pipe(gulp.dest('./dist/'));
3656
});
3757
gulp.task('js-min', function () {
@@ -40,5 +60,4 @@ gulp.task('js-min', function () {
4060
.pipe(concat('angular-wt-genius-min.js'))
4161
.pipe(gulp.dest('./dist/'));
4262
});
43-
4463
gulp.task('default', ['style', 'js', 'js-min']);

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-wt-genius",
3-
"version": "1.1.5",
3+
"version": "1.1.6",
44
"description": "Worktile/Lesschat front end util. ## wt-genius-notify ## wt-genius-localData ## wt-genius-validatorName",
55
"main": "gulpfile.js",
66
"scripts": {
@@ -24,6 +24,7 @@
2424
"gulp-less": "^3.0.3",
2525
"gulp-plumber": "^1.0.1",
2626
"gulp-uglify": "^1.2.0",
27-
"gulp-util": "^3.0.6"
27+
"gulp-util": "^3.0.6",
28+
"gulp-umd": "^0.2.1"
2829
}
2930
}

src/wt-notify/wt-notify.js

Lines changed: 69 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,82 +5,79 @@
55
* Version: 1.0.0 - 2015-08-25
66
* Anthor: zhenshuai
77
*/
8-
(function () {
9-
'use strict';
10-
angular.module('wt.genius')
11-
.provider('$wtNotify', [function () {
12-
var defaults = {
13-
title : 'Hey, 我在这里!',
14-
body : '',
15-
icon : '',
16-
tag : '',
17-
lang : 'en',
18-
timeout : 2,
19-
notifyShow : function () {
20-
},
21-
notifyClose: function () {
22-
},
23-
notifyClick: function () {
24-
},
25-
notifyError: function () {
8+
angular.module('wt.genius')
9+
.provider('$wtNotify', [function () {
10+
var defaults = {
11+
title : 'Hey, 我在这里!',
12+
body : '',
13+
icon : '',
14+
tag : '',
15+
lang : 'en',
16+
timeout : 2,
17+
notifyShow : function () {
18+
},
19+
notifyClose: function () {
20+
},
21+
notifyClick: function () {
22+
},
23+
notifyError: function () {
24+
}
25+
};
26+
var configOptions = {};
27+
this.config = function (value) {
28+
configOptions = value;
29+
};
30+
this.$get = [function () {
31+
var result;
32+
var notify = Notify.default;
33+
34+
function _notify(p) {
35+
var options = this.options = angular.extend({}, defaults, configOptions, p);
36+
var myNotify = new Notify.default(options.title, options);
37+
if (notify.needsPermission) {
38+
notify.requestPermission(function () {
39+
myNotify.show();
40+
});
41+
} else {
42+
myNotify.show();
2643
}
27-
};
28-
var configOptions = {};
29-
this.config = function (value) {
30-
configOptions = value;
31-
};
32-
this.$get = [function () {
33-
var result;
34-
var notify = Notify.default;
44+
}
3545

36-
function _notify(p) {
37-
var options = this.options = angular.extend({}, defaults, configOptions, p);
38-
var myNotify = new Notify.default(options.title, options);
46+
result = {
47+
notify : function (p) {
48+
//初始化,默认去验证权限
49+
return new _notify(p);
50+
},
51+
notSetPermission : notify.permissionLevel == 'default',
52+
checkPermission : function (onSuccess, onError, onThen) {
53+
//验证权限,设置开启与禁止
3954
if (notify.needsPermission) {
55+
if (!notify.isSupported()) {
56+
return;
57+
}
4058
notify.requestPermission(function () {
41-
myNotify.show();
59+
result.permissionLevel = 'granted';
60+
result.needsPermission = false;
61+
onSuccess && onSuccess();
62+
}, function () {
63+
result.permissionLevel = 'denied';
64+
result.needsPermission = true;
65+
onError && onError();
66+
}, function () {
67+
result.notSetPermission = true;
4268
});
4369
} else {
44-
myNotify.show();
70+
result.permissionLevel = 'granted';
71+
onSuccess && onSuccess();
4572
}
46-
}
47-
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-
if (notify.needsPermission) {
57-
if (!notify.isSupported()) {
58-
return;
59-
}
60-
notify.requestPermission(function () {
61-
result.permissionLevel = 'granted';
62-
result.needsPermission = false;
63-
onSuccess && onSuccess();
64-
}, function () {
65-
result.permissionLevel = 'denied';
66-
result.needsPermission = true;
67-
onError && onError();
68-
}, function () {
69-
result.notSetPermission = true;
70-
});
71-
} else {
72-
result.permissionLevel = 'granted';
73-
onSuccess && onSuccess();
74-
}
75-
result.notSetPermission = false;
76-
onThen && onThen();
77-
},
78-
needsPermission : notify.needsPermission,
79-
requestPermission: notify.requestPermission,
80-
isSupported : notify.isSupported,
81-
permissionLevel : notify.permissionLevel
82-
};
83-
return result;
84-
}];
85-
}]);
86-
})();
73+
result.notSetPermission = false;
74+
onThen && onThen();
75+
},
76+
needsPermission : notify.needsPermission,
77+
requestPermission: notify.requestPermission,
78+
isSupported : notify.isSupported,
79+
permissionLevel : notify.permissionLevel
80+
};
81+
return result;
82+
}];
83+
}]);

0 commit comments

Comments
 (0)