Skip to content

Commit 2a8ffc1

Browse files
committed
add umd support and move the source to the src directory
1 parent 9d6c2fa commit 2a8ffc1

File tree

6 files changed

+28
-8
lines changed

6 files changed

+28
-8
lines changed

Gruntfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = function (grunt)
1515
},
1616

1717
slider: {
18-
src: ['rzslider.less'],
18+
src: ['src/rzslider.less'],
1919
dest: 'dist/rzslider.css'
2020
},
2121

@@ -37,7 +37,7 @@ module.exports = function (grunt)
3737
rzslider: {
3838
files: {
3939
'dist/rzslider.min.js': [
40-
'rzslider.js'
40+
'src/rzslider.js'
4141
]
4242
}
4343
}

demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ <h2>Toggle slider example</h2>
115115
</body>
116116

117117
<script src="../bower_components/angular/angular.min.js"></script>
118-
<script src="../rzslider.js"></script>
118+
<script src="../src/rzslider.js"></script>
119119
<script>
120120
var app = angular.module('plunker', ['rzModule']);
121121

dist/rzslider.min.css

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/rzslider.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rzslider.js renamed to src/rzslider.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,25 @@
1111

1212
/*jslint unparam: true */
1313
/*global angular: false, console: false */
14-
15-
angular.module('rzModule', [])
14+
(function (root, factory) {
15+
16+
if (typeof define === 'function' && define.amd) {
17+
// AMD. Register as an anonymous module.
18+
define(['angular', 'underscore'], factory);
19+
} else if (typeof module === 'object' && module.exports) {
20+
// Node. Does not work with strict CommonJS, but
21+
// only CommonJS-like environments that support module.exports,
22+
// like Node.
23+
// to support bundler like browserify
24+
module.exports = factory(require('angular'));
25+
} else {
26+
// Browser globals (root is window)
27+
factory(root.angular);
28+
}
29+
30+
}(this, function (angular) {
31+
32+
var module = angular.module('rzModule', [])
1633

1734
.run(['$templateCache', function($templateCache) {
1835
'use strict';
@@ -1317,3 +1334,6 @@ function throttle(func, wait, options) {
13171334
* @property {bool} leading
13181335
* @property {bool} trailing
13191336
*/
1337+
1338+
return module
1339+
}));
File renamed without changes.

0 commit comments

Comments
 (0)