blacklight-spotlight 3.0.0.alpha.10 → 3.0.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spotlight/admin/crop.es6 +6 -0
  3. data/app/assets/javascripts/spotlight/admin/sir-trevor/block_controls.js +21 -12
  4. data/app/assets/stylesheets/spotlight/_featured_browse_categories_block.scss +4 -4
  5. data/app/assets/stylesheets/spotlight/_item_text_block.scss +6 -0
  6. data/app/assets/stylesheets/spotlight/_report_a_problem.scss +5 -2
  7. data/app/controllers/spotlight/resources/csv_upload_controller.rb +1 -1
  8. data/app/jobs/spotlight/add_uploads_from_csv.rb +30 -5
  9. data/app/mailers/spotlight/indexing_complete_mailer.rb +3 -2
  10. data/app/models/spotlight/contact.rb +1 -1
  11. data/app/models/spotlight/custom_field.rb +3 -3
  12. data/app/models/spotlight/featured_image.rb +1 -1
  13. data/app/models/spotlight/page_configurations.rb +1 -0
  14. data/app/models/spotlight/page_content.rb +2 -0
  15. data/app/models/spotlight/resources/csv_upload.rb +2 -1
  16. data/app/models/spotlight/resources/iiif_manifest.rb +2 -0
  17. data/app/services/spotlight/solr_document_builder.rb +1 -0
  18. data/app/values/custom_field_name.rb +1 -0
  19. data/app/views/spotlight/indexing_complete_mailer/documents_indexed.html.erb +9 -0
  20. data/app/views/spotlight/pages/_form.html.erb +1 -1
  21. data/app/views/spotlight/shared/_honeypot_field.html.erb +4 -0
  22. data/app/views/spotlight/shared/_report_a_problem.html.erb +7 -10
  23. data/config/i18n-tasks.yml +2 -0
  24. data/config/locales/spotlight.ar.yml +22 -18
  25. data/config/locales/spotlight.en.yml +13 -6
  26. data/lib/generators/spotlight/install_generator.rb +22 -1
  27. data/lib/generators/spotlight/templates/config/initializers/sir_trevor_rails.rb +10 -0
  28. data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +2 -0
  29. data/lib/spotlight/engine.rb +3 -0
  30. data/lib/spotlight/upload_field_config.rb +1 -0
  31. data/lib/spotlight/version.rb +1 -1
  32. data/spec/controllers/spotlight/browse_controller_spec.rb +1 -1
  33. data/spec/controllers/spotlight/resources/csv_upload_controller_spec.rb +4 -4
  34. data/spec/examples.txt +1410 -125
  35. data/spec/features/add_contacts_spec.rb +1 -1
  36. data/spec/features/browse_category_admin_spec.rb +2 -2
  37. data/spec/features/create_exhibit_spec.rb +5 -4
  38. data/spec/features/dashboard_spec.rb +5 -5
  39. data/spec/features/exhibits/administration_spec.rb +3 -3
  40. data/spec/features/exhibits/language_create_edit_spec.rb +3 -3
  41. data/spec/features/javascript/block_controls_spec.rb +2 -0
  42. data/spec/features/report_a_problem_spec.rb +5 -4
  43. data/spec/helpers/spotlight/pages_helper_spec.rb +2 -2
  44. data/spec/jobs/spotlight/add_uploads_from_csv_spec.rb +13 -1
  45. data/spec/mailers/spotlight/indexing_complete_mailer_spec.rb +11 -1
  46. data/spec/models/solr_document_spec.rb +2 -3
  47. data/spec/models/spotlight/access_controls_enforcement_search_builder_spec.rb +1 -0
  48. data/spec/models/spotlight/featured_image_spec.rb +0 -1
  49. data/spec/models/spotlight/role_spec.rb +2 -2
  50. data/spec/services/spotlight/exhibit_import_export_service_spec.rb +14 -2
  51. data/spec/services/spotlight/iiif_resource_resolver_spec.rb +1 -1
  52. data/spec/test_app_templates/Gemfile.extra +0 -3
  53. data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +3 -3
  54. data/spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb +7 -8
  55. data/vendor/assets/javascripts/leaflet-iiif.js +46 -21
  56. metadata +54 -24
