// specify the event_name without the prefix 'on' function hmtfwDispatchEvent(obj, event_name) { if (obj) { if (obj.fireEvent) { obj.fireEvent('on' + event_name); } else if (document.createEvent) { var evt= document.createEvent('HTMLEvents'); if (evt.initEvent) { evt.initEvent(event_name, true, true); } if (obj.dispatchEvent) { obj.dispatchEvent(evt); } } } } //// function hmtfwGetOfsLeft(event) { if (event.offsetX) { return event.offsetX; } else { return event.layerX; } } function hmtfwGetOfsTop(event) { if (event.offsetY) { return event.offsetY; } else { return event.layerY; } } function hmtfwGetScrollLeft(obj) { return (obj.pageXOffset) ? obj.pageXOffset : obj.scrollLeft; } function hmtfwGetScrollTop(obj) { return (obj.pageYOffset) ? obj.pageYOffset : obj.scrollTop; } function hmtfwSetScrollLeft(obj, left) { if (obj.pageXOffset) { obj.pageXOffset= left; } else { obj.scrollLeft= left; } } function hmtfwSetScrollTop(obj, top) { if (obj.pageYOffset) { obj.pageYOffset= top; } else { obj.scrollTop= top; } } function hmtfwGetScrollWidth(obj) { var test1 = obj.scrollWidth; var test2 = obj.offsetWidth; return Math.max(test1, test2); } function hmtfwGetScrollHeight(obj) { var test1 = obj.scrollHeight; var test2 = obj.offsetHeight return Math.max(test1, test2); } function hmtfwGetScrollWindowWidth(obj) { var test1 = obj.scrollWidth; var test2 = obj.offsetWidth; return Math.min(test1, test2); } function hmtfwGetScrollWindowHeight(obj) { var test1 = obj.scrollHeight; var test2 = obj.offsetHeight return Math.min(test1, test2); } function hmtfwGetPageScrollLeft(doc) { // courtesy of quirksmode.org if (doc.documentElement && doc.documentElement.pageYOffset) { // all except Explorer return doc.documentElement.pageXOffset; } else if (doc.documentElement && doc.documentElement.scrollTop) { // Explorer 6 Strict return doc.documentElement.scrollLeft; } else if (doc.body) { // all other Explorers return doc.body.scrollLeft; } } function hmtfwGetPageScrollTop(doc) { // courtesy of quirksmode.org if (doc.documentElement && doc.documentElement.pageYOffset) { // all except Explorer return doc.documentElement.pageYOffset; } else if (doc.documentElement && doc.documentElement.scrollTop) { // Explorer 6 Strict return doc.documentElement.scrollTop; } else if (doc.body) { // all other Explorers return doc.body.scrollTop; } } function hmtfwLocationWithScrollRatio(href, objId) { var obj= gE(objId); var h= href; if (obj) { var path; var search; if (h.indexOf('?') > 0) { path= h.substring(0, h.indexOf('?')); search= h.substring(h.indexOf('?'), h.length); } else { path= h; search= ''; } var pairs; var width= hmtfwGetScrollWidth(obj); var height= hmtfwGetScrollHeight(obj); var winwidth= hmtfwGetScrollWindowWidth(obj); var winheight= hmtfwGetScrollWindowHeight(obj); var url; if (hmtfwUseCookiesScrollRatio) { url= new hmtfwCookie(); } else { url= new hmtfwURLSearch(search); } url.setValue( hmtfwScrollRatioHParamName, ((width == 0) ? '' : (hmtfwGetScrollLeft(obj) + winwidth / 2) / width) ); url.setValue( hmtfwScrollRatioVParamName, ((height == 0) ? '' : (hmtfwGetScrollTop(obj) + winheight / 2) / height) ); if (!hmtfwUseCookiesScrollRatio) { h= path + url.getSearch(); } } location.href= h; return false; } function hmtfwRestoreScrollPosition(objId) { var obj= gE(objId); var h= location.search; if (obj) { var query; if (hmtfwUseCookiesScrollRatio) { query= new hmtfwCookie(); } else { query= new hmtfwURLSearch(h); } var ratio; var max; var min; var ofs; ratio= query.getValue(hmtfwScrollRatioHParamName); max= hmtfwGetScrollWidth(obj); min= hmtfwGetScrollWindowWidth(obj); if (ratio && ratio.length > 0) { ofs= Math.max(0, Math.min(max - min, ratio * max - min / 2)); hmtfwSetScrollLeft(obj, ofs); } ratio= query.getValue(hmtfwScrollRatioVParamName); max= hmtfwGetScrollHeight(obj); min= hmtfwGetScrollWindowHeight(obj); if (ratio && ratio.length > 0) { ofs= Math.max(0, Math.min(max - min, ratio * max - min / 2)); hmtfwSetScrollTop(obj, ofs); } } } function hmtfwURLSearch(q, sep) { // parts courtesy of http://www.eggheadcafe.com/articles/20020107.asp if (q.length > 1) this.q = q.substring(1, q.length); else this.q = null; this.keyValuePairs = new Array(); this.sep= sep || '&'; if(this.q) { for(var i=0; i < this.q.split(this.sep).length; i++) { this.keyValuePairs[i] = hmtfwStringTrim(this.q.split(this.sep)[i]); } } this.getKeyValuePairs = function() { return this.keyValuePairs; } this.getValue = function(s) { for(var j=0; j < this.keyValuePairs.length; j++) { if(this.keyValuePairs[j].split("=")[0] == s) { return decodeURIComponent(this.keyValuePairs[j].split("=")[1]); } } return null; } this.setValue = function(param, value) { for(var j=0; j < this.keyValuePairs.length; j++) { if(this.keyValuePairs[j].split("=")[0] == param) { this.keyValuePairs[j]= param + '=' + encodeURIComponent(value); return false; } } this.keyValuePairs[this.keyValuePairs.length]= param + '=' + encodeURIComponent(value); return true; } this.getParameters = function() { var a = new Array(this.getLength()); for(var j=0; j < this.keyValuePairs.length; j++) { a[j] = this.keyValuePairs[j].split("=")[0]; } return a; } this.getLength = function() { return this.keyValuePairs.length; } this.getSearch = function() { var s= ''; var sep= '?'; for(var j=0; j < this.keyValuePairs.length; j++) { s = s + sep + this.keyValuePairs[j]; sep= this.sep; } return s; } } function hmtfwCookie() { // parts courtesy of http://www.eggheadcafe.com/articles/20020107.asp this.q= document.cookie || ''; this.keyValuePairs = new Array(); this.sep= ';'; if(this.q) { for(var i=0; i < this.q.split(this.sep).length; i++) { this.keyValuePairs[i] = hmtfwStringTrim(this.q.split(this.sep)[i]); } } this.getKeyValuePairs = function() { return this.keyValuePairs; } this.getValue = function(s) { for(var j=0; j < this.keyValuePairs.length; j++) { if(this.keyValuePairs[j].split("=")[0] == s) { return decodeURIComponent(this.keyValuePairs[j].split("=")[1]); } } return null; } this.setValue = function(param, value) { this.setCookie(param, value); for(var j=0; j < this.keyValuePairs.length; j++) { if(this.keyValuePairs[j].split("=")[0] == param) { this.keyValuePairs[j]= param + '=' + encodeURIComponent(value); return false; } } this.keyValuePairs[this.keyValuePairs.length]= param + '=' + encodeURIComponent(value); return true; } this.getLength = function() { return this.keyValuePairs.length; } this.setCookie = function(param, value, path, domain, expiresGMT) { if (!path) path= ''; if (!domain) domain= ''; if (!expiresGMT) expiresGMT= ''; document.cookie= param + '=' + encodeURIComponent(value) + condtext('; expires=', '', expiresGMT) + condtext('; path=', '', path) + condtext('; domain=', '', domain) ; } } function hmtfwGetCookie(param) { var url= new hmtfwCookie(); return url.getValue(param); } function hmtfwStringTrim(str) { if (!str) return str; return str.replace(/^\s+/, '').replace(/\s+$/, ''); } function hmtfwSetFormAutoContinue(submit_elem_id, delay_millisec) { hmtfwAutoContinueTimeoutHandle= setTimeout("hmtfwAutoSubmitFormBySubelemId(\"" + submit_elem_id + "\");", delay_millisec); var o= gE(submit_elem_id); var step= 1000; if (!o) return; if (delay_millisec > 1000) { hmtfwAutoContinueIntervalHandle= setInterval( "hmtfwSetCountdown(\"" + submit_elem_id + "\", \"" + o.value + "\", " + (delay_millisec - step) + ", " + step + ");", step ); } } function hmtfwAutoSubmitFormBySubelemId(elem_id) { clearTimeout(hmtfwAutoContinueTimeoutHandle); var o= gE(elem_id); if (!o) return; o.form.submit(); } function hmtfwSetCountdown(submit_elem_id, base_caption, start_delay_millisec, step_millisec) { var o= gE(submit_elem_id); if (!hmtfwSetCountdown.counter) { hmtfwSetCountdown.counter= start_delay_millisec; } else { hmtfwSetCountdown.counter-= step_millisec; } if (!o) return; o.value= base_caption + " (" + (hmtfwSetCountdown.counter / 1000) + ")"; if ((hmtfwSetCountdown.counter / 1000) <= 0) { clearInterval(hmtfwAutoContinueIntervalHandle); } } var hmtfwScrollRatioHParamName= 'scrollRatioH'; var hmtfwScrollRatioVParamName= 'scrollRatioV'; var hmtfwUseCookiesScrollRatio= navigator.cookieEnabled == true; var hmtfwAutoContinueTimeoutHandle; var hmtfwAutoContinueIntervalHandle; function hmtfwDebug(text) { ( (window.console && console.log) || (window.opera && opera.postError) || window.alert ).call(this, text); } function hmtfwDefaultValueHandler() { jQuery('input[data-default-val]').each(function() { jQuery(this).val(jQuery(this).attr('data-default-val')).addClass('input-default-value'); }); jQuery('input[data-default-val]').focus(function() { if (jQuery(this).val() == jQuery(this).attr('data-default-val')){ jQuery(this).val('').removeClass('input-default-value'); } }); jQuery('input[data-default-val]').blur(function() { if (jQuery(this).val() == ''){ jQuery(this).val(jQuery(this).attr('data-default-val')).addClass('input-default-value'); } }); } /** * adjust the height of objects * * @return */ function hmtfwSetEqualHeight() { // defining the functions for legacy compatibility and IE 9 Object.keys = function( obj ) { var array = new Array(); for ( var prop in obj ) { if ( obj.hasOwnProperty( prop ) ) { array.push( prop ); } } return array; }; // adjust height for global equal height // ------------------------------------- var maxHeightGlobal= 0; jQuery('.ce-equal-height').each(function(index, element) { var elem= jQuery(element); maxHeightGlobal= Math.max(elem.height(), maxHeightGlobal); }); jQuery('.ce-equal-height').css('height', maxHeightGlobal); // equal height per row // -------------------- var storageHeight= new Object(); var maxHeightRow= 0; jQuery('.ce-equal-row-height').each(function(index, element) { var elem= jQuery(element); // store the original heigth for later use storageHeight[elem.attr('id')]= elem.height(); maxHeightRow= Math.max(elem.height(), maxHeightRow); }); // set all elements to the max possible heigth; // this gets us the required grid to determin the // final rows jQuery('.ce-equal-row-height').css('height', maxHeightRow); // group the elements by row var groupRow= new Object(); jQuery('.ce-equal-row-height').each(function(index, element) { var elem= jQuery(element); var topPos= elem.position().top; if (!groupRow[topPos]) { groupRow[topPos]= new Array(); } groupRow[topPos].push(elem.attr('id')); }); var rowKeys= Object.keys(groupRow); for(var i=0; i give the parent node's master check box the same state and remove indetermination state. parent.find('.tn_select_master_check_cell input:checkbox').prop({ indeterminate: false, checked: checked }); hmtfw_tree_node_select_master_check(parent, checked); } else if (all && !checked) { // all sibling nodes have the same "checked" state -> give the parent node's master check box the same state and remove indetermination state. parent.find('.tn_select_master_check_cell input:checkbox').prop({ indeterminate: false, checked: checked }); hmtfw_tree_node_select_master_check(parent, checked); } else { // the sibling nodes have different "checked" states -> give all parent node's master check boxes an indeterminate state. while (parent && parent.length > 0) { parent.find('.tn_select_master_check_cell input:checkbox').prop({ indeterminate: true, checked: false }); parent= parent.closest('.tn_subnodes').prev('.tn_select_node'); } } } /** * toggle the item picker panel. if it was made visible, then focus is placed in the ajax search field * * @param elem the item container or a descendant */ function hmtfw_item_picker_toggle(elem) { elem= jQuery(elem); if (!elem.hasClass('hmtfw_itemlist_container')) { elem= elem.closest('.hmtfw_itemlist_container'); } var picker= elem.find('.hmtfw_item_picker'); var place_focus= !picker.is(':visible'); picker.toggle(); if (place_focus) { var search_field= picker.find('.hmtfw_itemlist_tool input:text')[0]; if (typeof(search_field) != 'undefined') { search_field.focus(); } } else { nd(1); // close overlib popup } } /** * close the item picker panel * * @param elem the item container or a descendant */ function hmtfw_item_picker_close(elem) { elem= jQuery(elem); if (!elem.hasClass('hmtfw_itemlist_container')) { elem= elem.closest('.hmtfw_itemlist_container'); } var picker= elem.find('.hmtfw_item_picker'); nd(1); // close overlib popup picker.hide(); } /** * toggle the itemlist picker panel. if it was made visible, then focus is placed in the ajax search field * * @param elem a descendant of .hmtfw_itemlist_outer_container */ function hmtfw_itemlist_picker_toggle(elem) { elem= jQuery(elem); elem= elem.closest('.hmtfw_itemlist_outer_container'); var picker= elem.find('.hmtfw_itemlist_picker'); var place_focus= !picker.is(':visible'); picker.toggle(); if (place_focus) { var search_field= picker.find('.hmtfw_itemlist_tool input:text')[0]; if (typeof(search_field) != 'undefined') { search_field.focus(); } } else { nd(1); // close overlib popup } } /** * close the itemlist picker panel * * @param elem a descendant of .hmtfw_itemlist_outer_container */ function hmtfw_itemlist_picker_close(elem) { elem= jQuery(elem); elem= elem.closest('.hmtfw_itemlist_outer_container'); var picker= elem.find('.hmtfw_itemlist_picker'); nd(1); // close overlib popup picker.hide(); } function hmtfw_resource_quick_info_open(elem) { var obj= jQuery(elem); var resource_id= obj.data('hmtfw-resource-id'); var popup_id= 'hmtfw-resource-quick-info-' + resource_id; overlib( '
', CAPTION, 'Ressourcen-Quickinfo', STICKY, WIDTH, 300, CLOSECLICK, TOGGLEPOPUP, popup_id ); if (olVisible()) { jQuery.ajax({ url: hmtfw_resource_info_app_url, data: { action: 'QUICKINFO', resource_ids: resource_id }, cache: true, dataType: 'json', success: function (content, textStatus, jqXHR) { nd(0); overlib( content['info_html'], CAPTION, content['caption_html'], STICKY, WIDTH, 300, CLOSECLICK, TOGGLEPOPUP, popup_id ); } }); } } jQuery(document).ready(hmtfwSetEqualHeight); jQuery(document).load(hmtfwSetEqualHeight); jQuery(document).ready(hmtfwDefaultValueHandler); jQuery(document).ready(function () { jQuery('body').on('click', '.hmtfw-expand-cropped', function () { jQuery(this).parent().toggle(). // hide cropped content next().toggle(); // show full content return false; }); jQuery('body').on('click', '.hmtfw-collapse-cropped', function () { jQuery(this).parent().toggle(). // hide full content prev().toggle(); // show cropped content return false; }); // open/close the resource info hover when clicking on the resource info icon jQuery('body').on('click', '.hmtfw-resource-info-icon', function () { hmtfw_resource_quick_info_open(this); return false; }); // take care of proper opening / closing of single-item picker section jQuery('body').on('click', '.hmtfw_itemlist_container .hmtfw_item_picker_toggle_edit', function () { hmtfw_item_picker_toggle(this); // toggle picker return false; }); jQuery('body').on('click', '.hmtfw_itemlist_container.hidden .hmtfw_itemlist_close', function () { hmtfw_item_picker_close(this); // toggle picker return false; }); // take care of proper opening / closing of multi-item picker section jQuery('body').on('click', '.hmtfw_itemlist_outer_container .hmtfw_itemlist_picker_toggle_add', function () { hmtfw_itemlist_picker_toggle(this); // toggle picker return false; }); }); jQuery(document).ready(hmtfw_check_for_scrolling);