├── examples ├── chat.php ├── docs │ ├── php2javascript │ │ ├── elements_style.php │ │ ├── document.getElementById.php │ │ └── about.php │ ├── element_functions.php │ ├── php2javascript.php │ ├── resources │ │ └── css │ │ │ └── table.css │ ├── template.php │ ├── upgrading.php │ ├── manipulating_container.php │ ├── includes.php │ ├── access_fields_in_parameters.php │ ├── index.php │ ├── url_styles.php │ └── triggers.php ├── arc.php ├── resources │ ├── images │ │ ├── arrow.gif │ │ ├── try_it.png │ │ ├── console_error.png │ │ ├── cool_sunglasses.jpg │ │ ├── nav_bg_darker.jpg │ │ └── nav_separator_darker.jpg │ ├── send_form │ │ ├── top.png │ │ ├── blank.gif │ │ ├── bottom.png │ │ ├── shadow.gif │ │ ├── view.js │ │ └── iepngfix.htc │ ├── other │ │ └── test.js │ ├── css │ │ ├── style.css │ │ └── table.css │ └── html │ │ ├── test.html │ │ ├── login.html │ │ ├── test_form.html │ │ └── not_found.html ├── controllers │ ├── helper.php │ ├── post.php │ ├── pagination.php │ ├── alert.php │ ├── confirm.php │ ├── validation_uploader.php │ ├── params.php │ ├── keyup_update.php │ ├── click_ajax_request.php │ ├── controller.php │ ├── test.php │ ├── flush.php │ ├── bind.php │ ├── parameters.php │ ├── send_form.php │ ├── invalidate.php │ ├── send_input.php │ ├── ajax_request.php │ ├── overlay.php │ ├── update.php │ ├── recursive_ajax.php │ ├── messages.php │ ├── overlay_validation.php │ ├── search.php │ ├── calc.php │ ├── call.php │ ├── ajax_login.php │ ├── dropdown.php │ ├── progressbar.php │ ├── change_value.php │ └── upload_file.php ├── .htaccess ├── triggers.php ├── ajax.php ├── template_form.php ├── test.php ├── what_is_cjax.php ├── click.php ├── location.php ├── confirm_action.php ├── template.php ├── prepend.php ├── keypress.php ├── load_html_file.php ├── update.php ├── append.php ├── cross_domain_ajax.php ├── post.php ├── replace.php └── send_form.php ├── cjax ├── core │ ├── js │ │ ├── index.html │ │ ├── .htaccess │ │ └── cjax.js.php │ ├── classes │ │ ├── index.html │ │ ├── ext.class.php │ │ ├── std.class.php │ │ └── format.class.php │ ├── cache │ │ └── .htaccess │ ├── images │ │ ├── ok.gif │ │ ├── alert.gif │ │ ├── error.gif │ │ ├── loader.gif │ │ ├── close-x.png │ │ ├── loadingf.gif │ │ ├── process.gif │ │ ├── close-x-hover.png │ │ └── .htaccess │ ├── css │ │ └── .htaccess │ └── templates │ │ ├── .htaccess │ │ └── overlay.html ├── plugins │ ├── uploader │ │ ├── css │ │ │ └── style.css │ │ ├── .htaccess │ │ └── uploader.php │ ├── spin │ │ ├── .htaccess │ │ ├── fonts │ │ │ ├── oxp-demo.eot │ │ │ ├── oxp-demo.ttf │ │ │ ├── oxp-demo.woff │ │ │ ├── Elusive-Icons.eot │ │ │ ├── Elusive-Icons.ttf │ │ │ ├── Elusive-Icons.woff │ │ │ └── oxp-demo.svg │ │ ├── css │ │ │ └── style.css │ │ └── spin.js │ ├── autocomplete │ │ ├── .htaccess │ │ ├── css │ │ │ └── style.css │ │ ├── autocomplete.js │ │ └── helper.js │ ├── pagination │ │ ├── .htaccess │ │ └── pagination.css │ ├── progressbar │ │ ├── img │ │ │ ├── cj.png │ │ │ └── check.png │ │ └── progressbar.js │ ├── uploadify │ │ ├── uploadify-3.2 │ │ │ ├── uploadify.swf │ │ │ ├── browse-btn.png │ │ │ ├── uploadify-cancel.png │ │ │ ├── check-exists.php │ │ │ ├── Change Log.txt │ │ │ ├── uploadify.php │ │ │ ├── index.php │ │ │ ├── license.txt │ │ │ └── uploadify.css │ │ ├── .htaccess │ │ ├── uploadify.js │ │ ├── controllers │ │ │ └── uploadify.php │ │ └── uploadify.php │ ├── animate │ │ └── animate.js │ ├── validate │ │ ├── .htaccess │ │ ├── validate.php │ │ └── validate.js │ ├── basic │ │ ├── basic.js │ │ └── info.php │ ├── ExamplePlugin │ │ ├── controllers │ │ │ └── ExamplePlugin.php │ │ ├── css │ │ │ └── table.css │ │ └── ExamplePlugin.js │ └── hello_world │ │ └── hello_world.js ├── lib │ └── .htaccess ├── index.html ├── integration │ ├── codeigniter │ │ ├── application │ │ │ ├── controllers │ │ │ │ └── AjaxController.php │ │ │ ├── views │ │ │ │ ├── test.php │ │ │ │ └── test2.php │ │ │ └── response │ │ │ │ ├── sample.php │ │ │ │ └── test.php │ │ └── ajax.php │ └── default │ │ ├── testing.php │ │ └── ajax.php ├── includes.default.php ├── auth.default.php ├── integration.php └── config.default.php ├── response ├── .htaccess ├── test.php └── sample.php ├── htaccess.txt └── ajax.php /examples/chat.php: -------------------------------------------------------------------------------- 1 | '.print_r($_POST,1).''; 9 | } 10 | } -------------------------------------------------------------------------------- /cjax/plugins/uploader/.htaccess: -------------------------------------------------------------------------------- 1 | #Some systems might restrict access to remote unrecognized paths. This ensures the files are here are readable. 2 | Options +Indexes 3 | Order deny,allow 4 | Allow from all 5 | -------------------------------------------------------------------------------- /cjax/plugins/validate/.htaccess: -------------------------------------------------------------------------------- 1 | #Some systems might restrict access to remote unrecognized paths. This ensures the files are here are readable. 2 | Options +Indexes 3 | Order deny,allow 4 | Allow from all 5 | -------------------------------------------------------------------------------- /cjax/plugins/uploadify/.htaccess: -------------------------------------------------------------------------------- 1 | #Some systems might restrict access to remote unrecognized paths. This ensures the files are here are readable. 2 | Options +Indexes 3 | Order deny,allow 4 | Allow from all 5 | -------------------------------------------------------------------------------- /examples/controllers/pagination.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Access Denied 6 | 7 | 8 | This directory is not accessible. 9 | 10 | -------------------------------------------------------------------------------- /examples/controllers/alert.php: -------------------------------------------------------------------------------- 1 | alert($message); 11 | } 12 | } -------------------------------------------------------------------------------- /cjax/integration/codeigniter/application/controllers/AjaxController.php: -------------------------------------------------------------------------------- 1 | load->file(FCPATH.'ajax.php'); 8 | } 9 | 10 | } -------------------------------------------------------------------------------- /examples/controllers/confirm.php: -------------------------------------------------------------------------------- 1 | success("Do something.."); 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /examples/controllers/validation_uploader.php: -------------------------------------------------------------------------------- 1 | info($data . ' ' . $data2, 6); 12 | 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /examples/controllers/keyup_update.php: -------------------------------------------------------------------------------- 1 | document('title', $text); 10 | 11 | $ajax->div_response = $text; 12 | } 13 | } -------------------------------------------------------------------------------- /examples/controllers/click_ajax_request.php: -------------------------------------------------------------------------------- 1 | success("You clicked the button.. $message"); 11 | } 12 | } -------------------------------------------------------------------------------- /examples/ajax.php: -------------------------------------------------------------------------------- 1 | debug($_POST); 15 | } 16 | } -------------------------------------------------------------------------------- /examples/controllers/flush.php: -------------------------------------------------------------------------------- 1 | flush('#link1'); 10 | 11 | $ajax->info("Element has been flushed.. if you click it nothing will happen.",5); 12 | 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /cjax/plugins/basic/basic.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Basic Plugin Example 3 | * 4 | * basic.js 5 | */ 6 | 7 | //this is a very basic plugin demonstrating how to pass data accross. 8 | //look inside info.php for more comments and usage. 9 | function basic(a, b, c) 10 | { 11 | alert(this.test); 12 | 13 | } -------------------------------------------------------------------------------- /examples/controllers/bind.php: -------------------------------------------------------------------------------- 1 | info("same command.."); 20 | 21 | } 22 | } -------------------------------------------------------------------------------- /cjax/core/js/.htaccess: -------------------------------------------------------------------------------- 1 | #Some systems might restrict access to remote unrecognized paths. This ensures the files are here are readable. 2 | Options +Indexes 3 | Order deny,allow 4 | Allow from all 5 | 6 | 7 | RewriteEngine On 8 | #RewriteBase / 9 | #RewriteRule ^/?(cjax.*js)$ $1 [NC,QSA,L] 10 | 11 | -------------------------------------------------------------------------------- /examples/controllers/parameters.php: -------------------------------------------------------------------------------- 1 | alert($params); 16 | 17 | $ajax->update('params',$params); 18 | } 19 | } -------------------------------------------------------------------------------- /examples/controllers/send_form.php: -------------------------------------------------------------------------------- 1 | info("Validation Approved."); 10 | } 11 | 12 | function submit_form($form_fields) 13 | { 14 | $ajax = ajax(); 15 | 16 | $ajax->alert("Server Says....\n\nFields submitted: \n".print_r($form_fields,1)); 17 | } 18 | } -------------------------------------------------------------------------------- /htaccess.txt: -------------------------------------------------------------------------------- 1 | 2 | RewriteEngine On 3 | 4 | # If you are having problems with the rewrite rules, remove the "#" from the 5 | # line that begins "RewriteBase" below. You will also have to change the path 6 | # of the rewrite to reflect the path to your base path. 7 | #RewriteBase / 8 | 9 | 10 | RewriteRule ^/?ajax/(.*)$ ajax.php?$1 [NC,QSA,L] 11 | -------------------------------------------------------------------------------- /cjax/integration/codeigniter/application/views/test.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 |
6 |

Put your shades on, and get ready to run this test:

7 | Run Test 8 |
9 |
-------------------------------------------------------------------------------- /examples/controllers/invalidate.php: -------------------------------------------------------------------------------- 1 | invalid( 14 | array( 15 | 'text1'=> 'Enter Value..', 16 | 'text2'=> 'Enter Value..', 17 | 'text3'=> 'Enter Value..' 18 | ) 19 | ); 20 | } 21 | } -------------------------------------------------------------------------------- /cjax/integration/codeigniter/application/views/test2.php: -------------------------------------------------------------------------------- 1 | controller && $ajax->function) { 6 | 7 | //calling file, response/test.php:test() 8 | $ajax->call(array('test', 'test2handler')); 9 | } 10 | 11 | ?> 12 | 13 | 14 | Test 15 | init();?> 16 | 17 | 18 |
19 |
20 | 21 | -------------------------------------------------------------------------------- /examples/controllers/send_input.php: -------------------------------------------------------------------------------- 1 | success("This message was sent: $text",30); 11 | } 12 | 13 | function send_checkbox( $check ) 14 | { 15 | $ajax = CJAX::getInstance(); 16 | 17 | if($check) { 18 | $ajax->success("Is checked.."); 19 | } else { 20 | $ajax->warning("Is not checked.."); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /cjax/core/classes/ext.class.php: -------------------------------------------------------------------------------- 1 | $v) { 9 | $this->{$k} = $v; 10 | } 11 | } 12 | } 13 | 14 | function __set($setting, $value) 15 | { 16 | $this->$setting = $value; 17 | } 18 | 19 | function __get($setting) 20 | { 21 | if(isset($this->$setting)) { 22 | return $this->$setting; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /examples/controllers/ajax_request.php: -------------------------------------------------------------------------------- 1 | update('container1','This text was updated through ajax...'); 10 | 11 | $ajax->wait(2); 12 | 13 | $ajax->update('container2','This text too...'); 14 | 15 | $ajax->wait(3); 16 | 17 | $ajax->update('container2','And this....'); 18 | 19 | $ajax->wait(4); 20 | 21 | $ajax->update('container2','Updated!....'); 22 | } 23 | } -------------------------------------------------------------------------------- /cjax/plugins/uploadify/uploadify-3.2/check-exists.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | // Define a destination 9 | $targetFolder = '/uploads'; // Relative to the root and should match the upload folder in the uploader script 10 | 11 | if (file_exists($_SERVER['DOCUMENT_ROOT'] . $targetFolder . '/' . $_POST['filename'])) { 12 | echo 1; 13 | } else { 14 | echo 0; 15 | } 16 | ?> -------------------------------------------------------------------------------- /cjax/core/templates/overlay.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | 6 |
7 |
8 |
9 |
  10 |
11 |
12 |
-------------------------------------------------------------------------------- /examples/resources/css/style.css: -------------------------------------------------------------------------------- 1 | @CHARSET "ISO-8859-1"; 2 | 3 | 4 | #content { position: relative; margin: 0px; } 5 | 6 | .add { 7 | position:relative; 8 | width: 200px; 9 | height: 200px; 10 | float:left; 11 | margin-right:1px; 12 | background-color: #CEFFCE; 13 | } 14 | 15 | .odd { 16 | position:relative; 17 | width: 200px; 18 | height: 200px; 19 | float:left; 20 | margin-right:1px; 21 | background-color: #FFDDCC; 22 | } 23 | 24 | 25 | 26 | #container { 27 | clear:both; 28 | padding:0px; 29 | margin: 0px; 30 | margin-left: auto; 31 | margin-right: auto; 32 | } 33 | -------------------------------------------------------------------------------- /cjax/plugins/ExamplePlugin/controllers/ExamplePlugin.php: -------------------------------------------------------------------------------- 1 | 'test1','test2'=>'test2'); 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /cjax/plugins/uploadify/uploadify-3.2/Change Log.txt: -------------------------------------------------------------------------------- 1 | Uploadify Change Log 2 | Copyright (c) 2012 by Reactive Apps, Ronnie Garcia 3 | 4 | v3.2 5 | - Added a new option for itemTemplate where you can create an HTML template for the items that are added to the queue 6 | 7 | v3.1.1 8 | - Fixed issue with incorrect queueLength 9 | 10 | v3.1.0 11 | - Switched to the preferred jQuery plugin pattern 12 | - Added references to all elements 13 | - Removed flash based image 14 | - Added fallback method 15 | - Fixed onInit event 16 | - Added onDisable and onEnable events 17 | - Added SWFObject for flash detection 18 | - Added indication of cancelled files -------------------------------------------------------------------------------- /examples/controllers/overlay.php: -------------------------------------------------------------------------------- 1 | 2 | Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 3 |
4 |
5 | this text was loaded from file examples/resources/html/test.html 6 | -------------------------------------------------------------------------------- /examples/controllers/update.php: -------------------------------------------------------------------------------- 1 | content1 = $text; 13 | } 14 | 15 | 16 | } -------------------------------------------------------------------------------- /examples/template_form.php: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | Name: 6 |
7 |
8 | 9 |
10 |
11 |
12 |
13 | Last Name: 14 |
15 |
16 | 17 |
18 |
19 |
20 |
21 |
22 |
23 | 24 | 25 |
26 |
27 |
28 |
-------------------------------------------------------------------------------- /cjax/integration/default/testing.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | Test 9 | init(false);?> 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 | 18 |
19 |
20 |

Put your shades on, and get ready to run this test:

