Skip to content
Snippets Groups Projects
Commit fd21c2f3 authored by Marcus Baumgarten's avatar Marcus Baumgarten
Browse files

changes

parent 54bb92e7
No related branches found
No related tags found
No related merge requests found
$(document).ready(function () {
$('#select-view').change(function (event) {
var selected = $('option:selected', this).attr('value');
show_hide(selected);
});
});
/* referenzierte Bereiche einfärben */
$(window).bind('hashchange', function() {
var target = $(':target')
console.log('hashchange: ' + target);
if (!(target === undefined)) {
var offset = $(':target').offset();
console.log('offset: ' + offset);
var scrollto = offset.top;
$('html, body').animate({scrollTop:scrollto}, 0);
if (window.location.hash) sprung();
} else {
console.log('no target')
}
});
function commonAncestor (e1, e2) {
var p1 = e1.parents().get().reverse();
var p2 = e2.parents().get().reverse();
for (var i = 0; i < p1.length; i++) {
if (p1[i] != p2[i]) return p1[i - 1];
}
}
$(document).ready(sprung);
function sprung (event) {
console.log('sprung');
var targ = window.location.hash.substring(1);
console.log('target: ' + targ);
var startMarker = $("#" + targ);
if (startMarker.length == 0) return;
// TODO hier den Endmarker passend erstellen
ende = '#' + targ.substr(0, targ.indexOf('_beginn')) + "_ende";
console.log(ende);
var endMarker = $(ende);
console.log(endMarker);
// testen, ob Ende existiert
if (endMarker.length == 0) return;
var cA = $(commonAncestor(startMarker, endMarker));
// Step 1: highlight all »startMarker/following-sibling::node()«
// 1a: Wrap all of its siblings in a span: text-nodes cannot be accessed via jQuery »in the middle«
startMarker.parent().contents().filter(function() {
return this.nodeType === 3;
}).wrap("<span></span>");
// 1b: Colour its later siblings if they dont have the end point marker
var done = false;
startMarker.nextAll().addBack().each(function() {
if ($(this).has(endMarker).length > 0 || $(this).is(endMarker)) return;
else {
$(this).css("background-color", "rgb(187, 187, 187)");
}
});
// Step 2: highlight »(startMarker/parent::*/parent::* intersect endMarker/parent::*/parent::*)//*)«
// 2a: Get startMarker's parents up to the common ancestor
var parentsList = startMarker.parentsUntil(cA);
if (parentsList.has(endMarker).length === 0) {
// go through each of these and access later siblings
var has_returned = false;
parentsList.each(function() {
$(this).nextAll().each(function() {
if (has_returned) return;
// we need to handle the endMarker's parent differently
if ($(this).has(endMarker).length > 0) {
has_returned = true;
return;
} else {
$(this).css("background-color", "rgb(187, 187, 187)");
}
});
});
};
// Step 3: as step 1
// 3a: Wrap alls of endMarker's siblings in a span
endMarker.parent().contents().filter(function() {
return this.nodeType === 3;
}).wrap("<span></span>");
//3b: Colour its earlier siblings if they dont have start marker
$(endMarker.prevAll().addBack().get().reverse()).each(function() {
if ($(this).has(startMarker).length > 0 || $(this).is(startMarker)) return;
else {
$(this).css("background-color", "rgb(187, 187, 187)");
}
});
// Step 4: colour all ancestors to the common ancestor
// Get parents up until common ancestor
var parentsListEnd = endMarker.parentsUntil(cA.children().has(endMarker));
if (parentsListEnd.has(startMarker).length === 0) {
// Go through each of these and access earlier siblings
done = false;
parentsListEnd.each(function() {
$(this).prevAll().each(function() {
if (done) return;
if ($(this).has(startMarker).length > 0 || $(this).is(startMarker)) {
done = true;
return;
} else {
$(this).css("background-color", "rgb(187, 187, 187)");
}
});
});
}
}
/* toggle auf divs innerhalb des Textes */
$(document).ready(function() {
$('.rs-ref').click(
function (event) {
event.preventDefault();
var nid = $(this).attr('id') + '_' + $(this).attr('href').substring(1);
if (!$('#' + nid).length) {
var insert =
"<div id=\"" + nid + "\">" +
"<div class=\"pShow\">" +
"<img src=\"http://diglib.hab.de/edoc/ed000227/images/close.png\" alt=\"close\" width=\"100%\"" +
" onclick=\"javascript:$('#" + nid + "').detach()\"/>" +
$($(this).attr('href')).html() +
"</div>" +
"</div>"
$(this).after(insert);
}
else {
$('#' + nid).detach();
}
}
)
})
$(document).ready(function(){
$('#diplo').click(function(){
$('.orig').show();
$('.reg').hide();
})
$('#modern').click(function(){
$('.orig').hide();
$('.reg').show();
})
});
// eigene Absätze auf block oder inline setzen
$(document).ready(function(){
$('#modern').click(function(){
$('.pResp').css('display', 'block').css('margin-right', '1em').css('margin-top', '1em').css('textIndent', '1em').css
})
$('#diplo').click(function(){
$('.pResp').css('display', 'inline').css('margin-right', '0em').css('margin-top', '0em').css('textIndent', '0em').css;
})
$('#modern').click(function(){
$('.pStyle').css('display', 'block').css('margin-right', '1em').css('textIndent', '1em')
})
$('#diplo').click(function(){
$('.pStyle').css('display', 'block');
})
});
function gap(){
$('.rdg').toggle();
};
$(document).ready(function() {
$('.fnNumber').hover(mouseIn, mouseOut);
});
function mouseIn (event) {
var me = $(this);
var fm = $(me.attr('href')).html();
var fn = $('<span id="asdf">' + fm + '</span>');
fn.prependTo('body');
var maxWidth = 400;
var tPos, lPos, fWidth;
if (fn.width() > maxWidth) { fWidth = maxWidth; }
else { fWidth = fn.width(); }
fn.detach();
me.after(fn);
var dispWidth = window.innerWidth;
var frWidth = $( document ).width();
var wWidth = $( window ).width();
//console.log('fWidth: ' + fWidth + ', window.innerWidth: ' + dispWidth + ', document: ' + frWidth + ", wWidth: " + wWidth);
//console.log('offest.left: ' + me.offset().left + ", offset.top: " + me.offset().top);
//console.log('position.left: ' + me.position().left + ", position.top: " + me.position().top);
if ((fWidth + me.offset().left + 20) > window.innerWidth) {
lPos = window.innerWidth - fWidth - 20 - (dispWidth - wWidth);
tPos = me.position().top + 20;
fn.offset({ left: lPos, top: tPos});
fn.css('top', tPos);
}
else {
lPos = me.position().left + 20;
tPos = me.position().top + 20;
fn.css('left', lPos).css('top', tPos);
}
//console.log('lPos: ' + lPos + ", tPos: " + tPos);
fn.css('display', 'box').css('width' , fWidth).css('position', 'absolute');
fn.css('border', '1px solid').css('background-color', 'rgb(238,238,238)').css('padding', '5px')
.css('white-space', 'normal').css('color', 'black').css('z-index', '1').css('font-weight', 'normal')
.css('font-size', 'small').css('display', 'box');
}
function mouseOut () {
setTimeout(detach, 100);
}
function detach () {
$('#asdf').detach();
}
/* an passende Stelle in rechtem Frame scrollen; 2016-11-29 DK */
function pScroll (target) {
var n = window.name == 'display1' ? 'display2' : 'display1';
var frame = window.parent.frames[n].document;
var own = window.parent.frames[window.name].document;
$('.scrollTarget').toggleClass('scrollTarget', 0);
var eTarget = $('#' + target, frame);
var eOwn = $('#' + target, own);
var targetTop = eTarget.offset().top;
var ownTop = eOwn.offset().top;
$("html, body", frame).scrollTop(targetTop);
$('html, body', own).scrollTop(ownTop);
$eTarget.toggleClass('scrollTarget', 1);
$eOwn.toggleClass('scrollTarget', 1);
}
This diff is collapsed.
/*function tooltip(obj) {
if (!obj.length) return;
$("body").append('<div id="tooltip" />');
var tooltip = $("#tooltip");
var title;
obj.hover(function() {
title = $(this).attr("title") ?
$(this).attr("title") :
"No Title";
$(this).attr("title", "");
tooltip.html(title);
tooltip.stop(true, true)
.delay(50)
.fadeIn("slow")
.dequeue();
}, function() {
$(this).attr("title", title);
tooltip.stop(true,true).fadeOut("slow");
}).mousemove(function(e) {
tooltip.animate({
top:e.pageY + 10,
left:e.pageX + 10
},200);
});
}*/
/*jQuery(document).ready(function(){
tooltip($(".tooltip"));
});
*/
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment