Skip to content

Commit d6f41d9

Browse files
committed
Added stylesheet
1 parent 500c984 commit d6f41d9

File tree

5 files changed

+54
-42
lines changed

5 files changed

+54
-42
lines changed

Gruntfile.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,13 @@ module.exports = function(grunt) {
5858
files: 'Gruntfile.js',
5959
tasks: ['eslint']
6060
},
61-
src: {
61+
js: {
6262
files: 'src/**/*.js',
63-
tasks: ['babel', 'concat', 'qunit']
63+
tasks: ['babel', 'concat']
64+
},
65+
css: {
66+
files: 'src/**/*.css',
67+
tasks: ['autoprefixer', 'cssmin']
6468
},
6569
test: {
6670
files: 'test/**/*.js',
@@ -78,6 +82,23 @@ module.exports = function(grunt) {
7882
'tmp/jquery.<%= pkg.name %>.js': 'src/jquery.<%= pkg.name %>.js'
7983
}
8084
}
85+
},
86+
autoprefixer: {
87+
options: {
88+
browsers: ['last 10 versions', 'ie 8', 'ie 9']
89+
},
90+
dist: {
91+
files: {
92+
'dist/jquery.<%= pkg.name %>.css': 'src/jquery.<%= pkg.name %>.css'
93+
}
94+
},
95+
},
96+
cssmin: {
97+
target: {
98+
files: {
99+
'dist/jquery.<%= pkg.name %>.min.css': 'dist/jquery.<%= pkg.name %>.css'
100+
}
101+
},
81102
}
82103
});
83104

@@ -89,11 +110,13 @@ module.exports = function(grunt) {
89110
grunt.loadNpmTasks('grunt-eslint');
90111
grunt.loadNpmTasks('grunt-contrib-watch');
91112
grunt.loadNpmTasks('grunt-babel');
113+
grunt.loadNpmTasks('grunt-autoprefixer');
114+
grunt.loadNpmTasks('grunt-contrib-cssmin');
92115

93116
// Default task.
94-
grunt.registerTask('default', ['eslint', 'clean', 'babel', 'concat', 'qunit', 'uglify']);
117+
grunt.registerTask('default', ['eslint', 'clean', 'babel', 'concat', 'autoprefixer', 'cssmin', 'qunit', 'uglify']);
95118

96119
// Travis CI task.
97-
grunt.registerTask('travis', ['eslint', 'clean', 'babel', 'concat', 'qunit', 'uglify']);
120+
grunt.registerTask('travis', ['eslint', 'clean', 'babel', 'concat', 'autoprefixer', 'cssmin', 'qunit', 'uglify']);
98121

99122
};

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" type="text/css" media="screen" />
1010
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
11+
<link rel="stylesheet" href="dist/jquery.slotmachine.css" type="text/css" media="screen" />
1112

1213
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.1.min.js"></script>
1314
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
"eslint": "^1.10.3",
2323
"eslint-plugin-babel": "^3.0.0",
2424
"grunt": ">=0.4.5",
25+
"grunt-autoprefixer": "^3.0.4",
2526
"grunt-babel": "^6.0.0",
2627
"grunt-contrib-clean": ">=0.4.0",
2728
"grunt-contrib-concat": ">=0.3.0",
29+
"grunt-contrib-cssmin": "^0.14.0",
2830
"grunt-contrib-qunit": ">=0.2.0",
2931
"grunt-contrib-uglify": ">=0.2.0",
3032
"grunt-contrib-watch": ">=0.4.0",

