EllisLab/CodeIgniter — pull request #2404 by groovenectar (2013-04-14 20:52:46+00:00)
Title: Updates to JS/JQ libraries. New trigger event, native JS events sent to ...

...base add_event() instead of driver method, update element prep, bugfixes

None of these JavaScript/jQuery updates should affect existing implementations, only improve where applicable.

JavaScript/jQuery changes:

An `add_event()` function was added to the base library, since it should be possible to emulate adding events in any library or native JavaScript for most events. `_add_event()` is already in the jQuery library, but did not have a corresponding method in the parent class.

A couple bugfixes, where there were two underscores in child class (jQuery) methods, they have been changed to one (there were calls to non-existent methods such as "__hover").

All events that have a native JavaScript equivalent are changed in the base library to be, e.g. for "blur":
`$this->add_event($element, $js, 'blur', $trigger);`

Events such as "hover" do not have a native equivalent, so they remain calling the child library in the base library, e.g.:
`$this->js->_hover($element, $over, $out);`

A `trigger_event()` method was added to the base library, and a protected child equivalent. A `$trigger` option was added to all native events, to determine whether the event should be triggered as soon as it is declared. It is common to do that, especially with something like `onchange` to immediately update the view state.

Any methods that "toggle", such as `toggle()` and `toggleClass()` now have a last parameter that will force whether to show or hide the element (toggle state). This is native to jQuery, and should be easy to implement in any other library including native JS.

Updated `_prep_element($element = 'this')` to be more fitting for jQuery. If the first character is "$", it is assumed to be a JQ selector and returned directly. Otherwise if it is "this" it returns "`$(this)`" else it returns `'$(\'' . $element . '\')';`. Methods that call it are updated accordingly.