Skip to content

Commit

Permalink
Merge pull request #172 from Det-Kongelige-Bibliotek/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
siglun authored Aug 30, 2019
2 parents 2a043d3 + d0683ea commit 5ccf05d
Show file tree
Hide file tree
Showing 33 changed files with 534 additions and 68 deletions.
14 changes: 8 additions & 6 deletions app/assets/javascripts/DkBreve.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ $(document).ready(function () {
if(typeof (has_facs)!== 'undefined') {
if (!(has_facs)) {
document.getElementsByClassName('ocr')[0].addEventListener("scroll", function () {
let currentOcrPage = getOcrCurrentPage();
let currentOcrPage = getOcrCurrentPage();
let citationPageNumber = document.getElementById('pageNumber');
let hashTagInURI = document.getElementById('hashTagInURI');
if (citationPageNumber) {
Expand All @@ -212,11 +212,13 @@ $(document).ready(function () {
ocrScrollTopOffset = ocrScrollTop + 9, // Magic number 9 is 1 px less than the margin added when setting pages
ocrBreaks = $('.pageBreak', ocrElem);
var i = 0;
if ($(ocrBreaks[0]).position().top + ocrScrollTopOffset > ocrScrollTop) {
return 1; // user are before the very first pageBreak => page 1
}
while (i < ocrBreaks.length && $(ocrBreaks[i]).position().top + ocrScrollTopOffset <= ocrScrollTop) {
i++;
if ($(ocrBreaks).length){
if ($(ocrBreaks[0]).position().top + ocrScrollTopOffset > ocrScrollTop) {
return 1; // user are before the very first pageBreak => page 1
}
while (i < ocrBreaks.length && $(ocrBreaks[i]).position().top + ocrScrollTopOffset <= ocrScrollTop) {
i++;
}
}
return i + 1;
}
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/text_service/comments_in_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ var comments = document.querySelectorAll('a[title="Kommentar"]');
for (var i = 0; i < comments.length; i++) {
var comment = comments[i];
comment.dataset.toggle = "modal";
comment.dataset.target = "#comment";
comment.dataset.target = "#comment_modal";

comment.addEventListener("click", function (event) {
event.preventDefault()
var modal = document.getElementById('comment');
var modal = document.getElementById('comment_modal');
var modal_body = modal.getElementsByClassName('modal-body')[0];

var xhttp = new XMLHttpRequest();
Expand Down
33 changes: 33 additions & 0 deletions app/assets/javascripts/text_service/ie_message.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"use strict";
function ie_message() {
if (is_ie()){
var notification = document.querySelectorAll('.org-11bfca9f-f278-4d0e-8384-2a2d064e8f6c.ie_message');
if (notification){
notification[0].classList.remove('hidden');
}

}
}

function is_ie(){
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");

if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer, return version number
{
return true;
}
else // If another browser, return 0
{
return false;
}

return false;
}

function closeBanner(){
var banner = document.getElementById('ie_banner');
banner.style.display = 'none';
}

window.addEventListener('load', ie_message, false);
24 changes: 24 additions & 0 deletions app/assets/javascripts/text_service/infos_in_modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use strict";
var infos = document.querySelectorAll('a.info[title="Tekstkritik"]');

for (var i = 0; i < infos.length; i++) {
var info = infos[i];
info.dataset.toggle = "modal";
info.dataset.target = "#info_modal";

info.addEventListener("click", function (event) {
event.preventDefault()
let modal = document.getElementById('info_modal');
let modal_body = modal.getElementsByClassName('modal-body')[0];
let text_critic = this.parentElement.nextElementSibling;
modal_body.innerHTML = text_critic.innerHTML;
text_critic.setAttribute("style", "display: none !important");
let witnesses = text_critic.querySelectorAll('.witness[title]');
let modal_footer = modal.getElementsByClassName('modal-footer')[0];
modal_footer.innerHTML = '<div style="flex: 0 0 100%;"><b>]</b>: Lemma symbol</div>';
for (var i = 0; i < witnesses.length; i++) {
modal_footer.innerHTML += '<div style="flex: 0 0 100%;"><b>' + witnesses[i].innerHTML + '</b>: ' + witnesses[i].getAttribute('title')+'</div>';
}

});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"use strict";

function show_relevant_text_possibilities() {

let pageBreaks = document.querySelectorAll('.symbol.pagination.edition');
pageBreaks.forEach(function(pageBreak) {
pageBreak.parentElement.style.display = 'inline';
pageBreak.innerHTML = '<span class="hidden">&#128463;</span> ' + pageBreak.innerHTML;
});

pageBreaks = document.querySelectorAll('.symbol.pagination.other');
pageBreaks.forEach(function(pageBreak) {
pageBreak.innerHTML = '&#128463; ' + pageBreak.innerHTML;
});

let types = ['quote', 'comment', 'translation', 'modernized', 'info', 'person', 'place', 'title', 'pagination.other'];
types.forEach(function(type)
{
var symbols = document.querySelectorAll('.symbol.' + type);
if (symbols.length != 0){
var button = document.getElementById(type);
button.classList.remove("hidden");
}
});
}

window.addEventListener('load', show_relevant_text_possibilities(), false);
22 changes: 22 additions & 0 deletions app/assets/javascripts/text_service/toggle_info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use strict";

function toggle_infos() {
let text_infos = document.querySelectorAll("span.symbol.info");
if (this.checked) {
for (i = 0; i < text_infos.length; i++) {
text_infos[i].style.display = 'inline';
text_infos[i].classList.add('icon', 'info');
text_infos[i].parentElement.style.display = 'inline';
}
} else {
for (i = 0; i < text_infos.length; i++) {
text_infos[i].style.display = 'none';
text_infos[i].parentElement.style.display = 'none';
}
}
}

let show_infos = document.getElementById('Show_infos');
if (show_infos) {
show_infos.addEventListener('click', toggle_infos, false);
}
22 changes: 22 additions & 0 deletions app/assets/javascripts/text_service/toggle_locations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use strict";

function toggle_location() {
let text_locations = document.querySelectorAll("span.symbol.place");
if (this.checked) {
for (i = 0; i < text_locations.length; i++) {
text_locations[i].style.display = 'inline';
text_locations[i].classList.add('icon', 'location_on');
text_locations[i].parentElement.style.display = 'inline';
}
} else {
for (i = 0; i < text_locations.length; i++) {
text_locations[i].style.display = 'none';
text_locations[i].parentElement.style.display = 'none';
}
}
}

let show_locations = document.getElementById('Show_locations');
if (show_locations) {
show_locations.addEventListener('click', toggle_location, false);
}
22 changes: 22 additions & 0 deletions app/assets/javascripts/text_service/toggle_modernisation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use strict";

function toggle_modernizations() {
let text_modernizations = document.querySelectorAll("span.symbol.modernized");
if (this.checked) {
for (i = 0; i < text_modernizations.length; i++) {
text_modernizations[i].style.display = 'inline';
text_modernizations[i].classList.add('icon', 'filter_vintage');
text_modernizations[i].parentElement.style.display = 'inline';
}
} else {
for (i = 0; i < text_modernizations.length; i++) {
text_modernizations[i].style.display = 'none';
text_modernizations[i].parentElement.style.display = 'none';
}
}
}

let show_modernizations = document.getElementById('Show_modernizations');
if (show_modernizations) {
show_modernizations.addEventListener('click', toggle_modernizations, false);
}
34 changes: 34 additions & 0 deletions app/assets/javascripts/text_service/toggle_pagebreaks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"use strict";

function toggle_pagebreak() {
let text_pagebreaks = document.querySelectorAll(".symbol.pagination.other");
if (this.checked) {
for (i = 0; i < text_pagebreaks.length; i++) {
text_pagebreaks[i].style.display = 'inline';
text_pagebreaks[i].parentElement.style.display = 'inline';
}
} else {
for (i = 0; i < text_pagebreaks.length; i++) {
text_pagebreaks[i].style.display = 'none';
text_pagebreaks[i].parentElement.style.display = 'none';
}
}

text_pagebreaks = document.querySelectorAll(".symbol.pagination.edition");
if (this.checked) {
for (i = 0; i < text_pagebreaks.length; i++) {
text_pagebreaks[i].style.position = 'static';
text_pagebreaks[i].firstChild.classList.remove('hidden');
}
} else {
for (i = 0; i < text_pagebreaks.length; i++) {
text_pagebreaks[i].style.position = 'absolute';
text_pagebreaks[i].firstChild.classList.add('hidden');
}
}
}

let show_pagebreaks = document.getElementById('Show_pagebreaks');
if (show_pagebreaks) {
show_pagebreaks.addEventListener('click', toggle_pagebreak, false);
}
20 changes: 20 additions & 0 deletions app/assets/javascripts/text_service/toggle_persons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use strict";

function toggle_person() {
let text_persons = document.querySelectorAll("span.symbol.person");
if (this.checked) {
for (i = 0; i < text_persons.length; i++) {
text_persons[i].style.display = 'inline';
text_persons[i].classList.add('icon', 'person');
}
} else {
for (i = 0; i < text_persons.length; i++) {
text_persons[i].style.display = 'none';
}
}
}

let show_persons = document.getElementById('Show_persons');
if (show_persons) {
show_persons.addEventListener('click', toggle_person, false);
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"use strict";

function toggle_vis_kun_denne_del() {
let text_possibility_elements = document.getElementsByClassName("exposableDocumentFunctions");
let comments = document.querySelectorAll("span.symbol.quote");
if (this.checked) {
for (i = 0; i < text_possibility_elements.length; i++) {
text_possibility_elements[i].style.display = 'block';
for (i = 0; i < comments.length; i++) {
comments[i].style.display = 'block';
}
} else {
for (i = 0; i < text_possibility_elements.length; i++) {
text_possibility_elements[i].style.display = 'none';
for (i = 0; i < comments.length; i++) {
comments[i].style.display = 'none';
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions app/assets/javascripts/text_service/toggle_related_texts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Created by bimo on 9/28/18.
*/
"use strict";

function toggleRelatedTexts() {
let text_possibility_toolbar = document.getElementsByClassName("relatedTextsToolbar")[0];
let btn = document.getElementById("toggleRelatedTexts");

if (btn.classList.contains('active')) {
text_possibility_toolbar.classList.add('hidden');
} else {
text_possibility_toolbar.classList.remove('hidden');
}

btn.classList.toggle("active");
}
23 changes: 23 additions & 0 deletions app/assets/javascripts/text_service/toggle_text_comments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use strict";

function toggle_text_comments() {
let text_comments = document.querySelectorAll("span.symbol.comment");
if (this.checked) {
for (i = 0; i < text_comments.length; i++) {
text_comments[i].style.display = 'inline';
text_comments[i].classList.add('icon', 'comment');
text_comments[i].parentElement.classList.add ('show_comments');

}
} else {
for (i = 0; i < text_comments.length; i++) {
text_comments[i].style.display = 'none';
text_comments[i].parentElement.classList.remove ('show_comments');
}
}
}

let show_comments = document.getElementById('Show_comments');
if (show_comments) {
show_comments.addEventListener('click', toggle_text_comments, false);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
"use strict";

function toggleExposable() {
function toggleTextPossibilities() {
let text_possibility_toolbar = document.getElementsByClassName("textPossibilitiesToolbar")[0];
let btn = document.getElementById("toggleTextPossibilities");

Expand Down
22 changes: 22 additions & 0 deletions app/assets/javascripts/text_service/toggle_titles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use strict";

function toggle_title() {
let text_titles = document.querySelectorAll("span.symbol.title");
if (this.checked) {
for (i = 0; i < text_titles.length; i++) {
text_titles[i].style.display = 'inline';
text_titles[i].classList.add('icon', 'title');
text_titles[i].parentElement.style.display = 'inline';
}
} else {
for (i = 0; i < text_titles.length; i++) {
text_titles[i].style.display = 'none';
text_titles[i].parentElement.style.display = 'none';
}
}
}

let show_titles = document.getElementById('Show_titles');
if (show_titles) {
show_titles.addEventListener('click', toggle_title, false);
}
22 changes: 22 additions & 0 deletions app/assets/javascripts/text_service/toggle_translation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use strict";

function toggle_translation() {
let text_translations = document.querySelectorAll("span.symbol.translation");
if (this.checked) {
for (i = 0; i < text_translations.length; i++) {
text_translations[i].style.display = 'inline';
text_translations[i].classList.add('icon', 'translate');
text_translations[i].parentElement.style.display = 'inline';
}
} else {
for (i = 0; i < text_translations.length; i++) {
text_translations[i].style.display = 'none';
text_translations[i].parentElement.style.display = 'none';
}
}
}

let show_translations = document.getElementById('Show_translations');
if (show_translations) {
show_translations.addEventListener('click', toggle_translation, false);
}
Loading

0 comments on commit 5ccf05d

Please sign in to comment.