@@ -17,7 +17,7 @@ describe 'Add a contact to an exhibit', type: :feature do
17
17
  fill_in 'Location', with: 'Rome'
18
18
  fill_in 'Telephone', with: '(555) 555-5555 ext. 12345 (mobile)'
19
19
 
20
- click_button 'Save'
20
+ find('input[name="commit"]').click
21
21
  end
22
22
  expect(page).to have_content 'The contact was created.'
23
23
 
@@ -21,7 +21,7 @@ describe 'Browse Category Administration', type: :feature do
21
21
  expect(page).to have_css('#save-modal')
22
22
  fill_in 'search_title', with: 'Some search'
23
23
  expect do
24
- click_button 'Save'
24
+ find('input[name="commit"]').click
25
25
  exhibit.searches.reload
26
26
  end.to change { exhibit.searches.count }.by 1
27
27
  expect(exhibit.searches.last.query_params).to eq 'q' => 'xyz'
@@ -32,7 +32,7 @@ describe 'Browse Category Administration', type: :feature do
32
32
  click_button 'Save this search'
33
33
  expect(page).to have_css('#save-modal')
34
34
  select search.title, from: 'id'
35
- click_button 'Save'
35
+ find('input[name="commit"]').click
36
36
  expect(search.reload.query_params).to eq 'q' => 'xyz'
37
37
  end
38
38
  end
@@ -24,7 +24,7 @@ describe 'Create a new exhibit', type: :feature do
24
24
 
25
25
  fill_in 'Title', with: 'My exhibit title'
26
26
 
27
- click_button 'Save'
27
+ find('input[name="commit"]').click
28
28
 
29
29
  expect(page).to have_content 'The exhibit was created.'
30
30
  expect(Spotlight::Exhibit.last.slug).to eq 'my-exhibit-title'
@@ -39,7 +39,7 @@ describe 'Create a new exhibit', type: :feature do
39
39
  fill_in 'Title', with: 'My exhibit title'
40
40
  fill_in 'URL slug', with: 'custom-slug'
41
41
 
42
- click_button 'Save'
42
+ find('input[name="commit"]').click
43
43
 
44
44
  expect(page).to have_content 'The exhibit was created.'
45
45
  expect(Spotlight::Exhibit.last.slug).to eq 'custom-slug'
@@ -51,14 +51,15 @@ describe 'Create a new exhibit', type: :feature do
51
51
  fill_in 'Title', with: 'My exhibit title'
52
52
  fill_in 'URL slug', with: 'custom-slug'
53
53
 
54
- click_button 'Save'
54
+ find('input[name="commit"]').click
55
55
 
56
56
  visit spotlight.new_exhibit_path
57
57
 
58
58
  fill_in 'Title', with: 'My exhibit title'
59
59
  fill_in 'URL slug', with: 'custom-slug'
60
60
 
61
- click_button 'Save'
61
+ find('input[name="commit"]').click
62
+
62
63
  expect(page).to have_content 'has already been taken'
63
64
  end
64
65
  end
@@ -2,11 +2,6 @@
2
2
 
3
3
  describe 'Dashboard', type: :feature do
4
4
  let(:exhibit) { FactoryBot.create(:exhibit) }
5
- let(:admin) { FactoryBot.create(:exhibit_admin, exhibit: exhibit) }
6
- before do
7
- login_as(admin)
8
- end
9
-
10
5
  let!(:parent_feature_page) do
11
6
  FactoryBot.create(:feature_page, title: 'Parent Page', exhibit: exhibit)
12
7
  end
@@ -18,6 +13,11 @@ describe 'Dashboard', type: :feature do
18
13
  exhibit: exhibit
19
14
  )
20
15
  end
16
+ let(:admin) { FactoryBot.create(:exhibit_admin, exhibit: exhibit) }
17
+
18
+ before do
19
+ login_as(admin)
20
+ end
21
21
 
22
22
  it 'includes a list of recently edited feature pages' do
23
23
  visit spotlight.exhibit_dashboard_path(exhibit)
@@ -63,9 +63,9 @@ describe 'Exhibit Administration', type: :feature do
63
63
  it 'updates the aria-labels properly', js: true do
64
64
  visit spotlight.edit_exhibit_path(exhibit)
65
65
 
