Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Jquery often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Jquery, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 18 | class Jquery { |
||
|
1 ignored issue
–
show
|
|||
| 19 | protected $_di; |
||
|
1 ignored issue
–
show
|
|||
| 20 | protected $_ui; |
||
|
1 ignored issue
–
show
|
|||
| 21 | protected $_bootstrap; |
||
|
1 ignored issue
–
show
|
|||
| 22 | protected $libraryFile; |
||
| 23 | protected $_javascript_folder='js'; |
||
|
1 ignored issue
–
show
|
|||
| 24 | protected $jquery_code_for_load=array (); |
||
| 25 | protected $jquery_code_for_compile=array (); |
||
| 26 | protected $jquery_corner_active=FALSE; |
||
| 27 | protected $jquery_table_sorter_active=FALSE; |
||
| 28 | protected $jquery_table_sorter_pager_active=FALSE; |
||
| 29 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
||
| 30 | protected $jquery_events=array ( |
||
| 31 | "bind","blur","change","click","dblclick","delegate","die","error","focus","focusin","focusout","hover","keydown","keypress","keyup","live","load","mousedown","mousseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","off","on","one","ready","resize","scroll","select","submit","toggle","trigger","triggerHandler","undind","undelegate","unload" |
||
| 32 | ); |
||
| 33 | |||
| 34 | public function setDi($di) { |
||
| 37 | |||
| 38 | public function ui($ui=NULL) { |
||
| 44 | |||
| 45 | public function bootstrap($bootstrap=NULL) { |
||
| 51 | |||
| 52 | public function __construct() { |
||
| 54 | |||
| 55 | // -------------------------------------------------------------------- |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Inline |
||
| 59 | * |
||
| 60 | * Outputs a <script> tag |
||
| 61 | * |
||
| 62 | * @access public |
||
| 63 | * @param string $script |
||
| 64 | * @param boolean $cdata a CDATA section should be added |
||
| 65 | * @return string |
||
| 66 | */ |
||
| 67 | View Code Duplication | public function inline($script, $cdata=TRUE) { |
|
| 74 | |||
| 75 | // -------------------------------------------------------------------- |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Open Script |
||
| 79 | * |
||
| 80 | * Outputs an opening <script> |
||
| 81 | * |
||
| 82 | * @access private |
||
| 83 | * @param string $src |
||
| 84 | * @return string |
||
| 85 | */ |
||
| 86 | private function _open_script($src='') { |
||
| 91 | |||
| 92 | // -------------------------------------------------------------------- |
||
| 93 | |||
| 94 | /** |
||
| 95 | * Close Script |
||
| 96 | * |
||
| 97 | * Outputs an closing </script> |
||
| 98 | * |
||
| 99 | * @param string |
||
| 100 | * @return string |
||
| 101 | */ |
||
| 102 | private function _close_script($extra="\n") { |
||
| 105 | |||
| 106 | public function getLibraryScript() { |
||
| 111 | |||
| 112 | public function setLibraryFile($name) { |
||
| 115 | |||
| 116 | public function _setAjaxLoader($loader) { |
||
| 119 | |||
| 120 | // -------------------------------------------------------------------- |
||
| 121 | // Event Code |
||
| 122 | // -------------------------------------------------------------------- |
||
| 123 | |||
| 124 | /** |
||
| 125 | * Blur |
||
| 126 | * |
||
| 127 | * Outputs a jQuery blur event |
||
| 128 | * |
||
| 129 | * @param string The element to attach the event to |
||
| 130 | * @param string The code to execute |
||
| 131 | * @return string |
||
| 132 | */ |
||
| 133 | public function _blur($element='this', $js='') { |
||
| 136 | |||
| 137 | // -------------------------------------------------------------------- |
||
| 138 | |||
| 139 | /** |
||
| 140 | * Change |
||
| 141 | * |
||
| 142 | * Outputs a jQuery change event |
||
| 143 | * |
||
| 144 | * @param string The element to attach the event to |
||
| 145 | * @param string The code to execute |
||
| 146 | * @return string |
||
| 147 | */ |
||
| 148 | public function _change($element='this', $js='') { |
||
| 151 | |||
| 152 | // -------------------------------------------------------------------- |
||
| 153 | |||
| 154 | /** |
||
| 155 | * Outputs a jQuery click event |
||
| 156 | * |
||
| 157 | * @param string $element The element to attach the event to |
||
| 158 | * @param mixed $js The code to execute |
||
| 159 | * @param boolean $ret_false whether or not to return false |
||
| 160 | * @return string |
||
| 161 | */ |
||
| 162 | public function _click($element='this', $js=array(), $ret_false=TRUE) { |
||
| 175 | |||
| 176 | /** |
||
| 177 | * Outputs a jQuery contextmenu event |
||
| 178 | * |
||
| 179 | * @param string The element to attach the event to |
||
| 180 | * @param string The code to execute |
||
| 181 | * @return string |
||
| 182 | */ |
||
| 183 | public function _contextmenu($element='this', $js='') { |
||
| 186 | |||
| 187 | // -------------------------------------------------------------------- |
||
| 188 | |||
| 189 | /** |
||
| 190 | * Outputs a jQuery dblclick event |
||
| 191 | * |
||
| 192 | * @param string The element to attach the event to |
||
| 193 | * @param string The code to execute |
||
| 194 | * @return string |
||
| 195 | */ |
||
| 196 | public function _dblclick($element='this', $js='') { |
||
| 199 | |||
| 200 | // -------------------------------------------------------------------- |
||
| 201 | |||
| 202 | /** |
||
| 203 | * Outputs a jQuery error event |
||
| 204 | * |
||
| 205 | * @param string The element to attach the event to |
||
| 206 | * @param string The code to execute |
||
| 207 | * @return string |
||
| 208 | */ |
||
| 209 | public function _error($element='this', $js='') { |
||
| 212 | |||
| 213 | // -------------------------------------------------------------------- |
||
| 214 | |||
| 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 | public function _focus($element='this', $js='') { |
||
| 225 | |||
| 226 | // -------------------------------------------------------------------- |
||
| 227 | |||
| 228 | /** |
||
| 229 | * Outputs a jQuery hover event |
||
| 230 | * |
||
| 231 | * @param string - element |
||
| 232 | * @param string - Javascript code for mouse over |
||
| 233 | * @param string - Javascript code for mouse out |
||
| 234 | * @return string |
||
| 235 | */ |
||
| 236 | public function _hover($element='this', $over, $out) { |
||
| 243 | |||
| 244 | // -------------------------------------------------------------------- |
||
| 245 | |||
| 246 | /** |
||
| 247 | * Outputs a jQuery keydown event |
||
| 248 | * |
||
| 249 | * @param string The element to attach the event to |
||
| 250 | * @param string The code to execute |
||
| 251 | * @return string |
||
| 252 | */ |
||
| 253 | public function _keydown($element='this', $js='') { |
||
| 256 | |||
| 257 | // -------------------------------------------------------------------- |
||
| 258 | |||
| 259 | /** |
||
| 260 | * Outputs a jQuery keypress event |
||
| 261 | * |
||
| 262 | * @param string The element to attach the event to |
||
| 263 | * @param string The code to execute |
||
| 264 | * @return string |
||
| 265 | */ |
||
| 266 | public function _keypress($element='this', $js='') { |
||
| 269 | |||
| 270 | // -------------------------------------------------------------------- |
||
| 271 | |||
| 272 | /** |
||
| 273 | * Outputs a jQuery keydown event |
||
| 274 | * |
||
| 275 | * @param string The element to attach the event to |
||
| 276 | * @param string The code to execute |
||
| 277 | * @return string |
||
| 278 | */ |
||
| 279 | public function _keyup($element='this', $js='') { |
||
| 282 | |||
| 283 | // -------------------------------------------------------------------- |
||
| 284 | |||
| 285 | /** |
||
| 286 | * Outputs a jQuery load event |
||
| 287 | * |
||
| 288 | * @param string The element to attach the event to |
||
| 289 | * @param string The code to execute |
||
| 290 | * @return string |
||
| 291 | */ |
||
| 292 | public function _load($element='this', $js='') { |
||
| 295 | |||
| 296 | // -------------------------------------------------------------------- |
||
| 297 | |||
| 298 | /** |
||
| 299 | * Outputs a jQuery mousedown event |
||
| 300 | * |
||
| 301 | * @param string The element to attach the event to |
||
| 302 | * @param string The code to execute |
||
| 303 | * @return string |
||
| 304 | */ |
||
| 305 | public function _mousedown($element='this', $js='') { |
||
| 308 | |||
| 309 | // -------------------------------------------------------------------- |
||
| 310 | |||
| 311 | /** |
||
| 312 | * Outputs a jQuery mouseout event |
||
| 313 | * |
||
| 314 | * @param string The element to attach the event to |
||
| 315 | * @param string The code to execute |
||
| 316 | * @return string |
||
| 317 | */ |
||
| 318 | public function _mouseout($element='this', $js='') { |
||
| 321 | |||
| 322 | // -------------------------------------------------------------------- |
||
| 323 | |||
| 324 | /** |
||
| 325 | * Outputs a jQuery mouseover event |
||
| 326 | * |
||
| 327 | * @param string The element to attach the event to |
||
| 328 | * @param string The code to execute |
||
| 329 | * @return string |
||
| 330 | */ |
||
| 331 | public function _mouseover($element='this', $js='') { |
||
| 334 | |||
| 335 | // -------------------------------------------------------------------- |
||
| 336 | |||
| 337 | /** |
||
| 338 | * Outputs a jQuery mouseup event |
||
| 339 | * |
||
| 340 | * @param string The element to attach the event to |
||
| 341 | * @param string The code to execute |
||
| 342 | * @return string |
||
| 343 | */ |
||
| 344 | public function _mouseup($element='this', $js='') { |
||
| 347 | |||
| 348 | // -------------------------------------------------------------------- |
||
| 349 | |||
| 350 | /** |
||
| 351 | * Outputs script directly |
||
| 352 | * |
||
| 353 | * @param string The element to attach the event to |
||
| 354 | * @param string The code to execute |
||
| 355 | * @return string |
||
| 356 | */ |
||
| 357 | public function _output($array_js='') { |
||
| 368 | |||
| 369 | // -------------------------------------------------------------------- |
||
| 370 | |||
| 371 | /** |
||
| 372 | * Outputs a jQuery resize event |
||
| 373 | * |
||
| 374 | * @param string The element to attach the event to |
||
| 375 | * @param string The code to execute |
||
| 376 | * @return string |
||
| 377 | */ |
||
| 378 | public function _resize($element='this', $js='') { |
||
| 381 | |||
| 382 | // -------------------------------------------------------------------- |
||
| 383 | |||
| 384 | /** |
||
| 385 | * Outputs a jQuery scroll event |
||
| 386 | * |
||
| 387 | * @param string The element to attach the event to |
||
| 388 | * @param string The code to execute |
||
| 389 | * @return string |
||
| 390 | */ |
||
| 391 | public function _scroll($element='this', $js='') { |
||
| 394 | |||
| 395 | // -------------------------------------------------------------------- |
||
| 396 | |||
| 397 | /** |
||
| 398 | * Outputs a jQuery unload event |
||
| 399 | * |
||
| 400 | * @param string The element to attach the event to |
||
| 401 | * @param string The code to execute |
||
| 402 | * @return string |
||
| 403 | */ |
||
| 404 | public function _unload($element='this', $js='') { |
||
| 407 | |||
| 408 | // -------------------------------------------------------------------- |
||
| 409 | // Effects |
||
| 410 | // -------------------------------------------------------------------- |
||
| 411 | |||
| 412 | /** |
||
| 413 | * Insert content, specified by the parameter, after each element in the set of matched elements |
||
| 414 | * @param string $element |
||
| 415 | * @param string $value |
||
| 416 | * @param boolean $immediatly defers the execution if set to false |
||
| 417 | * @return string |
||
| 418 | */ |
||
| 419 | View Code Duplication | public function after($element='this', $value='', $immediatly=false){ |
|
| 427 | |||
| 428 | /** |
||
| 429 | * Get or set the value of an attribute for the first element in the set of matched elements or set one or more attributes for every matched element. |
||
| 430 | * @param string $element |
||
| 431 | * @param string $attributeName |
||
| 432 | * @param string $value |
||
| 433 | * @param boolean $immediatly delayed if false |
||
| 434 | */ |
||
| 435 | View Code Duplication | public function _attr($element='this', $attributeName, $value="", $immediatly=false) { |
|
| 446 | |||
| 447 | /** |
||
| 448 | * Execute a generic jQuery call with a value. |
||
| 449 | * @param string $jQueryCall |
||
| 450 | * @param string $element |
||
| 451 | * @param string $param |
||
| 452 | * @param boolean $immediatly delayed if false |
||
| 453 | */ |
||
| 454 | View Code Duplication | public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) { |
|
| 465 | /** |
||
| 466 | * Execute a generic jQuery call with 2 elements. |
||
| 467 | * @param string $jQueryCall |
||
| 468 | * @param string $to |
||
| 469 | * @param string $element |
||
| 470 | * @param boolean $immediatly delayed if false |
||
| 471 | * @return string |
||
| 472 | */ |
||
| 473 | public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) { |
||
| 481 | // -------------------------------------------------------------------- |
||
| 482 | |||
| 483 | /** |
||
| 484 | * Outputs a jQuery animate event |
||
| 485 | * |
||
| 486 | * @param string $element element |
||
| 487 | * @param string|array $params One of 'slow', 'normal', 'fast', or time in milliseconds |
||
| 488 | * @param string $speed |
||
| 489 | * @param string $extra |
||
| 490 | * @param boolean $immediatly delayed if false |
||
| 491 | * @return string |
||
| 492 | */ |
||
| 493 | public function _animate($element='this', $params=array(), $speed='', $extra='', $immediatly=false) { |
||
| 519 | |||
| 520 | // -------------------------------------------------------------------- |
||
| 521 | |||
| 522 | /** |
||
| 523 | * Outputs a jQuery hide event |
||
| 524 | * |
||
| 525 | * @param string $element element |
||
| 526 | * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds |
||
| 527 | * @param string $callback Javascript callback function |
||
| 528 | * @param boolean $immediatly delayed if false |
||
| 529 | * @return string |
||
| 530 | */ |
||
| 531 | View Code Duplication | public function _fadeIn($element='this', $speed='', $callback='', $immediatly=false) { |
|
| 545 | |||
| 546 | // -------------------------------------------------------------------- |
||
| 547 | |||
| 548 | /** |
||
| 549 | * Outputs a jQuery hide event |
||
| 550 | * |
||
| 551 | * @param string $element element |
||
| 552 | * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds |
||
| 553 | * @param string $callback Javascript callback function |
||
| 554 | * @param boolean $immediatly delayed if false |
||
| 555 | * @return string |
||
| 556 | */ |
||
| 557 | View Code Duplication | public function _fadeOut($element='this', $speed='', $callback='', $immediatly=false) { |
|
| 571 | |||
| 572 | // -------------------------------------------------------------------- |
||
| 573 | |||
| 574 | /** |
||
| 575 | * Outputs a jQuery hide action |
||
| 576 | * |
||
| 577 | * @param string $element element |
||
| 578 | * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds |
||
| 579 | * @param string $callback Javascript callback function |
||
| 580 | * @param boolean $immediatly delayed if false |
||
| 581 | * @return string |
||
| 582 | */ |
||
| 583 | View Code Duplication | public function _hide($element='this', $speed='', $callback='', $immediatly=false) { |
|
| 597 | |||
| 598 | // -------------------------------------------------------------------- |
||
| 599 | |||
| 600 | // -------------------------------------------------------------------- |
||
| 601 | |||
| 602 | /** |
||
| 603 | * Outputs a jQuery slideUp event |
||
| 604 | * |
||
| 605 | * @param string $element element |
||
| 606 | * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds |
||
| 607 | * @param string $callback Javascript callback function |
||
| 608 | * @param boolean $immediatly delayed if false |
||
| 609 | * @return string |
||
| 610 | */ |
||
| 611 | View Code Duplication | public function _slideUp($element='this', $speed='', $callback='', $immediatly=false) { |
|
| 625 | |||
| 626 | // -------------------------------------------------------------------- |
||
| 627 | |||
| 628 | /** |
||
| 629 | * Outputs a jQuery slideDown event |
||
| 630 | * |
||
| 631 | * @param string $element element |
||
| 632 | * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds |
||
| 633 | * @param string $callback Javascript callback function |
||
| 634 | * @param boolean $immediatly delayed if false |
||
| 635 | * @return string |
||
| 636 | */ |
||
| 637 | View Code Duplication | public function _slideDown($element='this', $speed='', $callback='', $immediatly=false) { |
|
| 651 | |||
| 652 | // -------------------------------------------------------------------- |
||
| 653 | |||
| 654 | /** |
||
| 655 | * Outputs a jQuery slideToggle event |
||
| 656 | * |
||
| 657 | * @param string $element element |
||
| 658 | * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds |
||
| 659 | * @param string $callback Javascript callback function |
||
| 660 | * @param boolean $immediatly delayed if false |
||
| 661 | * @return string |
||
| 662 | */ |
||
| 663 | View Code Duplication | public function _slideToggle($element='this', $speed='', $callback='', $immediatly=false) { |
|
| 677 | |||
| 678 | // -------------------------------------------------------------------- |
||
| 679 | |||
| 680 | /** |
||
| 681 | * Outputs a jQuery toggle event |
||
| 682 | * |
||
| 683 | * @param string $element element |
||
| 684 | * @param boolean $immediatly delayed if false |
||
| 685 | * @return string |
||
| 686 | */ |
||
| 687 | View Code Duplication | public function _toggle($element='this', $immediatly=false) { |
|
| 695 | |||
| 696 | // -------------------------------------------------------------------- |
||
| 697 | |||
| 698 | /** |
||
| 699 | * Execute all handlers and behaviors attached to the matched elements for the given event. |
||
| 700 | * @param string $element |
||
| 701 | * @param string $event |
||
| 702 | * @param boolean $immediatly delayed if false |
||
| 703 | */ |
||
| 704 | View Code Duplication | public function _trigger($element='this', $event='click', $immediatly=false) { |
|
| 712 | |||
| 713 | // -------------------------------------------------------------------- |
||
| 714 | |||
| 715 | /** |
||
| 716 | * Outputs a jQuery show event |
||
| 717 | * |
||
| 718 | * @param string $element element |
||
| 719 | * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds |
||
| 720 | * @param string $callback Javascript callback function |
||
| 721 | * @param boolean $immediatly delayed if false |
||
| 722 | * @return string |
||
| 723 | */ |
||
| 724 | View Code Duplication | public function _show($element='this', $speed='', $callback='', $immediatly=false) { |
|
| 738 | |||
| 739 | /** |
||
| 740 | * Places a condition |
||
| 741 | * @param string $condition |
||
| 742 | * @param string $jsCodeIfTrue |
||
| 743 | * @param string $jsCodeIfFalse |
||
| 744 | * @param boolean $immediatly delayed if false |
||
| 745 | * @return string |
||
| 746 | */ |
||
| 747 | public function _condition($condition, $jsCodeIfTrue, $jsCodeIfFalse=null, $immediatly=false) { |
||
| 757 | |||
| 758 | // -------------------------------------------------------------------- |
||
| 759 | // Plugins |
||
| 760 | // -------------------------------------------------------------------- |
||
| 761 | |||
| 762 | /** |
||
| 763 | * Creates a jQuery sortable |
||
| 764 | * |
||
| 765 | * @param string $element |
||
| 766 | * @param array $options |
||
| 767 | * @return void |
||
| 768 | */ |
||
| 769 | public function sortable($element, $options=array()) { |
||
| 782 | |||
| 783 | // -------------------------------------------------------------------- |
||
| 784 | |||
| 785 | /** |
||
| 786 | * Table Sorter Plugin |
||
| 787 | * |
||
| 788 | * @param string $table table name |
||
| 789 | * @param string $options plugin location |
||
| 790 | * @return string |
||
| 791 | */ |
||
| 792 | public function tablesorter($table='', $options='') { |
||
| 795 | |||
| 796 | // -------------------------------------------------------------------- |
||
| 797 | // Class functions |
||
| 798 | // -------------------------------------------------------------------- |
||
| 799 | |||
| 800 | /** |
||
| 801 | * Constructs the syntax for an event, and adds to into the array for compilation |
||
| 802 | * |
||
| 803 | * @param string $element The element to attach the event to |
||
| 804 | * @param string $js The code to execute |
||
| 805 | * @param string $event The event to pass |
||
| 806 | * @param boolean $preventDefault If set to true, the default action of the event will not be triggered. |
||
| 807 | * @param boolean $stopPropagation Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. |
||
| 808 | * @return string |
||
| 809 | */ |
||
| 810 | public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false) { |
||
| 827 | |||
| 828 | // -------------------------------------------------------------------- |
||
| 829 | |||
| 830 | /** |
||
| 831 | * As events are specified, they are stored in an array |
||
| 832 | * This function compiles them all for output on a page |
||
| 833 | * @param view $view |
||
| 834 | * @param string $view_var |
||
| 835 | * @param boolean $script_tags |
||
| 836 | * @return string |
||
| 837 | */ |
||
| 838 | public function _compile($view=NULL, $view_var='script_foot', $script_tags=TRUE) { |
||
| 877 | |||
| 878 | public function _addToCompile($jsScript) { |
||
| 881 | |||
| 882 | // -------------------------------------------------------------------- |
||
| 883 | |||
| 884 | /** |
||
| 885 | * Clears the array of script events collected for output |
||
| 886 | * |
||
| 887 | * @return void |
||
| 888 | */ |
||
| 889 | public function _clear_compile() { |
||
| 892 | |||
| 893 | // -------------------------------------------------------------------- |
||
| 894 | |||
| 895 | /** |
||
| 896 | * A wrapper for writing document.ready() |
||
| 897 | * |
||
| 898 | * @return string |
||
| 899 | */ |
||
| 900 | public function _document_ready($js) { |
||
| 911 | |||
| 912 | // -------------------------------------------------------------------- |
||
| 913 | |||
| 914 | /** |
||
| 915 | * Puts HTML element in quotes for use in jQuery code |
||
| 916 | * unless the supplied element is the Javascript 'this' |
||
| 917 | * object, in which case no quotes are added |
||
| 918 | * |
||
| 919 | * @param string $element |
||
| 920 | * @return string |
||
| 921 | */ |
||
| 922 | public function _prep_element($element) { |
||
| 928 | |||
| 929 | /** |
||
| 930 | * Puts HTML values in quotes for use in jQuery code |
||
| 931 | * unless the supplied value contains the Javascript 'this' or 'event' |
||
| 932 | * object, in which case no quotes are added |
||
| 933 | * |
||
| 934 | * @param string $value |
||
| 935 | * @return string |
||
| 936 | */ |
||
| 937 | View Code Duplication | public function _prep_value($value) { |
|
| 946 | |||
| 947 | // -------------------------------------------------------------------- |
||
| 948 | |||
| 949 | /** |
||
| 950 | * Ensures the speed parameter is valid for jQuery |
||
| 951 | * |
||
| 952 | * @param string|int $speed |
||
| 953 | * @return string |
||
| 954 | */ |
||
| 955 | private function _validate_speed($speed) { |
||
| 966 | // ------------------------------------------------------------------------ |
||
| 967 | protected function addLoading(&$retour, $responseElement) { |
||
| 978 | |||
| 979 | public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
||
| 985 | |||
| 986 | protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
||
| 999 | |||
| 1000 | protected function _getAjaxUrl($url,$attr){ |
||
| 1011 | |||
| 1012 | protected function _getOnAjaxDone($responseElement,$jsCallback){ |
||
| 1021 | |||
| 1022 | protected function _correctAjaxUrl($url) { |
||
| 1030 | |||
| 1031 | /** |
||
| 1032 | * Makes an ajax request and receives the JSON data types by assigning DOM elements with the same name |
||
| 1033 | * @param string $url the request address |
||
| 1034 | * @param string $params Paramètres passés au format JSON |
||
| 1035 | * @param string $method Method use |
||
| 1036 | * @param string $jsCallback javascript code to execute after the request |
||
| 1037 | */ |
||
| 1038 | public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
||
| 1049 | |||
| 1050 | /** |
||
| 1051 | * Makes an ajax request and receives the JSON data types by assigning DOM elements with the same name when $event fired on $element |
||
| 1052 | * @param string $element |
||
| 1053 | * @param string $event |
||
| 1054 | * @param string $url the request address |
||
| 1055 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get") |
||
| 1056 | */ |
||
| 1057 | View Code Duplication | public function _jsonOn($event,$element, $url,$parameters=array()) { |
|
| 1068 | |||
| 1069 | /** |
||
| 1070 | * Makes an ajax request and receives a JSON array data types by copying and assigning them to the DOM elements with the same name |
||
| 1071 | * @param string $url the request address |
||
| 1072 | * @param string $params Paramètres passés au format JSON |
||
| 1073 | * @param string $method Method use |
||
| 1074 | * @param string $jsCallback javascript code to execute after the request |
||
| 1075 | */ |
||
| 1076 | public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id",$immediatly=false) { |
||
| 1087 | /** |
||
| 1088 | * Makes an ajax request and receives the JSON data types by assigning DOM elements with the same name when $event fired on $element |
||
| 1089 | * @param string $element |
||
| 1090 | * @param string $event |
||
| 1091 | * @param string $url the request address |
||
| 1092 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get") |
||
| 1093 | */ |
||
| 1094 | View Code Duplication | public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) { |
|
| 1104 | |||
| 1105 | public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
||
| 1125 | |||
| 1126 | /** |
||
| 1127 | * Effectue un get vers $url sur l'évènement $event de $element en passant les paramètres $params |
||
| 1128 | * puis affiche le résultat dans $responseElement |
||
| 1129 | * @param string $element |
||
| 1130 | * @param string $event |
||
| 1131 | * @param string $url |
||
| 1132 | * @param string $params queryString parameters (JSON format). default : {} |
||
| 1133 | * @param string $responseElement |
||
| 1134 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
||
| 1135 | */ |
||
| 1136 | View Code Duplication | public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 1145 | |||
| 1146 | /** |
||
| 1147 | * Effectue un post vers $url sur l'évènement $event de $element en passant les paramètres $params |
||
| 1148 | * puis affiche le résultat dans $responseElement |
||
| 1149 | * @param string $element |
||
| 1150 | * @param string $event |
||
| 1151 | * @param string $url |
||
| 1152 | * @param string $params queryString parameters (JSON format). default : {} |
||
| 1153 | * @param string $responseElement |
||
| 1154 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
||
| 1155 | */ |
||
| 1156 | View Code Duplication | public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 1165 | |||
| 1166 | /** |
||
| 1167 | * Effectue un post vers $url sur l'évènement $event de $element en passant les paramètres du formulaire $form |
||
| 1168 | * puis affiche le résultat dans $responseElement |
||
| 1169 | * @param string $element |
||
| 1170 | * @param string $event |
||
| 1171 | * @param string $url |
||
| 1172 | * @param string $form |
||
| 1173 | * @param string $responseElement |
||
| 1174 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
||
| 1175 | */ |
||
| 1176 | View Code Duplication | public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 1186 | |||
| 1187 | /** |
||
| 1188 | * Call the JQuery method $jqueryCall on $element with parameters $param |
||
| 1189 | * @param string $element |
||
| 1190 | * @param string $jqueryCall |
||
| 1191 | * @param mixed $param |
||
| 1192 | * @param string $jsCallback javascript code to execute after the jquery call |
||
| 1193 | * @return string |
||
| 1194 | */ |
||
| 1195 | public function _doJQuery($element, $jqueryCall, $param="", $jsCallback="", $immediatly=false) { |
||
| 1205 | |||
| 1206 | /** |
||
| 1207 | * |
||
| 1208 | * @param string $event |
||
| 1209 | * @param string $element |
||
| 1210 | * @param string $elementToModify |
||
| 1211 | * @param string $jqueryCall |
||
| 1212 | * @param string|array $param |
||
| 1213 | * @param boolean $preventDefault |
||
| 1214 | * @param boolean $stopPropagation |
||
| 1215 | * @param string $jsCallback javascript code to execute after the jquery call |
||
| 1216 | * @return string |
||
| 1217 | */ |
||
| 1218 | public function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="") { |
||
| 1221 | |||
| 1222 | /** |
||
| 1223 | * Execute the code $js |
||
| 1224 | * @param string $js Code to execute |
||
| 1225 | * @param boolean $immediatly diffère l'exécution si false |
||
| 1226 | * @return String |
||
| 1227 | */ |
||
| 1228 | public function _exec($js, $immediatly=false) { |
||
| 1234 | |||
| 1235 | /** |
||
| 1236 | * |
||
| 1237 | * @param string $element |
||
| 1238 | * @param string $event |
||
| 1239 | * @param string $js Code to execute |
||
| 1240 | * @param boolean $preventDefault |
||
| 1241 | * @param boolean $stopPropagation |
||
| 1242 | * @return String |
||
| 1243 | */ |
||
| 1244 | public function _execOn($element, $event, $js, $preventDefault=false, $stopPropagation=false) { |
||
| 1247 | } |
||
| 1248 | /* End of file Jquery.php */ |