Skip to content

Commit d3b77ca

Browse files
author
Todd Wolfson
committed
Updates from production
1 parent 13fedc6 commit d3b77ca

File tree

5 files changed

+31
-16
lines changed

5 files changed

+31
-16
lines changed

grunt.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module.exports = function (grunt) {
22
grunt.initConfig({
33
lint: {
4-
all: ["grunt.js", "src/*.js", "src-test/*.js"]
4+
all: ["grunt.js", "tasks/*.js", "src-test/*.js"]
55
}
66
});
77

88
grunt.registerTask("default", "lint");
9-
grunt.loadTasks("src");
9+
grunt.loadTasks("tasks");
1010
};

package.json

+13-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "grunt-spritesmith",
33
"version": "0.0.2",
44
"description": "Grunt library for using spritesmith",
5-
"main": "index.js",
5+
"main": "grunt.js",
66
"scripts": {
77
"test": "grunt --base ./src-test/ --config ./src-test/grunt.js"
88
},
@@ -13,17 +13,22 @@
1313
"spritesheet",
1414
"css"
1515
],
16-
"author": "Todd Wolfson <[email protected]>",
16+
"author": {
17+
"name": "Todd Wolfson",
18+
"email": "[email protected]"
19+
},
1720
"license": "MIT",
1821
"dependencies": {
1922
"spritesmith": "git+ssh://[email protected]:Ensighten/spritesmith.git"
2023
},
21-
"optionalDependencies": {
24+
"devDependencies": {
2225
"grunt": "~0.3.12"
2326
},
2427
"private": true,
25-
"repositories": [{
26-
"type": "git",
27-
"url": "https://github.com/Ensighten/grunt-spritesmith.git"
28-
}]
29-
}
28+
"repositories": [
29+
{
30+
"type": "git",
31+
"url": "https://github.com/Ensighten/grunt-spritesmith.git"
32+
}
33+
]
34+
}

src-test/grunt.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ module.exports = function (grunt) {
1616
}
1717
});
1818

19-
grunt.loadTasks('../src');
19+
grunt.loadTasks('../tasks');
2020
grunt.registerTask('default', 'sprite test');
2121
};

src/grunt-spritesmith.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = function (grunt) {
1212

1313
// Verify all properties are here
1414
if (!src || !img || !css) {
15-
return grunt.fail("grunt.sprite requires a source, destImg, and destCSS property");
15+
return grunt.fatal("grunt.sprite requires a source, destImg, and destCSS property");
1616
}
1717

1818
// Load in all images from the src
@@ -52,10 +52,19 @@ module.exports = function (grunt) {
5252

5353
// Record all of the properties into cssVars
5454
// TODO: Find out of we can just make it an object in some namespace
55-
cssVars.push('$' + name + '_x = ' + coords.x + ';');
56-
cssVars.push('$' + name + '_y = ' + coords.y + ';');
57-
cssVars.push('$' + name + '_width = ' + coords.width + ';');
58-
cssVars.push('$' + name + '_height = ' + coords.height + ';');
55+
var x = coords.x + 'px',
56+
y = coords.y + 'px',
57+
offsetX = '-' + x,
58+
offsetY = '-' + y,
59+
width = coords.width + 'px',
60+
height = coords.height + 'px';
61+
cssVars.push('$' + name + '_x = ' + x + ';');
62+
cssVars.push('$' + name + '_y = ' + y + ';');
63+
cssVars.push('$' + name + '_offset_x = ' + offsetX + ';');
64+
cssVars.push('$' + name + '_offset_y = ' + offsetY + ';');
65+
cssVars.push('$' + name + '_width = ' + width + ';');
66+
cssVars.push('$' + name + '_height = ' + height + ';');
67+
cssVars.push('$' + name + ' = ' + [x, y, offsetX, offsetY, width, height].join(' ') + ';');
5968
});
6069

6170
// Join the cssVars with line feeds

tasks/grunt-spritesmith.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../src/grunt-spritesmith.js');

0 commit comments

Comments
 (0)