21 | Run Test 22 |
23 |
24 | 25 | 26 | 27 | 28 | 29 |
30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /examples/controllers/recursive_ajax.php: -------------------------------------------------------------------------------- 1 | 100) { 15 | $ajax->focus('count'); 16 | $ajax->warning("Too many requests can add overhead to our servers, please try reducing the number.", 5); 17 | $ajax->count = 30; 18 | return; 19 | } 20 | 21 | //update div 22 | $ajax->div_counter = "Call# $counter of $count.."; 23 | 24 | if($counter>=$count) { 25 | $ajax->div_counter ="$counter recursive AJAX requests were made."; 26 | } else { 27 | 28 | //fire call 29 | $ajax->call("ajax.php?recursive_ajax/call/$counter/$count"); 30 | } 31 | 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /cjax/plugins/hello_world/hello_world.js: -------------------------------------------------------------------------------- 1 | /* 2 | * plugin: hello_wold.js 3 | * 4 | * This plugin is for demontration purposes only, and it is only to show you some of the available 5 | * functions or variable at hand that you maybe you in the construction of your own plugin. 6 | * 7 | * 8 | */ 9 | 10 | function hello_world(a,b,c) 11 | { 12 | 13 | //sample of importing javascript into the scope 14 | //this.import('http://cjax.googlecode.com/svn/trunk/_extra/test_unit/plugins/js/test.js'); 15 | //sample of importing css to the page 16 | //this.import('http://cjax.googlecode.com/svn/trunk/_extra/test_unit/plugins/css/test.css'); 17 | 18 | //sample of preventing the next API $ajax->info() 19 | 20 | //this.overLayContent("Testing one is awesome.."); 21 | 22 | //CJAX.preventDefault(); 23 | 24 | //setTimeout('func2()',20000); 25 | 26 | //console.log('File base:', this.base); 27 | //console.log('This file:', this.file); 28 | //console.log('Paramters Passed:', a, b ,c); 29 | } -------------------------------------------------------------------------------- /examples/docs/php2javascript/document.getElementById.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | init();?> 9 | 10 | 11 |

getElementByid in PHP

12 | (5.0-RC2+) 13 |
14 | Syntax: $ajax->document([mixed property/function], [element_id], [callback]) 15 |
16 | Parameter: 17 |
18 | 32 |

Example

33 |
34 | 35 | 36 | code(" 39 | \$ajax->document(\"getElementById\",\"element_id\",\"function(element) { 40 | //your element is... 41 | alert(element); 42 | } 43 | \");" 44 | ); 45 | ?> 46 | 47 | -------------------------------------------------------------------------------- /cjax/plugins/uploadify/uploadify-3.2/uploadify.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | // Define a destination 9 | $targetFolder = '/uploads'; // Relative to the root 10 | 11 | $verifyToken = md5('unique_salt' . $_POST['timestamp']); 12 | 13 | if (!empty($_FILES) && $_POST['token'] == $verifyToken) { 14 | $tempFile = $_FILES['Filedata']['tmp_name']; 15 | $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder; 16 | $targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name']; 17 | 18 | // Validate the file type 19 | $fileTypes = array('jpg','jpeg','gif','png'); // File extensions 20 | $fileParts = pathinfo($_FILES['Filedata']['name']); 21 | 22 | if (in_array($fileParts['extension'],$fileTypes)) { 23 | move_uploaded_file($tempFile,$targetFile); 24 | echo '1'; 25 | } else { 26 | echo 'Invalid file type.'; 27 | } 28 | } 29 | ?> -------------------------------------------------------------------------------- /examples/controllers/messages.php: -------------------------------------------------------------------------------- 1 | process("You are about to see the type of messages you can display on the screen..",5); 10 | $ajax->update("msgs","You are about to see the type of messages you can display on the screen.."); 11 | $ajax->wait(5); 12 | 13 | $ajax->success($message. " Success message..."); 14 | $ajax->update("msgs"," Success message..."); 15 | $ajax->wait(5); 16 | 17 | $ajax->update("msgs"," Warning message..."); 18 | $ajax->warning("Warning message..."); 19 | $ajax->wait(5); 20 | 21 | $ajax->error($message. " Error Message..."); 22 | $ajax->update("msgs"," Error Message..."); 23 | $ajax->wait(5); 24 | 25 | $ajax->process($message. " You can run and display lots of stuff..",7); 26 | $ajax->update("msgs"," You can run and display lots of stuff.."); 27 | 28 | $ajax->wait(3); 29 | $ajax->update("msgs"," :) "); 30 | } 31 | } -------------------------------------------------------------------------------- /examples/test.php: -------------------------------------------------------------------------------- 1 | keypress('url', $ajax->call("ajax.php?test/remote/|url:encodeURIComponent|"), array(13,97,98,99)); 8 | 9 | ?> 10 | 11 | 12 | 13 | Test... 14 | init();?> 15 | 16 | 17 |

Keypress Event

18 |

19 | Support for keypress event (Cjax 5.4) 20 |
21 |

22 | code(" 24 | //Press enter, a, b or c, and the ajax request will go throgh. 25 | \$ajax->keypress('url', \$ajax->call(\"ajax.php?test/remote/|url:encodeURIComponent|\"), array(13,97,98,99)); 26 | 27 | //press enter and request will go through: 28 | \$ajax->keypress('url', \$ajax->call(\"ajax.php?test/remote/|url:encodeURIComponent|\"), 13); 29 | "); 30 | ?> 31 | 32 | 33 | -------------------------------------------------------------------------------- /examples/controllers/overlay_validation.php: -------------------------------------------------------------------------------- 1 | debug($_POST,'Post Debug Info',"These are the fields posted."); 10 | } 11 | 12 | function overlay2() 13 | { 14 | $ajax = ajax(); 15 | 16 | $rules = array( 17 | 'rules' => array( 18 | 'a[name]' => array( 19 | 'required' => true, 20 | 'minlength' => 5, 21 | ), 22 | 'a[last_name]' => array( 23 | 'required' => true, 24 | 'minlength' => 5, 25 | ) 26 | ), 27 | 'messages' => array( 28 | 'a[name]' => array( 29 | 'required' => 'Please enter your name', 30 | ), 31 | 'a[last_name]' => array( 32 | 'required' => 'Enter your last name', 33 | ) 34 | ) 35 | ); 36 | 37 | $ajax->overlayContent(file_get_contents('resources/html/test_form.html')); 38 | 39 | $ajax->on('overlayPop', $ajax->validate('button1','ajax.php?overlay_validation/form', $rules)); 40 | 41 | 42 | } 43 | } -------------------------------------------------------------------------------- /cjax/plugins/uploadify/uploadify-3.2/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UploadiFive Test 6 | 7 | 8 | 9 | 14 | 15 | 16 | 17 |

Uploadify Demo

18 |
19 |
20 | 21 |
22 | 23 | 36 | 37 | -------------------------------------------------------------------------------- /cjax/integration/codeigniter/ajax.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | init();?> 8 | Ajax Framework | Elements Functions 9 | 10 |

Element Functions

11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | 29 | 30 | 35 | 36 | 37 | 38 | 41 | 48 | 49 | 50 | 51 | 52 |
$alax->focus();Focus Element$alax->focus('#element_id');
$alax->append();Append HTML to element 22 | $alax->append('#element_id','Content Here'); 23 |
24 | $alax->append('#element_id','#element_id2'); 25 |
$alax->prepend();Prepend HTML to element 31 | $alax->prepend('#element_id','Content Here'); 32 |
33 | $alax->prepend('#element_id','#element_id2'); 34 |
$alax->click(); 39 | Triggers element's click. 40 | Or triggers a callback function on element's click. 42 | $alax->click('#element_id'); 43 |
44 | $alax->click('#element_id',"function(element) { 45 | alert(element); 46 | }"); 47 |
$alax->click('#element_id');
53 | -------------------------------------------------------------------------------- /examples/controllers/search.php: -------------------------------------------------------------------------------- 1 | '.print_r($out,1).'
');
59 | 		
60 | 	}
61 | 	
62 | }


--------------------------------------------------------------------------------
/examples/controllers/calc.php:
--------------------------------------------------------------------------------
 1 | buffer = $buffer.$action;
14 | 		$buffer = str_replace($operators_signs, $operators, $buffer);
15 | 		
16 | 		switch($action) {
17 | 			case 'm'://minus
18 | 			case 'p'://plus
19 | 			case 'd'://divide
20 | 			case 'x'://times
21 | 			break;
22 | 			case 'c': //clear
23 | 				$ajax->buffer = null;
24 | 				$ajax->result = 0;
25 | 			break;
26 | 			case 'e': //equal
27 | 				$buffer = rtrim($buffer,"e=+-\/*");
28 | 				
29 | 				eval("\$action = ({$buffer});");
30 | 				
31 | 				$ajax->result = $action;
32 | 				$ajax->buffer = $action;
33 | 			break;
34 | 			default: //number
35 | 				
36 | 				//get previous operator used, if not then keep putting numbers together
37 | 				$prev = rtrim($pre_buffer, $action);
38 | 				$prev = preg_replace("/[0-9]/", '', $prev);
39 | 				if(!in_array($prev, $operators_signs)) {
40 | 					$action = $buffer;
41 | 				} else {
42 | 					$action =  preg_replace("/.+[^0-9]/", '', $buffer);
43 | 				}
44 | 				$ajax->result = $action;
45 | 		
46 | 		}
47 | 	}
48 | }


--------------------------------------------------------------------------------
/examples/resources/html/login.html:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
 4 | Test Form
 5 | 
 6 | 
 7 | 
 8 | 
9 |
10 |
11 |
12 |

Ajax Login

13 |

test:test

14 |
15 |
16 |
    17 |
  • 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
  • 28 |
  • 29 | 30 |
  • 31 |
