conflit between colorbox and navigation script

vincent3569 Member, Translator
hello

with my zpArdoise theme, I have a conflit between the javascript of colorbox plugin and my personnal javascript for navigation with keyboard.

both scripts try to examine key events, but mine is used first and I want that colorbox script to be used first.

Do you have an idea to fix this issue ?

Maybe, is a variable who said that colorbox is used ?
I could use this variable to disable my javascript...

Thanks for you help.

Comments

  • I'm also interested in a solution to that «issue».
  • vincent3569 Member, Translator
    hi binoyte

    you can download my themes zpArdoise and i-feel-dirty which solve the problem.

    with i-feel-dirty, have a look on inc_header.php, lines 58 to 104, which allow keyboard navigation on image and news with, without conflict with colorbox :

    `

    <?php if (($_zp_gallery_page == 'image.php') || ((function_exists('is_NewsArticle')) && (is_NewsArticle()))) { ?>



    //<![CDATA[<br />
    <?php $NextURL = $PrevURL = false; ?>

    <?php if ($_zp_gallery_page == 'image.php') { ?>

    <?php if (hasNextImage()) { ?>var nextURL = "<? echo html_encode(getNextImageURL()); $NextURL = true; ?>";<?php } ?>

    <?php if (hasPrevImage()) { ?>var prevURL = "<? echo html_encode(getPrevImageURL()); $PrevURL = true; ?>";<?php } ?>

    <?php } else { ?>

    <?php if ((function_exists('checkForPage')) && (is_NewsArticle())) { ?>

    <?php if (getNextNewsURL()) { $article_url = getNextNewsURL(); ?>var nextURL = "<?php echo html_decode($article_url['link']); $NextURL = true; ?>";<?php } ?>

    <?php if (getPrevNewsURL()) { $article_url = getPrevNewsURL(); ?>var prevURL = "<?php echo html_decode($article_url['link']); $PrevURL = true; ?>";<?php } ?>

    <?php } ?>

    <?php } ?>

    var ColorboxActive = false; // cohabitation entre script de navigation et colorbox

    function keyboardNavigation(e) {

    if (ColorboxActive) return true; // cohabitation entre script de navigation et colorbox

    if (!e) e = window.event;

    if (e.altKey) return true;

    var target = e.target || e.srcElement;

    if (target && target.type) return true; //an input editable element

    var keyCode = e.keyCode || e.which;

    var docElem = document.documentElement;

    switch(keyCode) {

    case 63235: case 39:

    if (e.ctrlKey || (docElem.scrollLeft == docElem.scrollWidth-docElem.clientWidth)) {

    <?php if ($NextURL) { ?>window.location.href = nextURL; <?php } ?>return false; }

    break;

    case 63234: case 37:

    if (e.ctrlKey || (docElem.scrollLeft == 0)) {

    <?php if ($PrevURL) { ?>window.location.href = prevURL; <?php } ?>return false; }

    break;

    }

    return true;

    }

    document.onkeydown = keyboardNavigation;

    // cohabitation entre script de navigation et colorbox

    $(document).bind('cbox_open', function() {ColorboxActive = true; })

    $(document).bind('cbox_closed', function() {ColorboxActive = false; });

    //]]>



    <?php } ?>

    `

Sign In or Register to comment.