diff --git a/.gitignore b/.gitignore index f562c278..4b26396b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ *.sublime-workspace node_modules build/ -openseadragon.zip -openseadragon.tar diff --git a/Gruntfile.js b/Gruntfile.js index fda8fd6b..40af664e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -12,8 +12,11 @@ module.exports = function(grunt) { grunt.loadNpmTasks("grunt-git-describe"); // ---------- - var distribution = "build/openseadragon/openseadragon.js", + var packageJson = grunt.file.readJSON("package.json"), + distribution = "build/openseadragon/openseadragon.js", minified = "build/openseadragon/openseadragon.min.js", + packageDirName = "openseadragon-bin-" + packageJson.version, + packageDir = "build/" + packageDirName + "/", releaseRoot = "../site-build/built-openseadragon/", sources = [ "src/openseadragon.js", @@ -49,11 +52,12 @@ module.exports = function(grunt) { // ---------- // Project configuration. grunt.initConfig({ - pkg: grunt.file.readJSON("package.json"), + pkg: packageJson, clean: { build: ["build"], + package: [packageDir], release: { - src: [releaseRoot], + src: [releaseRoot + '*', '!' + releaseRoot + 'releases'], options: { force: true } @@ -84,18 +88,20 @@ module.exports = function(grunt) { compress: { zip: { options: { - archive: "build/openseadragon.zip" + archive: "build/releases/" + packageDirName + ".zip", + level: 9 }, files: [ - { expand: true, cwd: "build/", src: ["openseadragon/**"] } + { expand: true, cwd: "build/", src: [ packageDirName + "/**" ] } ] }, tar: { options: { - archive: "build/openseadragon.tar" + archive: "build/releases/" + packageDirName + ".tar.gz", + level: 9 }, files: [ - { expand: true, cwd: "build/", src: [ "openseadragon/**" ] } + { expand: true, cwd: "build/", src: [ packageDirName + "/**" ] } ] } }, @@ -150,6 +156,21 @@ module.exports = function(grunt) { grunt.file.copy("changelog.txt", "build/changelog.txt"); }); + // ---------- + // Copy:package task. + // Creates a directory tree to be compressed into a package. + grunt.registerTask("copy:package", function() { + grunt.file.recurse("build/openseadragon", function(abspath, rootdir, subdir, filename) { + var dest = packageDir + + (subdir ? subdir + "/" : '/') + + filename; + grunt.file.copy(abspath, dest); + }); + grunt.file.copy("changelog.txt", packageDir + "changelog.txt"); + grunt.file.copy("licenses/mit.txt", packageDir + "licenses/mit.txt"); + grunt.file.copy("licenses/new-bsd.txt", packageDir + "licenses/new-bsd.txt"); + }); + // ---------- // Copy:release task. // Copies the contents of the build folder into the release folder. @@ -177,8 +198,8 @@ module.exports = function(grunt) { // ---------- // Package task. - // Builds and creates the .zip and .tar files. - grunt.registerTask("package", ["build", "compress"]); + // Builds and creates the .zip and .tar.gz files. + grunt.registerTask("package", ["build", "copy:package", "compress", "clean:package"]); // ---------- // Publish task. diff --git a/README.md b/README.md index c3f66385..0fdad825 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # OpenSeadragon -This project is a fork of the OpenSeadragon project at http://openseadragon.codeplex.com/ +An open-source, web-based viewer for zoomable images, implemented in pure JavaScript. -## On the Web +See it in action at http://openseadragon.github.io/. -http://openseadragon.github.io/ +## Stable Builds + +See our [releases page](http://openseadragon.github.io/releases/). ## First Time Setup @@ -40,7 +42,7 @@ You can also publish the built version to the site-build repository. This assume 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. +... which will delete the existing openseadragon folder, along with the .zip and .tar.gz 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 @@ -60,6 +62,14 @@ OpenSeadragon is truly a community project; we welcome your involvement! When contributing, please attempt to match the code style already in the codebase. Note that we use four spaces per indentation stop. For more thoughts on code style, see https://github.com/rwldrn/idiomatic.js/. +When fixing bugs and adding features, when appropriate please also: + +* Update changelog.txt +* Add/update related unit tests +* Update related doc comments + +If you're new to the project, check out our [good first bug](https://github.com/openseadragon/openseadragon/issues?labels=good+first+bug&page=1&state=open) issues for some places to dip your toe in the water. + ## Licenses OpenSeadragon was initially released with a New BSD License ( preserved below ), while work done by Chris Thatcher is additionally licensed under the MIT License. diff --git a/changelog.txt b/changelog.txt index 871d7f84..eed40e53 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,12 +1,22 @@ OPENSEADRAGON CHANGELOG ======================= -0.9.125: In Progress +0.9.127: (in progress) + +0.9.126: + +* DZI JSONp was broken; fixed. + +0.9.125: * Fully deprecated OpenSeadragon.createFromDZI, safely deprecated Viewer.openTileSource and Viewer.openDZI to use Viewer.open internally. (#53 & #54). * Full page bug fix for when viewer is child of document body (#43). * Overlays for DZI bug fix (#45). +* DziTileSource: avoid changing relative paths (#56). +* Fix typo in preserveViewport handling (#77). +* Fix updateMulti timer leak after multiple Viewer.open() calls (#76). +* Minor documentation fixes. 0.9.124: diff --git a/openseadragon.sublime-project b/openseadragon.sublime-project index b7e30c92..f8e2dd71 100644 --- a/openseadragon.sublime-project +++ b/openseadragon.sublime-project @@ -3,7 +3,13 @@ [ { "path": ".", - "file_exclude_patterns": ["*.sublime-project", "*.sublime-workspace"] + "file_exclude_patterns": [ + "*.sublime-project", + "*.sublime-workspace" + ], + "folder_exclude_patterns": [ + "node_modules" + ] } ], "settings": diff --git a/package.json b/package.json index fe3dff04..4450061b 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "OpenSeadragon", - "version": "0.9.124", + "version": "0.9.126", "description": "Provides a smooth, zoomable user interface for HTML/Javascript.", "devDependencies": { "grunt": "~0.4.0", - "grunt-contrib-compress": "~0.4.0", + "grunt-contrib-compress": "~0.5.0", "grunt-contrib-concat": "~0.1.2", "grunt-contrib-jshint": "~0.1.1", "grunt-contrib-uglify": "~0.1.1", diff --git a/src/dzitilesource.js b/src/dzitilesource.js index 2a8150c4..6f148380 100644 --- a/src/dzitilesource.js +++ b/src/dzitilesource.js @@ -109,7 +109,7 @@ $.extend( $.DziTileSource.prototype, $.TileSource.prototype, { } if (url && !options.tilesUrl) { - options.tilesUrl = url.replace(/([^\/]+)\.dzi$/, '$1_files/'); + options.tilesUrl = url.replace(/([^\/]+)\.(dzi|xml|js)$/, '$1_files/'); } return options; diff --git a/src/strings.js b/src/strings.js index 7d990237..c2ae5ef7 100644 --- a/src/strings.js +++ b/src/strings.js @@ -6,21 +6,13 @@ // pythons gettext might be a reasonable approach. var I18N = { Errors: { - Failure: "Sorry, but Seadragon Ajax can't run on your browser!\n" + - "Please try using IE 7 or Firefox 3.\n", Dzc: "Sorry, we don't support Deep Zoom Collections!", Dzi: "Hmm, this doesn't appear to be a valid Deep Zoom Image.", Xml: "Hmm, this doesn't appear to be a valid Deep Zoom Image.", - Empty: "You asked us to open nothing, so we did just that.", ImageFormat: "Sorry, we don't support {0}-based Deep Zoom Images.", Security: "It looks like a security restriction stopped us from " + "loading this Deep Zoom Image.", - Status: "This space unintentionally left blank ({0} {1}).", - Unknown: "Whoops, something inexplicably went wrong. Sorry!" - }, - - Messages: { - Loading: "Loading..." + Status: "This space unintentionally left blank ({0} {1})." }, Tooltips: { diff --git a/src/viewer.js b/src/viewer.js index a87c52e9..df8dce87 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -24,10 +24,12 @@ var THIS = {}, * @param {String} options.xmlPath Xpath ( TODO: not sure! ), * @param {String} options.prefixUrl Url used to prepend to paths, eg button * images, etc. - * @param {Seadragon.Controls[]} options.controls Array of Seadragon.Controls, - * @param {Seadragon.Overlays[]} options.overlays Array of Seadragon.Overlays, - * @param {Seadragon.Controls[]} options.overlayControls An Array of ( TODO: + * @param {OpenSeadragon.Control[]} options.controls Array of OpenSeadragon.Control, + * @param {OpenSeadragon.Overlay[]} options.overlays Array of OpenSeadragon.Overlay, + * @param {OpenSeadragon.Control[]} options.overlayControls An Array of ( TODO: * not sure! ) + * @property {OpenSeadragon.Viewport} viewport The viewer's viewport, where you + * can access zoom, pan, etc. * **/ $.Viewer = function( options ) { @@ -115,8 +117,7 @@ $.Viewer = function( options ) { THIS[ this.hash ] = { "fsBoundsDelta": new $.Point( 1, 1 ), "prevContainerSize": null, - "lastOpenStartTime": 0, - "lastOpenEndTime": 0, + "updateRequestId": null, "animating": false, "forceRedraw": false, "mouseInside": false, @@ -355,7 +356,11 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, * @return {OpenSeadragon.Viewer} Chainable. */ close: function ( ) { - + if ( THIS[ this.hash ].updateRequestId !== null ){ + $.cancelAnimationFrame( THIS[ this.hash ].updateRequestId ); + THIS[ this.hash ].updateRequestId = null; + } + if( this.drawer ){ this.drawer.clearOverlays(); } @@ -956,16 +961,6 @@ function openTileSource( viewer, source ) { _this.close( ); } - // to ignore earlier opens - THIS[ _this.hash ].lastOpenStartTime = +new Date(); - - window.setTimeout( function () { - if ( THIS[ _this.hash ].lastOpenStartTime > THIS[ _this.hash ].lastOpenEndTime ) { - THIS[ _this.hash ].setMessage( $.getString( "Messages.Loading" ) ); - } - }, 2000); - - THIS[ _this.hash ].lastOpenEndTime = +new Date(); _this.canvas.innerHTML = ""; THIS[ _this.hash ].prevContainerSize = $.getElementSize( _this.container ); @@ -1014,7 +1009,7 @@ function openTileSource( viewer, source ) { }); } - if( _this.preserveVewport ){ + if( _this.preserveViewport ){ _this.viewport.resetContentSize( _this.source.dimensions ); } @@ -1076,7 +1071,7 @@ function openTileSource( viewer, source ) { THIS[ _this.hash ].animating = false; THIS[ _this.hash ].forceRedraw = true; - scheduleUpdate( _this, updateMulti ); + THIS[ _this.hash ].updateRequestId = scheduleUpdate( _this, updateMulti ); //Assuming you had programatically created a bunch of overlays //and added them via configuration @@ -1351,12 +1346,15 @@ function updateMulti( viewer ) { var beginTime; if ( !viewer.source ) { + THIS[ viewer.hash ].updateRequestId = null; return; } beginTime = +new Date(); updateOnce( viewer ); - scheduleUpdate( viewer, arguments.callee, beginTime ); + + THIS[ viewer.hash ].updateRequestId = scheduleUpdate( viewer, + arguments.callee, beginTime ); } function updateOnce( viewer ) { diff --git a/test/basic.js b/test/basic.js index ca4556c8..ff302670 100644 --- a/test/basic.js +++ b/test/basic.js @@ -1,5 +1,7 @@ (function() { + module('Basic'); + // TODO: Tighten up springs and use "immediate" where possible, so tests run faster // TODO: Test drag @@ -104,6 +106,7 @@ asyncTest('Close', function() { var closeHandler = function() { viewer.removeHandler('close', closeHandler); + $('#example').empty(); ok(true, 'Close event was sent'); start(); }; diff --git a/test/data/testpattern.js b/test/data/testpattern.js new file mode 100644 index 00000000..8081b54b --- /dev/null +++ b/test/data/testpattern.js @@ -0,0 +1,12 @@ +testpattern({ + Image: { + xmlns: 'http://schemas.microsoft.com/deepzoom/2008', + Format: 'jpg', + Overlap: 1, + TileSize: 254, + Size:{ + Height: 1000, + Width: 1000 + } + } +}); diff --git a/test/dzi-jsonp.js b/test/dzi-jsonp.js new file mode 100644 index 00000000..138de35b --- /dev/null +++ b/test/dzi-jsonp.js @@ -0,0 +1,51 @@ +(function() { + + // TODO: How to know if a tile has been drawn? The tile-drawn event used below + // is defunct. + + module('DZI JSONp'); + + var viewer = null; + + // ---------- + asyncTest('Open', function() { + $(document).ready(function() { + viewer = OpenSeadragon({ + id: 'example', + prefixUrl: '/build/openseadragon/images/', + tileSources: '/test/data/testpattern.js' + }); + + ok(viewer, 'Viewer exists'); + + var openHandler = function(eventSender, eventData) { + viewer.removeHandler('open', openHandler); + ok(true, 'Open event was sent'); + viewer.drawer.viewer = viewer; + viewer.addHandler('tile-drawn', tileDrawnHandler); + }; + + var tileDrawnHandler = function(eventSender, eventData) { + viewer.removeHandler('tile-drawn', tileDrawnHandler); + ok(true, 'A tile has been drawn'); + start(); + }; + + viewer.addHandler('open', openHandler); + }); + }); + + // ---------- + // asyncTest('Close', function() { + // var closeHandler = function() { + // viewer.removeHandler('close', closeHandler); + // $('#example').empty(); + // ok(true, 'Close event was sent'); + // start(); + // }; + + // viewer.addHandler('close', closeHandler); + // viewer.close(); + // }); + +})(); diff --git a/test/test.html b/test/test.html index 6ca53fa2..fe83f52d 100644 --- a/test/test.html +++ b/test/test.html @@ -17,5 +17,6 @@ +