Skip to content

Commit

Permalink
Merge branch '2.1.2' into remove-awesome
Browse files Browse the repository at this point in the history
  • Loading branch information
mejackreed committed Nov 8, 2016
2 parents 92c5c50 + ce4bce8 commit 77b614d
Show file tree
Hide file tree
Showing 21 changed files with 406 additions and 358 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ discovery.html
js/discovery
node_modules/
npm-debug.log
reports/
coverage/
data/ecodices
data/BnF
data/Harvard
Expand Down
108 changes: 1 addition & 107 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-git-describe');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-coveralls');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-githooks');
// grunt.loadNpmTasks('jasmine-jquery');

Expand Down Expand Up @@ -254,96 +252,6 @@ module.exports = function(grunt) {
ci: {
src: 'reports/coverage/PhantomJS*/lcov.info'
}
},

karma : {
options: {
configFile: 'karma.conf.js',
proxies: {
'/spec': 'http://localhost:9876/base/spec'
},
coverageReporter: {
reporters: [
{type: 'lcov'},
{type: 'html'},
{type: 'text-summary'}
],
dir: 'reports/coverage'
},
sauceLabs: {
},
customLaunchers: {
'sl_win7_chrome': {
base: 'SauceLabs',
browserName: 'chrome',
platform: 'Windows 7',
version: '39'
},
'sl_win7_firefox': {
base: 'SauceLabs',
browserName: 'firefox',
platform: 'Windows 7',
version: '35.0'
},
'sl_win7_ie09': {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 7',
version: '9'
},
'sl_win7_ie10': {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 7',
version: '10'
},
'sl_win7_ie11': {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 7',
version: '11'
}
}
},
test: {
reporters: ['spec'],
browsers: ['PhantomJS'],
singleRun: true
},
cover: {
preprocessors: {
'js/src/**/*.js': ['coverage']
},
reporters: ['progress', 'coverage'],
browsers: ['PhantomJS'],
singleRun: true
},
server: {
reporters: ['progress'],
browsers: ['Firefox'],
background: true
},
chrome: {
reporters: ['progress'],
browsers: ['Chrome'],
singleRun: true
},
firefox: {
reporters: ['progress'],
browsers: ['Firefox'],
singleRun: true
},
browsers: {
reporters: ['spec', 'saucelabs'],
browsers: [
'sl_win7_chrome',
'sl_win7_firefox',
// 'sl_win7_ie9',
// 'sl_win7_ie10',
'sl_win7_ie11'
],
singleRun: true
}
}
});

Expand Down Expand Up @@ -390,23 +298,9 @@ module.exports = function(grunt) {
// Runs server at specified port
grunt.registerTask('server', ['connect']);

// ----------
// Test task.
// Runs Jasmine tests
grunt.registerTask('test', 'karma:test');

// ----------
// Coverage task.
// Runs instanbul coverage
grunt.registerTask('cover', 'karma:cover');

// ----------
// Runs this on travis.
grunt.registerTask('ci', [
'jshint',
'test',
'cover',
'coveralls',
'karma:browsers'
'jshint'
]);
};
10 changes: 6 additions & 4 deletions js/src/annotations/annotationTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,19 @@
event: false
},
events: {
show: function(event, api) {
shown: function(event, api) {
if (params.onTooltipShown) { params.onTooltipShown(event, api); }
},
hidden: function(event, api) {
if (params.onTooltipHidden) { params.onTooltipHidden(event, api); }
_this.removeAllEvents(api, params);
},
visible: function (event, api) {
_this.removeAllEvents(api, params);
_this.addViewerEvents(api, params);
},
move: function (event, api) {
_this.removeAllEvents(api, params);
_this.addViewerEvents(api, params);
// _this.removeAllEvents(api, params);
// _this.addViewerEvents(api, params);
}
}
});
Expand Down Expand Up @@ -232,6 +232,8 @@
_this.addEditorEvents(api, viewerParams);
} else {
_this.eventEmitter.publish('annotationInEditMode.' + _this.windowId,[oaAnno]);
api.destroy();
jQuery(api.tooltip).remove();
}

_this.eventEmitter.publish('SET_ANNOTATION_EDITING.' + _this.windowId, {
Expand Down
30 changes: 18 additions & 12 deletions js/src/annotations/osd-region-draw-tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,37 +76,38 @@
}
},

render: function() {
render: function () {

if(this.parent.mode !== $.AnnotationsLayer.DISPLAY_ANNOTATIONS){
return ;
}
this.svgOverlay.restoreEditedShapes();
this.svgOverlay.paperScope.activate();
this.svgOverlay.paperScope.project.clear();
var _this = this;
_this.annotationsToShapesMap = {};
var deferreds = jQuery.map(this.list, function(annotation) {
var deferred = jQuery.Deferred(),
shapeArray;

for (var i = 0; i < this.list.length; i++) {
var shapeArray;
var annotation = this.list[i];
if (annotation.on && typeof annotation.on === 'object') {
if (!annotation.on.selector) {
return deferred;
continue;
} else if (annotation.on.selector.value.indexOf('<svg') !== -1) {
shapeArray = _this.svgOverlay.parseSVG(annotation.on.selector.value, annotation);
} else if (annotation.on.selector.value.indexOf('xywh=') !== -1) {
shapeArray = _this.parseRectangle(annotation.on.selector.value, annotation);
} else {
return deferred;
continue;
}
} else if (annotation.on && typeof annotation.on === 'string' && annotation.on.indexOf('xywh=') !== -1) {
shapeArray = _this.parseRectangle(annotation.on, annotation);
} else {
return deferred;
continue;
}
_this.svgOverlay.restoreLastView(shapeArray);
_this.annotationsToShapesMap[annotation['@id']] = shapeArray;
return deferred;
});
jQuery.when.apply(jQuery, deferreds).done(function() {
_this.eventEmitter.publish('overlaysRendered.' + _this.windowId);
});
}

var windowElement = _this.state.getWindowElement(_this.windowId);
this.annoTooltip = new $.AnnotationTooltip({
Expand All @@ -121,6 +122,7 @@
getAnnoFromRegion: _this.getAnnoFromRegion.bind(this)
});
this.svgOverlay.paperScope.view.draw();
_this.eventEmitter.publish('annotationsRendered.' + _this.windowId);
},

parseRectangle: function(rectString, annotation) {
Expand Down Expand Up @@ -261,6 +263,10 @@
});
_this.svgOverlay.paperScope.view.draw();
}));

