Skip to content
Snippets Groups Projects
Commit 8637c136 authored by aeschylus's avatar aeschylus Committed by GitHub
Browse files

Merge pull request #1491 from jeffreycwitt/feature/annotation-side-panel-2.6-updated

Feature/annotation side panel 2.6 updated
parents de2cdeb7 1f285733
Branches
Tags
No related merge requests found
......@@ -52,7 +52,7 @@
list-style-type: none;
border-left:0;
border-right:0;
padding:10px 10px 0 10px;
padding:10px 10px 10px 10px;
}
.annotationListItem:after {
......@@ -125,10 +125,26 @@
margin-top: 8px;
}
.annotationsPanel ul {
.annotationsPanel {
margin: 0;
margin-bottom: 10px;
padding-bottom: 100px;
overflow-y: scroll;
width: 280px;
padding-right: 10px;
position: absolute;
box-sizing: border-box;
left: 0;
top: 0px;
bottom: 0;
list-style-type: none;
font-size: 75%;
ul {
padding:0;
margin:0;
}
}
.toc {
margin:0;
......
......
......@@ -72,15 +72,19 @@
{ "manifestUri": "http://demos.biblissima-condorcet.fr/iiif/metadata/BVMM/chateauroux/manifest.json", "location": "Biblissima"},
{ "manifestUri": "https://manifests.britishart.yale.edu/Osbornfa1", "location": "Yale Beinecke"},
/* { "manifestUri": "http://demos.biblissima-condorcet.fr/iiif/metadata/florus-dispersus/manifest.json", "location": "Biblissima"}*/
{ "manifestUri": "https://media.nga.gov/public/manifests/multispectral_demo.json", "location": "National Gallery of Art"}
{ "manifestUri": "https://media.nga.gov/public/manifests/multispectral_demo.json", "location": "National Gallery of Art"},
{ "manifestUri": "https://scta.info/iiif/codex/sorb/manifest"},
{ "manifestUri": "https://scta.info/iiif/graciliscommentary/lon/manifest"},
{ "manifestUri": "https://scta.info/iiif/plaoulcommentary/sorb/manifest"}
],
"windowObjects": [],
"annotationEndpoint": { "name":"Local Storage", "module": "LocalStorageEndpoint" },
"sidePanelOptions" : {
"tocTabAvailable": true,
"layersTabAvailable": true,
"searchTabAvailable": true
}
"searchTabAvailable": true,
"annotations" : true
},
});
});
</script>
......
......
......@@ -55,7 +55,8 @@
"annotations" : false,
"tocTabAvailable": true,
"layersTabAvailable": false,
"searchTabAvailable": false
"searchTabAvailable": false,
"annotationTabAvailable": false
},
"sidePanelVisible" : true, //whether or not to make the side panel visible in this window on load. This setting is dependent on sidePanel being true
"overlay" : true, //whether or not to make the metadata overlay available/visible in this window
......
......
......@@ -48,23 +48,31 @@
},
tabStateUpdated: function(visible) {
var localState = this.localState();
localState.visible = localState.visible ? false : true;
localState = this.localState();
localState.visible = visible;
this.localState(localState);
visible ? this.element.show() : this.element.hide();
},
annotationListLoaded: function() {
var _this = this,
annotationSources = [],
localState = this.localState();
jQuery.each(_this.state.getWindowAnnotationsList(_this.windowId), function(index, value) {
if(typeof value.endpoint === 'string') {
annotationSources.push('manifest');
} else {
annotationSources.push(value.endpoint.name);
//loads annoations from external annotationLists
if(value.endpoint && typeof value.endpoint === 'string') {
annotationSources.push(value.resource);
}
else if (value.resource){
//loads annoations from external annotationLists
if(value.resource.endpoint && typeof value.resource.endpoint === 'string') {
annotationSources.push(value.resource);
}
//loads annoations from local annotation endpoint
else {
annotationSources.push(value.resource[0]);
}
}
});
// make unique
annotationSources = annotationSources.filter(function(itm,i,annotationSources){
return i==annotationSources.indexOf(itm);
......@@ -83,7 +91,6 @@
if(localState.annotationLists.length){
localState.empty = false;
}
this.localState(localState);
},
deselectList: function(listId) {
......@@ -146,18 +153,18 @@
var _this = this,
listItems = this.element.find('.annotationListItem');
listItems.on('click', function(event) {
//event.stopImmediatePropagation();
var listClicked = jQuery(this).data('id');
if(_this.localState().selectedList === listClicked){
//_this.deselectList(listClicked);
_this.eventEmitter.publish('listDeselected.' + _this.windowId, listClicked);
}else{
//_this.selectList(listClicked);
_this.eventEmitter.publish('listSelected.' + _this.windowId, listClicked);
}
});
// listItems.on('click', function(event) {
// //event.stopImmediatePropagation();
// var listClicked = jQuery(this).data('id');
// if(_this.localState().selectedList === listClicked){
// //_this.deselectList(listClicked);
// _this.eventEmitter.publish('listDeselected.' + _this.windowId, listClicked);
// }else{
// //_this.selectList(listClicked);
// _this.eventEmitter.publish('listSelected.' + _this.windowId, listClicked);
// }
//
// });
},
render: function(state) {
......@@ -184,8 +191,12 @@
'<div class="annotationsPanel">',
'<ul class="annotationSources">',
'{{#each annotationSources}}',
'<li class="annotationListItem {{#if this.selected}}selected{{/if}} {{#if this.focused }}focused{{/if}}" data-id="{{this.annotationSource}}">',
'<span>{{this.annotationSource}}</span>',
//'<li class="annotationListItem {{#if this.selected}}selected{{/if}} {{#if this.focused }}focused{{/if}}" data-id="{{this.annotationSource.chars}}">',
'<li class="annotationListItem" {{#if this.selected}}selected{{/if}} {{#if this.focused }}focused{{/if}}">',
'<span style="font-weight: bold">{{{this.annotationSource.label}}}</span>',
'<br/>',
'<span>{{{this.annotationSource.chars}}}</span>',
//'<span>{{this.annotationSource}}</span>',
'</li>',
'{{/each}}',
'</ul>',
......
......
......@@ -32,14 +32,14 @@
label: i18next.t('tabTitleIndex')
}
},
/*{
{
name : 'annotations',
options : {
available: _this.annotationsTabAvailable,
id:'annotationsTab',
label:'Annotations'
label:'Anno.'
}
},*/
},
{
name : 'search',
options : {
......
......
......@@ -77,8 +77,8 @@ describe('AnnotationsTab', function() {
});
it('should correctly set local state', function() {
subject.annotationListLoaded();
expect(subject.localState().annotationLists[0]).toEqual(jasmine.objectContaining({ annotationSource: 'manifest' }));
expect(subject.localState().annotationLists[1]).toEqual(jasmine.objectContaining({ annotationSource: 'endpointName' }));
expect(subject.localState().annotationLists[0]).toEqual(jasmine.objectContaining({ selected: false }));
// expect(subject.localState().annotationLists[1]).toEqual(jasmine.objectContaining({ selected: false }));
});
});
......@@ -177,16 +177,16 @@ describe('AnnotationsTab', function() {
spyOn(this.eventEmitter, 'publish');
subject.bindEvents();
});
it('should deselect a selected item when re-clicked', function() {
subject.localState({ selectedList: 'glub1' });
subject.element.find('.annotationListItem').first().click();
expect(this.eventEmitter.publish).toHaveBeenCalledWith('listDeselected.' + this.windowId, 'glub1');
});
it('should select an unselected item when clicked', function() {
subject.localState({ selectedList: 'glub2' });
subject.element.find('.annotationListItem').first().click();
expect(this.eventEmitter.publish).toHaveBeenCalledWith('listSelected.' + this.windowId, 'glub1');
});
// it('should deselect a selected item when re-clicked', function() {
// subject.localState({ selectedList: 'glub1' });
// subject.element.find('.annotationListItem').first().click();
// expect(this.eventEmitter.publish).toHaveBeenCalledWith('listDeselected.' + this.windowId, 'glub1');
// });
// it('should select an unselected item when clicked', function() {
// subject.localState({ selectedList: 'glub2' });
// subject.element.find('.annotationListItem').first().click();
// expect(this.eventEmitter.publish).toHaveBeenCalledWith('listSelected.' + this.windowId, 'glub1');
// });
});
describe('render', function() {
......
......
......@@ -24,6 +24,7 @@ describe('SidePanel', function() {
layersTabAvailable: false,
tocTabAvailable: false,
searchTabAvailable: false,
annotationsTabAvailable: false,
hasStructures: false
}, sidePanelOptions);
......@@ -35,6 +36,7 @@ describe('SidePanel', function() {
spyOn(Mirador, 'TableOfContents').and.callThrough();
spyOn(Mirador, 'SearchTab').and.callThrough();
spyOn(Mirador, 'LayersTab').and.callThrough();
spyOn(Mirador, 'AnnotationsTab').and.callThrough();
this.sidePanel = createSidePanel();
});
......@@ -74,9 +76,9 @@ describe('SidePanel', function() {
describe('update', function() {
it('should make panels unavailable or available', function() {
this.sidePanel.update('search', false);
expect(this.sidePanel.panelState.tabs[1].options.available).toBe(false);
expect(this.sidePanel.panelState.tabs[2].options.available).toBe(false);
this.sidePanel.update('search', true);
expect(this.sidePanel.panelState.tabs[1].options.available).toBe(true);
expect(this.sidePanel.panelState.tabs[2].options.available).toBe(true);
});
});
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment