Commit 9bddbecc authored by Valentin Hervieu's avatar Valentin Hervieu

Merge pull request #124 from e-cloud/dev#118

Add umd support. Extract template in its own file.
parents 9d6c2fae 4974c952
node_modules/ node_modules/
.idea/ .idea/
bower_components/ bower_components/
temp/
\ No newline at end of file
...@@ -15,7 +15,7 @@ module.exports = function (grunt) ...@@ -15,7 +15,7 @@ module.exports = function (grunt)
}, },
slider: { slider: {
src: ['rzslider.less'], src: ['src/rzslider.less'],
dest: 'dist/rzslider.css' dest: 'dist/rzslider.css'
}, },
...@@ -37,18 +37,79 @@ module.exports = function (grunt) ...@@ -37,18 +37,79 @@ module.exports = function (grunt)
rzslider: { rzslider: {
files: { files: {
'dist/rzslider.min.js': [ 'dist/rzslider.min.js': [
'rzslider.js' 'dist/rzslider.js'
] ]
} }
} }
},
ngtemplates: {
app: {
src: 'src/**.html',
dest: 'temp/templates.js',
options: {
htmlmin: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true, // Only if you don't use comment directives!
removeEmptyAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
},
module: 'rzModule',
url: function(url) {
return url.replace('src/', '');
},
bootstrap: function (module, script) {
return 'module.run(function($templateCache) {\n' + script + '\n});';
}
}
}
},
replace: {
dist: {
options: {
patterns: [
{
match: /\/\*templateReplacement\*\//,
replacement: '<%= grunt.file.read("temp/templates.js") %>'
}
]
},
files: [
{expand: true, flatten: true, src: ['src/rzslider.js'], dest: 'dist/'}
]
}
},
ngAnnotate: {
options: {
singleQuotes: true,
},
rzslider: {
files: [{
'dist/rzslider.js': 'dist/rzslider.js'
}, {
expand: true,
src: ['dist/rzslider.js']
}
]
}
} }
}); });
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-recess'); grunt.loadNpmTasks('grunt-recess');
grunt.loadNpmTasks('grunt-angular-templates');
grunt.loadNpmTasks('grunt-replace');
grunt.loadNpmTasks('grunt-ng-annotate');
grunt.registerTask('default', ['css', 'js']); grunt.registerTask('default', ['css', 'js']);
grunt.registerTask('css', ['recess']); grunt.registerTask('css', ['recess']);
grunt.registerTask('js', ['uglify']); grunt.registerTask('js', ['ngtemplates','replace', 'ngAnnotate', 'uglify']);
}; };
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
</body> </body>
<script src="../bower_components/angular/angular.min.js"></script> <script src="../bower_components/angular/angular.min.js"></script>
<script src="../rzslider.js"></script> <script src="../dist/rzslider.js"></script>
<script> <script>
var app = angular.module('plunker', ['rzModule']); var app = angular.module('plunker', ['rzModule']);
......
This diff is collapsed.
/*! jusas-angularjs-slider - v0.1.29 - (c) Rafal Zajac <rzajac@gmail.com>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com>, https://github.com/rzajac/angularjs-slider.git - 2015-09-09 */ /*! jusas-angularjs-slider - v0.1.29 - (c) Rafal Zajac <rzajac@gmail.com>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com>, https://github.com/rzajac/angularjs-slider.git - 2015-09-13 */
rzslider{position:relative;display:inline-block;width:100%;height:4px;margin:30px 0 15px 0;vertical-align:middle}rzslider span{position:absolute;display:inline-block;white-space:nowrap}rzslider span.rz-base{width:100%;height:100%;padding:0}rzslider span.rz-bar-wrapper{left:0;width:100%;height:32px;padding-top:16px;margin-top:-16px;box-sizing:border-box}rzslider span.rz-bar{left:0;z-index:0;width:100%;height:4px;background:#d8e0f3;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}rzslider span.rz-bar.rz-selection{z-index:1;background:#0db9f0;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}rzslider span.rz-pointer{top:-14px;z-index:2;width:32px;height:32px;cursor:pointer;background-color:#0db9f0;-webkit-border-radius:16px;-moz-border-radius:16px;border-radius:16px}rzslider span.rz-pointer:after{position:absolute;top:12px;left:12px;width:8px;height:8px;background:#fff;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;content:''}rzslider span.rz-pointer:hover:after{background-color:#fff}rzslider span.rz-pointer.rz-active:after{background-color:#451aff}rzslider span.rz-bubble{top:-32px;padding:1px 3px;color:#55637d;cursor:default}rzslider span.rz-bubble.rz-selection{top:16px}rzslider span.rz-bubble.rz-limit{color:#55637d} rzslider{position:relative;display:inline-block;width:100%;height:4px;margin:30px 0 15px 0;vertical-align:middle}rzslider span{position:absolute;display:inline-block;white-space:nowrap}rzslider span.rz-base{width:100%;height:100%;padding:0}rzslider span.rz-bar-wrapper{left:0;width:100%;height:32px;padding-top:16px;margin-top:-16px;box-sizing:border-box}rzslider span.rz-bar{left:0;z-index:0;width:100%;height:4px;background:#d8e0f3;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}rzslider span.rz-bar.rz-selection{z-index:1;background:#0db9f0;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}rzslider span.rz-pointer{top:-14px;z-index:2;width:32px;height:32px;cursor:pointer;background-color:#0db9f0;-webkit-border-radius:16px;-moz-border-radius:16px;border-radius:16px}rzslider span.rz-pointer:after{position:absolute;top:12px;left:12px;width:8px;height:8px;background:#fff;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;content:''}rzslider span.rz-pointer:hover:after{background-color:#fff}rzslider span.rz-pointer.rz-active:after{background-color:#451aff}rzslider span.rz-bubble{top:-32px;padding:1px 3px;color:#55637d;cursor:default}rzslider span.rz-bubble.rz-selection{top:16px}rzslider span.rz-bubble.rz-limit{color:#55637d}
\ No newline at end of file
This diff is collapsed.
...@@ -13,9 +13,12 @@ ...@@ -13,9 +13,12 @@
], ],
"devDependencies": { "devDependencies": {
"grunt": "~0.4.2", "grunt": "~0.4.2",
"grunt-angular-templates": "^0.5.7",
"grunt-contrib-mincss": "~0.3.2", "grunt-contrib-mincss": "~0.3.2",
"grunt-contrib-uglify": "~0.2.2", "grunt-contrib-uglify": "~0.2.2",
"grunt-ng-annotate": "^1.0.1",
"grunt-recess": "~0.4.0", "grunt-recess": "~0.4.0",
"grunt-replace": "^0.11.0",
"recess": "~1.1.9" "recess": "~1.1.9"
}, },
"author": "Rafal Zajac <rzajac@gmail.com>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com>", "author": "Rafal Zajac <rzajac@gmail.com>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com>",
......
<span class="rz-bar-wrapper"><span class="rz-bar"></span></span> <!-- // 0 The slider bar -->
<span class="rz-bar-wrapper"><span class="rz-bar rz-selection"></span></span> <!-- // 1 Highlight between two handles -->
<span class="rz-pointer"></span> <!-- // 2 Left slider handle -->
<span class="rz-pointer"></span> <!-- // 3 Right slider handle -->
<span class="rz-bubble rz-limit"></span> <!-- // 4 Floor label -->
<span class="rz-bubble rz-limit"></span> <!-- // 5 Ceiling label -->
<span class="rz-bubble"></span> <!-- // 6 Label above left slider handle -->
<span class="rz-bubble"></span> <!-- // 7 Label above right slider handle -->
<span class="rz-bubble"></span> <!-- // 8 Range label when the slider handles are close ex. 15 - 17 -->
\ No newline at end of file
...@@ -11,22 +11,25 @@ ...@@ -11,22 +11,25 @@
/*jslint unparam: true */ /*jslint unparam: true */
/*global angular: false, console: false */ /*global angular: false, console: false */
(function (root, factory) {
angular.module('rzModule', [])
if (typeof define === 'function' && define.amd) {
.run(['$templateCache', function($templateCache) { // AMD. Register as an anonymous module.
'use strict'; define(['angular', 'underscore'], factory);
var template = '<span class="rz-bar-wrapper"><span class="rz-bar"></span></span>' + // 0 The slider bar } else if (typeof module === 'object' && module.exports) {
'<span class="rz-bar-wrapper"><span class="rz-bar rz-selection"></span></span>' + // 1 Highlight between two handles // Node. Does not work with strict CommonJS, but
'<span class="rz-pointer"></span>' + // 2 Left slider handle // only CommonJS-like environments that support module.exports,
'<span class="rz-pointer"></span>' + // 3 Right slider handle // like Node.
'<span class="rz-bubble rz-limit"></span>' + // 4 Floor label // to support bundler like browserify
'<span class="rz-bubble rz-limit"></span>' + // 5 Ceiling label module.exports = factory(require('angular'));
'<span class="rz-bubble"></span>' + // 6 Label above left slider handle } else {
'<span class="rz-bubble"></span>' + // 7 Label above right slider handle // Browser globals (root is window)
'<span class="rz-bubble"></span>'; // 8 Range label when the slider handles are close ex. 15 - 17 factory(root.angular);
$templateCache.put('rzSliderTpl.html', template); }
}])
}(this, function (angular) {
var module = angular.module('rzModule', [])
.value('throttle', .value('throttle',
/** /**
...@@ -73,7 +76,7 @@ function throttle(func, wait, options) { ...@@ -73,7 +76,7 @@ function throttle(func, wait, options) {
}; };
}) })
.factory('RzSlider', ['$timeout', '$document', '$window', 'throttle', function($timeout, $document, $window, throttle) .factory('RzSlider', function($timeout, $document, $window, throttle)
{ {
'use strict'; 'use strict';
...@@ -1241,9 +1244,9 @@ function throttle(func, wait, options) { ...@@ -1241,9 +1244,9 @@ function throttle(func, wait, options) {
}; };
return Slider; return Slider;
}]) })
.directive('rzslider', ['RzSlider', function(Slider) .directive('rzslider', function(RzSlider)
{ {
'use strict'; 'use strict';
...@@ -1280,10 +1283,10 @@ function throttle(func, wait, options) { ...@@ -1280,10 +1283,10 @@ function throttle(func, wait, options) {
link: function(scope, elem, attr) link: function(scope, elem, attr)
{ {
return new Slider(scope, elem, attr); return new RzSlider(scope, elem, attr);
} }
}; };
}]); });
// IDE assist // IDE assist
...@@ -1317,3 +1320,8 @@ function throttle(func, wait, options) { ...@@ -1317,3 +1320,8 @@ function throttle(func, wait, options) {
* @property {bool} leading * @property {bool} leading
* @property {bool} trailing * @property {bool} trailing
*/ */
/*templateReplacement*/
return module
}));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment