Skip to content

Commit 3445af1

Browse files
committed
add handsontable
1 parent 03d7d2a commit 3445af1

File tree

8 files changed

+122
-16
lines changed

8 files changed

+122
-16
lines changed

Gruntfile.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ module.exports = function(grunt) {
4444
done();
4545
};
4646
});
47+
grunt.registerTask('default', ['check']);
4748

4849
function checkupdate(pkg, callback) {
4950
if (pkg.package) {
@@ -52,7 +53,7 @@ module.exports = function(grunt) {
5253
if (err) {
5354
callback(err);
5455
} else if (res.statusCode !== 200) {
55-
callback('status code: ' + res.statusCode);
56+
callback('status code: ' + res.statusCode + ' ' + pkg.package);
5657
} else {
5758
callback(null, body.version);
5859
}
@@ -74,7 +75,7 @@ module.exports = function(grunt) {
7475
if (err) {
7576
callback(err);
7677
} else if (res.statusCode !== 200) {
77-
callback('status code: ' + res.statusCode);
78+
callback('status code: ' + res.statusCode + ' ' + uri);
7879
} else {
7980

8081
var names = body.map(function(tag) {
@@ -91,5 +92,4 @@ module.exports = function(grunt) {
9192
s += latest || '';
9293
return s;
9394
}
94-
grunt.registerTask('default', ['check']);
9595
};

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 引入 CMD 模块指南
2+
3+
https://github.com/cmdjs/gallery#gallery

_tasks/download/tasks/download.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,16 @@ module.exports = function(grunt) {
5454
if (options.transform && typeof options.transform === 'function') {
5555
grunt.log.writeln('Transform code');
5656
code = options.transform(code);
57-
} else if (options.header && options.footer ) {
57+
} else if (options.header || options.footer ) {
5858
grunt.log.writeln('Add header and footer');
59-
code = [options.header, code, options.footer].join('\n');
59+
code = [options.header || '', code, options.footer || ''].join('\n');
6060
}
6161
grunt.file.write(path.join(options.dest, data.name), code);
6262
grunt.log.ok();
6363
}
6464
done();
6565
});
6666
});
67+
68+
grunt.registerTask('spm-build', ['clean:build', 'transport:src', 'concat:js', 'copy:build', 'uglify:js', 'clean:dist', 'copy:dist', 'clean:build', 'spm-newline']);
6769
};

handsontable/Gruntfile.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module.exports = function(grunt) {
2+
var pkg = grunt.file.readJSON('package.json');
3+
4+
grunt.initConfig({
5+
pkg: pkg,
6+
7+
download: {
8+
options: {
9+
dest: 'src'
10+
},
11+
js: {
12+
options: {
13+
transform: function(code) {
14+
return [
15+
'define(function(require, exports) {',
16+
'var previousJQuery = this.jQuery;',
17+
"this.jQuery = require('$');",
18+
code.replace(/exports/g, 'exports_'),
19+
"this.jQuery = previousJQuery;",
20+
"});"
21+
].join('\n');
22+
}
23+
},
24+
url: 'https://raw.github.com/warpech/jquery-handsontable/v<%= pkg.version%>/dist/jquery.handsontable.full.js',
25+
name: 'handsontable.js'
26+
},
27+
css: {
28+
url: 'https://raw.github.com/warpech/jquery-handsontable/v<%= pkg.version%>/dist/jquery.handsontable.full.css',
29+
name: "handsontable.css"
30+
}
31+
}
32+
});
33+
34+
grunt.loadTasks('../_tasks/download/tasks');
35+
grunt.registerTask('default', ['download']);
36+
};

handsontable/package.json

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"family": "jquery",
3+
"root": "jquery",
4+
"name": "handsontable",
5+
"title": "Handsontable",
6+
"version": "0.9.12",
7+
"author": {
8+
"name": "Marcin Warpechowski",
9+
"email": "[email protected]",
10+
"url": "http://www.nextgen.pl/"
11+
},
12+
"licenses": [
13+
{
14+
"type": "MIT",
15+
"url": "https://raw.github.com/warpech/jquery-handsontable/master/LICENSE"
16+
}
17+
],
18+
"description": "Minimalistic spreadsheet-like data grid editor that provides copy/paste functionality compatible with Excel/Google Docs",
19+
"homepage": "http://handsontable.com/",
20+
"docs": "https://github.com/warpech/jquery-handsontable",
21+
"demo": "http://handsontable.com/",
22+
"download": "https://github.com/warpech/jquery-handsontable/archive/master.zip",
23+
"keywords": [
24+
"grid",
25+
"datagrid",
26+
"table",
27+
"ui",
28+
"input",
29+
"ajax",
30+
"handsontable",
31+
"spreadsheet"
32+
],
33+
"bugs": "https://github.com/warpech/jquery-handsontable/issues",
34+
"dependencies": {
35+
"jquery": ">=1.7",
36+
"bootstrap-typeahead.js": "2.1.1",
37+
"contextMenu": ">=1.5.25"
38+
},
39+
"spm": {
40+
"alias": {
41+
"$": "$"
42+
},
43+
"output": ["handsontable.js", "handsontable.css"]
44+
}
45+
}