this.eventsSubscriptions.push(_this.eventEmitter.subscribe('refreshOverlay.' + _this.windowId, function (event) {
_this.render();
}));
},

getAnnoFromRegion: function(regionId) {
Expand Down
7 changes: 7 additions & 0 deletions js/src/annotations/osd-svg-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,13 @@
_this.annoTooltip = null;
_this.annoEditorVisible = false;
}));

this.eventsSubscriptions.push(this.eventEmitter.subscribe("ANNOTATIONS_LIST_UPDATED",function(event,options){
if(options.windowId) {
_this.eventEmitter.publish("refreshOverlay." + _this.windowId);
}
}));

},

deleteShape:function(shape){
Expand Down
68 changes: 57 additions & 11 deletions js/src/utils/jsonLd.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,66 @@
(function($) {

/** Get the language to use for displaying the given propertyValue.
*
* Uses the algorithm described in
* http://iiif.io/api/presentation/2.1/#language-of-property-values
*/
function getDisplayLanguage(languages, items) {
var itemLanguages = items.map(function(itm) {
if (typeof itm === 'string') {
return null;
} else {
return itm['@language'];
}
});

var bestLanguageMatch = null;
jQuery.each(languages, function(idx, lang) {
if (bestLanguageMatch !== null) {
return false;
} else {
if (itemLanguages.indexOf(lang) !== -1) {
bestLanguageMatch = lang;
}
}
});

// Only pick the first available language if **all** property values
// have an associated language
if (bestLanguageMatch === null && itemLanguages.indexOf(null) === -1) {
bestLanguageMatch = itemLanguages[0];
}
return bestLanguageMatch;
}

$.JsonLd = {
getTextValue: function(propertyValue, language) {
if (typeof language === 'undefined') { language = "en"; }
if (typeof propertyValue === 'undefined' || propertyValue === null) {return ''; }
else if (typeof propertyValue === 'string') { return propertyValue; }
var languages = window.navigator.languages || ['en'];
if (typeof language === 'string') {
languages = [language].concat(languages);
} else if (Array.isArray(language)) {
languages = language.concat(languages);
}

if (typeof propertyValue === 'undefined' || propertyValue === null) {
return '';
}
else if (typeof propertyValue === 'string') {
return propertyValue;
}
else if (Array.isArray(propertyValue)) {
var displayLanguage = getDisplayLanguage(languages, propertyValue);
var text = '';
jQuery.each(propertyValue, function(index, item) {
if (typeof item === "string") {
text += item;
text += "<br/>";
} else if (!text || item['@language'] === language) {
// {@value: ..., @language: ...}
text = item['@value'];
jQuery.each(propertyValue, function(idx, item) {
var textToAdd = '';
if (typeof item === 'string' && displayLanguage === null) {
textToAdd = item;
} else if (item['@language'] === displayLanguage) {
textToAdd = item['@value'];
}
if (textToAdd !== '' && text !== '') {
text += '<br/>';
}
text += textToAdd;
});
return text;
} else {
Expand Down
2 changes: 2 additions & 0 deletions js/src/widgets/annotationsLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
this.init();
};

$.AnnotationsLayer.DISPLAY_ANNOTATIONS = 'displayAnnotations';

$.AnnotationsLayer.prototype = {

init: function() {
Expand Down
3 changes: 1 addition & 2 deletions js/src/widgets/imageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@

this.element.find('.mirador-osd-refresh-mode').on('click', function() {
//update annotation list from endpoint
_this.eventEmitter.publish('updateAnnotationList.'+_this.windowId);
// _this.eventEmitter.publish('refreshOverlay.'+_this.windowId, '');
_this.eventEmitter.publish('updateAnnotationList.' + _this.windowId);
});
//Annotation specific controls

Expand Down
7 changes: 0 additions & 7 deletions js/src/widgets/sidePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,11 @@

render: function(renderingData) {
var _this = this;

if (!this.element) {
this.element = this.appendTo;
jQuery(_this.template(renderingData)).appendTo(_this.appendTo);
return;
}

if (renderingData.open) {
this.appendTo.removeClass('minimized');
} else {
this.appendTo.addClass('minimized');
}
},

template: Handlebars.compile([
Expand Down
1 change: 1 addition & 0 deletions js/src/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@
//delete targetSlot;
_this.layoutDescription = root;
_this.calculateLayout();
_this.eventEmitter.publish('slotRemoved',targetSlot);
},

newNode: function(type, parent) {
Expand Down
Loading

0 comments on commit 77b614d

Please sign in to comment.