66
- expect(find_field(email_id_0)['aria-label']).to eq 'Contact email 1'
66
+ expect(find_field(email_id_0)['aria-label']).to eq 'Recipient email 1'
67
67
  find('#another-email').click
68
- expect(find_field(email_id_1)['aria-label']).to eq 'Contact email 2'
68
+ expect(find_field(email_id_1)['aria-label']).to eq 'Recipient email 2'
69
69
  end
70
70
 
71
71
  it 'allows deletion of contact email addresses', js: true do
@@ -135,7 +135,7 @@ describe 'Exhibit Administration', type: :feature do
135
135
  find_all('.contact-email-delete').first.click
136
136
  end
137
137
 
138
- expect(page).to have_css("##{hidden_input_id_0}~div span.contact-email-delete-error", text: 'Problem deleting contact email: Not Found')
138
+ expect(page).to have_css("##{hidden_input_id_0}~div span.contact-email-delete-error", text: 'Problem deleting recipient: Not Found')
139
139
  end
140
140
  end
141
141
  end
@@ -13,7 +13,7 @@ describe 'Language', type: :feature do
13
13
  it 'successfully adds languages' do
14
14
  within '#language' do
15
15
  select 'Albanian'
16
- click_button 'Add language'
16
+ find('input[name="commit"]').click
17
17
  end
18
18
  expect(page).to have_css '.flash_messages', text: 'The language was created.'
19
19
  within '#language' do
@@ -27,7 +27,7 @@ describe 'Language', type: :feature do
27
27
  it 'successfully updates the language' do
28
28
  within '#language' do
29
29
  select 'Albanian'
30
- click_button 'Add language'
30
+ find('input[name="commit"]').click
31
31
  end
32
32
  expect(page).to have_css '.flash_messages', text: 'The language was created.'
33
33
  within '#language' do
@@ -43,7 +43,7 @@ describe 'Language', type: :feature do
43
43
  it 'successfully updates the language' do
44
44
  within '#language' do
45
45
  select 'Albanian'
46
- click_button 'Add language'
46
+ find('input[name="commit"]').click
47
47
  end
48
48
  expect(page).to have_css '.flash_messages', text: 'The language was created.'
49
49
  within '#language' do
@@ -27,10 +27,12 @@ describe 'Block controls' do
27
27
 
28
28
  within('.spotlight-block-controls') do
29
29
  expect(page).to have_css('.st-controls-group', count: 2)
30
+
30
31
  within(first('.st-controls-group')) do
31
32
  expect(page).to have_content 'Standard widgets'
32
33
  expect(page).to have_css('.st-block-controls__button')
33
34
  end
35
+
34
36
  within(all('.st-controls-group').last) do
35
37
  expect(page).to have_content 'Exhibit item widgets'
36
38
  expect(page).to have_css('.st-block-controls__button')
@@ -33,9 +33,10 @@ describe 'Report a Problem', type: :feature do
33
33
  it 'accepts a problem report', js: true do
34
34
  visit spotlight.exhibit_solr_document_path(exhibit, id: 'dq287tq6352')
35
35
  click_on 'Feedback'
36
+ expect(page).to have_css('.alert-primary', text: '/dq287tq6352')
36
37
  expect(find('#contact_form_current_url', visible: false).value).to end_with spotlight.exhibit_solr_document_path(exhibit, id: 'dq287tq6352')
37
- fill_in 'Name', with: 'Some Body'
38
- fill_in 'Email', with: 'test@example.com'
38
+ fill_in 'Your name', with: 'Some Body'
39
+ fill_in 'Your email', with: 'test@example.com'
39
40
  fill_in 'Message', with: 'This is my problem report'
40
41
 
41
42
  expect do
@@ -47,8 +48,8 @@ describe 'Report a Problem', type: :feature do
47
48
  visit spotlight.exhibit_solr_document_path(exhibit, id: 'dq287tq6352')
48
49
  click_on 'Feedback'
49
50
  expect(find('#contact_form_current_url', visible: false).value).to end_with spotlight.exhibit_solr_document_path(exhibit, id: 'dq287tq6352')
