javascriptkcfinder

Is there a way to open KCFinder in a lightbox, not through window.open?


The title says it all really, the way it works at the moment it will open as a popup in a new window, the problem I've found with this is that if you already have the window open and click the button to open up the popup, nothing will happen.

This means that people could potentially have the window open without realising, and get frustrated at clicking the button and having nothing happen.

Hope that makes sense, but the only way I can think to counter this would be to open KCFinder in a lightbox on the page, any ideas if this is possible?


Solution

  • I don't think there's a way to open it in a light box but you can record the name of the window it opens then check to see if the window is open and focus on it if it is already open. Try this:

    window.KCFinder = {
        callBack: function(fileUrl) {
            // do something with fileUrl
            window.KCFinder = null;
        }
    };
    
    if(typeof kcwindow == 'undefined' || kcwindow.closed) {
        kcwindow = window.open('/eshop/kcfinder/browse.php?type=images', 'kcfinder_textbox', 
            'status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=1, scrollbars=0, width=800, height=500'
        );
    } else {
        kcwindow.focus();
    }