*/
public function attach()
{
- Horde::addScriptFile('prototype.js', 'horde', true);
- Horde::addScriptFile('effects.js', 'horde', true);
- Horde::addScriptFile('KeyNavList.js', 'horde', true);
- Horde::addScriptFile('SpellChecker.js', 'horde', true);
+ Horde::addScriptFile('prototype.js', 'horde');
+ Horde::addScriptFile('effects.js', 'horde');
+ Horde::addScriptFile('KeyNavList.js', 'horde');
+ Horde::addScriptFile('SpellChecker.js', 'horde');
$url = $this->_getUrl('SpellChecker', 'horde', array('input' => $this->_params['targetId']));
* Adds the javascript code to the output (if output has already started)
* or to the list of script files to include via includeScriptFiles().
*
- * @param string $file The full javascript file name.
- * @param string $app The application name. Defaults to the current
- * application.
- * @param boolean $direct Include the file directly without passing it
- * through javascript.php
- * @param boolean $full Output a full URL
+ * @param string $file The full javascript file name.
+ * @param string $app The application name. Defaults to the current
+ * application.
+ * @param array $options Additional options:
+ * <pre>
+ * 'direct' - (boolean) Include the file directly without passing it
+ * through javascript.php.
+ * DEFAULT: true
+ * 'external' - (boolean) Treat $file as an external URL.
+ * DEFAULT: $file is located in the app's js/ directory.
+ * 'full' - (boolean) Output a full URL
+ * DEFAULT: false
+ * </pre>
*
* @throws Horde_Exception
*/
- static public function addScriptFile($file, $app = null, $direct = false,
- $full = false)
+ static public function addScriptFile($file, $app = null,
+ $options = array())
{
$hsf = Horde_Script_Files::singleton();
- $hsf->add($file, $app, $direct, $full);
+ if (empty($options['external'])) {
+ $hsf->add($file, $app, isset($options['direct']) ? $options['direct'] : true, !empty($options['full']));
+ } else {
+ $hsf->addExternal($file, $app);
+ }
}
/**
}
/**
- * Inlude script files from external sources.
- *
- * @param string $url The url to the external script file.
- * @param string $app The app scope
- */
- static public function addExternalScriptFile($url, $app = null)
- {
- $hsf = Horde_Script_Files::singleton();
- $hsf->addExternal($url, $app);
- }
-
- /**
* Get a token for protecting a form.
*
* @param string $slug Slug name.
*/
static public function popupJs($url, $options = array())
{
- Horde::addScriptFile('popup.js', 'horde', true);
+ Horde::addScriptFile('popup.js', 'horde');
$params = new stdClass;
$pos = strpos($url, '?');
public function __construct($params = array())
{
$fck_path = $GLOBALS['registry']->get('webroot', 'horde') . '/services/editor/fckeditor/';
- $js = "var oFCKeditor = new FCKeditor('" . $params['id'] . "'); oFCKeditor.BasePath = '" . $fck_path . "';";
+ $js = array(
+ 'var oFCKeditor = new FCKeditor("' . $params['id'] . '")',
+ 'oFCKeditor.BasePath = "' . $fck_path . '"'
+ );
if (!empty($params['no_notify'])) {
- $this->_js = '<script type="text/javascript" src="' . $fck_path . 'fckeditor.js"></script><script type="text/javascript">' . $js . '</script>';
+ $this->_js = '<script type="text/javascript" src="' . $fck_path . 'fckeditor.js"></script><script type="text/javascript">' . implode(';', $js) . '</script>';
} else {
- Horde::addScriptFile('prototype.js', 'horde', true);
- $GLOBALS['notification']->push('Event.observe(window, \'load\', function() {' . $js . ' oFCKeditor.ReplaceTextarea();});', 'javascript');
- $GLOBALS['notification']->push($fck_path . 'fckeditor.js', 'javascript-file');
+ Horde::addScriptFile('prototype.js', 'horde');
+ Horde::addScriptFile($fck_path . 'fckeditor.js', null, array('external' => true));
+ $js[] = 'oFCKeditor.ReplaceTextarea()';
+ Horde::addInlineScript($js, 'load');
}
}
'Xinha.startEditors(_editors); };';
if (empty($params['no_autoload'])) {
- Horde::addScriptFile('prototype.js', 'horde', true);
- $js .= 'Event.observe(window, \'load\', xinha_init);';
+ Horde::addScriptFile('prototype.js', 'horde');
}
if (!empty($params['no_notify'])) {
+ $js .= 'Event.observe(window, \'load\', xinha_init);';
$this->_js = '<script type="text/javascript">' . $js . '</script><script type="text/javascript" src="' . $xinha_path . 'XinhaCore.js"></script>';
} else {
- $GLOBALS['notification']->push($js, 'javascript');
- $GLOBALS['notification']->push($xinha_path . 'XinhaCore.js', 'javascript-file');
+ Horde::addScriptFile($xinha_path . 'XinhaCore.js', null, array('external' => true));
+ Horde::addInlineScript($js);
+ Horde::addInlineScript('xinha_init()', 'load');
}
}
if ($qcount > 8) {
if ($this->_params['outputJS']) {
- Horde::addScriptFile('prototype.js', 'horde', true);
+ Horde::addScriptFile('prototype.js', 'horde');
}
$out .= (($this->_params['citeblock']) ? '<br />' : '') .