GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (423)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

system/libraries/Javascript/Jquery.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 49 and the first side effect is on line 38.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * CodeIgniter
4
 *
5
 * An open source application development framework for PHP
6
 *
7
 * This content is released under the MIT License (MIT)
8
 *
9
 * Copyright (c) 2014 - 2015, British Columbia Institute of Technology
10
 *
11
 * Permission is hereby granted, free of charge, to any person obtaining a copy
12
 * of this software and associated documentation files (the "Software"), to deal
13
 * in the Software without restriction, including without limitation the rights
14
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
 * copies of the Software, and to permit persons to whom the Software is
16
 * furnished to do so, subject to the following conditions:
17
 *
18
 * The above copyright notice and this permission notice shall be included in
19
 * all copies or substantial portions of the Software.
20
 *
21
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
 * THE SOFTWARE.
28
 *
29
 * @package	CodeIgniter
30
 * @author	EllisLab Dev Team
31
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
32
 * @copyright	Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
33
 * @license	http://opensource.org/licenses/MIT	MIT License
34
 * @link	http://codeigniter.com
35
 * @since	Version 1.0.0
36
 * @filesource
37
 */
38
defined('BASEPATH') OR exit('No direct script access allowed');
39
40
/**
41
 * Jquery Class
42
 *
43
 * @package		CodeIgniter
44
 * @subpackage	Libraries
45
 * @category	Loader
46
 * @author		EllisLab Dev Team
47
 * @link		http://codeigniter.com/user_guide/libraries/javascript.html
48
 */