src/jquery.slotmachine.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.slotMachineNoTransition {
2+
transition: none !important;
3+
}
4+
5+
.slotMachineBlurFast {
6+
filter: blur(5px);
7+
}
8+
9+
.slotMachineBlurMedium {
10+
filter: blur(3px);
11+
}
12+
13+
.slotMachineBlurSlow {
14+
filter: blur(2px);
15+
}
16+
17+
.slotMachineBlurTurtle {
18+
filter: blur(1px);
19+
}
20+
21+
.slotMachineGradient {
22+
-webkit-mask-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(0,0,0,0)), color-stop(25%, rgba(0,0,0,1)), color-stop(75%, rgba(0,0,0,1)), color-stop(100%, rgba(0,0,0,0)) );
23+
mask: url("data:image/svg+xml;utf8,<svg version="1.1" xmlns="http:// www.w3.org/2000/svg" width="0" height="0"><mask id="slotMachineFadeMask" maskUnits="objectBoundingBox" maskContentUnits="objectBoundingBox"><linearGradient id="slotMachineFadeGradient" gradientUnits="objectBoundingBox" x="0" y="0"><stop stop-color="white" stop-opacity="0" offset="0"></stop><stop stop-color="white" stop-opacity="1" offset="0.25"></stop><stop stop-color="white" stop-opacity="1" offset="0.75"></stop><stop stop-color="white" stop-opacity="0" offset="1"></stop></linearGradient><rect x="0" y="-1" width="1" height="1" transform="rotate(90)" fill="url(#slotMachineFadeMask)"></rect></mask></svg>#slotMachineFadeMask");
24+
}

src/jquery.slotmachine.js

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,44 +26,6 @@ const pluginName = 'slotMachine',
2626
FX_GRADIENT = 'slotMachineGradient',
2727
FX_STOP = FX_GRADIENT;
2828

29-
// Set required styles, filters and masks
30-
$(document).ready(function documentReady() {
31-
32-
function getSvgFilter (blur) {
33-
return `<svg version="1.1" xmlns="http:// www.w3.org/2000/svg" width="0" height="0"><filter id="slotMachineBlurFilter${blur}"><feGaussianBlur stdDeviation="${blur}" /></filter></svg>#slotMachineBlurFilter${blur}`;
34-
}
35-
36-
function getBlurStyle (amount) {
37-
return `-webkit-filter: blur(${amount}px);-moz-filter: blur(${amount}px);-o-filter: blur(${amount}px);-ms-filter: blur(${amount}px);filter: blur(${amount}px);filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius="${amount}");filter: url("data:image/svg+xml;utf8,${getSvgFilter(amount)}");`;
38-
}
39-
40-
const slotMachineFadeMaskString = '<svg version="1.1" xmlns="http:// www.w3.org/2000/svg" width="0" height="0">' +
41-
'<mask id="slotMachineFadeMask" maskUnits="objectBoundingBox" maskContentUnits="objectBoundingBox">' +
42-
'<linearGradient id="slotMachineFadeGradient" gradientUnits="objectBoundingBox" x="0" y="0">' +
43-
'<stop stop-color="white" stop-opacity="0" offset="0"></stop>' +
44-
'<stop stop-color="white" stop-opacity="1" offset="0.25"></stop>' +
45-
'<stop stop-color="white" stop-opacity="1" offset="0.75"></stop>' +
46-
'<stop stop-color="white" stop-opacity="0" offset="1"></stop>' +
47-
'</linearGradient>' +
48-
'<rect x="0" y="-1" width="1" height="1" transform="rotate(90)" fill="url(#slotMachineFadeGradient)"></rect>' +
49-
'</mask>' +
50-
'</svg>#slotMachineFadeMask';
51-
52-
// CSS classes
53-
$('body').append('<style>' +
54-
`.${FX_NO_TRANSITION}{-webkit-transition: none !important;-moz-transition: none !important;-o-transition: none !important;-ms-transition: none !important;transition: none !important;}` +
55-
`.${FX_FAST}{${getBlurStyle(5)}}` +
56-
`.${FX_NORMAL}{${getBlurStyle(3)}}` +
57-
`.${FX_SLOW}{${getBlurStyle(2)}}` +
58-
`.${FX_TURTLE}{${getBlurStyle(1)}}` +
59-
`.${FX_GRADIENT}{` +
60-
'-webkit-mask-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(0,0,0,0)), color-stop(25%, rgba(0,0,0,1)), color-stop(75%, rgba(0,0,0,1)), color-stop(100%, rgba(0,0,0,0)) );' +
61-
`mask: url("data:image/svg+xml;utf8,${slotMachineFadeMaskString}");` +
62-
'}' +
63-
'</style>');
64-
65-
});
66-
6729
class Timer {
6830
constructor (cb, delay) {
6931
this.cb = cb;

0 commit comments

Comments
 (0)