Location: PHPKode > scripts > jQueryP > jqueryp/jQueryP_test.php
<?php
/**
 *	@package jQueryP
 *
 *	
 *
 *	04/29/2009
 *	@author Sam Shull <hide@address.com>
 *	@version 0.5
 *
 *	@copyright Copyright (c) 2009 Sam Shull <hide@address.com>
 *	@license <http://www.opensource.org/licenses/mit-license.html>
 *
 *	Permission is hereby granted, free of charge, to any person obtaining a copy
 *	of this software and associated documentation files (the "Software"), to deal
 *	in the Software without restriction, including without limitation the rights
 *	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 *	copies of the Software, and to permit persons to whom the Software is
 *	furnished to do so, subject to the following conditions:
 *	
 *	The above copyright notice and this permission notice shall be included in
 *	all copies or substantial portions of the Software.
 *	
 *	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 *	THE SOFTWARE.
 *
 *
 */
 
	function test_callback ()
	{
		$arguments = func_get_args();
		return '$(document.body).append("<br>Click: <code>"+' . json_encode(print_r($arguments, true)) . '+"</code>");';
	}
	
	function all_events ($event)
	{
		return '$(document.body).append("<br>'.$event->type.': <code>"+' . json_encode(print_r($event, true)) . '+"</code>");';
	}
	
	require "jQueryP.class.php";
?>
<html>
    <body style="height:6000px;">
        <input id="test"/>
        <table id="table">
        	<tr>
            	<td>Column 1</td>
                <td>Column 2</td>
            </tr>
            <tr>
            	<td>Column 1</td>
                <td>Column 2</td>
            </tr>
        </table>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
        <!--<script type="text/javascript" src="jquery.animate.colors.js"></script>-->
        <script type="text/javascript">
			$(function($){
			<?php
				//call this first, but in a script tag
				//to set the jQuery._encodeArguments function
				print jQueryP::setupProxies();
				
				$all_events = jQueryP::createProxy(array('callback' => 'all_events'));
				
				$window = JSVar('window');
				
				$begin_opacity = 0.9;
				$end_opacity = 0.1;
				
				
				print jQueryP($window)
								->bind('scroll user_event', $all_events)
								->toString();
								
				print jQueryP(JSVar('document.body'))
								//add a server side callback to the click event	
								->click(jQueryP::createProxy(array('callback' => 'test_callback')))
								->keyup($all_events)
								->toString();
				
				
				print 'var test = ' . 
						jQueryP('#test')
							->bind('mouseenter', jQueryP::createProxy(array('callback' => 'all_events')))
							->css(
								array(
										'border' 		=> '5px solid red', 
										'opacity' 		=> $begin_opacity,
										'position'		=> 'absolute',
										'top'			=> 0,
										'left'			=> 0,
								)
							)
							->animate(
								array(
										'opacity' 		=> $end_opacity,
										'top'			=> JSVar('screen.height/2'),
										'left'			=> JSVar('screen.width/2'),
										//'borderColor'	=> 'CadetBlue',
								), 
								1000, 
								JSFunction(
									JSVar('test')
										->animate(
											array(
													'opacity' 		=> $begin_opacity,
													'top'			=> 0,
													'left'			=> 0,
													//'borderColor'	=> 0xFF0000,
											), 
											1000,
											JSFunction(
												JSVar("test")
													->animate(
														array(
																'opacity' 		=> $end_opacity,
																'top'			=> JSVar('screen.height/2'),
																'left'			=> JSVar('screen.width/2'),
																//'borderColor'	=> 'LimeGreen',
														), 
														1000,
														JSFunction(
															JSVar("test")
																->animate(
																	array(
																			'opacity' 		=> $begin_opacity,
																			'top'			=> 100,
																			'left'			=> 0,
																			//'borderColor'	=> 0xFF0000,
																	), 
																	1000
																)
														)
													)
											)
										)
								)
							);
				
				print jQueryP($window)
								->triggerHandler('user_event')
								->toString();
			
			?>
				test.val("25");
			});
        </script>
    </body>
</html>
Return current item: jQueryP