Skip to content

Commit a3c4b99

Browse files
author
hooray
committed
增加waves.js插件
1 parent dd9c9ee commit a3c4b99

32 files changed

+4061
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Directory for instrumented libs generated by jscoverage/JSCover
11+
lib-cov
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage
15+
16+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17+
.grunt
18+
19+
# Compiled binary addons (http://nodejs.org/api/addons.html)
20+
build/Release
21+
22+
# Dist zipfile
23+
*.zip
24+
25+
# Dependency directory
26+
# Deployed apps should consider commenting this line out:
27+
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
28+
node_modules
29+
*.png
30+
31+
# Situs compiled dir
32+
situs
33+
34+
# Copied files generated by grunt
35+
docs/static/waves*
36+
37+
# Directory for SASS/SCSS/Stylus conversion tests
38+
tests/
39+
.sass-cache/
40+
41+
# Apple stuff
42+
.DS_Store
Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
var fs = require('fs');
2+
3+
module.exports = function(grunt) {
4+
grunt.initConfig({
5+
6+
less: {
7+
build: {
8+
options: {},
9+
files: {
10+
'dist/waves.css': 'src/less/waves.less'
11+
}
12+
},
13+
minified: {
14+
options: {
15+
cleancss:true
16+
},
17+
files: {
18+
'dist/waves.min.css': 'src/less/waves.less'
19+
}
20+
},
21+
// re-minify everything in tests/ so that they all
22+
// have the same minification for comparision
23+
test: {
24+
options: {
25+
cleancss:true,
26+
cleancssOptions: {
27+
keepSpecialComments:'0'
28+
}
29+
},
30+
files: {
31+
'tests/less/waves.min.css': 'src/less/waves.less',
32+
'tests/sass/waves.min.css': 'tests/sass/waves.css',
33+
'tests/scss/waves.min.css': 'tests/scss/waves.css',
34+
'tests/stylus/waves.min.css': 'tests/stylus/waves.css'
35+
}
36+
}
37+
},
38+
39+
jshint: {
40+
41+
files: [
42+
'gruntfile.js',
43+
'src/js/*.js',
44+
],
45+
46+
options: {
47+
globals: {
48+
console: true
49+
}
50+
}
51+
},
52+
53+
uglify: {
54+
options: {
55+
mangle: true, // false when debugging
56+
compress: {
57+
sequences: true,
58+
dead_code: true,
59+
conditionals: true,
60+
booleans: true,
61+
unused: true,
62+
if_return: true,
63+
join_vars: true,
64+
drop_console: true
65+
},
66+
sourceMap: true,
67+
sourceMapName: 'dist/waves.min.js.map',
68+
preserveComments: 'some'
69+
},
70+
js: {
71+
files: {
72+
'dist/waves.min.js': ['src/js/waves.js']
73+
}
74+
}
75+
},
76+
77+
// Copy to dist
78+
copy: {
79+
js: {
80+
expand: true,
81+
cwd: 'src/js',
82+
src: 'waves.js',
83+
dest: 'dist/'
84+
},
85+
docs: {
86+
expand: true,
87+
cwd: 'dist',
88+
src: ['waves.min.css', 'waves.min.js'],
89+
dest: 'docs/static'
90+
}
91+
},
92+
93+
//convert less to stylus
94+
execute: {
95+
less2stylus: {
96+
call: function(grunt, options, async) {
97+
var done = async();
98+
var exec = require('child_process').exec;
99+
exec('cd node_modules/less2stylus && node ./less2stylus ../../src/less/waves.less', function (error, stdout, stderr) {
100+
grunt.log.writeln('Executing less2styus...');
101+
102+
if (error) {
103+
grunt.log.writeln('Error! ' + error);
104+
}
105+
106+
var fs = require('fs');
107+
fs.writeFile("src/stylus/waves.styl", stdout, function(err) {
108+
if(err) {
109+
grunt.log.writeln(err);
110+
} else {
111+
grunt.log.writeln("Stylus file was saved!");
112+
}
113+
114+
done(); // let grunt resume
115+
});
116+
});
117+
}
118+
},
119+
120+
less2scss: {
121+
//FUTURE: Put less2scss as it's own script
122+
call: function(grunt, options, async) {
123+
var done = async();
124+
var text = fs.readFileSync('src/less/waves.less', {encoding:'utf8'});
125+
126+
//replace @ with $
127+
text = text.replace(/@(?!import|media|keyframes|-)/g, '$');
128+
//replace mixins
129+
text = text.replace(/\.([\w\-]*)\s*\((.*)\)\s*\{/g, '@mixin $1($2){');
130+
//replace includes
131+
text = text.replace(/\.([\w\-]*\(.*\)\s*;)/g, '@include $1');
132+
//replace string literals
133+
//eg. ~'!important' -> #{"!important"}
134+
text = text.replace(/~(?:\"|\')(.*)(?:\"|\')/g, '#{"$1"}');
135+
136+
//NOTE: for true less->scss transpiling we'd need to replace spin to adjust-hue (not needed but anyway)
137+
138+
fs.writeFileSync('src/scss/waves.scss', text);
139+
140+
done();
141+
}
142+
},
143+
144+
test: {
145+
call: function(grunt, options, async) {
146+
var done = async();
147+
var lessTest = fs.readFileSync('tests/less/waves.min.css', {encoding:'utf8'});
148+
var sassTest = fs.readFileSync('tests/sass/waves.min.css', {encoding:'utf8'});
149+
var scssTest = fs.readFileSync('tests/scss/waves.min.css', {encoding:'utf8'});
150+
var stylusTest = fs.readFileSync('tests/stylus/waves.min.css', {encoding:'utf8'});
151+
152+
var failure = false;
153+
if (lessTest != sassTest) {
154+
grunt.log.writeln('ERROR: sass failed test.');
155+
failure = true;
156+
}
157+
158+
if (lessTest != scssTest) {
159+
grunt.log.writeln('ERROR: scss failed test.');
160+
failure = true;
161+
}
162+
163+
if (lessTest != stylusTest) {
164+
grunt.log.writeln('ERROR: stylus failed test.');
165+
failure = true;
166+
}
167+
168+
if (sassTest != scssTest) {
169+
grunt.log.writeln('WARNING: sass files aren\'t equal?');
170+
failure = true;
171+
}
172+
173+
if (!failure) grunt.log.writeln('PASS: conversions generated same CSS');
174+
175+
done();
176+
}
177+
}
178+
},
179+
180+
'sass-convert': {
181+
options: {
182+
from: 'scss',
183+
to: 'sass',
184+
indent: 2
185+
},
186+
files: {
187+
cwd: 'src/scss',
188+
src: '*.scss',
189+
dest: 'src/sass'
190+
}
191+
},
192+
193+
sass: {
194+
test: {
195+
files: [{
196+
expand: true,
197+
cwd: 'src',
198+
src: ['**/*.sass', '**/*.scss'],
199+
dest: 'tests/',
200+
ext: '.css'
201+
}]
202+
}
203+
},
204+
205+
stylus: {
206+
test: {
207+
files: {
208+
'tests/stylus/waves.css': 'src/stylus/waves.styl'
209+
}
210+
}
211+
},
212+
213+
clean: {
214+
test: ['tests/*']
215+
},
216+
217+
watch: {
218+
script: {
219+
options: {
220+
spawn: false,
221+
event: ['added', 'deleted', 'changed']
222+
},
223+
files: ['src/**/*.js', 'src/**/*.less'],
224+
tasks: ['build']
225+
},
226+
grunt: {
227+
files: ['Gruntfile.js']
228+
}
229+
}
230+
});
231+
232+
// Load module
233+
grunt.loadNpmTasks('grunt-contrib-concat');
234+
grunt.loadNpmTasks('grunt-contrib-less');
235+
grunt.loadNpmTasks('grunt-contrib-jshint');
236+
grunt.loadNpmTasks('grunt-contrib-uglify');
237+
grunt.loadNpmTasks('grunt-contrib-copy');
238+
grunt.loadNpmTasks('grunt-contrib-watch');
239+
grunt.loadNpmTasks('grunt-contrib-sass');
240+
grunt.loadNpmTasks('grunt-contrib-stylus');
241+
grunt.loadNpmTasks('grunt-execute');
242+
grunt.loadNpmTasks('grunt-sass-convert');
243+
grunt.loadNpmTasks('grunt-contrib-clean');
244+
245+
// Create grunt task
246+
grunt.registerTask('build', [
247+
'less:build',
248+
'less:minified',
249+
'jshint',
250+
'uglify',
251+
'copy',
252+
'execute:less2stylus',
253+
'execute:less2scss',
254+
'sass-convert',
255+
'sass:test',
256+
'stylus:test',
257+
'less:test',
258+
'execute:test',
259+
'clean:test'
260+
]);
261+
262+
grunt.registerTask('default', ['build', 'watch']);
263+
};

static/plugins/Waves-0.7.5/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Alfiana E. Sibuea
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Waves
2+
3+
Click effect inspired by Google's Material Design
4+
http://fian.my.id/Waves/
5+
6+
## Documentation
7+
8+
Waves using [Situs](https://github.com/fians/situs) to generate documentation. Here are some steps to run documentation locally on your computer,
9+
10+
1. Make sure [Node.js](http://nodejs.org/) and [Ruby](https://www.ruby-lang.org/en/) installed in your computer.
11+
2. Install SASS via RubyGems (`gem install sass`).
12+
3. Install Situs globally via npm (`npm install situs -g`).
13+
4. Clone Waves's Github repository, if you haven't already (`git clone https://github.com/fians/Waves.git`).
14+
5. Run `npm install` to install the necessary local node packages.
15+
6. Install grunt globally with `npm install -g grunt-cli`.
16+
7. Run `grunt` to watch the directory, or simply `grunt build` to do a single build.
17+
8. Now just start Situs server (`situs server`), then visit [http://localhost:4000/](http://localhost:4000/) on your browser.
18+
19+
## Notes
20+
21+
Thanks for [BrowserStack](http://www.browserstack.com/) by providing a great testing tools for this projects.
22+
23+
24+
## License
25+
Waves created by [Alfiana Sibuea](http://fian.my.id), and released under [MIT license](https://github.com/fians/Waves/blob/master/LICENSE).
26+
27+
Copyright © 2014-2016 Alfiana E. Sibuea. All rights reserved.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "Waves",
3+
"homepage": "http://fian.my.id/Waves",
4+
"authors": [
5+
"Alfiana E. Sibuea <alfian.sibuea@gmail.com>"
6+
],
7+
"description": "Click effect inspired by Google's Material Design",
8+
"main": ["dist/waves.min.js", "dist/waves.min.css"],
9+
"keywords": [
10+
"click",
11+
"material-design"
12+
],
13+
"license": "MIT",
14+
"ignore": [
15+
"**/.*",
16+
"node_modules",
17+
"bower_components",
18+
"test",
19+
"tests"
20+
]
21+
}

0 commit comments

Comments
 (0)