/* * jQuery Functions Main for Wordpress Theme "Photoblog by Steffen Hollstein" * @requires jQuery v1.3.2 or later */ /************************ jQueryDebugOutput - BEGIN ************************/ if( !window.console ){ window.console = { log : function(){}, error : function(){}, warn : function(){} }; } function jQueryDebugOutput(settings){ /* Example: ----------------------- jQueryDebugOutput({ msg : error }); */ var settings = jQuery.extend({//default settings msg : null, debugOuputMessagePrefix : '[Wordpress Theme Debug Output] ' }, settings || {} ); //if( "console" in window && "firebug" in console ){ if( settings.msg ){ if( typeof(settings.msg) == "object" ){ console.debug( settings.msg ); } else { if( settings.msg != '' && settings.msg != ' ' ){ console.debug( settings.debugOuputMessagePrefix + settings.msg ); } else { console.debug( settings.msg ); } } } } /************************ jQueryDebugOutput - END ************************/ /************************ initModalboxContent / BEGIN ************************/ function initModalboxContent(){ jQuery( "a.eCM, a.nEM" ).click(function(event){ // nEM (NotEncodedMail) // eCM (enCodedMail) event.preventDefault(); var thisObj = jQuery( this ); var decodedMail = ''; if( thisObj.hasClass("eCM") ){ decodedMail = base64Decode( fse // fse (footer socialicons email) is set in header.php ); } else if( thisObj.hasClass("nEM") ){ decodedMail = fse; // fse (footer socialicons email) is set in header.php } var infoText = jsLocalizedStrings[ "eCmText" ] + ' ' + decodedMail + '.'; jQuery.fn.modalBox({ directCall : { data : infoText }, customClassName : "small" }); }); jQuery( "#pageWrapper #content div.globalTableLayout.contentLayoutWrapper div.globalTableLayout-Row div.globalTableLayout-Cell.cell-1 .entry-content img" ).parent( "a" ).click(function(event){ event.preventDefault(); var currentHref = jQuery( this ).attr( "href" ); var checkSource = currentHref.toLowerCase(); if( currentHref != "" && (checkSource.indexOf(".gif") != -1 || checkSource.indexOf(".jpg") != -1 || checkSource.indexOf(".png") != -1 ) ){ event.preventDefault(); jQuery.fn.modalBox({ directCall : { image : currentHref } }); } else { location.href = currentHref; } }); } /************************ initModalboxContent / END ************************/ /************************ initReplaceValueOnBlur / BEGIN ************************/ function initReplaceValueOnBlur(settings){ /* Example: ---------------------------------------------------------------- */ var settings = jQuery.extend({// default settings selector : 'input.replaceValueOnBlur', currentValue : '', isKeyPressed : false }, settings || {} ); jQuery( settings.selector ).unbind( "focusin focusout keypress" ).bind("focusin focusout keypress", function(event){ var thisObj = jQuery(this); var getValue = thisObj.val(); if( event.type == 'focusin' && !settings.isKeyPressed ){ if( getValue != ''){ settings.currentValue = getValue; } // reset value thisObj.val( '' ); } else if( event.type == 'focusout' && getValue == '' ){ // refill value thisObj.val( settings.currentValue ); // start "reset" and "refill" settings.isKeyPressed = false; } else if( event.type == 'keypress' ){ if( getValue == '' ){ // start "reset" and "refill" settings.isKeyPressed = false; } else { // stop "reset" and "refill" settings.isKeyPressed = true; } } }); } /************************ initReplaceValueOnBlur / END ************************/ /************************ initBase64TextDecoder / BEGIN ************************/ function initBase64TextDecoder(settings){ /* Example: ---------------------------------------------------------------- bXkgdGVzdCBzdHJpbmc= Online-Encoder: http://www.motobit.com/util/base64-decoder-encoder.asp */ var settings = jQuery.extend({// default settings selector : '.base64encoded' }, settings || {} ); if( jQuery(settings.selector).length > 0 ){ jQuery( settings.selector ).each(function(){ var thisObj = jQuery( this ); var getText = thisObj.text(); if( getText != "" ){ thisObj.text( base64Decode( getText ) ); } }); } } /************************ initBase64TextDecoder / END ************************/ /************************ prepareHeaderNavi / BEGIN ************************/ function prepareHeaderNavi(){ var headerNaviObj = jQuery( "#header .headerNavi" ); var getSubmenue = headerNaviObj.find( "ul.navi li ul li ul" ).parent( "li" ); var getSearchItem = headerNaviObj.find( "ul.navi li.search_item" ); if( !getSearchItem.hasClass("startAnimation") ){ if( typeof(getSearchItem.attr("searchitemlastwidth")) == "undefined" ){ getSearchItem.attr({ 'searchitemlastwidth' : getSearchItem.width() }); } var getWidthOfSearchItem = getSearchItem.attr( "searchitemlastwidth" ); var getWidthOfListItems = 60; // 60 == spacer headerNaviObj.find( "ul.navi li:visible" ).each(function(){ if( !jQuery(this).hasClass("search_item") ){ getWidthOfListItems += jQuery(this).width(); } }); var widthOfHeaderNaviObj = ( headerNaviObj.width() - getWidthOfSearchItem ); var hidingSearch = ( (widthOfHeaderNaviObj - getWidthOfListItems) <= 10 ); var setFinalWidth = ( hidingSearch ? 50 : getWidthOfSearchItem ); getSearchItem.addClass( "startAnimation" ).animate({ width : setFinalWidth + 'px' }, 400, function(){ var thisObj = jQuery( this ); var searchformHeaderObj = thisObj.find( "#searchformHeader" ); if( hidingSearch ){ thisObj.find( "#searchformHeader" ).hide(); if( jQuery(".searchformHeaderShowHide").length == 0 ){ thisObj.append( '
' ); } var searchformHeaderShowHideObj = thisObj.find( ".searchformHeaderShowHide" ); searchformHeaderShowHideObj.fadeIn( "fast" ).mouseover(function(){ jQuery( this ).fadeOut("fast", function(){ searchformHeaderObj.fadeIn("fast", function(){ getSearchItem.width( getWidthOfSearchItem ); headerNaviObj.find( "ul.navi li:visible:not('.search_item, .iconHome')" ).fadeOut( "fast" ); }).unbind( "mouseleave" ).bind("mouseleave", function(){ jQuery( this ).fadeOut("fast", function(){ searchformHeaderShowHideObj.fadeIn( "fast" ); headerNaviObj.find( "ul.navi li:not('.search_item, .iconHome')" ).fadeIn( "fast" ); }); }); }); }); } else { thisObj.find( ".searchformHeaderShowHide" ).fadeOut("fast", function(){ searchformHeaderObj.fadeIn( "fast" ); }); } thisObj.removeClass( "startAnimation" ); }); } // hasSubmenue if( !getSubmenue.hasClass("hasSubmenue") ){ getSubmenue.addClass( "hasSubmenue" ); } } /************************ prepareHeaderNavi / END ************************/ /************************ prepareHeaderLogo / BEGIN ************************/ function prepareHeaderLogo(){ var logoObj = jQuery( "#header .logo:not('.customLogo')" ); logoObj.css({ minWidth : ( logoObj.find( ".logoLeft" ).outerWidth(true) + logoObj.find( ".logoRight" ).outerWidth(true) ) }); } /************************ prepareHeaderLogo / END ************************/ /************************ preparePhotoGrid / BEGIN ************************/ function preparePhotoGrid(){ var photoGridCellObj = jQuery( "#content .photoGridCell" ); var photoGridInnerObj = photoGridCellObj.find( ".photoGridCellInner .photoGridCellInnerBody" ); var photoGridCellAddClassName = ''; var getLargeSource = false; // step 1: reset classes first photoGridCellObj.css({ visibility : 'hidden' }).removeClass( 'microBox smallBox mediumBox bigBox' ); // step 2: get dimensions var photoGridInnerObjDimensions = [ photoGridInnerObj.width(), photoGridInnerObj.height() ]; if( photoGridInnerObjDimensions[0] > 270 ){ photoGridCellAddClassName = 'bigBox'; getLargeSource = false; } else if ( photoGridInnerObjDimensions[0] > 190 ){ photoGridCellAddClassName = 'mediumBox'; getLargeSource = true; } else if ( photoGridInnerObjDimensions[0] > 55 ){ photoGridCellAddClassName = 'smallBox'; getLargeSource = true; } else { photoGridCellAddClassName = 'microBox'; getLargeSource = false; } photoGridInnerObj.find( ".photoGridHover" ).css({ visibility : 'hidden' }); photoGridCellObj.addClass( photoGridCellAddClassName ).css({ visibility : 'visible' }); photoGridInnerObj.each(function(){ var thisObj = jQuery( this ); /*~~~ renew image source - BEGIN ~~~*/ var getLastImageSourceMedium = thisObj.find( ".photoGridCellImage input[type='hidden'][name='photogridimage_src_medium']" ).val(); var getLastImageSourceLarge = thisObj.find( ".photoGridCellImage input[type='hidden'][name='photogridimage_src_large']" ).val(); // override image source thisObj.find( ".photoGridCellImage img.wp-post-image" ).attr({ src : ( getLargeSource ? getLastImageSourceLarge : getLastImageSourceMedium ) }); /*~~~ renew image source - END ~~~*/ if( !thisObj.hasClass("prepareSuccessful") ){ var getPostLink = thisObj.find( ".photoGridCellContent .entry-title a" ).attr( "href" ); var getZoomImage = thisObj.find( ".photoGridCellImage input[type='hidden'][name='photogridimage_src_full']" ).val(); var createHover = ''; if( typeof(getZoomImage) != "undefined" ){ thisObj.find( ".photoGridCellContent" ).addClass( "photoGridCellContentFadeinFadeOut" ).find( ".calendar" ).css({ visibility : 'visible', display : 'none' }); } createHover += ''; thisObj.append( createHover ).addClass( "prepareSuccessful" ); } }).unbind( "mouseenter mouseleave" ).bind("mouseenter mouseleave", function(event){ var thisObj = jQuery(this); if( !photoGridCellObj.hasClass("microBox") ){ var photoGridHoverObj = thisObj.find( ".photoGridHover" ); var getHoverDimensions = [ photoGridHoverObj.width(), thisObj.height() ]; if( event.type == 'mouseenter' ){ if( !thisObj.hasClass("animationLeftDone") ){ thisObj.addClass( "animationLeftDone" ).removeClass( "animationRightDone" ).find( ".photoGridHover" ).css({//reset position first top : (getHoverDimensions[1] - 80) + 'px', left : '-' + getHoverDimensions[0] + 'px', visibility : 'visible' }).animate({ left: '+=' + getHoverDimensions[0] + 'px' }, "fast", function(){ // Animation complete. }).prev( ".photoGridCellContentFadeinFadeOut" ).find( ".calendar" ).fadeIn( "fast" ); }; } else if( event.type == 'mouseleave' ){ if( !thisObj.hasClass("animationRightDone") ){ thisObj.addClass( "animationRightDone" ).removeClass( "animationLeftDone" ).find( ".photoGridHover" ).animate({ left: '-=' + getHoverDimensions[0] + 'px' }, "fast", function(){ // Animation complete. }).prev( ".photoGridCellContentFadeinFadeOut" ).find( ".calendar" ).fadeOut( "fast" ); }; } } }).find( ".photoGridHoverDetailview, .photoGridHoverZoom" ).die( "click mouseover mouseout" ).live("click mouseover mouseout", function(event){ var thisObj = jQuery(this); var getCurrentSrc = ''; var getDimensionsOfZoomImage = 55; if( event.type == 'click' ){ if( thisObj.is(".photoGridHoverDetailview") ){ getCurrentSrc = thisObj.find( "input[type='hidden'][name='photoblock_postlink']" ).val(); if( getCurrentSrc != '' ){ window.location.href = getCurrentSrc; } } else if( thisObj.is(".photoGridHoverZoom") ){ var getWidthOfWindow = parseInt( jQuery( window ).width() / 1.5 ); getCurrentSrc = thisObj.find( "input[type='hidden'][name='photoblock_zoomimage_link']" ).val(); if( getCurrentSrc != '' ){ jQuery.fn.modalBox({ directCall : { image : getCurrentSrc } }); } } } else if( event.type == 'mouseover' ){ thisObj.addClass( "hoverEvent" ); } else if( event.type == 'mouseout' ){ thisObj.removeClass( "hoverEvent" ); } }); } /************************ preparePhotoGrid / END ************************/ /************************ checkDimensionsOfViewport / BEGIN ************************/ function checkDimensionsOfViewport(){ var bodyObj = jQuery( "body" ); var widthOfWindow = jQuery( window ).width(); if( widthOfWindow <= 900 ){ bodyObj.removeClass( "mediumViewport largeViewport" ).addClass( "smallViewport" ); } else if( widthOfWindow <= 1180 ){ bodyObj.removeClass( "smallViewport largeViewport" ).addClass( "mediumViewport" ); } else { bodyObj.removeClass( "smallViewport mediumViewport" ).addClass( "largeViewport" ); } } /************************ checkDimensionsOfViewport / END ************************/ /************************ document ready / BEGIN ************************/ jQuery(document).ready(function(){ initModalboxContent(); initReplaceValueOnBlur(); initBase64TextDecoder(); }); /************************ document ready / END ************************/ /************************ window load, resize / BEGIN ************************/ jQuery(window).load(function(){ prepareHeaderNavi(); prepareHeaderLogo(); preparePhotoGrid(); checkDimensionsOfViewport(); }).resize(function(){ prepareHeaderNavi(); preparePhotoGrid(); checkDimensionsOfViewport(); }); /************************ window load, resize / END ************************/