50
- fill_in 'Name', with: 'Some Body'
51
- fill_in 'Email', with: 'test@example.com'
51
+ fill_in 'Your name', with: 'Some Body'
52
+ fill_in 'Your email', with: 'test@example.com'
52
53
  page.evaluate_script("$('#contact_form_#{honeypot_field_name}').val('possible_spam@spam.com')")
53
54
  fill_in 'Message', with: 'This is my problem report'
54
55
 
@@ -109,13 +109,13 @@ describe Spotlight::PagesHelper, type: :helper do
109
109
  end
110
110
 
111
111
  describe '#content_editor_class' do
112
- context 'with a sir-trevor backed page' do
112
+ context 'a sir-trevor backed page with a custom class' do
113
113
  it 'has a custom class' do
114
114
  expect(helper.content_editor_class(Spotlight::Page.new)).to eq 'js-st-instance'
115
115
  end
116
116
  end
117
117
 
118
- context 'with a sir-trevor backed page' do
118
+ context 'a sir-trevor backed page with a derived class' do
119
119
  it 'derives a css class name from the editor type' do
120
120
  expect(helper.content_editor_class(Spotlight::Page.new(content_type: 'Something::Custom'))).to eq 'js-something-custom-instance'
121
121
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- describe Spotlight::AddUploadsFromCSV do
3
+ describe Spotlight::AddUploadsFromCsv do
4
4
  subject(:job) { described_class.new(data, exhibit, user) }
5
5
 
6
6
  let(:exhibit) { FactoryBot.create(:exhibit) }
@@ -40,4 +40,16 @@ describe Spotlight::AddUploadsFromCSV do
40
40
 
41
41
  job.perform_now
42
42
  end
43
+
44
+ context 'with errors' do
45
+ it 'collects errors uploaded resources for each row of data' do
46
+ allow(Spotlight::IndexingCompleteMailer).to receive(:documents_indexed).and_return(double(deliver_now: true))
47
+ job.perform_now
48
+ expect(Spotlight::IndexingCompleteMailer).to have_received(:documents_indexed).with(
49
+ data, exhibit, user,
50
+ indexed_count: 1,
51
+ errors: { 1 => array_including(match(/relative URI: x/)), 2 => array_including(match(/Upload is invalid/)) }
52
+ )
53
+ end
54
+ end
43
55
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe Spotlight::IndexingCompleteMailer do
4
- subject { described_class.documents_indexed [1, 2, 3], exhibit, user }
4
+ subject { described_class.documents_indexed [1, 2, 3], exhibit, user, indexed_count: 3 }
5
5
 
6
6
  let(:user) { double(email: 'test@example.com') }
7
7
  let(:exhibit) { double(title: 'Exhibit title') }
@@ -29,4 +29,14 @@ describe Spotlight::IndexingCompleteMailer do
29
29
  it 'includes the exhibit title' do
30
30
  expect(subject.body.encoded).to match exhibit.title
31
31
  end
32
+
33
+ context 'with errors' do
34
+ subject { described_class.documents_indexed [], exhibit, user, indexed_count: 0, errors: { 1 => ['missing title'], 20 => ['whatever'] } }
35
+
36
+ it 'includes some errors' do
37
+ expect(subject.body.encoded).to match 'Errors'
38
+ expect(subject.body.encoded).to match 'Row 1: missing title'
39
+ expect(subject.body.encoded).to match 'Row 20: whatever'
40
+ end
41
+ end
32
42
  end
@@ -4,14 +4,13 @@ describe SolrDocument, type: :model do
4
4
  subject { document }
5
5
 
6
6
  let(:document) { described_class.new(id: 'abcd123') }
7
+ let(:exhibit_alt) { FactoryBot.create(:exhibit) }
8
+ let(:exhibit) { FactoryBot.create(:exhibit) }
7
9
 
8
10
  before do
9
11
  allow(subject).to receive_messages(reindex: nil)
10
12
  end
11
13
 
12
- let(:exhibit_alt) { FactoryBot.create(:exhibit) }
13
- let(:exhibit) { FactoryBot.create(:exhibit) }
14
-
15
14
  its(:to_key) { is_expected.to eq ['abcd123'] }
16
15
  its(:persisted?) { is_expected.to be_truthy }
17
16
 
@@ -3,6 +3,7 @@
3
3
  describe Spotlight::AccessControlsEnforcementSearchBuilder do