handsontable/spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
define(function(require) {
2+
3+
var $ = require("$");
4+
require('./src/handsontable');
5+
6+
describe('handsontable', function() {
7+
it('should has handsontable method', function() {
8+
expect($.fn.handsontable).to.be.a('function');
9+
expect($.support.htmlMenuitem).to.be.a('boolean');
10+
});
11+
});
12+
13+
});

index.html

+13-8
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
6-
<title>JQuery Family</title>
7-
<link href="node_modules/mocha/mocha.css?v=e5358" type="text/css" rel="stylesheet" charset="utf-8">
8-
<script src="node_modules/seajs/dist/sea.js"></script>
6+
<title>Gallery</title>
7+
<link href="node_modules/mocha/mocha.css" type="text/css" rel="stylesheet" charset="utf-8">
8+
<script src="node_modules/mocha/mocha.js"></script>
9+
<script src="sea-modules/seajs/seajs/2.1.1/sea.js"></script>
10+
<script src="sea-modules/jquery/jquery/1.7.2/jquery.js"></script>
911
<script src="node_modules/mocha/mocha.js"></script>
1012
<script src="node_modules/expect.js/expect.js"></script>
1113
<script type="text/javascript">
1214
seajs.config({
13-
base: './',
1415
alias: {
15-
'$': 'jquery/dist/jquery'
16+
'$': 'jquery/jquery/1.7.2/jquery'
1617
},
1718
map: [
1819
function(url) {
19-
var regex = /jquery\/(.*?)\/\d+\..*?\/(.*)$/
20-
return url.replace(regex, '$1/dist/$2')
20+
var regex = /gallery\/([^\/]*?)\/\d+\..*?\/(.*)$/
21+
if (regex.test(url)) {
22+
url = url.replace('sea-modules/', '');
23+
return url.replace(regex, '$1/dist/$2')
24+
}
25+
return url;
2126
}
2227
]
2328
});
@@ -30,7 +35,7 @@
3035
mocha.setup('bdd')
3136

3237
var modules = [
33-
'jquery', 'color', 'tablesorter', 'datatables'
38+
'handsontable'
3439
]
3540

3641
var specs = []

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
"version": "1.0.0",
44
"description": "jquery and its family members",
55
"dependencies": {
6-
"grunt-spm-build": "*",
76
"seajs": "*",
87
"mocha": "*",
98
"expect.js": "*",
109
"request": "*",
1110
"async": "*"
1211
},
13-
"scripts": {
14-
"test": "mocha-phantomjs index.html"
12+
"spm": {
13+
"engines": {
14+
"jquery": "jquery/jquery/1.7.2/jquery",
15+
"seajs": "seajs/seajs/2.1.1/sea"
16+
}
1517
}
1618
}

0 commit comments

Comments
 (0)