49
class CI_Jquery extends CI_Javascript {
50
51
	/**
52
	 * JavaScript directory location
53
	 *
54
	 * @var	string
55
	 */
56
	protected $_javascript_folder = 'js';
57
58
	/**
59
	 * JQuery code for load
60
	 *
61
	 * @var	array
62
	 */
63
	public $jquery_code_for_load = array();
64
65
	/**
66
	 * JQuery code for compile
67
	 *
68
	 * @var	array
69
	 */
70
	public $jquery_code_for_compile = array();
71
72
	/**
73
	 * JQuery corner active flag
74
	 *
75
	 * @var	bool
76
	 */
77
	public $jquery_corner_active = FALSE;
78
79
	/**
80
	 * JQuery table sorter active flag
81
	 *
82
	 * @var	bool
83
	 */
84
	public $jquery_table_sorter_active = FALSE;
85
86
	/**
87
	 * JQuery table sorter pager active
88
	 *
89
	 * @var	bool
90
	 */
91
	public $jquery_table_sorter_pager_active = FALSE;
92
93
	/**
94
	 * JQuery AJAX image
95
	 *
96
	 * @var	string
97
	 */
98
	public $jquery_ajax_img = '';
99
100
	// --------------------------------------------------------------------
101
102
	/**
103
	 * Constructor
104
	 *
105
	 * @param	array	$params
106
	 * @return	void
107
	 */
108
	public function __construct($params)
109
	{
110
		$this->CI =& get_instance();
111
		extract($params);
112
113
		if ($autoload === TRUE)
114
		{
115
			$this->script();
116
		}
117
118
		log_message('info', 'Jquery Class Initialized');
119
	}
120
121
	// --------------------------------------------------------------------
122
	// Event Code
123
	// --------------------------------------------------------------------
124
125
	/**
126
	 * Blur
127
	 *
128
	 * Outputs a jQuery blur event
129
	 *
130
	 * @param	string	The element to attach the event to
131
	 * @param	string	The code to execute
132
	 * @return	string
133
	 */
134
	protected function _blur($element = 'this', $js = '')
135
	{
136
		return $this->_add_event($element, $js, 'blur');
137
	}
138
139
	// --------------------------------------------------------------------
140
141
	/**
142
	 * Change
143
	 *
144
	 * Outputs a jQuery change event
145
	 *
146
	 * @param	string	The element to attach the event to
147
	 * @param	string	The code to execute
148
	 * @return	string
149
	 */
150
	protected function _change($element = 'this', $js = '')
151
	{
152
		return $this->_add_event($element, $js, 'change');
153
	}
154
155
	// --------------------------------------------------------------------
156
157
	/**
158
	 * Click
159
	 *
160
	 * Outputs a jQuery click event
161
	 *
162
	 * @param	string	The element to attach the event to
163
	 * @param	string	The code to execute
164
	 * @param	bool	whether or not to return false
165
	 * @return	string
166
	 */
167
	protected function _click($element = 'this', $js = '', $ret_false = TRUE)
168
	{
169
		is_array($js) OR $js = array($js);
170
171
		if ($ret_false)
172
		{
173
			$js[] = 'return false;';
174
		}
175
176
		return $this->_add_event($element, $js, 'click');
177
	}
178
179
	// --------------------------------------------------------------------
180
181
	/**
182
	 * Double Click
183
	 *
184
	 * Outputs a jQuery dblclick event
185
	 *
186
	 * @param	string	The element to attach the event to
187
	 * @param	string	The code to execute
188
	 * @return	string
189
	 */
190
	protected function _dblclick($element = 'this', $js = '')
191
	{
192
		return $this->_add_event($element, $js, 'dblclick');
193
	}
194
195
	// --------------------------------------------------------------------
196
197
	/**
198
	 * Error
199
	 *
200
	 * Outputs a jQuery error event
201
	 *
202
	 * @param	string	The element to attach the event to
203
	 * @param	string	The code to execute
204
	 * @return	string
205
	 */
206
	protected function _error($element = 'this', $js = '')
207
	{
208
		return $this->_add_event($element, $js, 'error');
209
	}
210
211
	// --------------------------------------------------------------------
212
213
	/**
214
	 * Focus
215
	 *
216
	 * Outputs a jQuery focus event
217
	 *
218
	 * @param	string	The element to attach the event to
219
	 * @param	string	The code to execute
220
	 * @return	string
221
	 */
222
	protected function _focus($element = 'this', $js = '')
223
	{
224
		return $this->_add_event($element, $js, 'focus');
225
	}
226
227
	// --------------------------------------------------------------------
228
229
	/**
230
	 * Hover
231
	 *
232
	 * Outputs a jQuery hover event
233
	 *
234
	 * @param	string	- element
235
	 * @param	string	- Javascript code for mouse over
236
	 * @param	string	- Javascript code for mouse out
237
	 * @return	string
238
	 */
239
	protected function _hover($element = 'this', $over = '', $out = '')
240
	{
241
		$event = "\n\t$(".$this->_prep_element($element).").hover(\n\t\tfunction()\n\t\t{\n\t\t\t{$over}\n\t\t}, \n\t\tfunction()\n\t\t{\n\t\t\t{$out}\n\t\t});\n";
242
243
		$this->jquery_code_for_compile[] = $event;
244
245
		return $event;
246
	}
247
248
	// --------------------------------------------------------------------
249
250
	/**
251
	 * Keydown
252
	 *
253
	 * Outputs a jQuery keydown event
254
	 *
255
	 * @param	string	The element to attach the event to
256
	 * @param	string	The code to execute
257
	 * @return	string
258
	 */
259
	protected function _keydown($element = 'this', $js = '')
260
	{
261
		return $this->_add_event($element, $js, 'keydown');
262
	}
263
264
	// --------------------------------------------------------------------
265
266
	/**
267
	 * Keyup
268
	 *
269
	 * Outputs a jQuery keydown event
270
	 *
271
	 * @param	string	The element to attach the event to
272
	 * @param	string	The code to execute
273
	 * @return	string
274
	 */
275
	protected function _keyup($element = 'this', $js = '')
276
	{
277
		return $this->_add_event($element, $js, 'keyup');
278
	}
279
280
	// --------------------------------------------------------------------
281
282
	/**
283
	 * Load
284
	 *
285
	 * Outputs a jQuery load event
286
	 *
287
	 * @param	string	The element to attach the event to
288
	 * @param	string	The code to execute
289
	 * @return	string
290
	 */
291
	protected function _load($element = 'this', $js = '')
292
	{
293
		return $this->_add_event($element, $js, 'load');
294
	}
295
296
	// --------------------------------------------------------------------
297
298
	/**
299
	 * Mousedown
300
	 *
301
	 * Outputs a jQuery mousedown event
302
	 *
303
	 * @param	string	The element to attach the event to
304
	 * @param	string	The code to execute
305
	 * @return	string
306
	 */
307
	protected function _mousedown($element = 'this', $js = '')
308
	{
309
		return $this->_add_event($element, $js, 'mousedown');
310
	}
311
312
	// --------------------------------------------------------------------
313
314
	/**
315
	 * Mouse Out
316
	 *
317
	 * Outputs a jQuery mouseout event
318
	 *
319
	 * @param	string	The element to attach the event to
320
	 * @param	string	The code to execute
321
	 * @return	string
322
	 */
323
	protected function _mouseout($element = 'this', $js = '')
324
	{
325
		return $this->_add_event($element, $js, 'mouseout');
326
	}
327
328
	// --------------------------------------------------------------------
329
330
	/**
331
	 * Mouse Over
332
	 *
333
	 * Outputs a jQuery mouseover event
334
	 *
335
	 * @param	string	The element to attach the event to
336
	 * @param	string	The code to execute
337
	 * @return	string
338
	 */
339
	protected function _mouseover($element = 'this', $js = '')
340
	{
341
		return $this->_add_event($element, $js, 'mouseover');
342
	}
343
344
	// --------------------------------------------------------------------
345
346
	/**
347
	 * Mouseup
348
	 *
349
	 * Outputs a jQuery mouseup event
350
	 *
351
	 * @param	string	The element to attach the event to
352
	 * @param	string	The code to execute
353
	 * @return	string
354
	 */
355
	protected function _mouseup($element = 'this', $js = '')
356
	{
357
		return $this->_add_event($element, $js, 'mouseup');
358
	}
359
360
	// --------------------------------------------------------------------
361
362
	/**
363
	 * Output
364
	 *
365
	 * Outputs script directly
366
	 *
367
	 * @param	array	$array_js = array()
368
	 * @return	void
369
	 */
370
	protected function _output($array_js = array())
371
	{
372
		if ( ! is_array($array_js))
373
		{
374
			$array_js = array($array_js);
375
		}
376
377
		foreach ($array_js as $js)
378
		{
379
			$this->jquery_code_for_compile[] = "\t".$js."\n";
380
		}
381
	}
382
383
	// --------------------------------------------------------------------
384
385
	/**
386
	 * Resize
387
	 *
388
	 * Outputs a jQuery resize event
389
	 *
390
	 * @param	string	The element to attach the event to
391
	 * @param	string	The code to execute
392
	 * @return	string
393
	 */
394
	protected function _resize($element = 'this', $js = '')
395
	{
396
		return $this->_add_event($element, $js, 'resize');
397
	}
398
399
	// --------------------------------------------------------------------
400
401
	/**
402
	 * Scroll
403
	 *
404
	 * Outputs a jQuery scroll event
405
	 *
406
	 * @param	string	The element to attach the event to
407
	 * @param	string	The code to execute
408
	 * @return	string
409
	 */
410
	protected function _scroll($element = 'this', $js = '')
411
	{
412
		return $this->_add_event($element, $js, 'scroll');
413
	}
414
415
	// --------------------------------------------------------------------
416
417
	/**
418
	 * Unload
419
	 *
420
	 * Outputs a jQuery unload event
421
	 *
422
	 * @param	string	The element to attach the event to
423
	 * @param	string	The code to execute
424
	 * @return	string
425
	 */
426
	protected function _unload($element = 'this', $js = '')
427
	{
428
		return $this->_add_event($element, $js, 'unload');
429
	}
430
431
	// --------------------------------------------------------------------
432
	// Effects
433
	// --------------------------------------------------------------------
434
435
	/**
436
	 * Add Class
437
	 *
438
	 * Outputs a jQuery addClass event
439
	 *
440
	 * @param	string	$element
441
	 * @param	string	$class
442
	 * @return	string
443
	 */
444
	protected function _addClass($element = 'this', $class = '')
445
	{
446
		$element = $this->_prep_element($element);
447
		return '$('.$element.').addClass("'.$class.'");';
448
	}
449
450
	// --------------------------------------------------------------------
451
452
	/**
453
	 * Animate
454
	 *
455
	 * Outputs a jQuery animate event
456
	 *
457
	 * @param	string	$element
458
	 * @param	array	$params
459
	 * @param	string	$speed	'slow', 'normal', 'fast', or time in milliseconds
460
	 * @param	string	$extra
461
	 * @return	string
462
	 */
463
	protected function _animate($element = 'this', $params = array(), $speed = '', $extra = '')
464
	{
465
		$element = $this->_prep_element($element);
466
		$speed = $this->_validate_speed($speed);
467
468
		$animations = "\t\t\t";
469
470
		foreach ($params as $param => $value)
471
		{
472
			$animations .= $param.": '".$value."', ";
473
		}
474
475
		$animations = substr($animations, 0, -2); // remove the last ", "
476
477
		if ($speed !== '')
478
		{
479
			$speed = ', '.$speed;
480
		}
481
482
		if ($extra !== '')
483
		{
484
			$extra = ', '.$extra;
485
		}
486
487
		return "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.');';
488
	}
489
490
	// --------------------------------------------------------------------
491
492
	/**
493
	 * Fade In
494
	 *
495
	 * Outputs a jQuery hide event
496
	 *
497
	 * @param	string	- element
498
	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
499
	 * @param	string	- Javascript callback function
500
	 * @return	string
501
	 */
502 View Code Duplication
	protected function _fadeIn($element = 'this', $speed = '', $callback = '')
503
	{
504
		$element = $this->_prep_element($element);
505
		$speed = $this->_validate_speed($speed);
506
507
		if ($callback !== '')
508
		{
509
			$callback = ", function(){\n{$callback}\n}";
510
		}
511
512
		return "$({$element}).fadeIn({$speed}{$callback});";
513
	}
514
515
	// --------------------------------------------------------------------
516
517
	/**
518
	 * Fade Out
519
	 *
520
	 * Outputs a jQuery hide event
521
	 *
522
	 * @param	string	- element
523
	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
524
	 * @param	string	- Javascript callback function
525
	 * @return	string
526
	 */
527 View Code Duplication
	protected function _fadeOut($element = 'this', $speed = '', $callback = '')
528
	{
529
		$element = $this->_prep_element($element);
530
		$speed = $this->_validate_speed($speed);
531
532
		if ($callback !== '')
533
		{
534
			$callback = ", function(){\n{$callback}\n}";
535
		}
536
537
		return '$('.$element.').fadeOut('.$speed.$callback.');';
538
	}
539
540
	// --------------------------------------------------------------------
541
542
	/**
543
	 * Hide
544
	 *
545
	 * Outputs a jQuery hide action
546
	 *
547
	 * @param	string	- element
548
	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
549
	 * @param	string	- Javascript callback function
550
	 * @return	string
551
	 */
552 View Code Duplication
	protected function _hide($element = 'this', $speed = '', $callback = '')
553
	{
554
		$element = $this->_prep_element($element);
555
		$speed = $this->_validate_speed($speed);
556
557
		if ($callback !== '')
558
		{
559
			$callback = ", function(){\n{$callback}\n}";
560
		}
561
562
		return "$({$element}).hide({$speed}{$callback});";
563
	}
564
565
	// --------------------------------------------------------------------
566
567
	/**
568
	 * Remove Class
569
	 *
570
	 * Outputs a jQuery remove class event
571
	 *
572
	 * @param	string	$element
573
	 * @param	string	$class
574
	 * @return	string
575
	 */
576
	protected function _removeClass($element = 'this', $class = '')
577
	{
578
		$element = $this->_prep_element($element);
579
		return '$('.$element.').removeClass("'.$class.'");';
580
	}
581
582
	// --------------------------------------------------------------------
583
584
	/**
585
	 * Slide Up
586
	 *
587
	 * Outputs a jQuery slideUp event
588
	 *
589
	 * @param	string	- element
590
	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
591
	 * @param	string	- Javascript callback function
592
	 * @return	string
593
	 */
594 View Code Duplication
	protected function _slideUp($element = 'this', $speed = '', $callback = '')
595
	{
596
		$element = $this->_prep_element($element);
597
		$speed = $this->_validate_speed($speed);
598
599
		if ($callback !== '')
600
		{
601
			$callback = ", function(){\n{$callback}\n}";
602
		}
603
604
		return '$('.$element.').slideUp('.$speed.$callback.');';
605
	}
606
607
	// --------------------------------------------------------------------
608
609
	/**
610
	 * Slide Down
611
	 *
612
	 * Outputs a jQuery slideDown event
613
	 *
614
	 * @param	string	- element
615
	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
616
	 * @param	string	- Javascript callback function
617
	 * @return	string
618
	 */
619 View Code Duplication
	protected function _slideDown($element = 'this', $speed = '', $callback = '')
620
	{
621
		$element = $this->_prep_element($element);
622
		$speed = $this->_validate_speed($speed);
623
624
		if ($callback !== '')
625
		{
626
			$callback = ", function(){\n{$callback}\n}";
627
		}
628
629
		return '$('.$element.').slideDown('.$speed.$callback.');';
630
	}
631
632
	// --------------------------------------------------------------------
633
634
	/**
635
	 * Slide Toggle
636
	 *
637
	 * Outputs a jQuery slideToggle event
638
	 *
639
	 * @param	string	- element
640
	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
641
	 * @param	string	- Javascript callback function
642
	 * @return	string
643
	 */
644 View Code Duplication
	protected function _slideToggle($element = 'this', $speed = '', $callback = '')
645
	{
646
		$element = $this->_prep_element($element);
647
		$speed = $this->_validate_speed($speed);
648
649
		if ($callback !== '')
650
		{
651
			$callback = ", function(){\n{$callback}\n}";
652
		}
653
654
		return '$('.$element.').slideToggle('.$speed.$callback.');';
655
	}
656
657
	// --------------------------------------------------------------------
658
659
	/**
660
	 * Toggle
661
	 *
662
	 * Outputs a jQuery toggle event
663
	 *
664
	 * @param	string	- element
665
	 * @return	string
666
	 */
667
	protected function _toggle($element = 'this')
668
	{
669
		$element = $this->_prep_element($element);
670
		return '$('.$element.').toggle();';
671
	}
672
673
	// --------------------------------------------------------------------
674
675
	/**
676
	 * Toggle Class
677
	 *
678
	 * Outputs a jQuery toggle class event
679
	 *
680
	 * @param	string	$element
681
	 * @param	string	$class
682
	 * @return	string
683
	 */
684
	protected function _toggleClass($element = 'this', $class = '')
685
	{
686
		$element = $this->_prep_element($element);
687
		return '$('.$element.').toggleClass("'.$class.'");';
688
	}
689
690
	// --------------------------------------------------------------------
691
692
	/**
693
	 * Show
694
	 *
695
	 * Outputs a jQuery show event
696
	 *
697
	 * @param	string	- element
698
	 * @param	string	- One of 'slow', 'normal', 'fast', or time in milliseconds
699
	 * @param	string	- Javascript callback function
700
	 * @return	string
701
	 */
702 View Code Duplication
	protected function _show($element = 'this', $speed = '', $callback = '')
703
	{
704
		$element = $this->_prep_element($element);
705
		$speed = $this->_validate_speed($speed);
706
707
		if ($callback !== '')
708
		{
709
			$callback = ", function(){\n{$callback}\n}";
710
		}
711
712
		return '$('.$element.').show('.$speed.$callback.');';
713
	}
714
715
	// --------------------------------------------------------------------
716
717
	/**
718
	 * Updater
719
	 *
720
	 * An Ajax call that populates the designated DOM node with
721
	 * returned content
722
	 *
723
	 * @param	string	The element to attach the event to
724
	 * @param	string	the controller to run the call against
725
	 * @param	string	optional parameters
726
	 * @return	string
727
	 */
728
729
	protected function _updater($container = 'this', $controller = '', $options = '')
730
	{
731
		$container = $this->_prep_element($container);
732
		$controller = (strpos('://', $controller) === FALSE) ? $controller : $this->CI->config->site_url($controller);
733
734
		// ajaxStart and ajaxStop are better choices here... but this is a stop gap
735
		if ($this->CI->config->item('javascript_ajax_img') === '')
736
		{
737
			$loading_notifier = 'Loading...';
738
		}
739
		else
740
		{
741
			$loading_notifier = '<img src="'.$this->CI->config->slash_item('base_url').$this->CI->config->item('javascript_ajax_img').'" alt="Loading" />';
742
		}
743
744
		$updater = '$('.$container.").empty();\n" // anything that was in... get it out
745
			."\t\t$(".$container.').prepend("'.$loading_notifier."\");\n"; // to replace with an image
746
747
		$request_options = '';
748
		if ($options !== '')
749
		{
750
			$request_options .= ', {'
751
					.(is_array($options) ? "'".implode("', '", $options)."'" : "'".str_replace(':', "':'", $options)."'")
752
					.'}';
753
		}
754
755
		return $updater."\t\t$($container).load('$controller'$request_options);";
756
	}
757
758
	// --------------------------------------------------------------------
759
	// Pre-written handy stuff
760
	// --------------------------------------------------------------------
761
762
	/**
763
	 * Zebra tables
764
	 *
765
	 * @param	string	$class
766
	 * @param	string	$odd
767
	 * @param	string	$hover
768
	 * @return	string
769
	 */
770
	protected function _zebraTables($class = '', $odd = 'odd', $hover = '')
771
	{
772
		$class = ($class !== '') ? '.'.$class : '';
773
		$zebra = "\t\$(\"table{$class} tbody tr:nth-child(even)\").addClass(\"{$odd}\");";
774
775
		$this->jquery_code_for_compile[] = $zebra;
776
777
		if ($hover !== '')
778
		{
779
			$hover = $this->hover("table{$class} tbody tr", "$(this).addClass('hover');", "$(this).removeClass('hover');");
780
		}
781
782
		return $zebra;
783
	}
784
785
	// --------------------------------------------------------------------
786
	// Plugins
787
	// --------------------------------------------------------------------
788
789
	/**
790
	 * Corner Plugin
791
	 *
792
	 * @link	http://www.malsup.com/jquery/corner/
793
	 * @param	string	$element
794
	 * @param	string	$corner_style
795
	 * @return	string
796
	 */
797
	public function corner($element = '', $corner_style = '')
798
	{
799
		// may want to make this configurable down the road
800
		$corner_location = '/plugins/jquery.corner.js';
801
802
		if ($corner_style !== '')
803
		{
804
			$corner_style = '"'.$corner_style.'"';
805
		}
806
807
		return '$('.$this->_prep_element($element).').corner('.$corner_style.');';
808
	}
809
810
	// --------------------------------------------------------------------
811
812
	/**
813
	 * Modal window
814
	 *
815
	 * Load a thickbox modal window
816
	 *
817
	 * @param	string	$src
818
	 * @param	bool	$relative
819
	 * @return	void
820
	 */
821
	public function modal($src, $relative = FALSE)
822
	{
823
		$this->jquery_code_for_load[] = $this->external($src, $relative);
824
	}
825
826
	// --------------------------------------------------------------------
827
828
	/**
829
	 * Effect
830
	 *
831
	 * Load an Effect library
832
	 *
833
	 * @param	string	$src
834
	 * @param	bool	$relative
835
	 * @return	void
836
	 */
837
	public function effect($src, $relative = FALSE)
838
	{
839
		$this->jquery_code_for_load[] = $this->external($src, $relative);
840
	}
841
842
	// --------------------------------------------------------------------
843
844
	/**
845
	 * Plugin
846
	 *
847
	 * Load a plugin library
848
	 *
849
	 * @param	string	$src
850
	 * @param	bool	$relative
851
	 * @return	void
852
	 */
853
	public function plugin($src, $relative = FALSE)
854
	{
855
		$this->jquery_code_for_load[] = $this->external($src, $relative);
856
	}
857
858
	// --------------------------------------------------------------------
859
860
	/**
861
	 * UI
862
	 *
863
	 * Load a user interface library
864
	 *
865
	 * @param	string	$src
866
	 * @param	bool	$relative
867
	 * @return	void
868
	 */
869
	public function ui($src, $relative = FALSE)
870
	{
871
		$this->jquery_code_for_load[] = $this->external($src, $relative);
872
	}
873
874
	// --------------------------------------------------------------------
875
876
	/**
877
	 * Sortable
878
	 *
879
	 * Creates a jQuery sortable
880
	 *
881
	 * @param	string	$element
882
	 * @param	array	$options
883
	 * @return	string
884
	 */
885
	public function sortable($element, $options = array())
886
	{
887
		if (count($options) > 0)
888
		{
889
			$sort_options = array();
890
			foreach ($options as $k=>$v)
891
			{
892
				$sort_options[] = "\n\t\t".$k.': '.$v;
893
			}
894
			$sort_options = implode(',', $sort_options);
895
		}
896
		else
897
		{
898
			$sort_options = '';
899
		}
900
901
		return '$('.$this->_prep_element($element).').sortable({'.$sort_options."\n\t});";
902
	}
903
904
	// --------------------------------------------------------------------
905
906
	/**
907
	 * Table Sorter Plugin
908
	 *
909
	 * @param	string	table name
910
	 * @param	string	plugin location
911
	 * @return	string
912
	 */
913
	public function tablesorter($table = '', $options = '')
914
	{
915
		$this->jquery_code_for_compile[] = "\t$(".$this->_prep_element($table).').tablesorter('.$options.");\n";
916
	}
917
918
	// --------------------------------------------------------------------
919
	// Class functions
920
	// --------------------------------------------------------------------
921
922
	/**
923
	 * Add Event
924
	 *
925
	 * Constructs the syntax for an event, and adds to into the array for compilation
926
	 *
927
	 * @param	string	The element to attach the event to
928
	 * @param	string	The code to execute
929
	 * @param	string	The event to pass
930
	 * @return	string
931
	 */
932
	protected function _add_event($element, $js, $event)
933
	{
934
		if (is_array($js))
935
		{
936
			$js = implode("\n\t\t", $js);
937
		}
938
939
		$event = "\n\t$(".$this->_prep_element($element).').'.$event."(function(){\n\t\t{$js}\n\t});\n";
940
		$this->jquery_code_for_compile[] = $event;
941
		return $event;
942
	}
943
944
	// --------------------------------------------------------------------
945
946
	/**
947
	 * Compile
948
	 *
949
	 * As events are specified, they are stored in an array
950
	 * This function compiles them all for output on a page
951
	 *
952
	 * @param	string	$view_var
953
	 * @param	bool	$script_tags
954
	 * @return	void
955
	 */
956
	protected function _compile($view_var = 'script_foot', $script_tags = TRUE)
957
	{
958
		// External references
959
		$external_scripts = implode('', $this->jquery_code_for_load);
960
		$this->CI->load->vars(array('library_src' => $external_scripts));
961
962
		if (count($this->jquery_code_for_compile) === 0)
963
		{
964
			// no inline references, let's just return
965
			return;
966
		}
967
968
		// Inline references
969
		$script = '$(document).ready(function() {'."\n"
970
			.implode('', $this->jquery_code_for_compile)
971
			.'});';
972
973
		$output = ($script_tags === FALSE) ? $script : $this->inline($script);
974
975
		$this->CI->load->vars(array($view_var => $output));
976
	}
977
978
	// --------------------------------------------------------------------
979
980
	/**
981
	 * Clear Compile
982
	 *
983
	 * Clears the array of script events collected for output
984
	 *
985
	 * @return	void
986
	 */
987
	protected function _clear_compile()
988
	{
989
		$this->jquery_code_for_compile = array();
990
	}
991
992
	// --------------------------------------------------------------------
993
994
	/**
995
	 * Document Ready
996
	 *
997
	 * A wrapper for writing document.ready()
998
	 *
999
	 * @param	array	$js
1000
	 * @return	void
1001
	 */
1002
	protected function _document_ready($js)
1003
	{
1004
		is_array($js) OR $js = array($js);
1005
1006
		foreach ($js as $script)
1007
		{
1008
			$this->jquery_code_for_compile[] = $script;
1009
		}
1010
	}
1011
1012
	// --------------------------------------------------------------------
1013
1014
	/**
1015
	 * Script Tag
1016
	 *
1017
	 * Outputs the script tag that loads the jquery.js file into an HTML document
1018
	 *
1019
	 * @param	string	$library_src
1020
	 * @param	bool	$relative
1021
	 * @return	string
1022
	 */
1023
	public function script($library_src = '', $relative = FALSE)
1024
	{
1025
		$library_src = $this->external($library_src, $relative);
1026
		$this->jquery_code_for_load[] = $library_src;
1027
		return $library_src;
1028
	}
1029
1030
	// --------------------------------------------------------------------
1031
1032
	/**
1033
	 * Prep Element
1034
	 *
1035
	 * Puts HTML element in quotes for use in jQuery code
1036
	 * unless the supplied element is the Javascript 'this'
1037
	 * object, in which case no quotes are added
1038
	 *
1039
	 * @param	string
1040
	 * @return	string
1041
	 */
1042
	protected function _prep_element($element)
1043
	{
1044
		if ($element !== 'this')
1045
		{
1046
			$element = '"'.$element.'"';
1047
		}
1048
1049
		return $element;
1050
	}
1051
1052
	// --------------------------------------------------------------------
1053
1054
	/**
1055
	 * Validate Speed
1056
	 *
1057
	 * Ensures the speed parameter is valid for jQuery
1058
	 *
1059
	 * @param	string
1060
	 * @return	string
1061
	 */
1062
	protected function _validate_speed($speed)
1063
	{
1064
		if (in_array($speed, array('slow', 'normal', 'fast')))
1065
		{
1066
			return '"'.$speed.'"';
1067
		}
1068
		elseif (preg_match('/[^0-9]/', $speed))
1069
		{
1070
			return '';
1071
		}
1072
1073
		return $speed;
1074
	}
1075
1076
}
1077