4
4
  class MockSearchBuilder < Blacklight::SearchBuilder
5
5
  attr_reader :blacklight_params, :scope
6
+
6
7
  def initialize(blacklight_params, scope)
7
8
  @blacklight_params = blacklight_params
8
9
  @scope = scope
@@ -36,7 +36,6 @@ describe Spotlight::FeaturedImage do
36
36
 
37
37
  context 'with an uploaded image' do
38
38
  before do
39
- featured_image.source = 'remote'
40
39
  featured_image.image = temp_image.image
41
40
  featured_image.save!
42
41
  end
@@ -37,10 +37,10 @@ describe Spotlight::Role, type: :model do
37
37
 
38
38
  describe 'that points at a user with an existing role' do
39
39
  let(:user) { FactoryBot.create(:user) }
40
- before { described_class.create!(role: 'curator', user: user) }
41
-
42
40
  let(:args) { { role: 'curator', user_key: user.email } }
43
41
 
42
+ before { described_class.create!(role: 'curator', user: user) }
43
+
44
44
  it 'is valid' do
45
45
  expect(subject).not_to be_valid
46
46
  expect(subject.errors.messages).to eq(user_key: ['already a member of this exhibit'])
@@ -412,10 +412,22 @@ describe Spotlight::ExhibitImportExportService do
412
412
  new_export = described_class.new(e).as_json
413
413
 
414
414
  actual = _deep_transform_values_in_object(new_export) do |v|
415
- v.is_a?(Time) ? nil : v
415
+ if DateTime.parse(v.to_s)
416
+ nil
417
+ else
418
+ v
419
+ end
420
+ rescue ArgumentError
421
+ nil
416
422
  end
417
423
  expected = _deep_transform_values_in_object(export) do |v|
418
- v.is_a?(Time) ? nil : v
424
+ if DateTime.parse(v.to_s)
425
+ nil
426
+ else
427
+ v
428
+ end
429
+ rescue ArgumentError
430
+ nil
419
431
  end
420
432
  expect(actual).to include expected
421
433
  end
@@ -68,7 +68,7 @@ describe Spotlight::IiifResourceResolver do
68
68
  end
69
69
  end
70
70
 
71
- context 'when the stored canvas ID is not present' do
71
+ context 'when the stored image ID is not present' do
72
72
  it 'raises a ManifestError' do
73
73
  resource.iiif_image_id = 'not-a-real-image-id'
74
74
 
@@ -1,3 +0,0 @@
1
- gem 'blacklight', '~> 7.0'
2
- gem 'sprockets', '< 4'
3
- gem 'thor', '~> 0.20'
@@ -2,7 +2,10 @@
2
2
 
3
3
  describe 'spotlight/metadata_configurations/_metadata_field', type: :view do
4
4
  let(:exhibit) { FactoryBot.create(:exhibit) }
5
+ let(:field) { Blacklight::Configuration::Field.new immutable: OpenStruct.new(another_view_type: false) }
6
+ let(:builder) { ActionView::Helpers::FormBuilder.new 'z', nil, view, {} }
5
7
  let(:p) { 'spotlight/metadata_configurations/metadata_field.html.erb' }
8
+
6
9
  before do
7
10
  assign(:exhibit, exhibit)
8
11
  assign(:blacklight_configuration, exhibit.blacklight_configuration)
@@ -14,9 +17,6 @@ describe 'spotlight/metadata_configurations/_metadata_field', type: :view do
14
17
  )
15
18
  end
16
19
 
17
- let(:field) { Blacklight::Configuration::Field.new immutable: OpenStruct.new(another_view_type: false) }
18
- let(:builder) { ActionView::Helpers::FormBuilder.new 'z', nil, view, {} }
19
-
20
20
  it 'uses the index_field_label helper to render the label' do
21
21
  allow(view).to receive(:index_field_label).with(anything, 'some_key').and_return 'Some label'
22
22
  render partial: p, locals: { key: 'some_key', config: field, f: builder }
@@ -2,6 +2,13 @@
2
2
 
3
3
  describe 'spotlight/search_configurations/_sort', type: :view do
4
4
  let(:exhibit) { FactoryBot.create(:exhibit) }
