From ce58055e07eb30bf3b8d84b25b725d37f143a5f9 Mon Sep 17 00:00:00 2001 From: edsilv Date: Mon, 10 Aug 2015 16:42:14 +0100 Subject: [PATCH] unified extension media opening --- .gitignore | 1 + bower.json | 2 +- gulpfile.js | 11 +++++++++++ package.json | 6 ++---- src/_Version.ts | 2 +- .../uv-seadragon-extension/Extension.ts | 16 +++++----------- src/modules/uv-shared-module/BaseExtension.ts | 11 ++++++++++- src/modules/uv-shared-module/BaseProvider.ts | 8 ++++++++ src/modules/uv-shared-module/IProvider.ts | 2 ++ tasks/theme.js | 2 +- 10 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 gulpfile.js diff --git a/.gitignore b/.gitignore index 6372651bc..66a5cba04 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ node_modules !tasks/*.js !config.js !Gruntfile.js +!gulpfile.js !src/lib/*.js !src/*/*/lib/*.js !src/extensions/*/dependencies.js diff --git a/bower.json b/bower.json index 0adc024c9..121606e83 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "Universal Viewer", - "version": "1.4.1", + "version": "1.4.2", "repository": { "type": "git", "url": "git://github.com/UniversalViewer/universalviewer" diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 000000000..dbf8ba55c --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,11 @@ +// todo: in the process of migrating to gulp. continue using grunt for now + +var gulp = require('gulp'); +var ts = require('gulp-typescript'); +var c = require('./config'); +var config = new c(); + +gulp.task('build:dev', function() { + return gulp.src(config.typescript.dev.src) + .pipe(ts(config.typescript.dev.options)); +}); \ No newline at end of file diff --git a/package.json b/package.json index e87574b62..acc8ba365 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "UniversalViewer", - "version": "1.4.1", + "version": "1.4.2", "description": "Navigate sequences of images in a zoomable, extensible interface.", "devDependencies": { "async": "^0.9.0", @@ -18,8 +18,6 @@ "grunt-sync": "^0.2.3", "grunt-text-replace": "~0.3.7", "grunt-typescript": "^0.6.2", - "gulp": "^3.9.0", - "gulp-typescript": "^2.8.0", "hooker": "^0.2.3", "json-schema-generator": "git://github.com/krg7880/json-schema-generator.git", "less": "^2.4.0", @@ -27,4 +25,4 @@ "ncp": "^2.0.0", "protractor": "1.3.1" } -} +} \ No newline at end of file diff --git a/src/_Version.ts b/src/_Version.ts index 4ff2bc490..498cdb132 100644 --- a/src/_Version.ts +++ b/src/_Version.ts @@ -1 +1 @@ -export var Version = '1.4.1'; \ No newline at end of file +export var Version = '1.4.2'; \ No newline at end of file diff --git a/src/extensions/uv-seadragon-extension/Extension.ts b/src/extensions/uv-seadragon-extension/Extension.ts index b5a7e2291..42059744e 100644 --- a/src/extensions/uv-seadragon-extension/Extension.ts +++ b/src/extensions/uv-seadragon-extension/Extension.ts @@ -227,17 +227,6 @@ class Extension extends BaseExtension { } } - viewMedia(): void { - var canvasIndex = parseInt(this.getParam(Params.canvasIndex)) || this.provider.getStartCanvasIndex(); - - if (this.provider.isCanvasIndexOutOfRange(canvasIndex)){ - this.showMessage(this.provider.config.content.canvasIndexOutOfRange); - return; - } - - this.viewPage(canvasIndex || this.provider.getStartCanvasIndex()); - } - updateSettings(): void { this.viewPage(this.provider.canvasIndex, true); $.publish(BaseCommands.SETTINGS_CHANGED); @@ -248,6 +237,11 @@ class Extension extends BaseExtension { // if it's a valid canvas index. if (canvasIndex === -1) return; + if (this.provider.isCanvasIndexOutOfRange(canvasIndex)){ + this.showMessage(this.provider.config.content.canvasIndexOutOfRange); + canvasIndex = 0; + } + if (this.provider.isPagingSettingEnabled() && !isReload){ var indices = this.provider.getPagedIndices(canvasIndex); diff --git a/src/modules/uv-shared-module/BaseExtension.ts b/src/modules/uv-shared-module/BaseExtension.ts index 2ac69d95f..be945c815 100644 --- a/src/modules/uv-shared-module/BaseExtension.ts +++ b/src/modules/uv-shared-module/BaseExtension.ts @@ -216,7 +216,7 @@ class BaseExtension implements IExtension { $.publish(BaseCommands.CREATED); this.setParams(); this.setDefaultFocus(); - this.viewCanvas(0); + this.viewCanvas(this.provider.getCanvasIndexParam()); } setParams(): void{ @@ -349,10 +349,19 @@ class BaseExtension implements IExtension { viewCanvas(canvasIndex: number): void { if (canvasIndex === -1) return; + + if (this.provider.isCanvasIndexOutOfRange(canvasIndex)){ + this.showMessage(this.provider.config.content.canvasIndexOutOfRange); + canvasIndex = 0; + } + this.provider.canvasIndex = canvasIndex; + $.publish(BaseCommands.CANVAS_INDEX_CHANGED, [canvasIndex]); this.triggerSocket(BaseCommands.CANVAS_INDEX_CHANGED, canvasIndex); + $.publish(BaseCommands.OPEN_MEDIA); + this.setParam(Params.canvasIndex, canvasIndex); } diff --git a/src/modules/uv-shared-module/BaseProvider.ts b/src/modules/uv-shared-module/BaseProvider.ts index 2dc284393..ac7215901 100644 --- a/src/modules/uv-shared-module/BaseProvider.ts +++ b/src/modules/uv-shared-module/BaseProvider.ts @@ -168,6 +168,14 @@ class BaseProvider implements IProvider{ return this.sequence.getLastCanvasLabel(); } + getCanvasIndexParam(): number { + return parseInt(Utils.Urls.GetHashParameter(this.paramMap[Params.canvasIndex], parent.document)) || 0; + } + + getSequenceIndexParam(): number { + return parseInt(Utils.Urls.GetHashParameter(this.paramMap[Params.sequenceIndex], parent.document)) || 0; + } + isCanvasIndexOutOfRange(index: number): boolean { return this.sequence.isCanvasIndexOutOfRange(index); } diff --git a/src/modules/uv-shared-module/IProvider.ts b/src/modules/uv-shared-module/IProvider.ts index 7975a2eee..ccf0896aa 100644 --- a/src/modules/uv-shared-module/IProvider.ts +++ b/src/modules/uv-shared-module/IProvider.ts @@ -17,6 +17,7 @@ interface IProvider{ getCanvasByIndex(index: number): any; getCanvasIndexById(id: string): number; getCanvasIndexByLabel(label: string): number; + getCanvasIndexParam(): number; getCanvasType(canvas?: Manifesto.ICanvas): Manifesto.CanvasType; getCurrentCanvas(): any; getFirstPageIndex(): number; @@ -34,6 +35,7 @@ interface IProvider{ getRendering(resource: any, format: Manifesto.RenderingFormat): Manifesto.IRendering; getRenderings(resource: any): Manifesto.IRendering[]; getSeeAlso(): any; + getSequenceIndexParam(): number; getSequenceType(): string; getService(resource: any, profile: Manifesto.ServiceProfile | string): Manifesto.IService; getStartCanvasIndex(): number; diff --git a/tasks/theme.js b/tasks/theme.js index db2f12361..bed8b2abb 100644 --- a/tasks/theme.js +++ b/tasks/theme.js @@ -159,7 +159,7 @@ module.exports = function (grunt) { } function getThemeDest(theme) { - var buildDir = grunt.config('dirs.build'); + var buildDir = grunt.config('config.dirs.build'); return path.join(buildDir, 'themes', theme); }