Topic: modal window again

Hi gang,

Fiddling with the modal window again, and getting some odd results.
The modal window displays fine, but the background does not darken to "black out" the
existing page it was spawned from.
$objResponse = new xajaxResponse();
        $objResponse->plugin( 'clsmodalWindow', 'addWindow', $this->windowContent('full', $value),
            array(
                'color'     =>  '#000000',
                'opacity'   =>  20,
                'frame'     =>  'parent',
                'bOverlay'  =>  true) );

What I have noticed odd, is the response from the debug.....


RECEIVED [status: 200, size: 1228 bytes, time: 264ms]:
<?xml version="1.0" encoding="utf-8" ?>
<xjx>
<cmd cmd="mw:aw" plg="clsmodalWindow">
<xjxobj>
<e><k>N0</k><v><![CDATA[S<div style="width:450px;height:300px;background:#FFFFFF;color:#000000;border:1px solid #999999;padding:5px">
        <a href="javascript:void(0)" onclick="xjxmW.closeWindow()">close</a><br/>
        <a href="javascript:void(0)" onclick="xajax_testWindow()">open new Window</a><br/>
        <form id="69c682d74dbc2f6e4e68809a250ae77f" method="post" enctype="multipart/form-data">
        <select name="windowoption" style="width:100px;"><option value="1">open new window</option><option value="2">close window</option></select><br>
        <input name="testinput" value="" type="text" style="width:100px;"/>
        </form>
        <a href="javascript:void(0)" onclick="xajax_actionClose(xajax.getFormValues('69c682d74dbc2f6e4e68809a250ae77f'))">submit formdata</a><br/>
        </div>]]></v></e>
<e><k>N1</k><v>
<xjxobj>
<e><k>Scolor</k><v>S#000000</v></e>
<e><k>Sopacity</k><v>N20</v></e>
<e><k>Sframe</k><v>Sparent</v></e>
<e><k>SbOverlay</k><v>B1</v></e>
</xjxobj>
</v></e>
<e><k>N2</k><v>*</v></e>
<e><k>N3</k><v>*</v></e>
<e><k>N4</k><v>Sparent</v></e>
<e><k>N5</k><v>N100</v></e>
</xjxobj>
</cmd>
</xjx>


There seems to be two sections with the Sparent... I dont know that this is expected or not,
but I have not seen it elsewhere, and is the only thing I can put my finger on, as in the test
it is not present.

Kind regards
Kevin

Re: modal window again

Yes that's very weird output, the <e><k>N0</k> etc is the way xajax passes an array so I don't see how that's getting generated.

You might check that you're including the latest version of modalWindow both php and js as I think the argument passing changed.

Anyway the test script below works for me and might be of use. It's quite cute actually as the background gets darker and darker the more windows you open and lightens up again as you close them.

<?php
require_once AJAX_FULLDIR . 'xajax.inc.php'; // NOTE: Change for your system.
require_once AJAX_FULLDIR . 'xajaxPluginManager.inc.php';
require_once AJAX_FULLDIR . '../xajax_plugins/response/modalWindow/modalWindow.inc.php';

function testWindow($count) {
    error_log("testWindow($count)");
    $window_content = <<<EOT
<div style="width:450px;height:300px;background:#FFFFFF;color:#000000;border:1px solid #999999;padding:5px">
<a href="javascript:void(0)" onclick="xajax_closeWindow()">close</a><br/>
<a href="javascript:void(0)" onclick="xajax_testWindow(XXXX)">open new Window</a><br/>
<form id="form_XXXX" method="post" enctype="multipart/form-data">
<select name="windowoption" style="width:100px;"><option value="1">open new window</option><option value="2">close window</option></select><br>
<input name="testinput" value="" type="text" style="width:100px;"/>
<input name="count" type="hidden" value="XXXX"/>
</form>
<a href="javascript:void(0)" onclick="xajax_actionClose(xajax.getFormValues('form_XXXX'))">submit formdata</a><br/>
</div>
EOT;
    $window_content = str_replace('XXXX', $count + 1, $window_content);
    $args = array('color' =>  '#000000', 'opacity' =>  20, 'frame' =>  'parent', 'bOverlay' =>  true);
    $objResponse = new xajaxResponse;
    $objResponse->plugin('clsmodalWindow', 'addWindow', $window_content, $args);
    return $objResponse;
}

function closeWindow() {
    error_log("closeWindow");
    $objResponse = new xajaxResponse;
    $objResponse->plugin( 'clsmodalWindow', 'closeWindow');
    return $objResponse;
}

function actionClose($form_data) {
    error_log("actionClose form_data=" . print_r($form_data, true));
    if ($form_data['windowoption'] == 1) return testWindow($form_data['count']);
    if ($form_data['windowoption'] == 2) return closeWindow();
    return new xajaxResponse;
}

$xajax = new xajax;

$xajax->configure('javascript URI', AJAX_URI_PATH); // NOTE: Change for your system.
$xajax->register(XAJAX_FUNCTION, 'testWindow');
$xajax->register(XAJAX_FUNCTION, 'closeWindow');
$xajax->register(XAJAX_FUNCTION, 'actionClose');

$xajax->processRequest();

?>
<html>
<head>
<title>Test</title>
<?php $xajax->printJavascript(); ?>
</head>
<body>
<input type="button" value="test" onclick="xajax_testWindow(1);">
</body>
</html>