/** * Returns a JavaScript snippet to be used on the AJAX callbacks for starting * visual effects. * * Example: * ScriptaculousHelper::visual_effect('highlight', 'posts', * array('duration' => 0.5 )); * * If no '$element_id' is given, it assumes "element" which should be a local * variable in the generated JavaScript execution context. This can be used * for example with drop_receiving_element(): * * ScriptaculousHelper::drop_receving_element(..., array(... * 'loading' => ScriptaculousHelper::visual_effect('fade'))); * * This would fade the element that was dropped on the drop receiving element. * * You can change the behaviour with various options, see * http://script.aculo.us for more documentation. * * @param type <description> * @param type <description> * @param type <description> * * @return string <description> */ function visual_effect($name, $element_id = FALSE, $js_opt = array()) { $element = $element_id ? "'{$element_id}'" : 'element'; switch ($name) { case 'toggle_appear': case 'toggle_blind': case 'toggle_slide': return sprintf("new Effect.toggle(%s, '%s', %s)", $element, substr($name, 7), JsHelper::options_for_javascript($js_opt)); } return sprintf("new Effect.%s(%s, %s)", TextHelper::camelize($name), $element, JsHelper::options_for_javascript($js_opt)); }
/** * Inserts HTML at the specified 'position' relative to the DOM element * identified by the given 'id'. * * 'position' may be one of: * * 'top':: HTML is inserted inside the element, before the * element's existing content. * 'bottom':: HTML is inserted inside the element, after the * element's existing content. * 'before':: HTML is inserted immediately preceeding the element. * 'after':: HTML is inserted immediately following the element. * * @param type <description> * @param type <description> * @param type <description> * * @return type <description> */ function insert_html($position, $id, $content) { $insertion = TextHelper::camelize($position); $this->call('new Insertion.' . $insertion, $id, $content); }
function test_camelize() { $foo = TextHelper::camelize('foo_bar_baz/FOO is great'); $this->assertEqual('FooBarBazFOOIsGreat', $foo); }