32 |
33 |
34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /cjax/plugins/spin/css/style.css: -------------------------------------------------------------------------------- 1 | /* Custom Stylesheet */ 2 | body, html { 3 | margin: 0; 4 | -webkit-font-smoothing: antialiased; 5 | background: #f4eedf; 6 | text-align: center; 7 | height: 100%; 8 | } 9 | 10 | body .header{ 11 | color: #fff; 12 | } 13 | 14 | .container { 15 | float: left; 16 | width: 100%; 17 | height: 100%; 18 | } 19 | 20 | /* ALL DEMO */ 21 | .main h1 { 22 | color: #000; 23 | } 24 | 25 | 26 | /* DEMO 1 */ 27 | .demo1 { 28 | background: #1ABC9C; 29 | } 30 | 31 | .demo1 h1 { 32 | color: #fff; 33 | } 34 | 35 | .demo1 .main h1 { 36 | font-size: 50px; 37 | } 38 | 39 | 40 | /* DEMO 2*/ 41 | .demo2 { 42 | background: #2ecc71; 43 | } 44 | 45 | .demo2 h1 { 46 | color: #fff; 47 | } 48 | 49 | .demo2 .main h1 { 50 | font-size: 50px; 51 | } 52 | 53 | /* DEMO 3 */ 54 | .demo3 { 55 | background: #e74c3c; 56 | } 57 | 58 | .demo3 h1 { 59 | color: #fff; 60 | } 61 | 62 | .demo3 .main h1 { 63 | font-size: 50px; 64 | } 65 | 66 | /* DEMO 4 */ 67 | .demo4 { 68 | background: #e67e22; 69 | } 70 | 71 | .demo4 h1 { 72 | color: #fff; 73 | } 74 | 75 | .demo4 .main h1 { 76 | font-size: 50px; 77 | } 78 | 79 | /* DEMO 5 */ 80 | .demo5 { 81 | background: #2c85dd; 82 | } 83 | 84 | .demo5 h1 { 85 | color: #fff; 86 | } 87 | 88 | .demo5 .main h1 { 89 | font-size: 50px; 90 | } -------------------------------------------------------------------------------- /cjax/includes.default.php: -------------------------------------------------------------------------------- 1 | $kv ) { 24 | if(!is_array($kv)) { 25 | $return[$k] = addslashes($kv); 26 | } else { 27 | foreach($kv as $k_level => $v_level2) { 28 | $return[$k][$k_level] = $v_level2; 29 | } 30 | } 31 | } 32 | $input = $return; 33 | } else { 34 | $input = addslashes($v); 35 | } 36 | break; 37 | case '_REQUEST': 38 | // 39 | break; 40 | case '_POST': 41 | // 42 | break; 43 | case '_GET': 44 | // 45 | break; 46 | default: 47 | //other inputs 48 | } 49 | 50 | return $input; 51 | } -------------------------------------------------------------------------------- /examples/controllers/call.php: -------------------------------------------------------------------------------- 1 | alert(print_r(func_get_args(),1)); 11 | } 12 | 13 | public function cache() 14 | { 15 | $message = " 16 | The ajax request you made when you clicked the link triggered this overlay from the backend. 17 |
18 | controller file: examples/controllers/call.php method name is cache(). 19 |
20 | The overlay is not part of this demo on itself, it is just data being cache. 21 |
22 | Anything, any response would otherwise be cache. 23 |
24 | if you click the link again it will trigger this overlay window again, 25 |
26 | only the ajax request is not longer made. 27 |
28 | You can use this option to cache large amounts of data, and make less requests to the server. 29 |
30 | "; 31 | 32 | ajax()->dialog($message, 'Cached'); 33 | } 34 | 35 | public function container() 36 | { 37 | echo "This text was echo'ed from the ajax controller."; 38 | } 39 | 40 | public function confirm() 41 | { 42 | $ajax = ajax(); 43 | $ajax->info("You clicked yes, then lets do some dangerous operation that required confirmation!", 8); 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /response/test.php: -------------------------------------------------------------------------------- 1 | success("Cjax was installed successfully.", 30); 19 | 20 | $ajax->response = "Version: {$ajax->version}"; 21 | 22 | $ajax->wait(3); 23 | 24 | //center text some what 25 | $ajax->response = array( 26 | 'style' => array( 27 | 'position' => 'relative', 28 | 'top' => '120px', 29 | 'left' => '200px' 30 | )); 31 | 32 | $ajax->wait(4); 33 | 34 | $ajax->response = array( 35 | 'style' => array( 36 | 'fontWeight' => 'bolder', 37 | 'fontSize' => '25px', 38 | 'left' => '200px' 39 | )); 40 | 41 | $ajax->wait(3); 42 | 43 | $ajax->spin('#cjax','spin'); 44 | $ajax->spin('#flip','flipUp'); 45 | 46 | $ajax->wait(5); 47 | 48 | 49 | $ajax->spin('#response','flip', 5000); 50 | 51 | 52 | $ajax->response2 = "Go ahead, lets Continue"; 53 | 54 | $ajax->response2 = array( 55 | 'style' => array( 56 | 'fontWeight' => 'bolder', 57 | 'fontSize' => '25px', 58 | 'left' => '200px' 59 | )); 60 | 61 | $step2 = true; 62 | include 'cjax/integration/default/testing.php'; 63 | } 64 | } -------------------------------------------------------------------------------- /cjax/plugins/uploadify/uploadify.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Uploadify //@uploadify; 3 | * 4 | * Dependencies: Cjax 5.0+, Jquery, jquery.uploadify 5 | * 6 | * Ref: 7 | * 8 | * http://www.uploadify.com/documentation/ 9 | * http://code.google.com/p/cjax 10 | * http://cjax.sourceforge.net 11 | * 12 | * by Cj Galindo 13 | * 14 | */ 15 | 16 | CJAX.importFile({ 17 | files: 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js,uploadify-3.2/uploadify.css', 18 | plugin:'uploadify', 19 | check: 'jQuery', 20 | payload: 'uploadify-3.2/jquery.uploadify.js' 21 | }); 22 | 23 | function uploadify(upload_id, options, session_id) 24 | { 25 | var base = this.base; 26 | 27 | options.formData = {'session_id' : session_id};// need this to communicate with the flash uploader 28 | 29 | if(options.checkExisting) { 30 | options.checkExisting = this.ajaxFile+'?uploadify/fileExists';//base+options.checkExisting; 31 | } 32 | if(!options.swf) { 33 | options.swf = base+'uploadify-3.2/uploadify.swf'; 34 | } 35 | if(!options.uploader) { 36 | options.uploader = this.ajaxFile+'?uploadify/upload'; 37 | } 38 | if(!options.buttonImage) { 39 | options.buttonImage = base+'uploadify-3.2/browse-btn.png'; 40 | } 41 | 42 | if(!/[^a-zA-Z0-9_]/.test(upload_id)) { 43 | upload_id = '#'+upload_id; 44 | } 45 | 46 | this.queue('jquery.uploadify.js', function() { 47 | $(upload_id).uploadify(options); 48 | 49 | }); 50 | } -------------------------------------------------------------------------------- /examples/controllers/ajax_login.php: -------------------------------------------------------------------------------- 1 | $username is available"; 8 | } 9 | 10 | function handler($username, $password) 11 | { 12 | $ajax = ajax(); 13 | 14 | if(!$username) { 15 | return $ajax->err = 'Enter your username.'; 16 | } 17 | if(!$password) { 18 | return $ajax->err = 'Enter your password.'; 19 | } 20 | 21 | $ajax->success("Hello $username, You haved successfully logged in."); 22 | 23 | $ajax->flush('a_login'); //clear the previous events (overlay) 24 | $ajax->overlay();//clear overlay 25 | 26 | $ajax->login_div = "Hello $username!, Logout Now.."; 27 | $ajax->insert('#login_div','#a_login', true); 28 | 29 | 30 | 31 | $ajax->click('a_login', $ajax->call('ajax.php?ajax_login/logout')); 32 | $ajax->a_login = 'Logout'; 33 | 34 | } 35 | 36 | function logout() 37 | { 38 | $ajax = ajax(); 39 | $ajax->flush('a_login'); 40 | $ajax->success("You haved logged out."); 41 | $ajax->a_login = 'Login'; 42 | $ajax->insert('#login_now_area','#a_login'); 43 | $ajax->login_div = 'Login Again..'; 44 | 45 | 46 | //$link = $ajax->click('button1',$ajax->form('ajax.php?ajax_login/handler','form1')); 47 | 48 | $ajax->click('a_login', $ajax->overlay('resources/html/login.html', array('left'=> '400px'))); 49 | $ajax->on('overlayPop', $ajax->click('button1',$ajax->form('ajax.php?ajax_login/handler','form1'))); 50 | 51 | } 52 | } -------------------------------------------------------------------------------- /cjax/integration/default/ajax.php: -------------------------------------------------------------------------------- 1 | select('dropdown2',$data); 31 | } 32 | 33 | /** 34 | * this function is almost identical to the function above, except it changes the dropdown into 35 | * a textbox if nothing is selected as a mode of input 36 | * 37 | * @param $selected 38 | */ 39 | function propagate_allow_input($selected) 40 | { 41 | $ajax = ajax(); 42 | $data = array(); 43 | 44 | 45 | switch($selected) { 46 | case 'options': 47 | $data[] = "Option 1"; 48 | $data[] = "Option 2"; 49 | $data[] = "Option 3"; 50 | $data[] = "Option 4"; 51 | $data[] = "Option 5"; 52 | break; 53 | case 'states': 54 | 55 | $data[] = "Texas"; 56 | $data[] = "Florida"; 57 | $data[] = "New York"; 58 | $data[] = "California"; 59 | $data[] = "New Mexico"; 60 | $data[] = "Maine"; 61 | break; 62 | } 63 | 64 | $ajax->select('dropdown2',$data,'Enter Something',true); 65 | 66 | } 67 | } -------------------------------------------------------------------------------- /cjax/plugins/spin/fonts/oxp-demo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copyright (C) 2012 by original authors @ fontello.com 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /cjax/plugins/uploadify/controllers/uploadify.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | 19 | class _uploadify { 20 | 21 | function fileExists() 22 | { 23 | $ajax = ajax(); 24 | $plugin = $ajax->uploadify(); 25 | 26 | 27 | if (file_exists($plugin->target . $_POST['filename'])) { 28 | echo 1; 29 | } else { 30 | echo 0; 31 | } 32 | } 33 | 34 | function upload() 35 | { 36 | $ajax = ajax(); 37 | 38 | $plugin = $ajax->uploadify(); 39 | 40 | $exts = $plugin->get('exts'); 41 | 42 | $target = $plugin->get('target'); 43 | 44 | 45 | $targetFolder = $target; 46 | 47 | if (!empty($_FILES)) { 48 | 49 | $tempFile = $_FILES['Filedata']['tmp_name']; 50 | 51 | $targetFile = rtrim($targetFolder,'/') . '/' . $_FILES['Filedata']['name']; 52 | // Validate the file type 53 | if($exts) { 54 | $fileTypes = $exts; // File extensions 55 | } else { 56 | $fileTypes = array('jpg','jpeg','gif','png'); // File extensions 57 | } 58 | $fileParts = pathinfo($_FILES['Filedata']['name']); 59 | if (in_array($fileParts['extension'],$fileTypes)) { 60 | echo $targetFile; 61 | if(move_uploaded_file($tempFile,$targetFile)) { 62 | echo '1'; 63 | } else { 64 | echo 'error!'; 65 | } 66 | } else { 67 | echo 'Invalid file type.'; 68 | } 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /cjax/core/js/cjax.js.php: -------------------------------------------------------------------------------- 1 | get('cjax_x_cache'); 17 | echo "//trying\n"; 18 | return $_cache; 19 | } 20 | if(isset($_REQUEST['json'])) { 21 | echo 'init();'; 22 | } else { 23 | if($ajax->config->caching && isset($_REQUEST['crc32'])) { 24 | $source = $ajax->tapCache($_REQUEST['crc32']); 25 | } else { 26 | $debug = $ajax->get('cjax_debug')? 1:0; 27 | $preload = $ajax->get('cjax_preload'); 28 | $_cache = $ajax->get('cjax_x_cache'); 29 | 30 | if(!$_cache) { 31 | $_cache = tryAgain(); 32 | if(!$_cache) { 33 | $_cache = tryAgain(); 34 | if(!$_cache) { 35 | $_cache = tryAgain(); 36 | if(!$_cache) { 37 | exit(); 38 | } 39 | } 40 | } 41 | } 42 | if($_cache && is_array($_cache)) { 43 | $_cache = CoreEvents::processScache($_cache); 44 | $_cache = CoreEvents::mkArray($_cache); 45 | } 46 | 47 | if($preload && is_array($preload)) { 48 | $preload = CoreEvents::processScache($preload); 49 | $preload = CoreEvents::mkArray($preload); 50 | } 51 | 52 | $source = 'CJAX.process_all("'.$_cache.'","'.$preload.'", '.$debug.', true);'; 53 | } 54 | 55 | 56 | if(!$source) { 57 | echo "//no source available"; 58 | } else { 59 | $ajax->flushCache(true); 60 | print $source; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /examples/resources/css/table.css: -------------------------------------------------------------------------------- 1 | @CHARSET "ISO-8859-1"; 2 | h2 { 3 | border-bottom: 1px dashed #999; 4 | display: inline; 5 | } 6 | 7 | 8 | .table a:link { 9 | text-decoration: none; 10 | } 11 | 12 | .table tr:hover { 13 | background-color: #F9F9F9; 14 | } 15 | 16 | 17 | .table { 18 | position: relative; 19 | width: 90%; 20 | border: 1px solid #DFDFDF; 21 | background-color: #F9F9F9; 22 | -moz-border-radius: 3px; 23 | -webkit-border-radius: 3px; 24 | border-radius: 3px; 25 | font-family: Verdana,Helvetica;; 26 | color: #0B6695; 27 | font-size: 11px; 28 | } 29 | 30 | .table td a { 31 | color: #0B6695 !important; 32 | font-family: Verdana,Helvetica; 33 | } 34 | 35 | .table td, .table th { 36 | border-top-color: white; 37 | border-bottom: 1px solid #DFDFDF; 38 | color: #555; 39 | } 40 | 41 | .table td { 42 | padding: 5px 5px 5px 2px; 43 | vertical-align: top; 44 | } 45 | 46 | 47 | .table th { 48 | text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px; 49 | font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; 50 | font-weight: normal; 51 | padding: 3px; 52 | text-align: left; 53 | line-height: 1.3em; 54 | font-size: 14px; 55 | } 56 | .table th:hover { 57 | cursor: pointer; 58 | } 59 | 60 | .table tr { 61 | -moz-border-bottom-colors: none; 62 | -moz-border-image: none; 63 | -moz-border-left-colors: none; 64 | -moz-border-right-colors: none; 65 | -moz-border-top-colors: none; 66 | border-color: #E6E6E6 #BFBFBF; 67 | border-style: solid; 68 | border-width: 1px; 69 | margin-bottom: -1px; 70 | } 71 | 72 | 73 | -------------------------------------------------------------------------------- /examples/resources/send_form/view.js: -------------------------------------------------------------------------------- 1 | eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('3(7.X){7["R"+a]=a;7["z"+a]=6(){7["R"+a](7.1k)};7.X("1e",7["z"+a])}E{7.19("z",a,15)}2 j=H V();6 a(){2 e=q.1d("1a");3(e){o(e,"P");2 N=B(q,"*","14");3((e.12<=10)||(N=="")){c(e,"P",d)}}4=B(q,"*","1n");k(i=0;i<4.b;i++){3(4[i].F=="1g"||4[i].F=="1f"||4[i].F=="1c"){4[i].1b=6(){r();c(v.5.5,"f",d)};4[i].O=6(){r();c(v.5.5,"f",d)};j.D(j.b,0,4[i])}E{4[i].O=6(){r();c(v.5.5,"f",d)};4[i].18=6(){o(v.5.5,"f")}}}2 C=17.16.13();2 A=q.M("11");3(C.K("J")+1){c(A[0],"J",d)}3(C.K("I")+1){c(A[0],"I",d)}}6 r(){k(2 i=0;ibasic(); 18 | //you could pass parameters in the constructor, and you will get them in the basic.js file. 19 | 20 | 21 | //passing variables 22 | $basic->set('test','Hello'); 23 | //or 24 | $basic->test = 'Hello'; 25 | 26 | //Now in your plugin basis.js you can access this variable as: 27 | 28 | alert(this.test); 29 | 30 | 31 | 32 | //to update parameters sent to the plugin, you would use alphabetic letters, a to z, 33 | //Example: 34 | 35 | $basic->set('a', 'Hello'); 36 | $basic->set('b', 'Hello'); 37 | $basic->set('c', 'Hello'); 38 | 39 | //Now all 3 variables above would be accessibly through parameters in your plugin basic.js. 40 | //You may also pass arrays, they will be returned as json objects. 41 | 42 | //These are means to transfer data across 43 | 44 | //You may also use: 45 | 46 | $basic->save('test','Hello'); 47 | 48 | // it will save your setting in a session or cookie. 49 | // this is specifially useful when using ajax controllers. 50 | 51 | $basic->get('test'); 52 | 53 | //There you go.. Look in Example plugin if you 54 | //are looking for a more meaningful way and power to develop robust functionality. 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /cjax/plugins/validate/validate.php: -------------------------------------------------------------------------------- 1 | overlay()->validate(); 19 | * $ajax->call()->validate(); 20 | * etc... 21 | * @param string $api - internal API name 22 | * @param array $args 23 | */ 24 | function rightHandler($api, $args, $xmlObj) 25 | { 26 | switch($api) { 27 | case '_overLay': 28 | 29 | $xmlObj->callback = $this; 30 | break; 31 | case '_overLayContent': 32 | $xmlObj->callback = $this; 33 | break; 34 | default: 35 | $xmlObj->callback = $this; 36 | } 37 | 38 | } 39 | 40 | function onLoad($button_id, $post_url, $rules = array(), $import_js = false) 41 | { 42 | $ajax = ajax(); 43 | 44 | $ajax->on('validate', $ajax->form($post_url)); 45 | 46 | $this->rules = $rules; 47 | } 48 | 49 | function onAjaxLoad($button_id, $post_url, $rules = array()) 50 | { 51 | return $this->onLoad($button_id,$post_url, $rules); 52 | } 53 | 54 | /** 55 | * 56 | * Add additional rules 57 | * @param unknown_type $name 58 | * @param unknown_type $rule 59 | */ 60 | function rule($name, $rule) 61 | { 62 | if(!$rule) { 63 | return; 64 | } 65 | $rules = $this->rules['rules']; 66 | $messages = $this->rules['messages']; 67 | 68 | foreach($rule as $k => $v) { 69 | if(is_array($v)) { 70 | if(isset($v[0])) { 71 | $rules[$name][$k] = $v[0]; 72 | } 73 | if(isset($v[1])) { 74 | $messages[$name][$k] = $v[1]; 75 | } 76 | } else { 77 | $rules[$name][$k] = $v; 78 | } 79 | } 80 | $this->rules['rules'] = $rules; 81 | $this->rules['messages'] = $messages; 82 | 83 | $this->set('c', $this->rules); 84 | } 85 | } -------------------------------------------------------------------------------- /response/sample.php: -------------------------------------------------------------------------------- 1 | success("Testing controller sample. Works ok."); 75 | } 76 | 77 | } 78 | 79 | -------------------------------------------------------------------------------- /cjax/core/classes/std.class.php: -------------------------------------------------------------------------------- 1 | progressbar($this->calc(20, 200)); 23 | * 24 | * for example, you have a process that takes 15 steps to complete 25 | * just pass the increment and the total. 26 | * 27 | * 28 | * @param $total 29 | * @param $number 30 | * @return float|int 31 | */ 32 | function calc($total, $number) 33 | { 34 | if ( $total > 0 ) { 35 | return round($number / ($total / 100),2); 36 | } else { 37 | return 0; 38 | } 39 | } 40 | 41 | 42 | function start($progressbar_num, $percentage) 43 | { 44 | $ajax = ajax(); 45 | 46 | if($percentage >= 100) { 47 | 48 | $ajax->progressbar('#progressbar' . $progressbar_num, 100); 49 | 50 | return false; 51 | } 52 | 53 | $steps = 10; 54 | 55 | switch ($progressbar_num) { 56 | case 2: 57 | 58 | $steps = 15; 59 | sleep(2); 60 | break; 61 | case 3: 62 | 63 | $steps = 25; 64 | 65 | sleep(1); 66 | 67 | break; 68 | case 4: 69 | 70 | $steps = 5; 71 | 72 | sleep(1); 73 | } 74 | 75 | $percentage += $steps; 76 | 77 | 78 | $ajax->progressbar('#progressbar' . $progressbar_num, $percentage); 79 | 80 | $ajax->call(array('progressbar','start', array($progressbar_num,$percentage))); 81 | 82 | } 83 | } -------------------------------------------------------------------------------- /examples/controllers/change_value.php: -------------------------------------------------------------------------------- 1 | text1 = "Random number..".rand(100,1000); 10 | } 11 | 12 | 13 | function check($element_id,$current_value) 14 | { 15 | $ajax = ajax(); 16 | 17 | if($current_value) { 18 | $ajax->check1 = false; 19 | } else { 20 | $ajax->check1 = true; 21 | } 22 | } 23 | 24 | function div($num = 0) 25 | { 26 | $ajax = ajax(); 27 | 28 | $text = array(); 29 | 30 | //Some random strings ....... 31 | $text[] = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. "; 32 | $text[] = "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown "; 33 | $text[] = "printer took a galley of type and scrambled it to make a type"; 34 | $text[] = "specimen book. It has survived not only five centuries, but also the leap into electronic"; 35 | $text[] = "typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of "; 36 | $text[] = "Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."; 37 | $text[] = "it is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout."; 38 | $text[] = "The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using"; 39 | $text[] = "'Content here, content here', making it look like readable English. Many desktop publishing packages and "; 40 | $text[] = "web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many"; 41 | $text[] = "web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like)."; 42 | 43 | $ajax->DIV_1 = $text[rand(0, count($text)-1)]; 44 | } 45 | } -------------------------------------------------------------------------------- /cjax/plugins/autocomplete/autocomplete.js: -------------------------------------------------------------------------------- 1 | /** 2 | * autocomplete 1.2 3 | * 4 | * Auto Complete Plugin for Cjax 5 | */ 6 | 7 | //allows to import these files before the plugin is ran. 8 | 9 | 10 | CJAX.importFile({ 11 | files: 'helper.js,css/style.css', 12 | plugin:'autocomplete', 13 | callbacks: { 14 | 0: function() { 15 | var element = CJAX._plugins['autocomplete'].element_id; 16 | 17 | autocomplete.ready(function() { 18 | AC.init(element); 19 | }); 20 | 21 | } 22 | } 23 | }); 24 | 25 | function autocomplete(url , fulll_load) { 26 | version = CJAX.version.replace(/[^0-9\.].*/, ''); 27 | 28 | CJAX.ajaxSettings.cache = true; 29 | 30 | var element = CJAX.$(CJAX._plugins['autocomplete'].element_id); 31 | var str = element.value; 32 | 33 | url = autocomplete.url = url.replace(/\/+$/, "");//remove any slashes at the end 34 | 35 | if (str) { 36 | 37 | this.ready(function() { 38 | //executes until helper.js if fully loaded. 39 | autocomplete.load('helper.js', function() { 40 | 41 | if (fulll_load) { 42 | 43 | var limit = 10; 44 | 45 | //element.setAttribute('disabled','disabled'); 46 | CJAX.info('Loading Image List..', 30) 47 | autocomplete.get(url, function (data) { 48 | //element.removeAttribute('disabled'); 49 | CJAX.message(); 50 | 51 | //convert json into js array 52 | new_data = Object.keys(data).map(function (key) { 53 | return data[key] 54 | }) 55 | //search string 56 | if (str.length == 1) { 57 | str = '^' + str; 58 | } 59 | new_data = new_data.filter(/./.test.bind(new RegExp(str, 'i'))); 60 | 61 | //how many records 62 | new_data = new_data.slice(0, limit) 63 | 64 | if (new_data) { 65 | AC.refresh(new_data, element); 66 | } 67 | }, 'json'); 68 | } else { 69 | 70 | autocomplete.get(url += '/' + str, function (data) { 71 | if (data) { 72 | AC.refresh(data, element); 73 | } 74 | }, 'json'); 75 | } 76 | }); 77 | }); 78 | } 79 | } -------------------------------------------------------------------------------- /examples/resources/send_form/iepngfix.htc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 68 | -------------------------------------------------------------------------------- /cjax/plugins/progressbar/progressbar.js: -------------------------------------------------------------------------------- 1 | /** 2 | * progressbar v1.0 3 | */ 4 | 5 | CJAX.importFile({ 6 | files: 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js,css/style.css', 7 | plugin:'progressbar', 8 | check: 'jQuery' 9 | }); 10 | //docs: 11 | function progressbar(element_id, progress, options) 12 | { 13 | 14 | if(!/[^a-zA-Z0-9_]/.test(element_id)) { 15 | element_id = '#'+element_id; 16 | } 17 | 18 | CJAX.$(element_id, function(elements) { 19 | 20 | 21 | for(x in elements) { 22 | 23 | var new_element = elements[x]; 24 | 25 | 26 | $(new_element).addClass('progressbar'); 27 | 28 | 29 | if(!$(new_element).attr('tagged')) { 30 | 31 | 32 | $(new_element).unbind('click').on('click',function() { 33 | 34 | if ($(this).find('.pbinfo').length <= 0) { 35 | $(this).append('
'); 36 | 37 | } 38 | 39 | var $info = $(this).find('.pbinfo'), 40 | $inner = $(this).find('.info-inner'), 41 | $p = $(this).attr("class").match(/p-\w+/).toString().substring(2); 42 | 43 | 44 | $inner.text(parseInt($p) + '%'); 45 | $info.addClass('js-active'); 46 | 47 | }); 48 | 49 | 50 | 51 | var img = $(new_element).find('img'); 52 | 53 | 54 | 55 | if (img.length) { 56 | 57 | img.addClass('avatar'); 58 | 59 | $(new_element).append($('
').addClass('avatar').append(img)); 60 | 61 | 62 | } 63 | 64 | 65 | $(new_element).attr('tagged', true); 66 | } 67 | 68 | $(new_element).attr('class', 69 | function(i, c){ 70 | 71 | return c.replace(/(^|\s)p-\S+/g, ''); 72 | }); 73 | 74 | 75 | $(new_element).addClass( "p-" + parseInt(progress) ); 76 | 77 | 78 | $(element_id).last().trigger('click'); 79 | 80 | } 81 | 82 | }); 83 | } -------------------------------------------------------------------------------- /cjax/integration/codeigniter/application/response/sample.php: -------------------------------------------------------------------------------- 1 | 4 |

PHP to JavaScript functions reference

5 |
6 | Please Read about PHP2JS: Read 7 | 8 |
    9 |
  • 10 |
    11 | document.getElementById() 12 |
    13 |
    14 | $ajax->document(); 15 |
    16 |
    17 | View Sample 18 |
    19 |
    20 |
  • 21 |
  • 22 |
    23 | document.title 24 |
    25 |
    26 | $ajax->document(); 27 |
    28 |
    29 | View Sample 30 |
    31 |
    32 |
  • 33 |
  • 34 |
    35 | document.write() 36 |
    37 |
    38 | $ajax->document(); 39 |
    40 |
    41 | View Sample 42 |
    43 |
    44 |
  • 45 |
  • 46 |
    47 | document.writeln() 48 |
    49 |
    50 | $ajax->document(); 51 |
    52 |
    53 | View Sample 54 |
    55 |
    56 |
  • 57 |
  • 58 |
    59 | window.confirm() 60 |
    61 |
    62 | $ajax->confirm(); 63 |
    64 |
    65 | View Sample 66 |
    67 |
    68 |
  • 69 |
  • 70 |
    71 | window.alert() 72 |
    73 |
    74 | $ajax->aler(); 75 |
    76 |
    77 | View Sample 78 |
    79 |
    80 |
  • 81 | 82 |
83 | -------------------------------------------------------------------------------- /cjax/integration/codeigniter/application/response/test.php: -------------------------------------------------------------------------------- 1 | load->view('test', array('data' => $a .' '.$b.' '.$c)); 21 | } 22 | 23 | /** 24 | * ajax.php?test/test2 25 | * 26 | * Here we are testing out the javascript library. 27 | * 28 | * Note: the library it is not meant to be included in ajax controllers - but in front-controllers, 29 | * it is being used here for the sake of simplicity in testing. 30 | */ 31 | function test2() 32 | { 33 | //see application/views/test2.php 34 | $this->load->view('test2'); 35 | } 36 | 37 | function test2handler() 38 | { 39 | $ajax = ajax(); 40 | 41 | $ajax->success("Cjax was installed successfully.", 30); 42 | 43 | $ajax->response = "Version: {$ajax->version}"; 44 | 45 | $ajax->wait(3); 46 | 47 | //center text some what 48 | $ajax->response = array( 49 | 'style' => array( 50 | 'position' => 'relative', 51 | 'top' => '120px', 52 | 'left' => '200px' 53 | )); 54 | 55 | $ajax->wait(4); 56 | 57 | $ajax->response = array( 58 | 'style' => array( 59 | 'fontWeight' => 'bolder', 60 | 'fontSize' => '25px', 61 | 'left' => '200px' 62 | )); 63 | 64 | $ajax->wait(3); 65 | 66 | $ajax->spin('#cjax','spin'); 67 | $ajax->spin('#flip','flipUp'); 68 | 69 | $ajax->wait(5); 70 | 71 | 72 | $ajax->spin('#response','flip', 5000); 73 | 74 | 75 | $ajax->response2 = "Go ahead, lets Continue"; 76 | 77 | $ajax->response2 = array( 78 | 'style' => array( 79 | 'fontWeight' => 'bolder', 80 | 'fontSize' => '25px', 81 | 'left' => '200px' 82 | )); 83 | } 84 | 85 | 86 | /** 87 | * 88 | * ajax.php?test/test3 89 | * 90 | * will return a json string to the ajax request. 91 | */ 92 | function test3() 93 | { 94 | $data = array('test1','test2','test3'); 95 | 96 | return $data; 97 | } 98 | } -------------------------------------------------------------------------------- /cjax/auth.default.php: -------------------------------------------------------------------------------- 1 | warning("Could no Authenticate. Please re-login"); 40 | } 41 | 42 | /* 43 | * Routing Handler 44 | * 45 | * Optonal Routing interception 46 | * 47 | * You may route the ajax request to other custom destination here. 48 | * 49 | * If your application offers some sort of addons or plugins system that handles ajax, 50 | * here is where you can intercept these requests and configure code your custom route to your application's 51 | * addons/plugins system. 52 | * 53 | * if you return true, the request will be intercepted and will not proceed to the controller that was meant to. 54 | * 55 | * If you return an array or an object it will print a json string and will not proceed to the controller that was meant to. 56 | * 57 | * If you return false, the request will proceed as normal to the destination controller. 58 | * 59 | * $controller string 60 | * $function strnig 61 | * $args array 62 | * $requesObj object or null. If a cotroller exists for this request the controller object is passed. 63 | */ 64 | function intercept($controller = null, $function = null , $args = array(), $requestObj = null) 65 | { 66 | return false; 67 | } 68 | 69 | } -------------------------------------------------------------------------------- /cjax/plugins/uploadify/uploadify.php: -------------------------------------------------------------------------------- 1 | options = $options; 28 | 29 | //Remove these if already on your page, or load manually 30 | //preload dependecies, import multiple files 31 | 32 | //updates 3rd paramaters in the plugin 33 | $this->set('c', session_id()); 34 | } 35 | 36 | /** 37 | * This function updates second parameter values options 38 | * eg. 39 | * $this->buttonText = "Button"; 40 | * $this->fileTypeDesc = "Images"; 41 | */ 42 | function __set($setting, $value) 43 | { 44 | //upload directory 45 | if($setting=='target') { 46 | if($dir = ajax()->config->upload_dir) { 47 | $value = rtrim($dir,'/') . '/uploadify/'; 48 | } 49 | if(!$value) { 50 | $value = './'; 51 | } 52 | if(!is_writable($value)) { 53 | 54 | $ajax = ajax(); 55 | $ajax->error("Uploadify: Target is not writable. Check directory exists and has proper permission, then try again."); 56 | 57 | //remove any pending uploadify tasks 58 | $this->abort(); 59 | return; 60 | } 61 | $this->save('target', $value); 62 | return; 63 | } 64 | 65 | /** 66 | * "fileTypeExts" only deals with client side, but there is a second 67 | * check in the ajax contoller, save it then we can get it there to make 68 | * sure we are using the right extensions. 69 | * see controlles/uploadify.php 70 | */ 71 | if($setting=='fileTypeExts') { 72 | $exts = preg_replace(array("/^\*\./","/\*|\;/"),'',$value); 73 | $exts = explode('.',$exts); 74 | 75 | //update extensions 76 | $this->exts = $exts; 77 | $this->save('exts', $exts); 78 | } 79 | //update options 80 | $this->options[$setting] = $value; 81 | 82 | //Save to options /second parameter 83 | $this->set('b', $this->options, $this->_id); //parameter, variable 84 | } 85 | } -------------------------------------------------------------------------------- /examples/resources/html/test_form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Test Form 5 | 6 | 7 | 8 |
9 |
10 |

Ajax Overlay and Validation

11 |
12 |
13 |

Form

14 |

Ajax Overlay and Validation...

15 |
16 |
    17 |
  • 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
  • 29 |
  • 30 | 31 |
    32 | 38 | 39 |
    40 |
  • 41 |
  • 42 | 43 |
    44 | 45 |
    46 |
  • 47 |
  • 48 | 49 | 50 |
    51 | 52 |
    53 |
  • 54 |
  • 55 | 56 |
  • 57 |
58 |
59 |
60 | 61 |
62 | 63 | 64 | -------------------------------------------------------------------------------- /examples/docs/resources/css/table.css: -------------------------------------------------------------------------------- 1 | @CHARSET "ISO-8859-1"; 2 | h2 { 3 | border-bottom: 1px dashed #999; 4 | margin-left: 4px; 5 | } 6 | 7 | .cjax_dialog,#cjax_dialog { 8 | position:relative; 9 | background-color:#FAFAFA; 10 | border-color:#CCCCCC; 11 | border-style:dotted !important; 12 | border-width:1px 2px 1px 2px !important; 13 | margin:12px -47% 22px; 14 | padding:25px 5px 20px 5px !important; 15 | color: #646464; 16 | text-align: left; 17 | width: 94%; 18 | left: 50%; 19 | font-size: 12px; 20 | word-wrap: break-word; 21 | font-family: tahoma; 22 | letter-spacing: 1px; 23 | } 24 | 25 | .cjax_dialog_title { 26 | position:relative; 27 | text-align: left; 28 | padding-left:10px; 29 | margin-top: -20px; 30 | top: -15px; 31 | font-weight: bolder; 32 | } 33 | 34 | 35 | .table a:link { 36 | text-decoration: none; 37 | } 38 | 39 | .table tr:hover { 40 | background-color: #F9F9F9; 41 | } 42 | 43 | 44 | .table { 45 | position: relative; 46 | width: 90%; 47 | border: 1px solid #DFDFDF; 48 | background-color: #F9F9F9; 49 | -moz-border-radius: 3px; 50 | -webkit-border-radius: 3px; 51 | border-radius: 3px; 52 | font-family: Verdana,Helvetica;; 53 | color: #0B6695; 54 | font-size: 11px; 55 | } 56 | 57 | .table td a { 58 | color: #0B6695 !important; 59 | font-family: Verdana,Helvetica; 60 | } 61 | 62 | .table td, .table th { 63 | border-top-color: white; 64 | border-bottom: 1px solid #DFDFDF; 65 | color: #555; 66 | } 67 | 68 | .table td { 69 | padding: 5px 5px 5px 2px; 70 | vertical-align: top; 71 | } 72 | 73 | 74 | .table th { 75 | text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px; 76 | font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; 77 | font-weight: normal; 78 | padding: 3px; 79 | text-align: left; 80 | line-height: 1.3em; 81 | font-size: 14px; 82 | } 83 | .table th:hover { 84 | cursor: pointer; 85 | } 86 | 87 | .table tr { 88 | -moz-border-bottom-colors: none; 89 | -moz-border-image: none; 90 | -moz-border-left-colors: none; 91 | -moz-border-right-colors: none; 92 | -moz-border-top-colors: none; 93 | border-color: #E6E6E6 #BFBFBF; 94 | border-style: solid; 95 | border-width: 1px; 96 | margin-bottom: -1px; 97 | } 98 | 99 | 100 | -------------------------------------------------------------------------------- /cjax/plugins/ExamplePlugin/css/table.css: -------------------------------------------------------------------------------- 1 | @CHARSET "ISO-8859-1"; 2 | h2 { 3 | border-bottom: 1px dashed #999; 4 | display: inline; 5 | } 6 | 7 | .cjax_dialog,#cjax_dialog { 8 | position:relative; 9 | background-color:#FAFAFA; 10 | border-color:#CCCCCC; 11 | border-style:dotted !important; 12 | border-width:1px 2px 1px 2px !important; 13 | margin:12px -47% 22px; 14 | padding:25px 5px 20px 5px !important; 15 | color: #646464; 16 | text-align: left; 17 | width: 94%; 18 | left: 50%; 19 | font-size: 12px; 20 | word-wrap: break-word; 21 | font-family: tahoma; 22 | letter-spacing: 1px; 23 | } 24 | 25 | .cjax_dialog_title { 26 | position:relative; 27 | text-align: left; 28 | padding-left:10px; 29 | margin-top: -20px; 30 | top: -15px; 31 | font-weight: bolder; 32 | } 33 | 34 | 35 | .table a:link { 36 | text-decoration: none; 37 | } 38 | 39 | .table tr:hover { 40 | background-color: #F9F9F9; 41 | } 42 | 43 | 44 | .table { 45 | position: relative; 46 | width: 90%; 47 | border: 1px solid #DFDFDF; 48 | background-color: #F9F9F9; 49 | -moz-border-radius: 3px; 50 | -webkit-border-radius: 3px; 51 | border-radius: 3px; 52 | font-family: Verdana,Helvetica;; 53 | color: #0B6695; 54 | font-size: 11px; 55 | } 56 | 57 | .table td a { 58 | color: #0B6695 !important; 59 | font-family: Verdana,Helvetica; 60 | } 61 | 62 | .table td, .table th { 63 | border-top-color: white; 64 | border-bottom: 1px solid #DFDFDF; 65 | color: #555; 66 | } 67 | 68 | .table td { 69 | padding: 5px 5px 5px 2px; 70 | vertical-align: top; 71 | } 72 | 73 | 74 | .table th { 75 | text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px; 76 | font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; 77 | font-weight: normal; 78 | padding: 3px; 79 | text-align: left; 80 | line-height: 1.3em; 81 | font-size: 14px; 82 | } 83 | .table th:hover { 84 | cursor: pointer; 85 | } 86 | 87 | .table tr { 88 | -moz-border-bottom-colors: none; 89 | -moz-border-image: none; 90 | -moz-border-left-colors: none; 91 | -moz-border-right-colors: none; 92 | -moz-border-top-colors: none; 93 | border-color: #E6E6E6 #BFBFBF; 94 | border-style: solid; 95 | border-width: 1px; 96 | margin-bottom: -1px; 97 | } 98 | 99 | 100 | -------------------------------------------------------------------------------- /cjax/core/classes/format.class.php: -------------------------------------------------------------------------------- 1 | "; 19 | 20 | if($title) { 21 | $html[] = "
"; 22 | $html[] = $title; 23 | $html[] = "
"; 24 | } 25 | 26 | $html[] = $content; 27 | 28 | $html[] =""; 29 | 30 | return implode($html); 31 | } 32 | 33 | /** 34 | * Show a prompt message 35 | * 36 | * @param string $str 37 | * @param string $title 38 | * @param bol $escape 39 | * @return STRING 40 | */ 41 | function prompt($msg,$title=null,$id = 'cjax_prompt_box') 42 | { 43 | self::$prompts++; 44 | 45 | $string = null; 46 | 47 | if($type = CJAX::CSS_INFO) { 48 | $css = "information"; 49 | } elseif ($type == CJAX::CSS_WARNING) { 50 | $css = "warning"; 51 | } 52 | 53 | $ajax = CJAX::getInstance(); 54 | 55 | $msg_id = $id.self::$prompts; 56 | 57 | if($title) { 58 | $string ="
$title
"; 59 | } 60 | 61 | $string =" 62 |
63 | $string 64 |
65 | $msg 66 |
67 |
68 |
69 | 70 | "; 71 | return $string; 72 | } 73 | 74 | 75 | public function message($text,$type= self::CSS_SUCCESS) 76 | { 77 | $ajax = CJAX::getInstance(); 78 | if($type==self::CSS_SUCCESS || !$type) { 79 | $css = " cjax_success"; 80 | } else if($type==self::CSS_WARNING) { 81 | $css = " cjax_warning"; 82 | } else if($type==self::CSS_ERROR) { 83 | $css = " cjax_error"; 84 | } else if($type==self::CSS_PROCESS) { 85 | $css = " cjax_process cjax_loading_f"; 86 | } else if($type==self::CSS_INFO) { 87 | $css = " cjax_info"; 88 | } else if($type==self::CSS_LOADING) { 89 | $css = " cjax_process cjax_loading_f"; 90 | } 91 | $data ="
$text
"; 92 | 93 | return $data; 94 | } 95 | 96 | } -------------------------------------------------------------------------------- /cjax/plugins/validate/validate.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Plugin: //@validate; 4 | * Dependencies: Cjax 4.3+, Jquery, jquery.validate 5 | * 6 | * Ref: 7 | * 8 | * http://docs.jquery.com/Main_Page 9 | * http://docs.jquery.com/Plugins/Validation 10 | * 11 | * http://code.google.com/p/cjax 12 | * http://code.google.com/p/ajax-framework-for-codeigniter 13 | * 14 | * @param form_id string 15 | * @param fields Json Object 16 | */ 17 | 18 | CJAX.importFile({ 19 | files: 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js', 20 | plugin:'validate', 21 | check: 'jQuery', 22 | payload: 'jquery.validate.min.js' 23 | }); 24 | 25 | function validate(btn_id, url, fields) 26 | { 27 | if(!btn_id) { 28 | console.error('Validate: Empty Submit Button'); 29 | return; 30 | } 31 | 32 | /** 33 | * uploadify jquery plugin was not detected, so we will try to load it automatically 34 | */ 35 | this.queue('jquery.validate.min.js',function() { 36 | 37 | if(!fields) { 38 | //an array was not passed. 39 | var fields = validate.params.c; 40 | } 41 | 42 | //get form 43 | var form = $('#'+btn_id).closest('form'); 44 | 45 | //prevent request or api and returns it in a function 46 | var callback = this.callback; 47 | 48 | function postCallback(buffer) 49 | { 50 | var postCallback = CJAX.decode(CJAX.xml('postCallback',buffer)); 51 | 52 | if(!postCallback) { 53 | return true; 54 | } 55 | postCallback = CJAX.util.json(postCallback); 56 | CJAX.process_all(postCallback,postCallback); 57 | } 58 | 59 | if(typeof fields.invalidHandler !='function') { 60 | _invalidHandler = function(form, validator) {}; 61 | } 62 | if(typeof fields.submitHandler !='function') { 63 | _submitHandler = function(form) { 64 | if(url) { 65 | CJAX.ajaxSettings.success = function() { 66 | postCallback(validate.buffer); 67 | CJAX.ajaxSettings.success = null; 68 | }; 69 | if(CJAX.callback.validate) { 70 | CJAX.callback.validate.call(); 71 | } 72 | } else { 73 | if(CJAX.callback.validate) { 74 | CJAX.callback.validate.call(); 75 | } 76 | postCallback(validate.buffer); 77 | } 78 | }; 79 | } 80 | 81 | 82 | var val = form.validate({ 83 | errorElement: (fields.errorElement? fields.errorElement: "div"), 84 | invalidHandler: _invalidHandler, 85 | submitHandler: _submitHandler, 86 | rules: fields.rules, 87 | messages: fields.messages 88 | }); 89 | }); 90 | } -------------------------------------------------------------------------------- /examples/controllers/upload_file.php: -------------------------------------------------------------------------------- 1 | upload() 7 | * for more info. For new location of the upload code see cjax/core/file/iframe.php 8 | * 9 | * 10 | * @deprecated 11 | * @author cj 12 | * 13 | */ 14 | class upload_file { 15 | 16 | function post($files) 17 | { 18 | $ajax = ajax(); 19 | 20 | //files listed under 'files' array are files that were successfully uploaded 21 | if($files) { 22 | 23 | // $ajax->alert("Controller Response:".print_r($files,1)); 24 | } 25 | //uncoment to see the response on the screen 26 | //$ajax->overlayContent($ajax->dialog("
".print_r($_REQUEST,1)."
","Controller Response: upload_file/post ")); 27 | } 28 | 29 | /** 30 | * 31 | * @deprecated 32 | * @param unknown_type $file_names 33 | */ 34 | function send_file($file_names = null) 35 | { 36 | $ajax = CJAX::getInstance(); 37 | $dir = realpath(dirname(__file__).'/../'); //directory where the file is uploaded.. 38 | 39 | if($_FILES || $ajax->get('cjax_iframe')) { 40 | if(!is_writable($dir)) { 41 | return $ajax->overlayContent("Directory $dir is not writeable.\nPermission denied.
(chmod $dir 777) or make sure the directory exists."); 42 | } 43 | 44 | if(empty($_FILES)) { 45 | return $ajax->overlay("ajax.php?controller=upload_file&function=error"); 46 | } 47 | $file = $_FILES['my_file']; 48 | if(!$file['name']) { 49 | exit('error'); 50 | } 51 | 52 | $temp = (($file['tmp_name'])?$file['tmp_name']:null); 53 | 54 | $temp = trim($temp,DIRECTORY_SEPARATOR); 55 | if(@move_uploaded_file($temp,$dir.'/'.$file['name'])) { 56 | $ajax->success("File uploaded..",10); 57 | } else { 58 | $ajax->warning("Could not move file"); 59 | } 60 | } else if ($ajax->request()) { 61 | $ajax->process("Uploading file..",1000); 62 | //Ajax request 63 | //PRE-POST FILE 64 | if(!$_REQUEST['my_file']) { 65 | $ajax->warning("Please select a file"); 66 | $ajax->focus('my_file'); 67 | exit(); 68 | } 69 | 70 | } 71 | } 72 | 73 | 74 | function error() 75 | { 76 | $ajax = ajax(); 77 | $upload_max = $ajax->toMB(ini_get('upload_max_filesize')); 78 | $post_max = $ajax->toMB($pmax = ini_get('post_max_size'));// / 2; 79 | $max_size = ($upload_max < $post_max) ? $upload_max : $post_max; 80 | $cause = ($upload_max < $post_max) ? "upload_max_filesize " : "post_max_size "; 81 | 82 | echo "Could not upload file. This server limits max upload to {$max_size}MB ($cause in php.ini). "; 83 | 84 | } 85 | 86 | } -------------------------------------------------------------------------------- /examples/docs/template.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | Template 13 | init();?> 14 | 15 | 16 |
17 |
18 | 19 |
20 |
21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 |

Cjax Framework

31 |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 46 |
47 | 48 | 49 |
50 | 51 |
52 | 53 | 54 | 55 | Template 56 | 57 | 58 |
59 | 60 |

Examples

61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
70 |
71 | 72 | 73 |
74 |

75 | Previous Topic:  Previous Class 76 |    ·   77 | Top of Page   ·   78 | Demos Home   ·   79 | 80 |

81 |

82 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  83 | Cjax 84 |

85 |
86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /cjax/plugins/autocomplete/helper.js: -------------------------------------------------------------------------------- 1 | 2 | var autoCompleteHelper = {}; 3 | autoCompleteHelper = function() { 4 | this.minChars = 1; 5 | this.field = null; 6 | this.item_id = 0; 7 | this.helper = null; 8 | this.helperContent = ""; 9 | this.data = []; 10 | }; 11 | autoCompleteHelper.prototype = { 12 | init:function(idOfTheField) { 13 | this.field = CJAX.$(idOfTheField); 14 | if(!this.field) { 15 | alert('Element #'+idOfTheField+' was not found.'); 16 | } else { 17 | this.createHelper(); 18 | this.field.onblur = this.onFieldOut; 19 | } 20 | }, 21 | refresh: function(data, element) { 22 | var list = new String(''); 23 | 24 | 25 | if(element.value.length >= this.minChars) { 26 | 27 | for (x in data) { 28 | list += '' + data[x] + ''; 29 | } 30 | } 31 | 32 | this.helper.innerHTML = list; 33 | this.showHelper(); 34 | this.positionHelper(); 35 | }, 36 | element: function(element) { 37 | if(this.field !=element) { 38 | AC.init(element.id); 39 | this.field = element; 40 | this.field.onfocus = this.onFieldIn; 41 | this.field.onblur = this.onFieldOut; 42 | } 43 | }, 44 | onFieldIn:function() { 45 | //AC.loop(); 46 | }, 47 | onFieldOut:function() { 48 | clearTimeout(AC.item_id); 49 | setTimeout("AC.hideHelper()", 120); 50 | }, 51 | select:function(item, id) { 52 | this.field.value = item; 53 | this.hideHelper(); 54 | 55 | var params = CJAX._plugins.autocomplete.options; 56 | if(params.c && typeof params.c == 'string') { 57 | if(params.d) { 58 | switch(params.d) { 59 | case 'id': 60 | item = id; 61 | } 62 | } 63 | 64 | CJAX.ajaxSettings.cache = true; 65 | autocomplete.get(params.c + '/' + item); 66 | } 67 | }, 68 | // helper 69 | createHelper:function() { 70 | this.helper = document.createElement("div"); 71 | this.helper.style.width = (this.field.offsetWidth - 22) + "px"; 72 | this.helper.setAttribute("id", "helper"); 73 | this.helper.innerHTML = ""; 74 | document.body.appendChild(this.helper); 75 | this.positionHelper(); 76 | //this.hideHelper(); 77 | }, 78 | positionHelper:function() { 79 | var position = {x:0, y:0}; 80 | var e = this.field; 81 | while(e) { 82 | position.x += e.offsetLeft; 83 | position.y += e.offsetTop; 84 | e = e.offsetParent; 85 | } 86 | this.helper.style.left = position.x + "px"; 87 | this.helper.style.top = (position.y + this.field.offsetHeight)+ "px"; 88 | }, 89 | showHelper:function() { 90 | this.helper.style.display = "block"; 91 | }, 92 | hideHelper:function() { 93 | setTimeout(function() { 94 | this.helper.style.display = "none"; 95 | }, 20); 96 | } 97 | }; 98 | 99 | var AC = new autoCompleteHelper(); -------------------------------------------------------------------------------- /examples/what_is_cjax.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | Template 13 | init();?> 14 | 15 | 16 |
17 |
18 | 19 |
20 |
21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 |

Cjax Framework

31 |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 46 |
47 | 48 | 49 |
50 | 51 |
52 | 53 | 54 | 55 | Cjax is more actions, less code, more server side logic, less dependencies. 56 | 57 | 58 | 59 |
60 | 61 |

Examples

62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 |
71 |
72 | 73 | 74 |
75 |

76 | Previous Topic:  Previous Class 77 |    ·   78 | Top of Page   ·   79 | Demos Home   ·   80 | 81 |

82 |

83 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  84 | Cjax 85 |

86 |
87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /examples/resources/html/not_found.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | An Error Ocurred 5 | 6 | 7 |
8 |
9 | 10 |
11 |
12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 |

Cjax Framework

22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 35 | 36 | 37 |
38 | 39 | 40 |
41 | 42 |
43 | 44 | 45 | 46 |

47 | Cjax was not detected in the parent directory. Make sure the framework is placed in the upper directory. 48 |
49 | You may download Cjax from its website: 50 | 51 |

52 | 53 |

54 | Download 55 | https://cjax.sourceforge.net/ 56 |

57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |
67 |
68 | 69 | 70 |
71 |

72 | Previous Topic:  Previous Class 73 |    ·   74 | Top of Page   ·   75 | Demos Home   ·   76 | 77 |

78 |

79 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  80 | Cjax 81 |

82 |
83 | 84 | 85 | -------------------------------------------------------------------------------- /cjax/plugins/uploadify/uploadify-3.2/uploadify.css: -------------------------------------------------------------------------------- 1 | /* 2 | Uploadify 3 | Copyright (c) 2012 Reactive Apps, Ronnie Garcia 4 | Released under the MIT License 5 | */ 6 | 7 | .uploadify { 8 | position: relative; 9 | margin-bottom: 1em; 10 | } 11 | .uploadify-button { 12 | background-color: #505050; 13 | background-image: linear-gradient(bottom, #505050 0%, #707070 100%); 14 | background-image: -o-linear-gradient(bottom, #505050 0%, #707070 100%); 15 | background-image: -moz-linear-gradient(bottom, #505050 0%, #707070 100%); 16 | background-image: -webkit-linear-gradient(bottom, #505050 0%, #707070 100%); 17 | background-image: -ms-linear-gradient(bottom, #505050 0%, #707070 100%); 18 | background-image: -webkit-gradient( 19 | linear, 20 | left bottom, 21 | left top, 22 | color-stop(0, #505050), 23 | color-stop(1, #707070) 24 | ); 25 | background-position: center top; 26 | background-repeat: no-repeat; 27 | -webkit-border-radius: 30px; 28 | -moz-border-radius: 30px; 29 | border-radius: 30px; 30 | border: 2px solid #808080; 31 | color: #FFF; 32 | font: bold 12px Arial, Helvetica, sans-serif; 33 | text-align: center; 34 | text-shadow: 0 -1px 0 rgba(0,0,0,0.25); 35 | width: 100%; 36 | } 37 | .uploadify:hover .uploadify-button { 38 | background-color: #606060; 39 | background-image: linear-gradient(top, #606060 0%, #808080 100%); 40 | background-image: -o-linear-gradient(top, #606060 0%, #808080 100%); 41 | background-image: -moz-linear-gradient(top, #606060 0%, #808080 100%); 42 | background-image: -webkit-linear-gradient(top, #606060 0%, #808080 100%); 43 | background-image: -ms-linear-gradient(top, #606060 0%, #808080 100%); 44 | background-image: -webkit-gradient( 45 | linear, 46 | left bottom, 47 | left top, 48 | color-stop(0, #606060), 49 | color-stop(1, #808080) 50 | ); 51 | background-position: center bottom; 52 | } 53 | .uploadify-button.disabled { 54 | background-color: #D0D0D0; 55 | color: #808080; 56 | } 57 | .uploadify-queue { 58 | margin-bottom: 1em; 59 | } 60 | .uploadify-queue-item { 61 | background-color: #F5F5F5; 62 | -webkit-border-radius: 3px; 63 | -moz-border-radius: 3px; 64 | border-radius: 3px; 65 | font: 11px Verdana, Geneva, sans-serif; 66 | margin-top: 5px; 67 | max-width: 350px; 68 | padding: 10px; 69 | } 70 | .uploadify-error { 71 | background-color: #FDE5DD !important; 72 | } 73 | .uploadify-queue-item .cancel a { 74 | background: url('uploadify-cancel.png') 0 0 no-repeat; 75 | float: right; 76 | height: 16px; 77 | text-indent: -9999px; 78 | width: 16px; 79 | } 80 | .uploadify-queue-item.completed { 81 | background-color: #E5E5E5; 82 | } 83 | .uploadify-progress { 84 | background-color: #E5E5E5; 85 | margin-top: 10px; 86 | width: 100%; 87 | } 88 | .uploadify-progress-bar { 89 | background-color: #0099FF; 90 | height: 3px; 91 | width: 1px; 92 | } -------------------------------------------------------------------------------- /examples/docs/upgrading.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | Upgrading 13 | init();?> 14 | 15 | 16 |
17 |
18 | 19 |
20 |
21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 |

Cjax Framework

31 |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 46 |
47 | 48 | 49 |
50 | 51 |
52 | 53 | 54 | 55 |

Upgrading

56 |

57 | Using an older version?. To upgrade simply download the newest version and overwrite all Cjax files, in most cases that should be enough to upgrade to a newer version.
58 | To be sure, see release notes or changeLog to see if there are any changes that would affect a previous release. 59 |

60 | 61 | 62 |
63 |
64 | 65 | 66 |
67 |

68 | Previous Topic:  Previous Class 69 |    ·   70 | Top of Page   ·   71 | Demos Home   ·   72 | 73 |

74 |

75 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  76 | Cjax 77 |

78 |
79 | 80 | 81 | -------------------------------------------------------------------------------- /examples/docs/manipulating_container.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | init();?> 8 | Ajax Framework | Manipulating Elements 9 | 10 |

Manipulating Elements/Containers

11 | With the release of 5.0-RC1 One of the new features is the ability to manipulate any element on the HTML document through PHP. 12 |
13 | All elements (divs,spans,buttons,images,anchors, etc) will accept general JavaScript properties if they are passed in an array.
14 | In addition some elements may accept Cjax Properties as well such as ajax requests, or ajax form, 15 | continue reading to see some examples. 16 | 17 |

Examples

18 | The following example adds style properties to div HTML element with the ID of "div_container".
19 | These style properties are a small example, there is no limitation 20 | on which properties you may add, to see a full list of style properties click here. 21 | code(" 23 | \$ajax->div_container = array( 24 | 'style' => array( 25 | 'backgroundColor' => '#FF9E3E', 26 | 'width' => '300px', 27 | 'heigh' => '200px' 28 | ));"); 29 | ?> 30 | You may also assign/set direct element properties that would otherwise go in their tag constructor. 31 | You may set element properties to any element as long that element has an id. 32 |
Example
33 | code(" 35 | \$ajax->html_table = array('width' => 600); 36 | 37 | \$ajax->td_id = array('width' => 200,'height' => 100, 'colspan' => 3); 38 | 39 | \$ajax->tr_id = array('innerHTML' => 'some data'); 40 | 41 | ");?> 42 |
Example
43 | code(" 45 | \$ajax->some_image = array('width' => 300,'height' => 200, 'src' => 'some/image/url'); 46 | 47 | //see 'Main Property' documentation for 'Elements Properties' 48 | //changes the src property of an image 49 | \$ajax->some_image = 'some/image/url'; 50 | ");?> 51 |
52 | 53 | 54 | While you assign some properties to an element, you may still continue manipulating it. All properties accumulate. 55 |

56 | If the container has node of type div or span, you may assign Ajax requests to it, the response of the request will flow to the container. 57 | 58 | code(" 60 | \$ajax->div_container = \$ajax->call(\"url/to/a/controller\"); 61 | ");?> 62 |
63 | If the element you'd like to manipulate is a button, you may assign Ajax Forms to it (element must be inside a form). 64 | code(" 66 | \$ajax->button_id = \$ajax->form(\"url/to/post/action\"); 67 | ");?> 68 | Assigning a string to the button will change it's value/label. While it still submits the ajax form above. 69 | code(" 71 | \$ajax->button_id = \"Button Label\"; 72 | ");?> 73 | 74 | code(" 76 | //change the id of the DIV 77 | \$ajax->div_container = array('id' => 'New_div_id'); 78 | 79 | //div_container does exist anymore, now is New_div_id 80 | \$ajax->New_div_id = \"Hello!\"; 81 | ");?> 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /cjax/integration.php: -------------------------------------------------------------------------------- 1 | "; 15 | 16 | } 17 | } else if (file_exists($dir)) { 18 | unlink($dir); 19 | } 20 | } 21 | 22 | // Function to Copy folders and files 23 | function rcopy($src, $dst, $rm = false) { 24 | if (file_exists ( $dst )) 25 | !$rm || rrmdir ( $dst ); 26 | if (is_dir ( $src )) { 27 | is_dir($dst) || mkdir ( $dst ); 28 | //echo "Copying Directory: $src - $dst
"; 29 | $files = scandir ( $src ); 30 | foreach ( $files as $file ) 31 | if ($file != "." && $file != "..") 32 | rcopy ( rtrim($src,'/') . '/' . $file, rtrim($dst,'/'). '/' . $file); 33 | } else if (file_exists ( $src )) { 34 | //echo "Copying File: $src - $dst
"; 35 | if(is_file($dst)) { 36 | unlink($dst); 37 | } 38 | if(strpos($src,'integration.php') !== false) { 39 | return true; 40 | } 41 | if(!copy ( $src, $dst )) { 42 | // echo "Could not copy file." . "
" . print_r(error_get_last(), 1) . "
"; 43 | } 44 | } 45 | } 46 | 47 | function moveSelf() 48 | { 49 | $cwd = dirname(__FILE__); 50 | $dir = dirname($cwd); 51 | 52 | $files = array( 53 | '%s/response', 54 | '%s/README.md' 55 | ); 56 | foreach($files as $v) { 57 | rrmdir(sprintf($v,$dir)); 58 | } 59 | @unlink(__FILE__); 60 | } 61 | if(is_file('composer.json')) { 62 | 63 | $sanity_check = error_get_last(); 64 | 65 | $composer = json_decode(file_get_contents('composer.json')); 66 | 67 | if($composer->name == 'codeigniter/framework') { 68 | $cwd = dirname(__FILE__); 69 | 70 | $dir = dirname($cwd); 71 | 72 | $files = array( 73 | '%s/cjax/integration/codeigniter/application' => '%s/application', 74 | // '%s/cjax/integration/default/ajax.php' => '%s/ajax.php', 75 | '%s/cjax/integration/codeigniter/ajax.php' => '%s/ajax.php', 76 | // '%s/cjax' => '%s/application/libraries/cjax', 77 | ); 78 | 79 | foreach( $files as $src => $dist) { 80 | rcopy(sprintf($src, $dir), sprintf($dist,$dir)); 81 | } 82 | 83 | 84 | if(error_get_last() != $sanity_check) { 85 | // die(sprintf("The following error occured:
%s
", print_r(error_get_last(),1))); 86 | } 87 | 88 | register_shutdown_function('moveSelf'); 89 | 90 | $url = $_SERVER['REQUEST_URI']; 91 | if(!$_SERVER['QUERY_STRING']) { 92 | $url = '?test/test/abc'; 93 | } 94 | 95 | header("Cache-Control: no-cache, must-revalidate"); 96 | exit(header("Location: {$url}")); 97 | } 98 | } -------------------------------------------------------------------------------- /examples/click.php: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | Click 16 | init();?> 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |

Cjax Framework

29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 42 | 43 | 44 |
45 | 46 | 47 |
48 | 49 |
50 | 51 | 52 |
53 | Click function in addition to bind actions to elements, it can also be used for the simplest task, to trigger a simple click event. 54 |

55 |

56 | The trigger of a click can be very useful, specially when toggling elements after an operations has been finished or 57 | simply to trigger further actions that a simple trigger can save you from having to rewrite an entire different section. 58 |

59 | 60 |

61 | The trigger is fire programmatically, using DOM. Not simply calling, click(). 62 |

63 |

Examples

64 | 65 | Lets assume there is a link with the id of "link1", to trigger a click on that element is fairly simple. 66 | code(" 67 | \$ajax->click('link1'); 68 | ");?> 69 | 70 |

71 | 72 | 73 | 74 |
75 |
76 | 77 | 78 |
79 |

80 | Previous Topic:  Previous Class 81 |    ·   82 | Top of Page   ·   83 | Demos Home   ·   84 | 85 |

86 |

87 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  88 | Cjax 89 |

90 |
91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /examples/docs/includes.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | Includes 13 | init();?> 14 | 15 | 16 |
17 |
18 | 19 |
20 |
21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 |

Cjax Framework

31 |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 46 |
47 | 48 | 49 |
50 | 51 |
52 | 53 | 54 | 55 | 56 |

Includes

57 | Some times you may need to include files or dependencies while making ajax request. The includes sections 58 | provides you with a section where you may include any files or load extra dependecies without modifying core files. 59 |
60 | To start including files use file: cjax/includes.default.php. For changes to take effect you must rename file includes.default.php 61 | to includes.php. 62 |
63 | Includes are loaded right before the request is triggered and before authentication, and routing. 64 |
65 | 66 |
67 |
68 | 69 | 70 |
71 |

72 | Previous Topic:  Previous Class 73 |    ·   74 | Top of Page   ·   75 | Demos Home   ·   76 | 77 |

78 |

79 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  80 | Cjax 81 |

82 |
83 | 84 | 85 | -------------------------------------------------------------------------------- /cjax/plugins/ExamplePlugin/ExamplePlugin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Example Plugin 1.0 3 | * 4 | * There are files included in this package but this is the only file required. The other files 5 | * only offer additional information and prospective of the scope of tools you can use to further develop. 6 | * 7 | */ 8 | 9 | /** 10 | * This plugin is for demonstration purpose only. 11 | * Do see the comments in the code for some samples of API and methods available. 12 | * 13 | */ 14 | function ExamplePlugin(arg1, arg2) 15 | { 16 | 17 | //alerts data set in the contructors $ajax->ExamplePlugin(); 18 | //alert(arg1.test1); 19 | //alert(arg1.test2); 20 | 21 | //see plugins's api documentation to see all the available functions and variables available. 22 | 23 | /** 24 | * The following statement shows several things: 25 | * How to request ajax to the plugin itself, usage or parameters 26 | * 27 | * the ":json" part of the url tells ajax to return a json object. 28 | * 29 | * 30 | */ 31 | this.call(this.ajaxFile+'?ExamplePlugin:json/docs', function(response) { 32 | 33 | //alert(response.test1); 34 | //alert(response.test2); 35 | }); 36 | 37 | 38 | //You may access the parameters the same order they were sent. 39 | //arg1.test1; 40 | 41 | //arg1.test2 42 | 43 | //arg2 44 | 45 | /** 46 | * this.prevent() 47 | * 48 | * You can intercept other ajax APIs executed after the plugin was called. 49 | * Using the method this.prevent(); 50 | * 51 | * this.prevent() will stop other APIs, and returns them into one function which you may 52 | * use at your own pase. 53 | * 54 | * Example: 55 | * 56 | * Lets say in your controller you use 57 | * 58 | * $ajax->Exec('button', $ajax->form('url','form_id')); 59 | * 60 | * The above Api will submit a form attached to a button, 61 | * 62 | * but lets say you want to do something else before the form is submitted through ajax, 63 | * this is a case where you can use this method. 64 | * 65 | * if you use prevent(), that Api will be intercepted and not executed. 66 | * Then it gives you the controll of execution of that API, in the returned value. 67 | * Which you may execute. 68 | * 69 | * var Api = this.prevent(); 70 | * 71 | * setTimeout(function() { 72 | * Api(); 73 | * },5000); 74 | * you may prevent more than one APIs by passing a number in this 75 | * function this.prevent(3); - will prevent 3 APIs and they all are returned back to you. 76 | * 77 | * 78 | */ 79 | //this.prevent() 80 | 81 | //sample of importing javascript into the scope 82 | this.import('http://cjax.googlecode.com/svn/trunk/_extra/test_unit/plugins/js/test.js', function() { 83 | console.log('File was imported.'); 84 | }); 85 | //sample of importing css to the page 86 | this.import('http://cjax.googlecode.com/svn/trunk/_extra/test_unit/plugins/css/test.css'); 87 | 88 | //sample of preventing the next API $ajax->info() 89 | 90 | 91 | //CJAX.preventDefault(); 92 | 93 | //setTimeout('func2()',20000); 94 | 95 | //console.log('File base:', this.base); 96 | //console.log('This file:', this.file); 97 | //console.log('Paramters Passed:', a, b ,c); 98 | } -------------------------------------------------------------------------------- /examples/location.php: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 15 | 16 | Location/Redirect Ajax 17 | init();?> 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 |

Cjax Framework

30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 43 | 44 | 45 |
46 | 47 | 48 |
49 | 50 |
51 | 52 |

53 | Ever tried to redirect a page from the server, while you are in an ajax call? well, you can't, oh wait - erase that, with Cjax yes you can. 54 |
55 | Here is where this function is most useful. You can use it and it will redirect from the server or from 56 | anywhere you call it. If you just call it without parameters, it will refresh the page you are on. 57 |

58 |
59 | You can redirect to a different url, or site, by using the location function. 60 | 61 | 62 |

Examples

63 | 64 | Redirect to a new url. 65 | code(" 67 | \$ajax->location('http://cjax.sourceforge.net/'); 68 | 69 | "); 70 | ?> 71 |
72 | Refresh page. 73 | code(" 75 | \$ajax->location(); 76 | 77 | "); 78 | ?> 79 |
80 | 81 | 82 | 83 |
84 |
85 | 86 | 87 |
88 |

89 | Previous Topic:  Previous Class 90 |    ·   91 | Top of Page   ·   92 | Demos Home   ·   93 | 94 |

95 |

96 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  97 | Cjax 98 |

99 |
100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /examples/confirm_action.php: -------------------------------------------------------------------------------- 1 | click("button1",$ajax->call("ajax.php?confirm/confirm_action",null,"Are you sure?")); 8 | 9 | ?> 10 | 11 | 12 | 13 | Confirm before firing ajax request 14 | init();?> 15 | 16 | 17 |
18 |
19 | 20 |
21 |
22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |

Cjax Framework

32 |
33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 45 | 46 | 47 |
48 | 49 | 50 |
51 | 52 |
53 | 54 | 55 | Confirm whether the action about to be performed is really desired. 56 |
57 | 58 |

Examples

59 | 60 | 61 | 62 | 63 | code(" 65 | \$ajax->click(\"button1\",\$ajax->call(\"ajax.php?confirm/confirm_action\",null,\"Are you sure?\")); 66 | 67 | ", true,true); 68 | ?> 69 | 70 | 71 | 72 | 73 | 74 |
75 |
76 | 77 | 78 |
79 |

80 | Previous Topic:  Previous Class 81 |    ·   82 | Top of Page   ·   83 | Demos Home   ·   84 | 85 |

86 |

87 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  88 | Cjax 89 |

90 |
91 | 92 | 93 | -------------------------------------------------------------------------------- /examples/template.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | Template 13 | init();?> 14 | 15 | 16 |
17 |
18 | 19 |
20 |
21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 |

Cjax Framework

31 |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 46 |
47 | 48 | 49 |
50 | 51 |
52 | 53 |
Project development is new to github. Give us a star.
54 | 55 | 56 |
57 | 58 |

59 | 60 | Template 61 | 62 | 63 |

64 | 65 |

Examples

66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 |
75 |
76 | 77 | 78 |
79 |

80 | Previous Topic:  Previous Class 81 |    ·   82 | Top of Page   ·   83 | Demos Home   ·   84 | 85 |

86 |

87 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  88 | Cjax 89 |

90 |
91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /examples/docs/access_fields_in_parameters.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | Parameters 13 | init();?> 14 | 15 | 16 |
17 |
18 | 19 |
20 |
21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 |

Cjax Framework

31 |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 46 |
47 | 48 | 49 |
50 | 51 |
52 | 53 | 54 | 55 |

Access fields in parameters

56 | 57 | To be able to access your form fields through parameters in your ajax controllers you will need to name your fields the following way: 58 |
59 | 60 | 61 |
62 | 63 |

Examples

64 | 65 | 66 | 67 | 68 |
69 | code(" 72 | 73 | 74 | 75 | "); 76 | ?> 77 | 78 | 79 | 80 | 81 |
82 |
83 | 84 | 85 |
86 |

87 | Previous Topic:  Previous Class 88 |    ·   89 | Top of Page   ·   90 | Demos Home   ·   91 | 92 |

93 |

94 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  95 | Cjax 96 |

97 |
98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /examples/docs/index.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | Cjax Framework Docs 13 | init();?> 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 |

Cjax Framework

26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 38 | 39 | 40 |
41 | 42 | 43 |
44 | 45 |
46 | 47 | 48 | 49 |

50 | Want to contribute to this documentation?, you may do so by folking the source code(under docs): https://github.com/ajaxboy/cjax. We could use a hand. 51 |

52 | 53 | 54 | 55 | 56 |

Installing and Upgrading

57 | 65 | 66 |

Troubleshooting

67 | 72 | 73 | 74 |

Plugins Docs

75 | 80 | 81 | 82 |

Misc

83 | 88 | 89 | 90 |
91 |
92 | 93 | 94 |
95 |

96 | Previous Topic:  Previous Class 97 |    ·   98 | Top of Page   ·   99 | Demos Home   ·   100 | 101 |

102 |

103 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  104 | Cjax 105 |

106 |
107 | 108 | 109 | -------------------------------------------------------------------------------- /cjax/plugins/uploader/uploader.php: -------------------------------------------------------------------------------- 1 | _id; 29 | $ajax = ajax(); 30 | 31 | if($ajax->config->upload_dir) { 32 | $target_directory = $ajax->config->upload_dir; 33 | } 34 | if(!$target_directory) { 35 | $target_directory = './'; 36 | } 37 | if(!is_writable($target_directory)) { 38 | return $ajax->warning("Cjax Upload: Directory '$target_directory' is not writable, , aborting..",5); 39 | } 40 | if(!isset($options['text'])) { 41 | $options['text'] = 'Uploading File(s)...'; 42 | } 43 | if(!isset($options['ext'])) { 44 | $options['ext'] = array('jpg','jpeg','gif','png'); 45 | } 46 | if(!isset($options['files_require'])) { 47 | $options['files_require'] = true; 48 | } 49 | if(!isset($options['form_id']) ) { 50 | $options['form_id'] = null; 51 | } 52 | $ajax->text = $options['text']; 53 | $target = rtrim($target_directory,'/') . '/'; 54 | 55 | if(!isset($options['before'])) { 56 | $options['url'] = null; 57 | } 58 | 59 | if(!isset($options['target'])) { 60 | $options['target'] = $target; 61 | } 62 | $options['instance_id'] = $instance_id; 63 | $this->set('a', $options, $instance_id); 64 | //usually we call save, but there could be more than one instance. 65 | $this->save('upload_options' . $instance_id, $options); 66 | 67 | $this->options = $options; 68 | } 69 | 70 | /** 71 | * 72 | * Handles right api assignments eg: 73 | * 74 | * $ajax->validate()->uploader(); 75 | * $ajax->call()->uploader(); 76 | * etc... 77 | * @param string $api - internal API name 78 | * @param array $args 79 | */ 80 | function rightHandler($api, $args, $xmlObj) 81 | { 82 | $xmlObj->postCallback = $this; 83 | } 84 | 85 | /** 86 | * Right handler routed 87 | * 88 | * handles chain call $ajax->someApi->uploader(); 89 | * 90 | * @param unknown_type $value 91 | */ 92 | function callbackHandler($sender , $receiver, $setting) 93 | { 94 | switch($setting) { 95 | case 'postCallback': 96 | $event = CoreEvents::$cache[$receiver->id]; 97 | 98 | $callback = CoreEvents::$cache[$sender->id]; 99 | 100 | $event['postCallback'][$sender->id] = $callback; 101 | $sender->delete(); 102 | 103 | $callbacks = CoreEvents::processScache($event['postCallback']); 104 | $callbacks = CoreEvents::mkArray($callbacks,'json', true); 105 | $event['postCallback'] = "$callbacks"; 106 | 107 | CoreEvents::$cache[$receiver->id] = $event; 108 | 109 | CoreEvents::simpleCommit(); 110 | break; 111 | } 112 | } 113 | 114 | function onAjaxLoad($options = array(), $target_directory = null) 115 | { 116 | return $this->onLoad($options, $target_directory); 117 | } 118 | 119 | } -------------------------------------------------------------------------------- /examples/prepend.php: -------------------------------------------------------------------------------- 1 | prepend('#response','#other_element'); 9 | $ajax->prepend('#response','This HTML was prepended to #response'); 10 | 11 | ?> 12 | 13 | 14 | 15 | Prepend with ajax 16 | init();?> 17 | 18 | 19 |
20 |
21 | 22 |
23 |
24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | 32 | 33 |

Cjax Framework

34 |
35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 47 | 48 | 49 |
50 | 51 | 52 |
53 | 54 |
55 | 56 | 57 | 58 | Prepend html or elements before target element. 59 |
60 | 61 |

Examples

62 | 63 | 64 | 65 |
66 | code(" 68 | //Appending HTML 69 | \$ajax->prepend('#response','This HTML was prepended to #response'); 70 | //Appending or moving an element to #response 71 | \$ajax->prepend('#response','#other_element'); 72 | ", true, true); 73 | ?> 74 | 75 | 76 | 77 | 78 | 79 |
#Response
80 |
 
81 |
 
82 |
#Other element
83 |
84 |
85 | 86 | 87 |
88 |

89 | Previous Topic:  Previous Class 90 |    ·   91 | Top of Page   ·   92 | Demos Home   ·   93 | 94 |

95 |

96 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  97 | Cjax 98 |

99 |
100 | 101 | 102 | -------------------------------------------------------------------------------- /examples/docs/url_styles.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | Cjax - URL Styles 13 | init();?> 14 | 15 | 16 |
17 |
18 | 19 |
20 |
21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 |

Cjax Framework

31 |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 46 |
47 | 48 | 49 |
50 | 51 |
52 | 53 | 54 | 55 |

Ajax Framework URL Styles

56 |
57 | You may access your controllers in any of the following ways: 58 |

59 | 60 | 61 | 62 |
63 | 64 |

Examples

65 | 66 | code(" 68 | ajax.php?controller=\$controller&function=\$function 69 | ajax.php?\$controller/\$function 70 | ajax.php/\$controller/\$function 71 | 72 | With Mod-Rewrite: 73 | 74 | ajax/\$controller/\$function 75 | or: 76 | *Any-word*/\$controller/\$function 77 | *Any-word* - a word of your choosing by changing the word 'ajax' in file .htaccess 78 | ",false); 79 | ?> 80 | 81 | 82 | 83 | 84 | 85 | 86 |
87 |
88 | 89 | 90 |
91 |

92 | Previous Topic:  Previous Class 93 |    ·   94 | Top of Page   ·   95 | Demos Home   ·   96 | 97 |

98 |

99 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  100 | Cjax 101 |

102 |
103 | 104 | 105 | -------------------------------------------------------------------------------- /cjax/plugins/spin/spin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Cjax plugin spin v1.0 3 | */ 4 | CJAX.importFile({ 5 | //list of files to load separated by comma, can use relative path to this plugin 6 | files: 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js,css/simpletextrotator.css,css/elusive-webfont.css', 7 | plugin:'spin', // this plugin's name 8 | check : 'jQuery', //check if this Object exists, it quits loading it if it does 9 | payload:'js/jquery.simple-text-rotator.js' //waits until 1st in files (jquery is loaded) 10 | }); 11 | 12 | function spin(element_id, animation, speed) 13 | { 14 | if(!element_id) { 15 | 16 | console.warn('No Element ID', 'spin plugin'); 17 | 18 | return false; 19 | } 20 | if(typeof speed == 'undefined') { 21 | var speed = 200; 22 | } 23 | 24 | //makes sure that the file is loaded. Or waits until it loads. 25 | //particularly needed when calling during ajax call, and none of the files are loaded. 26 | this.load('jquery.simple-text-rotator.js', function(obj) { 27 | 28 | if (!/^#|\./i.test(element_id)) { 29 | element_id = '#' + element_id; 30 | } 31 | 32 | var animate = function () { 33 | switch (animation) { 34 | case 'flip': 35 | if (!speed) { 36 | var speed = 1000; 37 | } 38 | $(element_id).textrotator({ 39 | animation: "flip", 40 | speed: speed 41 | }); 42 | break; 43 | case 'spin': 44 | 45 | $(element_id).textrotator({ 46 | animation: "spin", 47 | separator: "," 48 | }); 49 | 50 | break; 51 | case 'flipUp': 52 | if (!speed) { 53 | var speed = 2000; 54 | } 55 | $(element_id).textrotator({ 56 | animation: "flipUp", 57 | speed: speed 58 | }); 59 | 60 | break; 61 | case 'flipCubeUp': 62 | $(element_id).textrotator({ 63 | animation: "flipCubeUp" 64 | }); 65 | 66 | break; 67 | case 'flipCube': 68 | $(element_id).textrotator({ 69 | animation: "flipCube", 70 | separator: "|" 71 | }); 72 | break; 73 | case 'fade': 74 | $(element_id).textrotator({ 75 | animation: "fade", 76 | separator: "|" 77 | }); 78 | break; 79 | case 'stop': 80 | console.log('trygin to stop'); 81 | $(element_id).stop(); 82 | break; 83 | default: 84 | $(element_id).textrotator({ 85 | animation: "flipCube", 86 | separator: "|" 87 | }); 88 | } 89 | $(element_id).data('default', $(element_id).text()) 90 | }; 91 | 92 | spin.ready(function () { 93 | spin.repeat(animate); 94 | }); 95 | 96 | }); 97 | 98 | } -------------------------------------------------------------------------------- /examples/keypress.php: -------------------------------------------------------------------------------- 1 | keypress('text_url', $ajax->call("ajax.php?test/remote/|url|"), array(13,97,98,99)); 10 | 11 | ?> 12 | 13 | 14 | 15 | Keypress 16 | init();?> 17 | 18 | 19 |
20 |
21 | 22 |
23 |
24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | 32 | 33 |

Cjax Framework

34 |
35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 47 | 48 | 49 |
50 | 51 | 52 |
53 | 54 |
55 | 56 | 57 | 58 | Support for keypress event 59 |
60 | 61 |

Examples

62 | 63 | 64 | 65 | 66 |

67 | code(" 69 | //Press enter, a, b or c, and the ajax request will go throgh. 70 | \$ajax->keypress('url', \$ajax->call(\"ajax.php?test/remote/|url|\"), array(13,97,98,99)); 71 | 72 | //press enter and request will go through: 73 | \$ajax->keypress('url', \$ajax->call(\"ajax.php?test/remote/|url|\"), 13); 74 | 75 | ", true, true); 76 | ?> 77 | 78 | 79 | Press Enter, a, b c, and the call go through, or it won't. 80 | 81 |
82 | 83 | 84 |
85 |
86 | 87 | 88 |
89 |

90 | Previous Topic:  Previous Class 91 |    ·   92 | Top of Page   ·   93 | Demos Home   ·   94 | 95 |

96 |

97 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  98 | Cjax 99 |

100 |
101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /examples/load_html_file.php: -------------------------------------------------------------------------------- 1 | div_container = $ajax->call("resources/html/test.html"); 9 | 10 | ?> 11 | 12 | 13 | 14 | Load External File With Ajax 15 | init();?> 16 | 17 | 18 |
19 |
20 | 21 |
22 |
23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 |

Cjax Framework

33 |
34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 46 | 47 | 48 |
49 | 50 | 51 |
52 | 53 |
54 | 55 | 56 | Load external HTML file (or any plain file) 57 |
58 | 59 |

Examples

60 | 61 | 62 | 63 | 64 | code(" 66 | \$ajax->call(\"resources/html/test.html\",\"div_container\"); 67 | 68 | // ---- OR ---- 69 | 70 | //This is the preffered way if you want to do more actions 71 | \$ajax->div_container = \$ajax->call(\"resources/html/test.html\"); 72 | 73 | ");?> 74 | 75 | The text below was loaded with ajax. 76 |
77 | 78 | 79 |
80 | 81 |
82 |
83 | 84 | 85 |
86 |

87 | Previous Topic:  Previous Class 88 |    ·   89 | Top of Page   ·   90 | Demos Home   ·   91 | 92 |

93 |

94 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  95 | Cjax 96 |

97 |
98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /examples/update.php: -------------------------------------------------------------------------------- 1 | click("button1",$ajax->call("ajax.php?update/update_box")); 8 | 9 | ?> 10 | 11 | 12 | 13 | Update elements with Ajax 14 | init(false);?> 15 | 25 | 26 | 27 |
28 |
29 | 30 |
31 |
32 | 33 | 34 | 35 |
36 | 37 | 38 | 39 | 40 | 41 |

Cjax Framework

42 |
43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 55 | 56 | 57 |
58 | 59 | 60 |
61 | 62 |
63 | 64 | 65 | 66 | Update elements on your page with ajax. If you are looking for something more powerful use UpdateX. 67 | 68 | 69 |
70 | 71 |

Examples

72 | 73 | 74 | 75 |
76 | code(" 78 | \$ajax->update('content1',\$text); 79 | //OR 80 | \$ajax->content1 = \$text; 81 | ", true, true);?> 82 | 83 | 84 | 85 | 86 | 87 | 88 |
89 |
90 |
91 | 92 | 93 |
94 |

95 | Previous Topic:  Previous Class 96 |    ·   97 | Top of Page   ·   98 | Demos Home   ·   99 | 100 |

101 |

102 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  103 | Cjax 104 |

105 |
106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /examples/docs/php2javascript/about.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | init();?> 6 | JavaScript functions in PHP 7 | 8 | 9 |

JavaScript functions in PHP

10 | 5.0-RC1 introduced a great future, which allows you to access a element's properties and assign all sort of properties, in 5.0-RC2 we're taking it a step further. 11 |

12 | 13 | The intention is not access all JavaScript function and Objects through PHP, we've already done that. In 5.0-RC2 you can and are able
14 | to access all properties, window, document, functions and Objects in Javascript through PHP, however this is a brand new feature - and 15 | not all functions are documented. 16 |
17 | 18 | The purpose of these features is not intention to lead the framework into working with raw Javascript in PHP, but rather to give more tools 19 | to developers and to stay resourceful to face given problems. 20 |

21 | Since most of this is not documented, in the mean time fortunely they all follow a logical pattern, and it is possible to access them with basic knowledge of JavaScript functions. 22 |

23 | 24 | 25 | As of version 5.0-RC2, $ajax has direct acces to invoke ALL Javascript functions and Objects in the HTML document. That's right any. 26 | 27 |

28 |

Usage

29 | 30 | $ajax->[OBJECT]([getter], param, param, param, param); 31 |
32 | Importat: If a plugin exists with name of the [OBJECT], the plugin will take priority over Js functions. 33 |

34 | All parameters are optional. 35 |

36 | [OBJECT] - Is the name of the JavaScript object or function you want to access. So the usage is very similar as if it is for JavaScript.

37 |
38 | [getter] - If what you are accessing is a function within an object then you will need to specify, 39 | which property or function you want to get to. 40 |
41 | For example to access the body's HTML you may do this: 42 | Example: 43 |
44 | code(" 45 | \$ajax->document('body.innerHTML','Content Here'); 46 | ");?> 47 | 48 | 49 |
50 | Other examples:
51 | code(" 52 | \$ajax->document('write','Content Here'); 53 | ");?> 54 | 55 |
56 | Other examples:
57 | code(" 58 | \$ajax->window('alert','Content Here'); 59 | ");?> 60 | 61 |
62 | This is the same as above: 63 | code(" 64 | \$ajax->alert('Content Here'); 65 | ");?> 66 | If the function is just a normal function (not an object) and doesn't require a getter, then the [getter] will be treated as parameter also. 67 |
68 |
69 | Some functions that are getters though, such as document.getElementById and window.confirm, were enhanced to permit a callback. 70 |
71 |
72 | These two examples are the exceptions, and more will be allowed to have callbacks eventually. 73 |
74 |

Example

75 | code(" 77 | \$ajax->document(\"getElementById\",\"element_id\",\"function(element) { 78 | //your element is... 79 | alert(element); 80 | } 81 | \");" 82 | ); 83 | ?> 84 |

Example

85 | code(" 87 | \$ajax->confirm(\"Are you sure?\",\"function() { 88 | //the user clicked yes 89 | 90 | } 91 | \");" 92 | ); 93 | ?> 94 |
95 | Please be warned that this feature is still new and we can't guaranteed all JS functions will work as expected. 96 |


97 | 98 | -------------------------------------------------------------------------------- /cjax/config.default.php: -------------------------------------------------------------------------------- 1 | ajax_file = '/ajax.php'; 15 | 16 | 17 | 18 | /** 19 | * Setting to where the js directory is. 20 | * Eg: http://yoursite.com/cjax/ 21 | */ 22 | $config->js_path = ''; 23 | 24 | 25 | /** 26 | * Having issues on page load not loading some times? 27 | * Cjax uses PHP sessions to pass data across, some times sessions fail or some setting on the server's cache 28 | * may cause unexpented behavior, and could cause cjax not to able to pass the data - in that case 29 | * this option allows cjax to fallback on a small footprint on the page to be able to pass the pending data. 30 | * 31 | */ 32 | $config->fallback = false; 33 | 34 | /** 35 | * This setting bypasses fallback. Don't turn on fallback and caching at the same time, do one of the two. 36 | */ 37 | $config->caching = false; 38 | 39 | /** 40 | * Allows the access to ajax.php from browser where otherwise it would only allow access to ajax request or inclusion. 41 | */ 42 | $config->ajax_view = false; 43 | 44 | /** 45 | * Config displays javaScript debug information in firebug console. 46 | */ 47 | $config->debug = false; 48 | 49 | /** 50 | * Only debug for this IP: 51 | * Enter an IP below if you want to debug ONLY for this specific IP. 52 | * You may also enter an array of IPs 53 | * 54 | */ 55 | $config->ip_debug = ''; 56 | 57 | /** 58 | * Init URL 59 | * 60 | * $ajax->init() - prints the script tags to include the framework. 61 | * 62 | * Generally you won't need to touch this. If you experience problems where the script path is not being 63 | * set correctly, or you are using very fancy URLs where the paths can be confusing, then you might find 64 | * this helpful. This will help the framework find the correct path to the js file in a case where it cannot 65 | * be found. 66 | * 67 | * Eg: http://your/site/url (where ajax.php is located). 68 | */ 69 | $config->init_url = ''; 70 | 71 | /** 72 | * Use camel case in class names 73 | * 74 | * Make class names 75 | * readLikeThis 76 | * instead of: 77 | * read_like_this 78 | * or 79 | * true is default. 80 | */ 81 | $config->camelize = true; 82 | /** 83 | * if camerilize is true, 84 | * is the first letter capitalize? 85 | */ 86 | $config->camelizeUcfirst = false; 87 | 88 | /** 89 | * Optionally, you may opt to specify a default upload location. 90 | * Uploading plugins may upload files may access a default upload location 91 | * specify that path here. The path may or may not end with a slash. 92 | */ 93 | $config->upload_dir = ''; 94 | 95 | 96 | /** 97 | * URL of directory where images are uploaded. 98 | * Eg: http://yoursite.com/uploads/ 99 | * This setting is used by any feature that would display images 100 | * including the ajax uploader plugin. 101 | */ 102 | $config->preview_url = ''; 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /examples/docs/triggers.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | Triggers 13 | init();?> 14 | 15 | 16 |
17 |
18 | 19 |
20 |
21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 |

Cjax Framework

31 |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 46 |
47 | 48 | 49 |
50 | 51 |
52 | 53 | 54 | 55 | Cjax triggers is the action you take to trigger an event. You can use these triggers to bind actions to elements. 56 | 57 | 58 |
59 | 60 |

Examples

61 | 62 | 63 |
  • 64 | click() 65 |
  • 66 |
  • 67 | change() 68 |
  • 69 |
  • 70 | keyup() 71 |
  • 72 |
  • 73 | keydown() 74 |
  • 75 |
  • 76 | keypress() 77 |
  • 78 |
  • 79 | On() 80 |
  • 81 |
    82 | 83 | 84 | 85 | 86 | 87 | 88 |
    89 |
    90 | 91 | 92 |
    93 |

    94 | Previous Topic:  Previous Class 95 |    ·   96 | Top of Page   ·   97 | Demos Home   ·   98 | 99 |

    100 |

    101 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  102 | Cjax 103 |

    104 |
    105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /examples/append.php: -------------------------------------------------------------------------------- 1 | append('#response','This HTML was appended to #response'); 8 | 9 | $ajax->append('#response','#other_element'); 10 | ?> 11 | 12 | 13 | 14 | Prepend 15 | init();?> 16 | 17 | 18 |
    19 |
    20 | 21 |
    22 |
    23 | 24 | 25 | 26 |
    27 | 28 | 29 | 30 | 31 | 32 |

    Cjax Framework

    33 |
    34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 46 | 47 | 48 |
    49 | 50 | 51 |
    52 | 53 |
    54 | 55 | 56 | 57 | Append html or elements after target element 58 | 59 | 60 | 61 |
    62 | 63 |

    Examples

    64 | 65 | 66 | 67 | code(" 69 | //Appending HTML 70 | \$ajax->append('#response','This HTML was appended to #response'); 71 | //Appending or moving an element to #response 72 | \$ajax->append('#response','#other_element'); 73 | ", true, true); 74 | ?> 75 | 76 |
    #Response
    77 |
     
    78 |
     
    79 |
    #Other element
    80 | 81 |
    82 |
    83 | 84 | 85 |
    86 |

    87 | Previous Topic:  Previous Class 88 |    ·   89 | Top of Page   ·   90 | Demos Home   ·   91 | 92 |

    93 |

    94 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  95 | Cjax 96 |

    97 |
    98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /examples/cross_domain_ajax.php: -------------------------------------------------------------------------------- 1 | config->crossdomain_url; //reserved, some servers don't allow outbund requestt. 10 | //For testing purposes the crossdomain_url setting can be speficied in config. 11 | if(!$url) { 12 | $url = 'http://ajax-framework-for-codeigniter.googlecode.com/svn/trunk/_extra/test/cross_domain.php'; 13 | } 14 | 15 | $ajax->click('btn_request', $ajax->call($url,'div_response')); 16 | 17 | 18 | ?> 19 | 20 | 21 | 22 | Cross Domain Ajax 23 | init();?> 24 | 25 | 26 |
    27 |
    28 | 29 |
    30 |
    31 | 32 | 33 | 34 |
    35 | 36 | 37 | 38 | 39 | 40 |

    Cjax Framework

    41 |
    42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 54 | 55 | 56 |
    57 | 58 | 59 |
    60 | 61 |
    62 | 63 | 64 | With cross domain ajax you can request any other remote content/html or text back and forth, you can also request commands from remote ajax controllers. 65 | 66 | 67 |

    Examples

    68 | 69 | code(" 71 | \$ajax->click('btn_request', \$ajax->call('https://raw.githubusercontent.com/ajaxboy/cjax/master/CHANGELOG.txt','div_response')); 72 | ", true, true); 73 | ?> 74 | 75 | 76 | The link bellow will fire a request to a different domain. 77 |
    78 | Request 79 |
    80 |
    81 | 82 |
    83 |
    84 | 85 | 86 |
    87 |

    88 | Previous Topic:  Previous Class 89 |    ·   90 | Top of Page   ·   91 | Demos Home   ·   92 | 93 |

    94 |

    95 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  96 | Cjax 97 |

    98 |
    99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /cjax/plugins/pagination/pagination.css: -------------------------------------------------------------------------------- 1 | .pagination { 2 | display: inline-block; 3 | padding-left: 0; 4 | margin: 20px 0; 5 | border-radius: 4px; 6 | } 7 | .pagination > li { 8 | display: inline; 9 | } 10 | .pagination > li > a, 11 | .pagination > li > span { 12 | position: relative; 13 | float: left; 14 | padding: 6px 12px; 15 | margin-left: -1px; 16 | line-height: 1.42857143; 17 | color: #428bca; 18 | text-decoration: none; 19 | background-color: #fff; 20 | border: 1px solid #ddd; 21 | } 22 | .pagination > li:first-child > a, 23 | .pagination > li:first-child > span { 24 | margin-left: 0; 25 | border-top-left-radius: 4px; 26 | border-bottom-left-radius: 4px; 27 | } 28 | .pagination > li:last-child > a, 29 | .pagination > li:last-child > span { 30 | border-top-right-radius: 4px; 31 | border-bottom-right-radius: 4px; 32 | } 33 | .pagination > li > a:hover, 34 | .pagination > li > span:hover, 35 | .pagination > li > a:focus, 36 | .pagination > li > span:focus { 37 | color: #2a6496; 38 | background-color: #eee; 39 | border-color: #ddd; 40 | } 41 | .pagination > .active > a, 42 | .pagination > .active > span, 43 | .pagination > .active > a:hover, 44 | .pagination > .active > span:hover, 45 | .pagination > .active > a:focus, 46 | .pagination > .active > span:focus { 47 | z-index: 2; 48 | color: #fff; 49 | cursor: default; 50 | background-color: #428bca; 51 | border-color: #428bca; 52 | } 53 | .pagination > .disabled > span, 54 | .pagination > .disabled > span:hover, 55 | .pagination > .disabled > span:focus, 56 | .pagination > .disabled > a, 57 | .pagination > .disabled > a:hover, 58 | .pagination > .disabled > a:focus { 59 | color: #777; 60 | cursor: not-allowed; 61 | background-color: #fff; 62 | border-color: #ddd; 63 | } 64 | .pagination-lg > li > a, 65 | .pagination-lg > li > span { 66 | padding: 10px 16px; 67 | font-size: 18px; 68 | } 69 | .pagination-lg > li:first-child > a, 70 | .pagination-lg > li:first-child > span { 71 | border-top-left-radius: 6px; 72 | border-bottom-left-radius: 6px; 73 | } 74 | .pagination-lg > li:last-child > a, 75 | .pagination-lg > li:last-child > span { 76 | border-top-right-radius: 6px; 77 | border-bottom-right-radius: 6px; 78 | } 79 | .pagination-sm > li > a, 80 | .pagination-sm > li > span { 81 | padding: 5px 10px; 82 | font-size: 12px; 83 | } 84 | .pagination-sm > li:first-child > a, 85 | .pagination-sm > li:first-child > span { 86 | border-top-left-radius: 3px; 87 | border-bottom-left-radius: 3px; 88 | } 89 | .pagination-sm > li:last-child > a, 90 | .pagination-sm > li:last-child > span { 91 | border-top-right-radius: 3px; 92 | border-bottom-right-radius: 3px; 93 | } 94 | .pager { 95 | padding-left: 0; 96 | margin: 20px 0; 97 | text-align: center; 98 | list-style: none; 99 | } 100 | .pager li { 101 | display: inline; 102 | } 103 | .pager li > a, 104 | .pager li > span { 105 | display: inline-block; 106 | padding: 5px 14px; 107 | background-color: #fff; 108 | border: 1px solid #ddd; 109 | border-radius: 15px; 110 | } 111 | .pager li > a:hover, 112 | .pager li > a:focus { 113 | text-decoration: none; 114 | background-color: #eee; 115 | } 116 | .pager .next > a, 117 | .pager .next > span { 118 | float: right; 119 | } 120 | .pager .previous > a, 121 | .pager .previous > span { 122 | float: left; 123 | } 124 | .pager .disabled > a, 125 | .pager .disabled > a:hover, 126 | .pager .disabled > a:focus, 127 | .pager .disabled > span { 128 | color: #777; 129 | cursor: not-allowed; 130 | background-color: #fff; 131 | } -------------------------------------------------------------------------------- /examples/post.php: -------------------------------------------------------------------------------- 1 | 'world', 12 | 'world' => 'hello!', 13 | 'someVar' => 'someValue', 14 | 'x' => 'y' 15 | ); 16 | 17 | $ajax->post = $vars; 18 | $ajax->call("ajax.php?post/post_sample",'div_response'); 19 | ?> 20 | 21 | 22 | 23 | Post Data Width Ajax 24 | init();?> 25 | 26 | 27 |
    28 |
    29 | 30 |
    31 |
    32 | 33 | 34 | 35 |
    36 | 37 | 38 | 39 | 40 | 41 |

    Cjax Framework

    42 |
    43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 55 | 56 | 57 |
    58 | 59 | 60 |
    61 | 62 |
    63 | 64 | 65 | 66 | Post variables using ajax 67 | 68 | 69 |
    70 | 71 |

    Examples

    72 | 73 | 74 | 75 |
    76 | code(" 78 | \$vars = array( 79 | 'hello' => 'world', 80 | 'world' => 'hello!', 81 | 'someVar' => 'someValue', 82 | 'x' => 'y' 83 | ); 84 | 85 | \$ajax->post = \$vars; 86 | \$ajax->call(\"ajax.php?post/post_sample\",'div_response'); 87 | "); 88 | ?> 89 | Controller: 90 | code(" 92 | class post { 93 | 94 | 95 | function post_sample() 96 | { 97 | echo 'Response is
    '.print_r(\$_POST,1).'
    '; 98 | } 99 | } 100 | ", true , true); 101 | ?> 102 | 103 | 104 | 105 | 106 | 107 |
    108 | 109 |
    110 |
    111 | 112 | 113 |
    114 |

    115 | Previous Topic:  Previous Class 116 |    ·   117 | Top of Page   ·   118 | Demos Home   ·   119 | 120 |

    121 |

    122 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  123 | Cjax 124 |

    125 |
    126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /examples/replace.php: -------------------------------------------------------------------------------- 1 | replace('#response',"
    #response was replaced with this html
    "); 9 | 10 | $ajax->replace('#other_element',"#other_element2"); 11 | ?> 12 | 13 | 14 | 15 | Replace elements with ajax 16 | init();?> 17 | 18 | 19 |
    20 |
    21 | 22 |
    23 |
    24 | 25 | 26 | 27 |
    28 | 29 | 30 | 31 | 32 | 33 |

    Cjax Framework

    34 |
    35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 47 | 48 | 49 |
    50 | 51 | 52 |
    53 | 54 |
    55 | 56 | 57 | 58 | Replace an element with other element or with HTML. 59 | 60 | 61 | 62 |
    63 | 64 |

    Examples

    65 | 66 | 67 | 68 | code(" 70 | \$ajax->replace('#response',\"
    #response was replaced with this html
    \"); 71 | //Appending or moving an element to #response 72 | \$ajax->replace('#other_element',\"#other_element2\"); 73 | ", true, true); 74 | ?> 75 | 76 | 77 |
    #Response
    78 |
     
    79 |
    #Other element
    80 |
    #Other element2: This element replace #Other element
    81 | 82 |
    83 |
    84 | 85 | 86 |
    87 |

    88 | Previous Topic:  Previous Class 89 |    ·   90 | Top of Page   ·   91 | Demos Home   ·   92 | 93 |

    94 |

    95 | CodeIgniter  ·  Copyright © 2006 - 2012  ·  96 | Cjax 97 |

    98 |
    99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /examples/send_form.php: -------------------------------------------------------------------------------- 1 | click("btnSubmit",$ajax->form("ajax.php?send_form/submit_form")); 7 | 8 | ### below is an HTML form. All you need is the id of the button that submits the form, and all the code is needed is above. 9 | ### look inside controllers/send_form.php for response code sample. 10 | 11 | ?> 12 | 13 | 14 | init(false);?> 15 | 16 | Send Form... 17 | 18 | 19 | 20 | 21 |

    Submit form with Ajax

    22 |
    23 | Convert any HTML form over to ajax 24 |
    25 |
    26 |
    27 | code(" 29 | //bind button to ajax-form request 30 | //gets the buttons's form and uses it. 31 | \$ajax->click(\"btnSubmit\",\$ajax->form(\"ajax.php?send_form/submit_form\")); 32 | ");?> 33 | Controller: 34 | code(" 36 | class send_form { 37 | 38 | function submit_form(\$form_fields) 39 | { 40 | \$ajax = ajax(); 41 | 42 | \$ajax->alert(\"Server Says....\\n\\t\\t\".print_r(\$form_fields,1)); 43 | } 44 | } 45 | ");?> 46 |
    47 |
    48 | 49 |
    50 | 51 |

    Send form to server using ajax..

    52 | 53 |
    54 |
    55 |

    Submit Form

    56 |

    Send any form data through ajax...

    57 |
    58 |
      59 |
    • 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 |
    • 71 | 72 | 73 |
      74 | 80 | 81 |
      82 |
    • 83 |
    • 84 | 85 |
      86 | 87 |
      88 |
    • 89 | 90 | 91 |
      92 | 93 |
      94 |
    • 95 | 96 |
    • 97 | 98 |
    • 99 |
    100 |
    101 | 104 |
    105 | 106 |
    107 | 108 | 109 | 110 | --------------------------------------------------------------------------------