This commit is contained in:
thatcher 2013-02-28 14:38:12 -05:00
commit 2f938766b3
4 changed files with 64 additions and 11 deletions

View File

@ -7,6 +7,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks("grunt-contrib-qunit");
grunt.loadNpmTasks("grunt-contrib-connect");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-clean");
var distribution = "build/openseadragon/openseadragon.js",
minified = "build/openseadragon/openseadragon.min.js",
@ -43,6 +44,19 @@ module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
clean: {
build: ["build"],
release: {
src: [
"../site-build/openseadragon",
"../site-build/openseadragon.zip",
"../site-build/openseadragon.tar"
],
options: {
force: true
}
}
},
concat: {
options: {
banner: "/**\n * @version <%= pkg.name %> <%= pkg.version %>\n */\n\n"
@ -93,7 +107,7 @@ module.exports = function(grunt) {
},
watch: {
files: [ "grunt.js", "src/*.js" ],
tasks: "default"
tasks: "build"
},
jshint: {
options: {
@ -109,20 +123,45 @@ module.exports = function(grunt) {
}
});
// Copy task.
grunt.registerTask("copy", function() {
// Copy:build task.
// Copies the image files into the appropriate location in the build folder.
grunt.registerTask("copy:build", function() {
grunt.file.recurse("images", function(abspath, rootdir, subdir, filename) {
grunt.file.copy(abspath, "build/openseadragon/images/" + (subdir || "") + filename);
});
});
// Default task.
grunt.registerTask("default", ["jshint:beforeconcat", "concat", "jshint:afterconcat", "uglify", "copy"]);
// Copy:release task.
// Copies the contents of the build folder into ../site-build.
grunt.registerTask("copy:release", function() {
grunt.file.recurse("build", function(abspath, rootdir, subdir, filename) {
var dest = "../site-build/"
+ (subdir ? subdir + "/" : "")
+ filename;
grunt.file.copy(abspath, dest);
});
});
// Build task.
// Cleans out the build folder and builds the code and images into it, checking lint.
grunt.registerTask("build", [
"clean:build", "jshint:beforeconcat", "concat", "jshint:afterconcat", "uglify", "copy:build"
]);
// Test task.
grunt.registerTask("test", ["default", "connect", "qunit"]);
// Builds and runs unit tests.
grunt.registerTask("test", ["build", "connect", "qunit"]);
// Package task.
grunt.registerTask("package", ["default", "compress"]);
// Builds and creates the .zip and .tar files.
grunt.registerTask("package", ["build", "compress"]);
// Publish task.
// Cleans the built files out of ../site-build and copies newly built ones over.
grunt.registerTask("publish", ["package", "clean:release", "copy:release"]);
// Default task.
// Does a normal build.
grunt.registerTask("default", ["build"]);
};

View File

@ -46,6 +46,14 @@ If you want to build tar and zip files for distribution (they will also appear i
grunt package
Note that the `build` folder is masked with .gitignore; it's just for your local use, and won't be checked in to the repository.
You can also publish the built version to the site-build repository. This assumes you have cloned it next to this repository. The command is:
grunt publish
... which will delete the existing openseadragon folder, along with the .zip and .tar files, out of the site-build folder and replace them with newly built ones from the source in this repository; you'll then need to commit the changes to site-build.
## Testing
Our tests are based on [QUnit](http://qunitjs.com/) and [PhantomJS](http://phantomjs.org/); they're both installed when you run `npm install`. At the moment we don't have much in the way of tests, but we're working to fix that. To run on the command line:

View File

@ -1,6 +1,6 @@
{
"name": "OpenSeadragon",
"version": "0.9.120",
"version": "0.9.121",
"description": "Provides a smooth, zoomable user interface for HTML/Javascript.",
"dependencies": {
"grunt": "~0.4.0",
@ -10,7 +10,8 @@
"grunt-contrib-uglify": "~0.1.1",
"grunt-contrib-qunit": "~0.1.1",
"grunt-contrib-connect": "~0.1.2",
"grunt-contrib-watch": "~0.2.0"
"grunt-contrib-watch": "~0.2.0",
"grunt-contrib-clean": "~0.4.0"
},
"scripts": {
"test": "grunt test"

View File

@ -695,6 +695,10 @@
THIS[ tracker.hash ].lastPinchDelta =
Math.abs( touchA.x - touchB.x ) +
Math.abs( touchA.y - touchB.y );
THIS[ tracker.hash ].pinchMidpoint = new $.Point(
( touchA.x + touchB.x ) / 2 ,
( touchA.y + touchB.y ) / 2
);
//$.console.debug("pinch start : "+THIS[ tracker.hash ].lastPinchDelta);
}
@ -756,6 +760,7 @@
}
if( event.touches.length + event.changedTouches.length == 2 ){
THIS[ tracker.hash ].lastPinchDelta = null;
THIS[ tracker.hash ].pinchMidpoint = null;
//$.console.debug("pinch end");
}
event.preventDefault();
@ -961,8 +966,8 @@
onMouseWheelSpin( tracker, {
shift: false,
pageX: ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2,
pageY: ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2,
pageX: THIS[ tracker.hash ].pinchMidpoint.x,
pageY: THIS[ tracker.hash ].pinchMidpoint.y,
detail:(
THIS[ tracker.hash ].lastPinchDelta > pinchDelta
) ? 1 : -1