Skip to content

Commit

Permalink
Merge branch '2.3.0' into search-within
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschylus committed Mar 16, 2017
2 parents fd12d96 + 134d122 commit 032c32a
Show file tree
Hide file tree
Showing 28 changed files with 67 additions and 46 deletions.
3 changes: 3 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = function(grunt) {
'node_modules/jquery-migrate/dist/jquery-migrate.min.js',
'node_modules/jquery-ui-dist/jquery-ui.min.js',
'node_modules/bootstrap/js/modal.js',
'node_modules/bootstrap/js/transition.js',
'node_modules/bootbox/bootbox.js',
'node_modules/jquery.scrollto/jquery.scrollTo.min.js',
'js/lib/jquery.qtip.min.js',
Expand All @@ -49,6 +50,8 @@ module.exports = function(grunt) {

// source files
sources = [
'js/src/mirador.js',
'js/src/utils/handlebars.js',
'js/src/*.js',
'js/src/viewer/*.js',
'js/src/manifests/*.js',
Expand Down
4 changes: 2 additions & 2 deletions js/src/annotations/annotationTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@
},

//when this is being used to edit an existing annotation, insert them into the inputs
editorTemplate: Handlebars.compile([
editorTemplate: $.Handlebars.compile([
'<form id="annotation-editor-{{windowId}}" class="annotation-editor annotation-tooltip" {{#if id}}data-anno-id="{{id}}"{{/if}}>',
'<div>',
// need to add a delete, if permissions allow
Expand All @@ -445,7 +445,7 @@
'</form>'
].join('')),

viewerTemplate: Handlebars.compile([
viewerTemplate: $.Handlebars.compile([
'<div class="all-annotations" id="annotation-viewer-{{windowId}}">',
'{{#each annotations}}',
'<div class="annotation-display annotation-tooltip" data-anno-id="{{id}}">',
Expand Down
2 changes: 1 addition & 1 deletion js/src/annotations/tinymce-annotation-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
});
},

editorTemplate: Handlebars.compile([
editorTemplate: $.Handlebars.compile([
'<textarea class="text-editor" placeholder="{{t "comments"}}…">{{#if content}}{{content}}{{/if}}</textarea>',
'<input id="tags-editor-{{windowId}}" class="tags-editor" placeholder="{{t "addTagsHere"}}…" {{#if tags}}value="{{tags}}"{{/if}}>'
].join(''))
Expand Down
4 changes: 2 additions & 2 deletions js/src/utils/dialog-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
},
_attachEvents:function(el){
var _this = this;
jQuery(el).on("shown.bs.modal",function(){
el.init(function(){
// set bigger z-index that one used in qtip
var zIndex = 20000;

jQuery(el).css('z-index',zIndex);
// workaround because bootstap does not support external configuration for backdrop parent
jQuery('.modal-backdrop').prependTo(_this.container).css('z-index',zIndex);
});
jQuery(el).on("hidden.bs.modal",function(){
jQuery(el).on('hidden.bs.modal',function(){
jQuery('.modal-backdrop').remove();
});
}
Expand Down
7 changes: 7 additions & 0 deletions js/src/utils/handlebars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(function($) {

$.Handlebars = (function() {
return Handlebars.create();
})();

}(Mirador));
6 changes: 3 additions & 3 deletions js/src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@
this.element.css('background-color', '#333').css('background-image','url('+backgroundImage+')').css('background-position','left top')
.css('background-repeat','repeat');

//register Handlebars helper
Handlebars.registerHelper('t', function(i18n_key) {
//register $.Handlebars helper
$.Handlebars.registerHelper('t', function(i18n_key) {
var result = i18next.t(i18n_key);
return new Handlebars.SafeString(result);
return new $.Handlebars.SafeString(result);
});

//check all buttons in mainMenu. If they are all set to false, then don't show mainMenu
Expand Down
2 changes: 1 addition & 1 deletion js/src/viewer/bookmarkPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
jQuery(this.element).show({effect: "slide", direction: "up", duration: 300, easing: "swing"});
},

template: Handlebars.compile([
template: $.Handlebars.compile([
'<div id="bookmark-panel">',
'<h3>{{t "bookmarkTitle"}}</h3>',
'<span>',
Expand Down
10 changes: 5 additions & 5 deletions js/src/viewer/mainMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
});
},

template: Handlebars.compile([
template: $.Handlebars.compile([
'{{#if userLogo}}',
'<ul class="user-logo {{mainMenuCls}}">',
'{{userlogo userLogo}}',
Expand Down Expand Up @@ -244,14 +244,14 @@
}
};

Handlebars.registerHelper('userbtns', function (userButtons) {
return new Handlebars.SafeString(
$.Handlebars.registerHelper('userbtns', function (userButtons) {
return new $.Handlebars.SafeString(
jQuery('<ul class="user-buttons ' + this.mainMenuCls +'"></ul>').append(processUserButtons(userButtons)).get(0).outerHTML
);
});

Handlebars.registerHelper('userlogo', function (userLogo) {
return new Handlebars.SafeString(
$.Handlebars.registerHelper('userlogo', function (userLogo) {
return new $.Handlebars.SafeString(
processUserBtn(userLogo).get(0).outerHTML
);
});
Expand Down
4 changes: 2 additions & 2 deletions js/src/viewer/manifestListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
this.maxPreviewImagesWidth = this.resultsWidth - (this.repoWidth + this.margin + this.metadataWidth + this.margin + this.remainingWidth);
this.maxPreviewImagesWidth = this.maxPreviewImagesWidth * 0.95;

Handlebars.registerHelper('pluralize', function(count, singular, plural) {
$.Handlebars.registerHelper('pluralize', function(count, singular, plural) {
if (count === 1) {
return singular;
} else {
Expand Down Expand Up @@ -246,7 +246,7 @@
var _this = this;
},

template: Handlebars.compile([
template: $.Handlebars.compile([
'<li data-index-number={{index}}>',
'<div class="repo-image">',
'{{#if repoImage}}',
Expand Down
2 changes: 1 addition & 1 deletion js/src/viewer/manifestsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
_this.element.find('#manifest-search').keyup();
},

template: Handlebars.compile([
template: $.Handlebars.compile([
'<div id="manifest-select-menu">',
'<div class="container">',
'<div class="manifest-panel-controls">',
Expand Down
2 changes: 1 addition & 1 deletion js/src/viewer/workspacePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
_this.hide();
},

template: Handlebars.compile([
template: $.Handlebars.compile([
'<div id="workspace-select-menu">',
'<h1>{{t "changeLayout"}}</h1>',
'<h3 class="grid-text"></h3>',
Expand Down
2 changes: 1 addition & 1 deletion js/src/widgets/annotationsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
this.element.hide();
}
},
template: Handlebars.compile([
template: $.Handlebars.compile([
'<div class="annotationsPanel">',
'<ul class="annotationSources">',
'{{#each annotationSources}}',
Expand Down
2 changes: 1 addition & 1 deletion js/src/widgets/bookView.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
}
},

template: Handlebars.compile([
template: $.Handlebars.compile([
'<div class="book-view">',
'</div>'
].join('')),
Expand Down
6 changes: 3 additions & 3 deletions js/src/widgets/contextControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
});
},

annotationTemplate: Handlebars.compile([
annotationTemplate: $.Handlebars.compile([
'{{#if showEdit}}',
'<a class="mirador-osd-pointer-mode hud-control selected" title="{{t "pointerTooltip"}}">',
'<i class="fa fa-mouse-pointer"></i>',
Expand Down Expand Up @@ -297,7 +297,7 @@
'{{/if}}'
].join('')),

manipulationTemplate: Handlebars.compile([
manipulationTemplate: $.Handlebars.compile([
'{{#if showRotate}}',
'<a class="hud-control mirador-osd-rotate-right" title="{{t "rotateRightTooltip"}}">',
'<i class="fa fa-lg fa-rotate-right"></i>',
Expand Down Expand Up @@ -346,7 +346,7 @@
].join('')),

// for accessibility, make sure to add aria-labels just like above
editorTemplate: Handlebars.compile([
editorTemplate: $.Handlebars.compile([
'<div class="mirador-osd-context-controls hud-container">',
'<a class="mirador-osd-back hud-control" role="button">',
'<i class="fa fa-lg fa-arrow-left"></i>',
Expand Down
2 changes: 1 addition & 1 deletion js/src/widgets/hud.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
});
},

template: Handlebars.compile([
template: $.Handlebars.compile([
'<div class="mirador-hud">',
'{{#if showNextPrev}}',
'<a class="mirador-osd-previous hud-control ">',
Expand Down
2 changes: 1 addition & 1 deletion js/src/widgets/imageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
}
},

template: Handlebars.compile([
template: $.Handlebars.compile([
'<div class="image-view">',
'</div>'
].join('')),
Expand Down
2 changes: 1 addition & 1 deletion js/src/widgets/metadataView.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
return textWithLinks;
},

template: Handlebars.compile([
template: $.Handlebars.compile([
'<div class="sub-title">{{t "details"}}:</div>',
'<div class="{{metadataListingCls}}">',
'{{#each details}}',
Expand Down
2 changes: 1 addition & 1 deletion js/src/widgets/sidePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
}
},

template: Handlebars.compile([
template: $.Handlebars.compile([
'<div class="tabContentArea">',
'<ul class="tabGroup">',
'</ul>',
Expand Down
2 changes: 1 addition & 1 deletion js/src/widgets/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
this.element.find(tabClass).addClass('selected');

},
template: Handlebars.compile([
template: $.Handlebars.compile([
'<ul class="tabGroup">',
'{{#each tabs}}',
'<li class="tab {{this.options.id}} {{#unless @index}}selected{{/unless}}" data-tabId="{{this.options.id}}">',
Expand Down
2 changes: 1 addition & 1 deletion js/src/widgets/thumbnailsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
}
},

template: Handlebars.compile([
template: $.Handlebars.compile([
'<div class="{{thumbnailCls}}">',
'<ul class="{{listingCssCls}}" role="list" aria-label="Thumbnails">',
'{{#thumbs}}',
Expand Down
8 changes: 4 additions & 4 deletions js/src/widgets/toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
});
},

emptyTemplate: Handlebars.compile([
emptyTemplate: $.Handlebars.compile([
'<ul class="toc">',
'<li class="leaf-item open">',
'<h2><span>{{t "noIndex"}}</span></h2>',
Expand All @@ -381,7 +381,7 @@

template: function(tplData) {

var template = Handlebars.compile([
var template = $.Handlebars.compile([
'<ul class="toc">',
'{{#nestedRangeLevel ranges}}',
'<li class="{{#if children}}has-child{{else}}leaf-item{{/if}}">',
Expand All @@ -398,7 +398,7 @@

var previousTemplate;

Handlebars.registerHelper('nestedRangeLevel', function(children, options) {
$.Handlebars.registerHelper('nestedRangeLevel', function(children, options) {
var out = '';

if (options.fn !== undefined) {
Expand All @@ -413,7 +413,7 @@
return out;
});

Handlebars.registerHelper('tocLevel', function(id, label, level, children) {
$.Handlebars.registerHelper('tocLevel', function(id, label, level, children) {
var caret = '<i class="fa fa-caret-right toc-caret"></i>',
cert = '<i class="fa fa-certificate star"></i>';
return '<h' + (level+1) + '><a class="toc-link" data-rangeID="' + id + '">' + caret + cert + '<span>' + label + '</span></a></h' + (level+1) + '>';
Expand Down
2 changes: 1 addition & 1 deletion js/src/workspaces/slot.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
},

// template should be based on workspace type
template: Handlebars.compile([
template: $.Handlebars.compile([
'<div id="{{slotID}}" class="{{workspaceSlotCls}}">',
'<div class="slotIconContainer">',
// '<a href="javascript:;" class="mirador-btn mirador-icon-window-menu" title="Replace object"><i class="fa fa-table fa-lg fa-fw"></i>',
Expand Down
2 changes: 1 addition & 1 deletion js/src/workspaces/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@
},

// template should be based on workspace type
template: Handlebars.compile([
template: $.Handlebars.compile([
'<div class="window">',
'<div class="manifest-info">',
'<div class="window-manifest-navigation">',
Expand Down
2 changes: 2 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ module.exports = function(config) {
'node_modules/sinon/pkg/sinon.js',
'node_modules/jasmine-jquery/lib/jasmine-jquery.js',
// app
'js/src/mirador.js',
'js/src/utils/handlebars.js',
'js/src/*.js',
'js/src/viewer/*.js',
'js/src/manifests/*.js',
Expand Down
4 changes: 2 additions & 2 deletions spec/annotations/osd-svg-overlay.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ describe('Overlay', function() {

beforeEach(function() {
//register Handlebars helper
Handlebars.registerHelper('t', function(i18n_key) {
Mirador.Handlebars.registerHelper('t', function(i18n_key) {
var result = i18next.t(i18n_key);
return new Handlebars.SafeString(result);
return new Mirador.Handlebars.SafeString(result);
});

var id = 'test';
Expand Down
4 changes: 2 additions & 2 deletions spec/annotations/tinymce-annotation-editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ describe('TinyMCEAnnotationBodyEditor', function() {
var subject;

beforeEach(function() {
Handlebars.registerHelper('t', function(i18n_key) {
Mirador.Handlebars.registerHelper('t', function(i18n_key) {
var result = i18next.t(i18n_key);
return new Handlebars.SafeString(result);
return new Mirador.Handlebars.SafeString(result);
});
subject = new Mirador.TinyMCEAnnotationBodyEditor();
});
Expand Down
23 changes: 16 additions & 7 deletions spec/utils/dialog-builder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,36 @@ describe('Dialog Builder', function () {
beforeEach(function () {
// stub bootbox.js ( DialogBuilder is wrapper)
bootbox = jasmine.createSpy();
bootbox.confirm = jasmine.createSpy();
bootbox.dialog = jasmine.createSpy();
var self = this;
self.initSpy = jasmine.createSpyObj('initSpy', ['init']);
bootbox.confirm = jasmine.createSpy('confirm').and.returnValue(self.initSpy);

bootbox.dialog = jasmine.createSpy().and.returnValue(self.initSpy);

bootbox.setDefaults = jasmine.createSpy();

this.dialogBuilder = new Mirador.DialogBuilder();
});

it('should call setDefaults',function(){
it('should call setDefaults', function () {
expect(bootbox.setDefaults).toHaveBeenCalled();
});

it('should call underlying confirm method', function () {
var onConfirm = function(){};
this.dialogBuilder.confirm('msg',onConfirm);
expect(bootbox.confirm).toHaveBeenCalledWith('msg',onConfirm);
var onConfirm = function () {
};
this.initSpy.init.calls.reset();
this.dialogBuilder.confirm('msg', onConfirm);
expect(bootbox.confirm).toHaveBeenCalledWith('msg', onConfirm);
expect(this.initSpy.init).toHaveBeenCalled();
});

it('should call underlying dialog method',function(){
it('should call underlying dialog method', function () {
var opts = {};
this.initSpy.init.calls.reset();
this.dialogBuilder.dialog(opts);
expect(bootbox.dialog).toHaveBeenCalledWith(opts);
expect(this.initSpy.init).toHaveBeenCalled();
})

});
Empty file added spec/utils/handlebars.test.js
Empty file.

0 comments on commit 032c32a

Please sign in to comment.