• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
modalWindow with xajax

#1
[eluser]Unknown[/eluser]
>:-( I am trying to install This Plugin http://www.amp-lified.de/file.php?14
that allows you to add one or more Modal Windows in your web-application , it was made with xajax , i dont know how to setup those libraries in my application ,,

http://xajaxproject.org/plugins/default/view/17

$core = './xajax/xajax_core';
require_once( $core . '/xajax.inc.php' );
$xajax = new xajax();
require_once( $core . '/xajaxPlugin.inc.php' );
require_once( $core . '/xajaxPluginManager.inc.php' );
require_once './xajax/xajax_plugins/response/modalWindow/modalWindow.inc.php';


$objResponse = new xajaxResponse();
$objResponse->plugin( 'clsmodalWindow', 'addWindow', $windowcontent); >Sad


could you give me a hand thanks a lot

#2
[eluser]Unknown[/eluser]
It works fine for me. I'm using PHP5, CI 1.6, xajax_0.5b4, und modalWindow_0.0.3 from amp-lified.de.
The trick is to set correct location for the javascript. As we see in line 124, modalWindow.inc.php
The path is hardcoded in this script.


--Step 1-- Directory Structure
Code:
mySite [top-level]
    |-- system
    |
    |-- app
    |    |-- controller
    |    |    testxajax.php
    |    |
    |    |-- init
    |    |    init_xajax.php    
    |    |        
    |    |-- libraries
    |    |    |-- xajax-core
    |    |    xajax.php (moved from xajax-core/xajax.inc.php)
    |    |    |-- xajax-plugins
    |    |    |    |-- response
    |    |    |    |    modalWindow.inc.php (or anywhere)
    |    |
    |    |-- views
    |    |    |-- test    
    |
    |-- js (collection of all my javascript)
    |    |-- xajax-js
    |    |-- xajax-plugins
    |    |    |-- response
    |    |    |    |-- modalWindow  (hardcoded path)
    |    |    |    |    modalWindow.js

--Step 2-- Configuration
--A--
we should go to line 248, xajax.php, alter:
$sLocalFolder = dirname(__FILE__)."/xajax_core";

--B--
index.php in root,
$application_folder = "../app";

--C--
From CI Wiki

app/init/init_xajax.php
Code:
if ( ! class_exists('xajax') )
        require_once(APPPATH.'libraries/xajax'.EXT);


--Step 3-- Views and Controller
Based on wiki xajax perfect

--A-- Test modalWindow
app/views/test/test_xajaxplugin.php
Code:
<html>
<head>
    <title>modal Window Plugin</title>
    <?=$xajax_js?>    
    <style type="text/css">
        body {
            font-size: 10px;    font-family: Arial, Helvetica, sans-serif;        
            color:#3F4752;    background: #FFFFFF;
        }    
        a    {    color:#3F4752;    text-decoration:none;    }
    </style>    
</head>

<body>
    <h1>modal Window</h1>
    &lt;input type="button" onclick="xajax_testWindow();" value="show modal window" /&gt;
&lt;/body&gt;
&lt;/html&gt;

--B-- Testing Controller
Here comes the best part.
app/controllers/testxajax.php
Code:
&lt;?php
Class Testxajax Extends Controller {

    function __construct () {
        parent::__construct();    
        
        $this->load->library('xajax');        
        $this->xajax->setFlag("debug", true);        

        require_once( APPPATH.'libraries/xajax_plugins/response/modalWindow.inc.php');                
    }
    
    //-- CI's Segment
    public function modal() {    
        $this->xajax->register(XAJAX_FUNCTION, array('testWindow',&$this,'testWindow'));    
        $this->xajax->register(XAJAX_FUNCTION, array('actionClose',&$this,'actionClose'));
        $this->xajax->processRequest();
    
        $data['xajax_js'] = $this->xajax->getJavascript('../js/');
        $this->load->view('test/test_xajaxplugin', $data);          
    }    
    
    //-- XAJAX's Function  
    public function testWindow() {    
        $objResponse = new xajaxResponse();
        $objResponse->plugin( 'clsmodalWindow', 'addWindow',
            $this->windowContentTest(), '#000000', 20 );
        return $objResponse;
    }

    public function actionClose($data) {
        // now you can close your window, or, if you want, open a new window        
        $objResponse = new xajaxResponse();
        
        if ( $data['windowoption'] == 1 )    {
            $objResponse->plugin( 'clsmodalWindow', 'addWindow',
                $this->windowContentSubmit($data), 'red', 20 );
        }    else    {
            $objResponse->plugin( 'clsmodalWindow', 'closeWindow');
        }    
    
        return $objResponse;
    }        
    
    //-- Serve View
    private function windowContentTest() {
        $width = rand( 100, 500 );
        $height = rand( 100, 500 );
        $id = md5(microtime());
        
        return '
    <div    style="width:' . $width . 'px;height:' . $height . 'px;
            background:#FFFFFF;color:#000000;border:1px solid #999999;padding:5px">
        &lt;a href="[removed]void(0)"    onclick="xajax.closeWindow()"    &gt;close</a><br/>
        &lt;a href="[removed]void(0)"    onclick="xajax_testWindow()"    &gt;open new Window</a><br/>
        &lt;form id="' . $id . '" method="post" enctype="multipart/form-data"&gt;
        <select name="windowoption" style="width:100px;">
            <option value="1">open new window</option>
            <option value="2">close window</option>
        </select><br>
        &lt;input name="testinput" value="" type="text" style="width:100px;"/&gt;
        &lt;/form&gt;
        &lt;a    href="[removed]void(0)"
                onclick="xajax_actionClose(xajax.getFormValues(\'' . $id . '\'))"
        &gt;submit formdata</a><br/>
    </div>';        
    }
    
    private function windowContentSubmit($data) {
        // do something with data...    
        $content = print_r( $data, true );
        return '            
        <div    style="width:200px;height:200px;
                background:#456789;color:#000000;border:1px solid #999999;padding:5px">
            &lt;a href="[removed]void(0)" onclick="xajax.closeWindow()"&gt;close</a><br/>
            ' . $content . '
         </div>';
    }    

}    // class
?&gt;

I think the code is clear enough.

I wish this could help.

~epsi sayidina [: little gnubie :]

#3
[eluser]Unknown[/eluser]
thank u it works very well !!!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.