Skip to content

Commit ab354fb

Browse files
committed
UMD
Wrapped code in UMD (Universal Module Definition) to work with Browserify/Webpack. Added default variables to Sass file.
1 parent 25ca028 commit ab354fb

File tree

10 files changed

+123
-81
lines changed

10 files changed

+123
-81
lines changed

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jquery-selectric",
33
"description": "Fast, simple and light jQuery plugin to customize HTML selects",
4-
"version": "1.9.3",
4+
"version": "1.9.5",
55
"keywords": [
66
"select",
77
"selectbox",
@@ -27,7 +27,7 @@
2727
"js",
2828
"src",
2929
"*.md",
30-
"Gruntfile.js",
30+
"gulpfile.js",
3131
"package.json"
3232
],
3333
"dependencies": {

gulpfile.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ var gulp = require('gulp'),
33
fs = require('fs');
44

55
var getPackageJson = function() {
6-
return JSON.parse(fs.readFileSync('./package.json', 'utf8'));
7-
};
6+
return JSON.parse(fs.readFileSync('./package.json', 'utf8'));
7+
};
8+
89

910
/*======================================
1011
Bump version
@@ -20,6 +21,7 @@ gulp.task('bump', function() {
2021
.pipe(gulp.dest('./'));
2122
});
2223

24+
2325
/*======================================
2426
Javascript
2527
======================================*/
@@ -37,9 +39,9 @@ gulp.task('js', ['bump'], function() {
3739
' * /,\'',
3840
' * /\'',
3941
' *',
40-
' * Selectric \u03DE v<%= pkg.version %> (<%= new Date().toString().substr(4, 11) %>) - http://lcdsantos.github.io/jQuery-Selectric/',
42+
' * Selectric \u03DF v<%= pkg.version %> (<%= new Date().toString().substr(4, 11) %>) - http://lcdsantos.github.io/jQuery-Selectric/',
4143
' *',
42-
' * Copyright (c) <%= new Date().getFullYear() %> Leonardo Santos; Dual licensed: MIT\/GPL',
44+
' * Copyright (c) <%= new Date().getFullYear() %> Leonardo Santos; MIT License',
4345
' *',
4446
' */\n\n'
4547
].join('\n');
@@ -55,12 +57,13 @@ gulp.task('js-min', ['bump'], function() {
5557

5658
return gulp.src('src/jquery.selectric.js')
5759
.pipe($.uglify())
58-
.pipe($.header('/*! Selectric ϟ v<%= pkg.version %> (<%= new Date().toJSON().slice(0,10) %>) - git.io/tjl9sQ - Copyright (c) <%= new Date().getFullYear() %> Leonardo Santos - Dual licensed: MIT/GPL */\n', { pkg: pkg }))
60+
.pipe($.header('/*! Selectric \u03DF v<%= pkg.version %> (<%= new Date().toJSON().slice(0,10) %>) - git.io/tjl9sQ - Copyright (c) <%= new Date().getFullYear() %> Leonardo Santos - MIT License */\n', { pkg: pkg }))
5961
.pipe($.rename({ suffix: '.min' }))
6062
.pipe(gulp.dest('./public'))
6163
.pipe($.connect.reload());
6264
});
6365

66+
6467
/*======================================
6568
CSS
6669
======================================*/
@@ -73,11 +76,16 @@ gulp.task('css', function() {
7376
browsers: ['last 2 versions', '> 1%', 'ie 8', 'ie 7']
7477
}))
7578
.pipe($.csscomb())
76-
.pipe($.header('/*======================================\n Selectric v<%= pkg.version %>\n======================================*/\n', { pkg: pkg }))
79+
.pipe($.header([
80+
'/*======================================',
81+
' Selectric v<%= pkg.version %>',
82+
'======================================*/\n\n'
83+
].join('\n'), { pkg: pkg }))
7784
.pipe(gulp.dest('./public'))
7885
.pipe($.connect.reload());
7986
});
8087

88+
8189
/*======================================
8290
Live preview
8391
======================================*/
@@ -93,6 +101,7 @@ gulp.task('html', function() {
93101
.pipe($.connect.reload());
94102
});
95103

104+
96105
/*======================================
97106
Watch
98107
======================================*/
@@ -102,6 +111,7 @@ gulp.task('watch', ['serve'], function() {
102111
gulp.watch(['./public/*.html'], ['html']);
103112
});
104113

114+
105115
/*======================================
106116
ZIP
107117
======================================*/
@@ -113,6 +123,7 @@ gulp.task('zip', function() {
113123
.pipe(gulp.dest('./'));
114124
});
115125

