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