Skip to content

Commit

Permalink
Merge pull request #906 from UCLALibrary/remove-dead-utils-functions
Browse files Browse the repository at this point in the history
remove dead functions from utils/utils.js, …
  • Loading branch information
aeschylus committed May 6, 2016
2 parents 3641e47 + 89f9d30 commit 1f13d8c
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 78 deletions.
49 changes: 0 additions & 49 deletions js/src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@
return thumbnailUrl;
};

$.getImagesListByManifest = function(manifest) {
return manifest.sequences[0].canvases;
};

$.getCollectionTitle = function(metadata) {
return metadata.details.label || '';
};

/*
miscellaneous utilities
*/
Expand Down Expand Up @@ -153,30 +145,6 @@
};
};

$.parseRegion = function(url) {
url = new URI(url);
var regionString = url.hash();
regionArray = regionString.split('=')[1].split(',');
return regionArray;
};

$.getOsdFrame = function(region, currentImg) {
var imgWidth = currentImg.width,
imgHeight = currentImg.height,
canvasWidth = currentImg.canvasWidth,
canvasHeight = currentImg.canvasHeight,
widthNormaliser = imgWidth/canvasWidth,
heightNormaliser = imgHeight/canvasHeight,
rectX = (region[0]*widthNormaliser)/imgWidth,
rectY = (region[1]*heightNormaliser)/imgWidth,
rectW = (region[2]*widthNormaliser)/imgWidth,
rectH = (region[3]*heightNormaliser)/imgWidth;

var osdFrame = new OpenSeadragon.Rect(rectX,rectY,rectW,rectH);

return osdFrame;
};

// http://upshots.org/javascript/jquery-test-if-element-is-in-viewport-visible-on-screen
$.isOnScreen = function(elem, outsideViewportFactor) {
var factor = 1;
Expand Down Expand Up @@ -238,23 +206,6 @@
return layoutDescription;
};

$.generateRange = function(start, stop, step) {
if (arguments.length <= 1) {
stop = start || 0;
start = 0;
}
step = step || 1;

var length = Math.max(Math.ceil((stop - start) / step), 0);
var range = Array(length);

for (var idx = 0; idx < length; idx++, start += step) {
range[idx] = start;
}

return range;
};

// Configurable Promises
$.createImagePromise = function(imageUrl) {
var img = new Image(),
Expand Down
2 changes: 1 addition & 1 deletion spec/utils/iiif.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('iiif', function () {
describe('Iiif', function () {
xit('getImageUrl', function () {
});

Expand Down
4 changes: 2 additions & 2 deletions spec/utils/jsonBlobApi.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('util/jsonBlobApi', function () {
describe('JsonBlobApi', function () {
xit('readSync', function () {
});
xit('save', function () {
});
});
});
2 changes: 1 addition & 1 deletion spec/utils/jsonLd.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('utils/jsonLd', function () {
describe('JsonLd', function () {
xit('getTextValue', function () {
});
});
2 changes: 1 addition & 1 deletion spec/utils/openSeadragon.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('utils/openSeadragon', function () {
describe('OpenSeadragon', function () {
xit('Construction', function () {
});
});
2 changes: 1 addition & 1 deletion spec/utils/saveController.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('saveController', function () {
describe('SaveController', function () {

beforeEach(function() {
this.config = {
Expand Down
39 changes: 24 additions & 15 deletions spec/utils/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
describe('Utils', function() {
beforeEach(function() {
this.utils = Mirador;
var imagesList = [{
'id': 1,
this.imagesList = [{
'@id': '1',
'title': '1r',
'height': 10,
'width': 20
}, {
'id': 2,
'@id': '2',
'title': '1v',
'height': 15,
'width': 25
}],
}];

imageTitlesAndIds = [{
'id': 1,
this.imageTitlesAndIds = [{
'@id': '1',
'title': '1r'
}, {
'id': 2,
'@id': '2',
'title': '1v'
}];
manifests = {
this.manifests = {
"manifest-1234": {
"uri":"http://xyz.edu/data/Manifest.json",
"metadata": {
Expand All @@ -29,7 +29,7 @@ describe('Utils', function() {
}
},
"sequences": [{
"imagesList": imagesList
"imagesList": this.imagesList
}]
}
};
Expand All @@ -39,12 +39,6 @@ describe('Utils', function() {
expect(this.utils.trimString(' abc ')).toEqual('abc');
});

it('should return a collection title for a given metadata', function() {
expect(this.utils.getCollectionTitle({ 'details': { 'label': 'abc' } })).toEqual('abc');
expect(this.utils.getCollectionTitle({ 'details': { } })).toEqual('');
});


describe('XHR utils', function() {
beforeEach(function() {
this.server = sinon.fakeServer.create();
Expand Down Expand Up @@ -111,4 +105,19 @@ describe('Utils', function() {
});
});
});

describe('getImageIndexById', function() {
it('should return index of the image with the given id', function() {
expect(this.utils.getImageIndexById(this.imagesList, '1')).toBe(0);
expect(this.utils.getImageIndexById(this.imagesList, '2')).toBe(1);
// TODO: should expect -1 or throw exception instead
expect(this.utils.getImageIndexById(this.imagesList, '0')).toBe(0);
});
});

describe('getThumbnailForCanvas', function() {
xit('should get the proper thumbnail for a canvas', function () {

});
});
});
2 changes: 1 addition & 1 deletion spec/viewer/mainMenu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('MainMenu Class', function () {
describe('MainMenu', function () {

describe('default configuration', function() {
beforeEach(function() {
Expand Down
4 changes: 2 additions & 2 deletions spec/viewer/manifestListItem.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('viewer/manifestListItem', function () {
describe('ManifestListItem', function () {
xit('fetchTplData', function () {
});
xit('render', function () {
Expand All @@ -13,4 +13,4 @@ describe('viewer/manifestListItem', function () {
});
xit('show', function () {
});
});
});
4 changes: 2 additions & 2 deletions spec/viewer/manifestsPanel.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('viewer/manifestsPanel', function() {
describe('ManifestsPanel', function() {
beforeEach(function() {
jasmine.getJSONFixtures().fixturesPath = 'spec/fixtures';
this.dummyManifestContent = getJSONFixture('dummyManifest.json');
Expand Down Expand Up @@ -114,4 +114,4 @@ describe('viewer/manifestsPanel', function() {
expect(this.panel.manifestListItems.length).toBe(1);
});

});
});
2 changes: 1 addition & 1 deletion spec/widgets/annotationsLayer.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('AnnotatinsLayer', function() {
describe('AnnotationsLayer', function() {

beforeEach(function() {

Expand Down
4 changes: 2 additions & 2 deletions spec/workspaces/slot.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('workspaces/slot', function () {
describe('Slot', function () {
xit('listenForActions', function () {
});
xit('bindEvents', function () {
Expand All @@ -11,4 +11,4 @@ describe('workspaces/slot', function () {
});
xit('addItem', function () {
});
});
});

0 comments on commit 1f13d8c

Please sign in to comment.