126+
116127
/*======================================
117128
GitHub Pages
118129
======================================*/
@@ -121,6 +132,7 @@ gulp.task('gh-pages', function() {
121132
.pipe($.ghPages());
122133
});
123134

135+
124136
/*======================================
125137
Default tasks
126138
======================================*/

package.json

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
{
22
"name": "selectric",
3-
"version": "1.9.3",
3+
"version": "1.9.5",
44
"main": "public/jquery.selectric.js",
55
"title": "jQuery Selectric",
66
"author": {
77
"name": "Leonardo Santos",
88
"email": "leocs.1991@gmail.com"
99
},
10-
"licenses": [
11-
{
12-
"type": "MIT",
13-
"url": "http://opensource.org/licenses/MIT"
14-
},
15-
{
16-
"type": "GPL-3.0",
17-
"url": "http://opensource.org/licenses/GPL-3.0"
18-
}
19-
],
10+
"license": "MIT",
2011
"description": "Fast, simple and light jQuery plugin to customize HTML selects",
2112
"keywords": [
2213
"jquery-plugin",
@@ -40,18 +31,19 @@
4031
"jquery": "^2.1.4"
4132
},
4233
"devDependencies": {
43-
"gulp": "^3.9.0",
44-
"gulp-autoprefixer": "^2.3.1",
45-
"gulp-bump": "^0.3.1",
46-
"gulp-connect": "^2.2.0",
47-
"gulp-csscomb": "^3.0.3",
48-
"gulp-gh-pages": "^0.5.2",
49-
"gulp-header": "^1.2.2",
50-
"gulp-load-plugins": "^0.10.0",
34+
"browserify": "^13.0.0",
35+
"gulp": "^3.9.1",
36+
"gulp-autoprefixer": "^3.1.0",
37+
"gulp-bump": "^1.0.0",
38+
"gulp-connect": "^3.0.0",
39+
"gulp-csscomb": "^3.0.6",
40+
"gulp-gh-pages": "^0.5.4",
41+
"gulp-header": "^1.7.1",
42+
"gulp-load-plugins": "^1.2.0",
5143
"gulp-rename": "^1.2.2",
52-
"gulp-sass": "^2.0.1",
53-
"gulp-uglify": "^1.2.0",
54-
"gulp-util": "^3.0.5",
55-
"gulp-zip": "^3.0.2"
44+
"gulp-sass": "^2.2.0",
45+
"gulp-uglify": "^1.5.3",
46+
"gulp-util": "^3.0.7",
47+
"gulp-zip": "^3.2.0"
5648
}
5749
}

public/demo.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,5 @@ <h3>Sizes</h3>
385385
ga('require', 'displayfeatures');
386386
ga('send', 'pageview');
387387
</script>
388-
389-
390-
391388
</body>
392389
</html>

public/jquery.selectric.js

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,35 @@
99
* /,'
1010
* /'
1111
*
12-
* Selectric Ϟ v1.9.3 (Jul 08 2015) - http://lcdsantos.github.io/jQuery-Selectric/
12+
* Selectric ϟ v1.9.5 (Feb 26 2016) - http://lcdsantos.github.io/jQuery-Selectric/
1313
*
14-
* Copyright (c) 2015 Leonardo Santos; Dual licensed: MIT/GPL
14+
* Copyright (c) 2016 Leonardo Santos; MIT License
1515
*
1616
*/
1717

18-
;(function($) {
18+
(function(factory) {
19+
if (typeof define === 'function' && define.amd) {
20+
define(['jquery'], factory);
21+
} else if (typeof module === 'object' && module.exports) {
22+
// Node/CommonJS
23+
module.exports = function( root, jQuery ) {
24+
if ( jQuery === undefined ) {
25+
if ( typeof window !== 'undefined' ) {
26+
jQuery = require('jquery');
27+
}
28+
else {
29+
jQuery = require('jquery')(root);
30+
}
31+
}
32+
factory(jQuery);
33+
return jQuery;
34+
};
35+
} else {
36+
// Browser globals
37+
factory(jQuery);
38+
}
39+
}(function($) {
40+
1941
'use strict';
2042

2143
var pluginName = 'selectric',
@@ -142,7 +164,7 @@
142164
originalWidth = $original.width();
143165

144166
$.each(postfixes, function(i, currClass) {
145-
var c = customClass.prefix + currClass;
167+
var c = customClass.prefix + '-' + currClass;
146168
_this.classes[currClass.toLowerCase()] = customClass.camelCase ? c : _utils.toDash(c);
147169
});
148170

@@ -552,4 +574,5 @@
552574
};
553575

554576
$.fn[pluginName].hooks = hooks;
555-
}(jQuery));
577+
578+
}));

0 commit comments

Comments
 (0)