5
+ let(:f) do
6
+ form_helper = nil
7
+ controller.view_context.bootstrap_form_for(exhibit.blacklight_configuration, url: '/update') do |f|
8
+ form_helper = f
9
+ end
10
+ form_helper
11
+ end
5
12
 
6
13
  before do
7
14
  original_config = Spotlight::Engine.blacklight_config.deep_dup
@@ -16,14 +23,6 @@ describe 'spotlight/search_configurations/_sort', type: :view do
16
23
  )
17
24
  end
18
25
 
19
- let(:f) do
20
- form_helper = nil
21
- controller.view_context.bootstrap_form_for(exhibit.blacklight_configuration, url: '/update') do |f|
22
- form_helper = f
23
- end
24
- form_helper
25
- end
26
-
27
26
  it 'has a disabled relevance sort option' do
28
27
  render partial: 'spotlight/search_configurations/sort', locals: { f: f }
29
28
  expect(rendered).to have_selector "input[name='blacklight_configuration[sort_fields][relevance][enable]'][disabled='disabled']"
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Leaflet-IIIF 2.0.0
2
+ * Leaflet-IIIF 3.0.0
3
3
  * IIIF Viewer for Leaflet
4
4
  * by Jack Reed, @mejackreed
5
5
  */
@@ -32,7 +32,7 @@ L.TileLayer.Iiif = L.TileLayer.extend({
32
32
  }
33
33
 
34
34
  options = L.setOptions(this, options);
35
- this._infoDeferred = new $.Deferred();
35
+ this._infoPromise = null;
36
36
  this._infoUrl = url;
37
37
  this._baseUrl = this._templateUrl();
38
38
  this._getInfo();
@@ -48,27 +48,39 @@ L.TileLayer.Iiif = L.TileLayer.extend({
48
48
  miny = (y * tileBaseSize),
49
49
  maxx = Math.min(minx + tileBaseSize, _this.x),
50
50
  maxy = Math.min(miny + tileBaseSize, _this.y);
51
-
51
+
52
52
  var xDiff = (maxx - minx);
53
53
  var yDiff = (maxy - miny);
54
54
 
55
+ // Canonical URI Syntax for v2
56
+ var size = Math.ceil(xDiff / scale) + ',';
57
+ if (_this.type === 'ImageService3') {
58
+ // Cannonical URI Syntax for v3
59
+ size = size + Math.ceil(yDiff / scale);
60
+ }
61
+
55
62
  return L.Util.template(this._baseUrl, L.extend({
56
63
  format: _this.options.tileFormat,
57
64
  quality: _this.quality,
58
65
  region: [minx, miny, xDiff, yDiff].join(','),
59
66
  rotation: 0,
60
- size: Math.ceil(xDiff / scale) + ','
67
+ size: size
61
68
  }, this.options));
62
69
  },
63
70
  onAdd: function(map) {
64
71
  var _this = this;
65
72
 
66
- // Wait for deferred to complete
67
- $.when(_this._infoDeferred).done(function() {
73
+ // Wait for info.json fetch and parse to complete
74
+ Promise.all([_this._infoPromise]).then(function() {
75
+ // Store unmutated imageSizes
76
+ _this._imageSizesOriginal = _this._imageSizes.slice(0);
68
77
 
69
78
  // Set maxZoom for map
70
79
  map._layersMaxZoom = _this.maxZoom;
71
80
 
81
+ // Call add TileLayer
82
+ L.TileLayer.prototype.onAdd.call(_this, map);
83
+
72
84
  // Set minZoom and minNativeZoom based on how the imageSizes match up
73
85
  var smallestImage = _this._imageSizes[0];
74
86
  var mapSize = _this._map.getSize();
@@ -88,9 +100,6 @@ L.TileLayer.Iiif = L.TileLayer.extend({
88
100
  _this._prev_map_layersMinZoom = _this._map._layersMinZoom;
89
101
  _this._map._layersMinZoom = newMinZoom;
90
102
 
91
- // Call add TileLayer
92
- L.TileLayer.prototype.onAdd.call(_this, map);
93
-
94
103
  if (_this.options.fitBounds) {
95
104
  _this._fitBounds();
96
105
  }
@@ -112,12 +121,16 @@ L.TileLayer.Iiif = L.TileLayer.extend({
112
121
  tile.tile.style.height = height + 'px';
113
122
 
114
123
  });
124
+ })
125
+ .catch(function(err){
126
+ console.error(err);
115
127
  });
116
128
  },
117
129
  onRemove: function(map) {
118
130
  var _this = this;
119
-
131
+
120
132
  map._layersMinZoom = _this._prev_map_layersMinZoom;
133
+ _this._imageSizes = _this._imageSizesOriginal;
121
134
 
122
135
  // Remove maxBounds set for this image
123
136
  if(_this.options.setMaxBounds) {
@@ -156,9 +169,14 @@ L.TileLayer.Iiif = L.TileLayer.extend({
156
169
  _getInfo: function() {
157
170
  var _this = this;
158
171
 
159
- // Look for a way to do this without jQuery
160
- $.getJSON(_this._infoUrl)
161
- .done(function(data) {
172
+ _this._infoPromise = fetch(_this._infoUrl)
173
+ .then(function(response) {
174
+ return response.json();
175
+ })
176
+ .catch(function(err){
177
+ console.error(err);
178
+ })
179
+ .then(function(data) {
162
180
  _this.y = data.height;
163
181
  _this.x = data.width;
164
182
 
@@ -176,6 +194,7 @@ L.TileLayer.Iiif = L.TileLayer.extend({
176
194
  }else {
177
195
  _this.profile = data.profile;
178
196
  }
197
+ _this.type = data.type;
179
198
 
180
199
  _this._setQuality();
181
200
 
@@ -197,10 +216,13 @@ L.TileLayer.Iiif = L.TileLayer.extend({
197
216
  };
198
217
 
199
218
  // Calculates maximum native zoom for the layer
200
- _this.maxNativeZoom = Math.max(ceilLog2(_this.x / _this.options.tileSize),
201
- ceilLog2(_this.y / _this.options.tileSize));
219
+ _this.maxNativeZoom = Math.max(
220
+ ceilLog2(_this.x / _this.options.tileSize),
221
+ ceilLog2(_this.y / _this.options.tileSize),
222
+ 0
223
+ );
202
224
  _this.options.maxNativeZoom = _this.maxNativeZoom;
203
-
225
+
204
226
  // Enable zooming further than native if maxZoom option supplied
205
227
  if (_this._customMaxZoom && _this.options.maxZoom > _this.maxNativeZoom) {
206
228
  _this.maxZoom = _this.options.maxZoom;
@@ -208,7 +230,7 @@ L.TileLayer.Iiif = L.TileLayer.extend({
208
230
  else {
209
231
  _this.maxZoom = _this.maxNativeZoom;
210
232
  }
211
-
233
+
212
234
  for (var i = 0; i <= _this.maxZoom; i++) {
213
235
  scale = Math.pow(2, _this.maxNativeZoom - i);
214
236
  width_ = Math.ceil(_this.x / scale);
@@ -221,10 +243,11 @@ L.TileLayer.Iiif = L.TileLayer.extend({
221
243
 
222
244
  _this._tierSizes = tierSizes;
223
245
  _this._imageSizes = imageSizes;
224
-
225
- // Resolved Deferred to initiate tilelayer load
226
- _this._infoDeferred.resolve();
246
+ })
247
+ .catch(function(err){
248
+ console.error(err);
227
249
  });
250
+
228
251
  },
229
252
 
230
253
  _setQuality: function() {
@@ -259,7 +282,6 @@ L.TileLayer.Iiif = L.TileLayer.extend({
259
282
  return this._infoToBaseUrl() + '{region}/{size}/{rotation}/{quality}.{format}';
260
283
  },
261
284
  _isValidTile: function(coords) {
262
- var tileBounds = this._tileCoordsToBounds(coords);
263
285
  var _this = this;
264
286
  var zoom = _this._getZoomForUrl();
265
287
  var sizes = _this._tierSizes[zoom];
@@ -276,6 +298,9 @@ L.TileLayer.Iiif = L.TileLayer.extend({
276
298
  return true;
277
299
  }
278
300
  },
301
+ _tileShouldBeLoaded: function(coords) {
302
+ return this._isValidTile(coords);
303
+ },
279
304
  _getInitialZoom: function (mapSize) {
280
305
  var _this = this;
281
306
  var tolerance = 0.8;