function test_javascript_tag() { $javascript = new JavaScriptHelper(); //static call $this->AssertEqual(JavascriptHelper::javascript_tag("alert('test akelos');"), "<script type=\"text/javascript\">\n//<![CDATA[\nalert('test akelos');\n//]]>\n</script>"); //object call $this->AssertEqual($javascript->javascript_tag("alert('test akelos');"), "<script type=\"text/javascript\">\n//<![CDATA[\nalert('test akelos');\n//]]>\n</script>"); }
/** * Makes the element with the DOM ID specified by +element_id+ receive * dropped draggable elements (created by draggable_element). * and make an AJAX call By default, the action called gets the DOM ID * of the element as parameter. * * Example: * <%= drop_receiving_element("my_cart", :url => * { :controller => "cart", :action => "add" }) %> * * You can change the behaviour with various options, see * http://script.aculo.us for more documentation. */ function drop_receiving_element($element_id, $options = array()) { $options['with'] = !empty($options['with']) ? $options['with'] : "'id='" . urlencode(element . id); $options['onDrop'] = !empty($options['onDrop']) ? $options['onDrop'] : "function(element){" . PrototypeHelper::remote_function($options) . "}"; foreach ($options as $key => $option) { /** * @todo: fix this code when implemented PrototypeHelper * * if (in_array(PrototypeHelper::AJAX_OPTIONS[$option])) { * unset($options[$option]); * } */ } if (in_array($options['accept'])) { $options['accept'] = JavascriptHelper::_array_or_string_for_javascript($options['accept']); } if (in_array($options['hoverclass'])) { $options['hoverclass'] = "'{$options['hoverclass']}'"; } return JavascriptHelper::javascript_tag("Droppables.add('{$element_id}', " . JavascriptHelper::_options_for_javascript($options) . ")"); }