/** hviap-cc-replacement **/
function hviapCheck(mandator){
$('a').not('.cc-ed').each(function(){
var thisHref = $(this).attr('href');
if(typeof thisHref != 'undefined' && thisHref.indexOf('hviap-cc') != -1){
thisHref = 'hviap' + ((mandator != 'ct') ? '-' + mandator : '') + thisHref.substr(8);
$(this).attr('href', thisHref).addClass('cc-ed');
}
});
var hviapReCheck = setTimeout('hviapCheck("' + mandator + '")',2000);
}
$(document).ready(function(){
var wls = window.location.search;
if (wls.indexOf('mandator=') != -1) {
var m = hviapCheck(wls.split('mandator=')[1]);
}
});
$(window).load(function() {
/* Check for Android */
var ua = navigator.userAgent.toLowerCase(),
isAndroid = ua.indexOf("android") > -1, //&& ua.indexOf("mobile");
android = 0;
if(isAndroid) {
android = 1;
}
/**
heise-online Sonderlocken
*/
/* Checkt, ob Tabelle im iFrame läuft */
var isIniFrame = (window.location != window.parent.location) ? 1 : 0;
/* Fuegt ho-Stylesheet an */
if (isIniFrame === 1) {
var newStr;
$('head > link').each(function(e) {
var that = $(this),
href = that.attr('href');
if (href.indexOf('tabelle') >= 0) {
var split = href.split('tabelle-20140819.css');
newStr = split[0] + "ho-tabelle-20140819.css";
}
});
$('head').append('');
/* Target-Attr fuer alle im Body
href-Attr ohne hviap Zusatz
*/
$('.fixme #scroller #original a').each(function(e) {
var that = $(this),
href = that.attr('href'),
split = href.split('?url=');
that.attr('href', split[1]);
that.attr('target','_blank');
});
}
/**
Preload
*/
$('.preload').fadeOut(400);
$('').prependTo('body');
// Sonderlocke fuer spezielle Tabelle
sonderlocke_ct0215_148_150();
/**
data-index check (Colspan-Elemente koennen falsche data-indizes in einer Zeile produzieren)
*/
$('.fixme #scroller #original div').each(function(e) {
var that = $(this),
thisColspanVal = that.data('colspan'),
thisDataIndex = that.data('index');
if(thisColspanVal === undefined){
thisColspanVal = 1;
}
var diff = thisDataIndex + thisColspanVal;
that.next().attr('data-index', diff);
});
/**
Sonderlocke fuer tb_b_head, die gleichen colspan wie der Titel haben
*/
if ($('.titel').data('colspan') >= 3 ) {
var titleColspan = $('.fixme #original .titel').data('colspan');
tbbhead = $('.fixme #original .tb_b_head[data-index=0][data-colspan='+titleColspan+']'),
tbbheadColspan = tbbhead.data('colspan'),
tbbheadIndex = tbbhead.data('index');
tbbhead.attr('data-colspan', tbbheadColspan-1).attr('data-index', tbbheadIndex+1);
$('').insertBefore(tbbhead);
}
/**
Rowspan Berechnung
Die fehlenden Zellen müssen von der Zeile mit den wenigsten Elementen her aufgefüllt werden
*/
$('.fixme #scroller #original li').children('[data-rowspan]').each( function() {
var that = $(this),
rowspan = that.data('rowspan'),
data_index = that.data('index');
/*...klone entsprechende Zelle und füge sie soviele Zeilen darunter hinzu, wie der Rowspan-Wert -1 angegeben ist */
target_row = that.parent().nextAll();
that.clone(true).insertBefore(target_row.slice(0, rowspan-1).children('[data-index='+data_index+']')).css('color', 'rgba(0,0,0,0)').removeAttr('data-rowspan');
/* Erhöht den data-index der Zellen, die durch die neuen Elemente verschoben wurden */
target_row.slice(0, rowspan-1).children('[data-index='+data_index+']').nextAll().each(function() {
var that = $(this),
thisDataIndex = that.attr('data-index');
if (thisDataIndex == '0' && that.hasClass('tb_b_head')) {
var span = $('');
that.prepend(span);
}
that.attr('data-index', +thisDataIndex+1);
});
});
/**
+ Colspan-Gruppen im Inhaltsbereich und
+ Überschriftsgruppen bestimmen
Dient dem korrekten Klappen von Spaltenueberschriften mit colspan Attribut
*/
var maxColspan = $('.fixme #scroller .titel').data('colspan');
var indexVar = 0;
$('.fixme #scroller li:not(.partrow) div:not(.titel)').each(function() {
var that = $(this),
groupColSpanVal = that.attr('data-colspan'),
dataIndexVal = that.attr('data-index'),
groupCounter = [];
if (groupColSpanVal !== undefined){
if (indexVar >= maxColspan-1) {
indexVar = 0;
}
indexVar = dataIndexVal-1;
for (var p = groupColSpanVal; p > 0; p--) {
indexVar++;
groupCounter.push(indexVar);
}
that.attr('data-grouparray', '[,'+groupCounter+',]');
}
});
/* Füge fehlende Klapp-Icons hinzu */
$('.fixme li').has('.tb_b_head').each(function(e) {
var that = $(this),
thatChildren = that.children();
thatChildren.each(function(){
var that = $(this);
if(!that.children('.toggle').length && that.data('index') > 0 && that.prevAll().attr('data-colspan') === undefined && !that.children('.noicon').length){
that.prepend('');
}
});
});
/* Alle Tabellenköpfe bekommen immer ein , das sie immer Fett sein sollen */
$('.fixme li .tb_b_head .kein_stil, .fixme li .tb_b .kein_stil').each(function(e){
var that = $(this);
that.wrapInner('');
});
/* Löscht Rowclose-Icon in tb_b die aus mehreren Elementen bestehen (= ohne Partrow-Attr) */
$('.fixme #original .tb_b').parent('li').not('[data-partrow]').find('.toggle').remove();
/* Tabellen mit diesen Pfeilen werden korrekt angezeigt */
$('.fixme .gruenpfeilhoch, .fixme .rotpfeilrunter, .fixme .blaupfeilrechts').each(function(e) {
var that = $(this);
if(that.prev().length !== 0) {
that.before('
');
}
});
/* Tabellen mit doppelten Pfeilen reparieren (Seit neuer Xtension) */
$('.fixme .po, .fixme .pu').each(function(e) {
var that = $(this);
if (that.children().length === 0) {
that.remove();
}
});
/* tb_u Zeilen bekommen ein partrow */
$('.fixme #original div.tb_u').parent().addClass('partrow');
/* Wenn Tabelle aus 3 Spalten besteht, lösche die Icons aus den tb_b_head (Weil nicht mehr Klickbar) */
if ($('.titel').data('colspan') <= 3 ) {
$('.tb_b_head').find('.toggle').remove();
}
/* Lösche Icons aus tb_b_head, falls sie bei Zellen mit colspan Attr hinzugefügt wurden
Lösche Icons aus tb_b_head, falls Zellen leer sind */
$('.tb_b_head').each(function() {
var that = $(this);
$('.tb_b_head[data-colspan]').find('.toggle').remove();
if (!that.text().trim().length) {
that.find('.toggle').remove();
}
});
/**
+ Berechnet die Breite der Zellen
+ Berechnet die korrekte Breite der colspan-Zellen
+ Berechnet die Höhe jeder Zelle in einer Zeile
*/
calcCellDimensions();
/**
Cloning
*/
/* Gibt es ein .tb_z1 in der Tabelle?
Definiert, ob eine fixe linke Spalte erzeugt werden soll
*/
var needLeftColumn = $('#scroller #original li:gt(0) .tb_z1').length;
/* Header Table */
var fixedTable = $('').prependTo('.fixme');
$('#scroller #original .titel').parent().clone(true).appendTo($('#fixedTable'));
$('#scroller #original .tb_b_head').parent().clone(true).appendTo($('#fixedTable'));
/* Linke Spalte */
if (needLeftColumn){
var fixedTableLeft = $('').appendTo('#scroller');
$('#scroller #original li:gt(0)').clone(true).appendTo($('#fixedTableLeft'));
$('#fixedTableLeft li div').not('div[data-index=0]').css('visibility', 'hidden'); /* Entfernt alle p die nicht benötigt werden */
$('#fixedTableLeft li .tb_b_head').parent().remove(); /* Entfernt die überflüssigen .tb_b_head */
}
/* Top/Left Ecke (aus rein optischen Gründen sobald mehr als 1 tb_b_head vorhanden ist...)*/
if ($('#fixedTable .tb_b_head').size() > 1 && needLeftColumn) {
var fixedTableSubheader = $('').prependTo('.fixme');
$('#scroller .tb_b_head[data-index=0]').clone(true).appendTo($('#fixedTableSubheader li'));
$('#fixedTable .tb_b_head[data-index=0]').css('color', 'rgba(0,0,0,0)').css('background-color', '#fff');
var elementWidth = $('#fixedTableSubheader li div').outerWidth();
$('#fixedTableSubheader li').css('width', elementWidth-1);
}
/* Löscht die zuvor geclonten Elemente aus der Scroll-Liste */
$('#scroller #original .titel').parent().remove();
$('#scroller #original .tb_b_head').parent().remove();
$('#scroller #original div.tb_u').css('color', 'rgba(0,0,0,0)');
/* Löscht Text in der ersten Tabellenspalte (die geklont wurde) */
if (needLeftColumn){
$('#scroller #original li div[data-index=0]').css('color', 'rgba(0,0,0,0)').css('background-color', '#fff');
$('#scroller #original li div[data-index=0] img').css('visibility', 'hidden');
}
/* Löscht den Inhalt den verdeckten .tb_b Zellen */
$('#scroller #original .tb_b[data-index=0]').css('color', 'rgba(0,0,0,0)');
$('#scroller #original .tb_b[data-index=0]').find('.toggle').css('visibility', 'hidden');
/**
Berechnet die gesamte Breite der Tabelle
- kommt nach dem Cloning, da auch die neuen fixen Tabellenteile berechnet werden müssen
*/
calcTotalWidth();
/* Partrows brechen um, wenn Viewport schmaler als Zeile ist */
calcLineBreak();
/**
Speichere Text der Titelzeilen mit colspan in data-Attr
- Beim klappen von Spalten wird evtl eine Ellipse erzeugt, der Originaltext bleibt so erhalten
*/
$('.fixme #fixedTable [data-colspan]').each(function(e) {
var that = $(this),
text = that.children().text(),
textWidth = that.find('span').width();
that.data('textValue', text);
that.data('textWidth', textWidth);
});
/**
Click-Events der Spalten/Zeilen-Köpfe (sobald mehr als 2 Spalten vorhanden sind)
*/
/*...für Spalten / Columns */
if ($('.titel').data('colspan') >= 3 ) {
$('.tb_b_head').has('.toggle').on('click', function(e){
var that = $(this),
target_data_colspan = that.attr('data-colspan');
target_data_attr = that.attr('data-index');
target_width = that.attr('data-width');
/* Überprüfe, ob evtl Titelgruppen verkleinert/vergößert werden müssen */
if (that.hasClass('colclose')) {
$('[data-grouparray*=",'+target_data_attr+',"]').each(function(e) {
var that = $(this),
parentHeaderWidthNew = that.width();
that.css("width", parentHeaderWidthNew+(target_width-4));
});
} else if (!that.hasClass('colclose')) {
$('[data-grouparray*=",'+target_data_attr+',"]').each(function(e) {
var that = $(this),
parentHeaderWidthNew = that.width();
that.css("width", parentHeaderWidthNew-(target_width-4));
});
}
/* Toggle entsprechende Spalten */
if (target_data_attr !== 0 && target_data_colspan === undefined){
$('[data-index="'+target_data_attr+'"]:not([data-colspan])').toggleClass('colclose');
$('[data-index="'+target_data_attr+'"]strong').toggle();
$('[data-index="'+target_data_attr+'"]sup').toggle();
$('[data-index="'+target_data_attr+'"] > span').toggleClass('rowopen'); /*Icon*/
$('[data-index="'+target_data_attr+'"] img').toggle(); /*Image*/
$('[data-index="'+target_data_attr+'"] .gruenpfeilhoch').toggle(); /* Grüner Pfeil */
$('[data-index="'+target_data_attr+'"] .rotpfeilrunter').toggle(); /* Roter Pfeil */
$('[data-index="'+target_data_attr+'"] .blaupfeilrechts').toggle(); /* Blauer Pfeil */
/* Neuberechnung der Breite */
/* Berechne die Breite aller Elemente in einer Zeile */
var width = 0;
$('.fixme #fixedTable .tb_b_head').parent().eq(0).children().each(function(index) {
var that = $(this);
width += that.outerWidth(true);
});
/* Setze Breite aller Container (Kopf; linke, fixe Spalte; Haupttabelle) */
$('.fixme #scroller #original, .fixme #fixedTable, .fixme #fixedTableLeft').css('width', width);
$('.fixme div.tb_b, .fixme div.tb_u, .fixme .titel').css('width', width);
$('.fixme .partrow div.tb_b').parent().css('width', width);
$('.fixme .titel').attr('data-totalWidth', width);
/* Berechne Zeilenumbrueche */
calcLineBreak();
/* Zellen mit colspan werden umgebrochen, sobald Text länger als Zelle wird
Zusaetzlich werden alle Siblings ebenfalls in ihrer Höhe verändert, damit die Zeile einheitlich bleibt */
$('.fixme #scroller [data-colspan]').not('.partrowClosed, .partrowClosed_big, .partrowClosed_big_2').each(function(e) {
var that = $(this);
that.siblings().andSelf().css('height', '');
var tallest = 0;
that.siblings().andSelf().each(function() {
var that = $(this),
thisHeight = that.height();
if(thisHeight > tallest) {
tallest = thisHeight;
}
});
that.siblings().andSelf().height(tallest);
});
/* Sobald eine colspan-Zelle in den Titelspalten schmaler als ihr Inhalt wird, ersetze den Text durch eine Ellipse */
$('.fixme #fixedTable [data-colspan][data-grouparray*=",'+target_data_attr+',"]').each(function(e) {
var that = $(this),
cellWidth = that.width(),
currentText = that.data('textValue'),
textWidth = that.data('textWidth');
if (cellWidth < textWidth) {
if(that.find('strong').length){
that.children().children().html("\u2026");
}
else {
that.children().children().html("\u2026");
}
} else {
if(that.find('strong').length){
that.children().children().html(""+currentText+"");
}
else {
that.children().children().html(currentText);
}
}
});
/* Sonderlocke für Zeilen mit mehreren .tb_b (welche kein Colspan besitzen) */
$('#fixedTableLeft li, #scroller #original li').not('.partrow').find('div.tb_b').each(function(index) {
var that = $(this),
tb_bColspan = that.attr('data-colspan'), /* Besitzt das .tb_b ein colspan? */
dataWidth = that.attr('data-width');
if (tb_bColspan === undefined) {
that.css('width', dataWidth);
}
});
}
/* Fixed-Elemente müssen erneut positioniert werden (falls 3 Head-Zeilen vorhanden sind) */
fixedPosition();
/* Dimensionen der Liste wurden verändert -> iScroll refreshen */
if (android === 0){
setTimeout(function () {
myScroll.refresh();
}, 0);
} else if (android === 1){
setTimeout(function () {
myScrollAndroid.refresh();
}, 0);
}
/* Aktuelle Translate-Value des #scroller Divs an fixed-ELemente übergeben */
setTimeout(function () {
translateValue('#scroller #original');
}, 100);
/* Zentriere Tabelle erneut, da sich die groesse geaendert hat */
centerTabelle(isIniFrame);
});
}
/*... für Zeilen / Rows */
$('.fixme .partrow').on('click', function(e) {
/* Definiere die Trennlinie */
var that = $(this),
partrowNum = that.attr('data-partrow'),
thisHeight = that.children().height();
/* Wende entsprechende Styles auf Trennlinie an */
if (that.children().children().length !== 0) { /* alle Trennlinien die ein beinhalten (.find('strong')*/
$('[data-partrow="'+partrowNum+'"] div span').not('.new').toggleClass('rowopen'); /*Icon*/
$('[data-partrow="'+partrowNum+'"]').children().toggleClass('partrowClosed');
/* Blende alle Reihen bis zur nächsten Trennlinie aus */
$('#scroller #original li[data-partrow='+partrowNum+']').nextUntil('.partrow').toggle();
$('#fixedTableLeft li[data-partrow='+partrowNum+']').nextUntil('.partrow').toggle();
}
/* Zentriere alle img-Elemente */
centerImg();
/* Dimensionen der Liste wurden verändert -> iScroll refreshen */
if (android === 0){
setTimeout(function () {
myScroll.refresh();
}, 0);
} else if (android === 1){
setTimeout(function () {
myScrollAndroid.refresh();
}, 0);
}
/* Aktuelle Translate-Value des #scroller Divs an fixed-ELemente übergeben */
setTimeout(function () {
translateValue('#scroller #original');
}, 100);
/* Zentriere Tabelle erneut, da sich die groesse geaendert hat */
centerTabelle(isIniFrame);
});
/**
iScroll NEU
*/
var myScroll, myScrollAndroid;
if (android === 1) {
if (isIniFrame === 0) {
myScrollAndroid = new IScroll('#scroller', {scrollX: true, scrollY: true, hScrollbar: false, vScrollbar: false, probeType: 3, mouseWheel: true, click:(parseFloat(navigator.userAgent.match(/Android [\d+\.]{3,5}/)[0].replace('Android ','')) < 4.4 ? false : true)});
myScrollAndroid.on('scroll', updatePosition);
myScrollAndroid.on('scrollEnd', updatePosition);
} else if(isIniFrame === 1) {
myScrollAndroid = new IScroll('#scroller', {scrollX: true, scrollY: true, scrollbars: true, interactiveScrollbars: true, probeType: 3, mouseWheel: true, click:(parseFloat(navigator.userAgent.match(/Android [\d+\.]{3,5}/)[0].replace('Android ','')) < 4.4 ? false : true)});
myScrollAndroid.on('scroll', updatePosition);
myScrollAndroid.on('scrollEnd', updatePosition);
}
} else if (android === 0) {
if (isIniFrame === 0) {
myScroll = new IScroll('#scroller', {scrollX: true, scrollY: true, hScrollbar: false, vScrollbar: false, probeType: 3, mouseWheel: true, click:true });
myScroll.on('scroll', updatePosition);
myScroll.on('scrollEnd', updatePosition);
} else if(isIniFrame === 1) {
myScroll = new IScroll('#scroller', {scrollX: true, scrollY: true, scrollbars: true, interactiveScrollbars: true, probeType: 3, mouseWheel: true, click:true});
myScroll.on('scroll', updatePosition);
myScroll.on('scrollEnd', updatePosition);
}
}
document.body.addEventListener("touchmove", function(event) {
event.preventDefault();
}, false);
/*Zentriert die Tabelle, wenn:
a)man sich in einem iFrame befindet
b)die Tabelle kleiner als der Viewport ist
*/
centerTabelle(isIniFrame);
});
function updatePosition () {
$('#fixedTable .tb_b_head').parent().css('-webkit-transform', 'translate3d(' + this.x + 'px, 0, 0)')
.css('-moz-transform', 'translate3d(' + this.x + 'px, 0, 0)')
.css('-ms-transform', 'translate3d(' + this.x + 'px, 0, 0)')
.css('-o-transform', 'translate3d(' + this.x + 'px, 0, 0)')
.css('transform', 'translate3d(' + this.x + 'px, 0, 0)');
$('#fixedTableLeft').css('-webkit-transform', 'translate3d(0,' + this.y + 'px, 0)')
.css('-moz-transform', 'translate3d(0,' + this.y + 'px, 0)')
.css('-ms-transform', 'translate3d(0,' + this.y + 'px, 0)')
.css('-o-transform', 'translate3d(0,' + this.y + 'px, 0)')
.css('transform', 'translate3d(0,' + this.y + 'px, 0)');
/* Wenn Tabelle nach links gescrollt wird, fuege weißen Rand an erste fixe Spalte hinzu */
if (this.x < 0) {
$('#fixedTableLeft [data-index=0]').removeClass('fixedTableLeftScrollingBorder_2').addClass('fixedTableLeftScrollingBorder');
$('#fixedTableSubheader').addClass('fixedTableSubHeaderScrollingBorder');
} else if (this.x >= 0) {
$('#fixedTableLeft [data-index=0]').removeClass('fixedTableLeftScrollingBorder').addClass('fixedTableLeftScrollingBorder_2');
$('#fixedTableSubheader').removeClass('fixedTableSubHeaderScrollingBorder');
}
}
/**
Aktueller transform:translate Value an fixed-Elemente übergeben
*/
function translateValue(el) {
var transform = $(el).css("-webkit-transform") ||
$(el).css("-moz-transform") ||
$(el).css("-ms-transform") ||
$(el).css("-o-transform") ||
$(el).css("transform");
var values = transform.match(/-?[0-9\.]+/g);
var matX = values[4];
var matY = values[5];
$('#fixedTable .tb_b_head').parent().css('-webkit-transform', 'translate3d(' + matX + 'px, 0, 0)')
.css('-moz-transform', 'translate3d(' + matX + 'px, 0, 0)')
.css('-ms-transform', 'translate3d(' + matX + 'px, 0, 0)')
.css('-o-transform', 'translate3d(' + matX + 'px, 0, 0)')
.css('transform', 'translate3d(' + matX + 'px, 0, 0)');
$('#fixedTableLeft').css('-webkit-transform', 'translate3d(0,' + matY + 'px, 0)')
.css('-moz-transform', 'translate3d(0,' + matY + 'px, 0)')
.css('-ms-transform', 'translate3d(0,' + matY + 'px, 0)')
.css('-o-transform', 'translate3d(0,' + matY + 'px, 0)')
.css('transform', 'translate3d(0,' + matY + 'px, 0)');
}
/**
iScroll Container neu berechnen (resize)
*/
function resizeiScroll(){
var headerHeight = $('#fixedTable').outerHeight();
$('#scroller').css('width', $(window).width());
$('#scroller').css('height', $(window).height()-headerHeight);
$('body').scrollLeft(0).scrollTop(0);
setTimeout(function () {
translateValue('#scroller #original');
}, 100);
}
/**
Funktion fuer alle Zeilen/Spalten/Zellen, deren Text passend zum Viewport umgebrochen werden müssen
Beinhaltet auch fixedPosition(), da die Position der fixen Elemente angepasst werden muss
*/
function calcLineBreak() {
var totalWidth = $('.titel').attr('data-totalWidth'),
windowWidth = $(window).width();
/* Partrows */
$('.fixme .partrow div.tb_b').each(function(f) {
var widthGesamt = 0;
$(this).children().each(function(e) {
widthGesamt += $(this).width();
if (widthGesamt <= windowWidth - 20) {
$(this).parent().css('height', "");
$(this).parent().width(totalWidth - 22);
} else if (widthGesamt > windowWidth - 20) {
$(this).parent().width(windowWidth - 20);
$(this).parent().css('height', "");
}
});
});
/* Titel */
$('.fixme .titel').each(function() {
var that = $(this);
if (that.width() <= windowWidth - 20) {
that.width(totalWidth - 22);
that.css('height', "");
}
if (that.width() > windowWidth - 20) {
that.width(windowWidth - 20);
that.css('height', "");
}
});
/* Tabellenlegende */
$('.fixme div.tb_u').each(function() {
var that = $(this);
if (that.width() <= windowWidth - 20) {
that.width(totalWidth - 22);
that.css('height', "");
}
if (that.width() > windowWidth - 20) {
that.width(windowWidth - 20);
that.css('height', "");
that.parent().width(totalWidth);
}
});
fixedPosition();
}
/**
Brechnet Dimensionen der Zellen (abhängig von Viewport-Größe)
*/
var var1=0, var2=0, var3=0;
function calcCellDimensions() {
/**
Viewport Check
*/
/* (Tablet klein ODER Phone) UND mehr als 2 Spalten */
if ((($('.smallViewport').css('line-height') === '1px' || $('.smallViewport').css('line-height') === '2px')) && $('.titel').data('colspan') !== 2) {
$('body').data('small', 1);
++var1;
var2 = 0;
var3 = 0;
/* Normal */
} else if ($('.smallViewport').css('line-height') === '0px') {
$('body').data('small', 0);
++var2;
var1 = 0;
var3 = 0;
/* (Tablet klein ODER Phone) UND 2 Spalten */
} else if ((($('.smallViewport').css('line-height') === '1px' || $('.smallViewport').css('line-height') === '2px')) && $('.titel').data('colspan') === 2) {
var windowWidth = $(window).width(),
cellcount = $('.fixme .titel').data('colspan');
newCellWidth = windowWidth / cellcount;
$('.fixme li:not(.partrow) div:not(.tb_u, .titel)').each(function(){
$(this).css('width', newCellWidth-22);
$('.fixme #fixedTableSubheader li').css('width', newCellWidth-1);
});
$('.fixme ul img').css('max-width', (newCellWidth-22)-20);
$('body').data('small', 2);
var1 = 0;
var2 = 0;
var3 = 1;
}
/**
Beim Wechsel von Normal -> Tablet klein; Tablet -> Phone wird Breite+Hoehe berechnet
Speichere Status der eingeklappten Spalten/Zeilen
*/
if(var1 === 1 || var2 === 1 || var3 === 1){
/* Eingeklappte Zellen in Arrays sammeln */
var eingeklappteSpalten = [];
var eingeklappteZeilen = [];
$('.fixme #fixedTable .tb_b_head.colclose').each(function(e) {
var that = $(this);
eingeklappteSpalten.push(that);
});
$('.fixme #scroller #fixedTableLeft .tb_b.partrowClosed').each(function(e) {
var that = $(this);
eingeklappteZeilen.push(that);
});
/* Ausklappen */
for (var i = 0; i < eingeklappteSpalten.length; i++) {
eingeklappteSpalten[i].trigger('click');
}
for (var j = 0; j < eingeklappteZeilen.length; j++) {
eingeklappteZeilen[j].trigger('click');
}
/* Berechne Breite der einzelnen Zellen */
if($('body').data('small') === 1){
equalWidth(140);
} else if ($('body').data('small') === 0) {
equalWidth(240);
}
/* Berechnung der Breite von colspan-Zellen (nach equalWidth, da wir Einzelzellenbreite für colspans vorher wissen muessen) */
$('.fixme div[data-colspan]').not('.fixme .tb_b, .fixme .titel, .fixme .tb_u').each (function(e) {
var that = $(this);
var colspanVal = that.data('colspan');
var numbers;
/* GroupArray der colspan-Zelle auslesen */
var thisGroupArray = that.attr('data-grouparray');
if (thisGroupArray !== undefined) {
numbers = thisGroupArray.match(/\d+/g);
}
/* Durch Array laufen und passende .tb_b_head-Widths suchen und addieren */
var cellWidths = 0;
for (var i = 0; i < numbers.length; i++) {
var thisWidth = $('.fixme div[data-index="'+numbers[i]+'"]').not('[data-colspan]').outerWidth();
cellWidths += thisWidth;
}
that.css('width', cellWidths-22);
});
/* Höhe berechnen */
equalHeight();
/* Einklappen*/
for (var k = 0; k < eingeklappteSpalten.length; k++) {
eingeklappteSpalten[k].trigger('click');
}
for (var l = 0; l < eingeklappteZeilen.length; l++) {
eingeklappteZeilen[l].trigger('click');
}
}
/* Zentriere img-Elemente */
centerImg();
/* Färbe kostenlos */
colorKostenlos();
}
/**
Jede Zelle pro Zeile bekommt gleiche Höhe
*/
function equalHeight() {
/* Reset der Zeilenhöhe + img-Margin */
$('.fixme ul li').children().css('height', '');
$('.fixme li div:not(.tb_z1, .tb_z1_dunkel)').find('img').css('margin-top', '');
/* Neuberechnung der Zeilenhöhe */
$('.fixme ul li').each(function() {
var that = $(this),
tallest = 0;
$(this).children().each(function() {
var that = $(this),
thisHeight = that.height();
if(thisHeight > tallest) {
tallest = thisHeight;
}
});
that.children().height(tallest);
/* fixedTableSubheader-Zellen behalten ihre ursprüngliche Höhe, da sie nie verändert wird */
if ($('.fixme #fixedTableSubheader').length) {
$('.fixme #fixedTableSubheader li div').each(function(e){
var that = $(this);
var origHeight = $('.fixme #fixedTable li').has('.tb_b_head').eq(e).children('[data-index=0]').height();
that.height(origHeight);
});
}
});
}
/**
Jede Spalte bekommt gleiche minimal nötige Breite
*/
function equalWidth(widthThreshold) {
var eLength = $('.fixme .titel').data('colspan');
/* Berechne maximale Breite einer Spalte */
var calcRowWidth = function() {
var innerMaxWidth = 0;
$('.fixme li:not(.partrow) div:not(.tb_u, .titel, [data-colspan])[data-index="'+i+'"]').each(function(e) {
var that = $(this),
elementWidth = 0;
/* Wenn Zelle ein toggle-icon hat, muss dessen Breite berücksichtig werden */
if(that.children().is('.toggle')){
elementWidth = that.textWidth()+45;
} else {
elementWidth = that.textWidth()+15;
}
/* Spalte darf nicht breiter als x Pixel werden */
if(elementWidth > widthThreshold){
elementWidth = widthThreshold;
}
/* Bestimme groesste Zellenbreite in Spalte */
if(elementWidth > innerMaxWidth){
innerMaxWidth = elementWidth;
}
});
return innerMaxWidth;
};
var minrowWidth = widthThreshold;
for(i=0; i <= eLength-1; i++){
if(i === 0){
var firstRowWidth = calcRowWidth();
$('.fixme #fixedTableSubheader li').css('width', firstRowWidth+21);
}
var rowWidth = calcRowWidth();
//console.log('rowWidth = ');
//console.log(rowWidth);
//console.log('minrowWidth = ');
//console.log(minrowWidth);
if(rowWidth <= minrowWidth) {
minrowWidth = rowWidth;
}
if(typeof(cellusedaspadding) !== 'undefined') {
minrowWidth = rowWidth;
}
$('.fixme li:not(.partrow) div:not(.tb_u, .titel, [data-colspan])[data-index="'+i+'"]').css('width', rowWidth).attr('data-width', rowWidth);
$('.fixme ul div img').css('max-width', minrowWidth);
}
}
/**
Berechnet die gesamte Breite der Tabelle
- eigene Funktion, da bei resize oder orientationchange die erste Spalte neu berechnet wird
- es aendert sich dadurch die maximale Tabellenbreite
*/
function calcTotalWidth() {
var totalWidth = 0;
if($('.fixme #scroller #original .titel').attr('data-colspan') === 1){
$('.fixme #scroller #original li .tb_z1:eq(0)').parent().children().each(function(index) {
totalWidth += $(this).outerWidth(true);
});
} else {
$('.fixme #scroller #original li .tb_z1:eq(0)').parent().children().each(function(index) {
totalWidth += $(this).outerWidth(true);
});
}
$('.titel').attr('data-totalWidth', totalWidth);
$('.fixme #scroller #original, .fixme #fixedTable, .fixme #fixedTableLeft, .fixme #scroller .partrow').css('width', totalWidth);
}
/**
Mögliche Images zentrieren (nur Bilder die im Inhaltsbereich vorkommen, nicht in den linken fixed-Elementen)
*/
function centerImg() {
$('.fixme li div:not(.tb_z1, .tb_z1_dunkel)').find('img').each(function() {
var that = $(this);
if (that.parent().find('img').length === 1) {
var imageHeight = that.height();
var cellHeight = that.parent().height();
that.css('margin-top', '');
if (imageHeight < cellHeight) {
that.css('margin-top', (cellHeight/2) - imageHeight/2);
}
}
});
}
/* Zentriert die Tabellen */
function centerTabelle(isIniFrame) {
if (isIniFrame === 1) {
var breiteTabelle = $('.fixme .titel').outerWidth();
var hoeheTabelle = $('.fixme #scroller #original').outerHeight() + $('.fixme #fixedTable').outerHeight();
var breiteViewport = $(window).width();
var hoeheViewport = $(window).height();
var centerX = breiteViewport/2 - breiteTabelle/2;
if(breiteTabelle <= breiteViewport){
$('.fixme').css('left', centerX);
$('.fixme .iScrollVerticalScrollbar').css('right', centerX+1);
} else if (breiteTabelle > breiteViewport){
$('.fixme').css('left', 0);
$('.fixme .iScrollVerticalScrollbar').css('right', 1);
}
var centerY = hoeheViewport/2 - hoeheTabelle/2;
if(hoeheTabelle <= hoeheViewport){
$('.fixme').css('top', centerY);
$('.fixme .iScrollHorizontalScrollbar').css('bottom', centerY);
} else if (hoeheTabelle > hoeheViewport){
$('.fixme').css('top', 0);
$('.fixme .iScrollHorizontalScrollbar').css('bottom', 0);
}
}
}
/**
Resize-Funktion
*/
$(window).resize( function() {
/* Checkt, ob Tabelle im iFrame läuft */
var isIniFrame = (window.location != window.parent.location) ? 1 : 0;
resizeiScroll();
calcLineBreak();
calcCellDimensions();
calcTotalWidth();
centerTabelle(isIniFrame);
});
/**
OrientationEvent
*/
if (window.DeviceOrientationEvent) {
window.addEventListener('orientationchange', resizeiScroll, false);
window.addEventListener('orientationchange', calcLineBreak, false);
window.addEventListener('orientationchange', calcCellDimensions, false);
window.addEventListener('orientationchange', calcTotalWidth, false);
window.addEventListener('orientationchange', centerTabelle, false);
}
/**
Positionierung der Fixed-Elemente vom oberen Viewport-Rand
*/
function fixedPosition() {
var titleHeight = $('#fixedTable .titel').outerHeight();
var headerHeight = $('#fixedTable').outerHeight();
var fixedTableLeftWidth = $('#fixedTableLeft').outerWidth();
$('.fixme #scroller').css('top', headerHeight)
.css('height', $(window).height()-headerHeight);
$('.fixme #fixedTableLeft').css('top', '0');
$('.fixme #fixedTableSubheader').css('top', titleHeight);
}
/**
Funktion färbt kostenlos
*/
function colorKostenlos() {
if( $('.fixme #original .tb_z2 strong').text() == 'kostenlos' ) {
$('.fixme #original .tb_z2 strong').css('color', '#31A1AB');
}
}
/**
Funtion zur Breitenbestimmung von Text
*/
$.fn.textWidth = function(text, font) {
if (!$.fn.textWidth.fakeEl){
$.fn.textWidth.fakeEl = $('').hide().appendTo(document.body);
}
$.fn.textWidth.fakeEl.text(text || this.val() || this.text()).css('font', font || this.css('font'));
return $.fn.textWidth.fakeEl.width();
};
function sonderlocke_ct0215_148_150(){
var titel = $('.fixme #scroller #original li .titel').text();
if(titel === 'Kombinationsmöglichkeiten Display-Anschlüsse'){
$('.fixme #scroller #original .tb_b_head[data-index="0"] strong:contains("Display-Eingang")').css('float', 'right');
$('.fixme #scroller #original .tb_b_head[data-index="0"] strong:contains("Grafik-Ausgang")').css('float', 'left').after('');
}
}