Skip to content

Commit

Permalink
unified extension media opening
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Aug 10, 2015
1 parent ca096e9 commit ce58055
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ node_modules
!tasks/*.js
!config.js
!Gruntfile.js
!gulpfile.js
!src/lib/*.js
!src/*/*/lib/*.js
!src/extensions/*/dependencies.js
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Universal Viewer",
"version": "1.4.1",
"version": "1.4.2",
"repository": {
"type": "git",
"url": "git://github.com/UniversalViewer/universalviewer"
Expand Down
11 changes: 11 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -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));
});
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -18,13 +18,11 @@
"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",
"lodash": "^3.1.0",
"ncp": "^2.0.0",
"protractor": "1.3.1"
}
}
}
2 changes: 1 addition & 1 deletion src/_Version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export var Version = '1.4.1';
export var Version = '1.4.2';
16 changes: 5 additions & 11 deletions src/extensions/uv-seadragon-extension/Extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down
11 changes: 10 additions & 1 deletion src/modules/uv-shared-module/BaseExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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);
}

Expand Down
8 changes: 8 additions & 0 deletions src/modules/uv-shared-module/BaseProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions src/modules/uv-shared-module/IProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tasks/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit ce58055

Please sign in to comment.