Skip to content

Commit

Permalink
Revert "Fix mistake in french locale"
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschylus committed Nov 7, 2016
1 parent ef67095 commit ad20429
Show file tree
Hide file tree
Showing 16 changed files with 152 additions and 344 deletions.
10 changes: 4 additions & 6 deletions js/src/annotations/annotationTooltip.js
Expand Up @@ -153,19 +153,19 @@
event: false
},
events: {
shown: function(event, api) {
show: 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,8 +232,6 @@
_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: 12 additions & 18 deletions js/src/annotations/osd-region-draw-tool.js
Expand Up @@ -76,38 +76,37 @@
}
},

render: function () {

if(this.parent.mode !== $.AnnotationsLayer.DISPLAY_ANNOTATIONS){
return ;
}
render: function() {
this.svgOverlay.restoreEditedShapes();
this.svgOverlay.paperScope.activate();
this.svgOverlay.paperScope.project.clear();
var _this = this;
_this.annotationsToShapesMap = {};

for (var i = 0; i < this.list.length; i++) {
var shapeArray;
var annotation = this.list[i];
var deferreds = jQuery.map(this.list, function(annotation) {
var deferred = jQuery.Deferred(),
shapeArray;
if (annotation.on && typeof annotation.on === 'object') {
if (!annotation.on.selector) {
continue;
return deferred;
} 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 {
continue;
return deferred;
}
} else if (annotation.on && typeof annotation.on === 'string' && annotation.on.indexOf('xywh=') !== -1) {
shapeArray = _this.parseRectangle(annotation.on, annotation);
} else {
continue;
return deferred;
}
_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 @@ -122,7 +121,6 @@
getAnnoFromRegion: _this.getAnnoFromRegion.bind(this)
});
this.svgOverlay.paperScope.view.draw();
_this.eventEmitter.publish('annotationsRendered.' + _this.windowId);
},

parseRectangle: function(rectString, annotation) {
Expand Down Expand Up @@ -263,10 +261,6 @@
});
_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: 0 additions & 7 deletions js/src/annotations/osd-svg-overlay.js
Expand Up @@ -414,13 +414,6 @@
_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: 11 additions & 57 deletions js/src/utils/jsonLd.js
@@ -1,66 +1,20 @@
(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) {
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;
}
if (typeof language === 'undefined') { language = "en"; }
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(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/>';
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'];
}
text += textToAdd;
});
return text;
} else {
Expand Down
2 changes: 0 additions & 2 deletions js/src/widgets/annotationsLayer.js
Expand Up @@ -17,8 +17,6 @@
this.init();
};

$.AnnotationsLayer.DISPLAY_ANNOTATIONS = 'displayAnnotations';

$.AnnotationsLayer.prototype = {

init: function() {
Expand Down
3 changes: 2 additions & 1 deletion js/src/widgets/imageView.js
Expand Up @@ -270,7 +270,8 @@

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

Expand Down
7 changes: 7 additions & 0 deletions js/src/widgets/sidePanel.js
Expand Up @@ -187,11 +187,18 @@

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: 0 additions & 1 deletion js/src/workspace.js
Expand Up @@ -364,7 +364,6 @@
//delete targetSlot;
_this.layoutDescription = root;
_this.calculateLayout();
_this.eventEmitter.publish('slotRemoved',targetSlot);
},

newNode: function(type, parent) {
Expand Down

0 comments on commit ad20429

Please sign in to comment.