$gallery_mode = 'Normal';
$gallery_passwd = '';
- $notification->push('document.gallery.gallery_name.focus();', 'javascript');
+ Horde::addInlineScript(array(
+ '$("gallery_name").focus()'
+ ), 'dom');
$title = _("Adding A New Gallery");
break;
$gallery_mode = 'Normal';
$gallery_passwd = '';
- $notification->push('document.gallery.gallery_name.focus();', 'javascript');
+ Horde::addInlineScript(array(
+ '$("gallery_name").focus()'
+ ), 'dom');
+
$title = sprintf(_("Adding A Subgallery to %s"), $parent->get('name'));
break;
exit;
}
+Horde::addInlineScript(array(
+ 'Sortable.create("sortContainer", { tag: "div", overlap: "horizontal", constraint: false })'
+), 'dom');
+
Horde::addScriptFile('effects.js', 'horde');
Horde::addScriptFile('dragdrop.js', 'horde');
+
$title = sprintf(_("%s :: Sort"), $gallery->get('name'));
require ANSEL_TEMPLATES . '/common-header.inc';
require ANSEL_TEMPLATES . '/menu.inc';
. '</a></div>';
}
echo '</div>';
-$notification->push('Sortable.create(\'sortContainer\', {tag: \'div\', overlap: \'horizontal\', constraint: false })', 'javascript');
require $registry->get('templates', 'horde') . '/common-footer.inc';
$datefmt = $prefs->getValue('date_format');
$amountfmt = $prefs->getValue('amount_format');
+$js_onload = array();
+
if ($pageOb['mode'] == 'edit') {
/* Fix date format. */
$datefmt = Fima::convertDateFormat($datefmt);
/* Add current date in first field if no postings. */
foreach ($postings as $key => $value) {
if ($value['date'] == '') {
- $notification->push('document.getElementById(\'date1\').value = \'' . strftime($datefmt) . '\';', 'javascript');
+ $js_onload[] = '$("date1").setValue(' . Horde_Serialize::serialize(strftime($datefmt), Horde_Serialize::JSON, $registry->getCharset()) . ')';
}
break;
}
/* Select first date field. */
- $notification->push('updateResult(); updateAssetResult(_getall(\'asset[]\')[0]); document.getElementById(\'date1\').focus(); document.getElementById(\'date1\').select();', 'javascript');
+ $js_onload[] = 'updateResult()';
+ $js_onload[] = 'updateAssetResult(_getall("asset[]")[0])';
+ $js_onload[] = '$("date1").focus().select()';
}
+Horde::addInlineScript($js_onload, 'dom');
+
require FIMA_TEMPLATES . '/common-header.inc';
if ($print_view) {
require_once $registry->get('templates', 'horde') . '/javascript/print.js';
$datefmt = $prefs->getValue('date_format');
$amountfmt = $prefs->getValue('amount_format');
-$notification->push('document.report.report_id.focus();', 'javascript');
+Horde::addInlineScript(array(
+ '$("report_id").focus()'
+), 'dom');
+
require FIMA_TEMPLATES . '/common-header.inc';
require FIMA_TEMPLATES . '/menu.inc';
if ($browser->hasFeature('javascript')) {
$datefmt = $prefs->getValue('date_format');
$amountfmt = $prefs->getValue('amount_format');
+Horde::addInlineScript(array(
+ '$("search_type").focus()'
+), 'dom');
+
$title = _("Search Postings");
-$notification->push('document.search.search_type.focus();', 'javascript');
require FIMA_TEMPLATES . '/common-header.inc';
require FIMA_TEMPLATES . '/menu.inc';
if ($browser->hasFeature('javascript')) {
class Horde_Alarm_Handler_Desktop extends Horde_Alarm_Handler
{
/**
- * A notification handler.
+ * A notification callback.
*
- * @var Horde_Notification_Handler
+ * @var callback
*/
- protected $_notification;
+ protected $_jsNotify;
/**
* An icon URL.
*
* @param array $params Any parameters that the handler might need.
* Required parameter:
- * - notification: A Horde_Notification_Handler
+ * - js_notify: A Horde_Notification_Handler
* instance.
* Optional parameter:
* - icon: URL of an icon to display.
public function __construct(array $params = null)
{
/*
- if (!isset($params['notification'])) {
- throw new Horde_Alarm_Exception('Parameter \'notification\' missing.');
+ if (!isset($params['js_notify'])) {
+ throw new InvalidArgumentException('Parameter \'js_notify\' missing.');
}
- if (!($params['notification'] instanceof Horde_Notification_Handler)) {
- throw new Horde_Alarm_Exception('Parameter \'notification\' is not a Horde_Notification_Handler object.');
+ if (!is_callable($params['js_notify'])) {
+ throw new Horde_Alarm_Exception('Parameter \'js_notify\' is not a Horde_Notification_Handler object.');
}
- $this->_notification = $params['notification'];
+ $this->_jsNotify = $params['jsNotify'];
if (isset($params['icon'])) {
$this->_icon = $params['icon'];
}
*/
- $this->_notification = isset($params['notification']) ? $params['notification'] : $GLOBALS['injector']->getInstance('Horde_Notification');
+ $this->_jsNotify = isset($params['js_notify'])
+ ? $params['js_notify']
+ : array('Horde', 'addInlineScript');
$this->_icon = isset($params['icon']) ? $params['icon'] : (string)Horde_Themes::img('alerts/alarm.png');
}
/**
- * Notifies about an alarm through Horde_Notification.
+ * Notifies about an alarm through javscript.
*
* @param array $alarm An alarm hash.
*/
$this->_icon,
addslashes($alarm['title']),
isset($alarm['text']) ? addslashes($alarm['text']) : '');
- $this->_notification->push($js, 'javascript');
+ call_user_func($this->_jsNotify($js));
}
/**
);
$handler_params = array(
- 'notification' => $injector->getInstance('Horde_Notification'),
+ 'js_notify' => array('Horde', 'addInlineScript'),
'icon' => (string)Horde_Themes::img('alerts/alarm.png')
);
$alarm->addHandler('desktop', new Horde_Alarm_Handler_Desktop($handler_params));
+++ /dev/null
-<?php
-/**
- * The Horde_Notification_Listener_Javascript:: class provides functionality
- * for inserting javascript code from the message stack into the page.
- *
- * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Jan Schneider <jan@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Notification
- */
-class Horde_Notification_Listener_Javascript extends Horde_Notification_Listener
-{
- /**
- * Constructor.
- */
- public function __construct()
- {
- $this->_handles['javascript'] = 'Horde_Notification_Event';
- $this->_handles['javascript-file'] = 'Horde_Notification_Event';
- $this->_name = 'javascript';
- }
-
- /**
- * Outputs the javascript code if there are any messages on the
- * 'javascript' message stack and if the 'notify_javascript' option is set.
- *
- * @param array $events The list of events to handle.
- * @param array $options An array of options:
- * <pre>
- * 'noscript' - TODO
- * </pre>
- */
- public function notify($events, $options = array())
- {
- $files = $js_text = array();
-
- foreach ($events as $event) {
- switch ($event->type) {
- case 'javascript':
- $js_text[] = strval($event);
- break;
-
- case 'javascript-file':
- $files[] = strval($event);
- break;
- }
- }
-
- if (empty($options['noscript']) && !empty($js_text)) {
- echo '<script type="text/javascript">//<![CDATA[' . "\n";
- }
-
- echo implode('', $js_text);
-
- if (empty($options['noscript'])) {
- if (!empty($js_text)) {
- echo "\n//]]></script>\n";
- }
-
- foreach ($files as $file) {
- echo '<script type="text/javascript" src="' . htmlspecialchars($file) . "\"></script>\n";
- }
- }
- }
-
-}
<api>beta</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Added unit tests.
+ <notes>* Removed javascript listener.
+ * Added unit tests.
* Added Horde_Notification::replace().
* Initial Horde 4 package.
</notes>
</dir> <!-- /lib/Horde/Notification/Handler -->
<dir name="Listener">
<file name="Audio.php" role="php" />
- <file name="Javascript.php" role="php" />
<file name="Status.php" role="php" />
</dir> <!-- /lib/Horde/Notification/Listener -->
<dir name="Storage">
<file name="ListenerTest.php" role="test" />
<dir name="Listener">
<file name="AudioTest.php" role="test" />
- <file name="JavascriptTest.php" role="test" />
<file name="StatusTest.php" role="test" />
</dir> <!-- /test/Horde/Notification/Class/Notification/Listener -->
</dir> <!-- /test/Horde/Notification/Class/Notification -->
<install name="lib/Horde/Notification/Handler/Decorator/Base.php" as="Horde/Notification/Handler/Decorator/Base.php" />
<install name="lib/Horde/Notification/Handler/Decorator/Log.php" as="Horde/Notification/Handler/Decorator/Log.php" />
<install name="lib/Horde/Notification/Listener/Audio.php" as="Horde/Notification/Listener/Audio.php" />
- <install name="lib/Horde/Notification/Listener/Javascript.php" as="Horde/Notification/Listener/Javascript.php" />
<install name="lib/Horde/Notification/Listener/Status.php" as="Horde/Notification/Listener/Status.php" />
<install name="lib/Horde/Notification/Storage/Interface.php" as="Horde/Notification/Storage/Interface.php" />
<install name="lib/Horde/Notification/Storage/Object.php" as="Horde/Notification/Storage/Object.php" />
<install name="test/Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php" as="Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php" />
<install name="test/Horde/Notification/Class/Notification/ListenerTest.php" as="Horde/Notification/Class/Notification/ListenerTest.php" />
<install name="test/Horde/Notification/Class/Notification/Listener/AudioTest.php" as="Horde/Notification/Class/Notification/Listener/AudioTest.php" />
- <install name="test/Horde/Notification/Class/Notification/Listener/JavascriptTest.php" as="Horde/Notification/Class/Notification/Listener/JavascriptTest.php" />
<install name="test/Horde/Notification/Class/Notification/Listener/StatusTest.php" as="Horde/Notification/Class/Notification/Listener/StatusTest.php" />
</filelist>
</phprelease>
+++ /dev/null
-<?php
-/**
- * Test the javascript listener class.
- *
- * @category Horde
- * @package Notification
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Notification
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../../../Autoload.php';
-
-/**
- * Test the javascript listener class.
- *
- * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Horde
- * @package Notification
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Notification
- */
-class Horde_Notification_Class_Notification_Listener_JavascriptTest extends PHPUnit_Extensions_OutputTestCase
-{
- public function testMethodHandleHasEventClassForjavascriptMessages()
- {
- $listener = new Horde_Notification_Listener_Javascript();
- $this->assertEquals('Horde_Notification_Event', $listener->handles('javascript'));
- }
-
- public function testMethodGetnameHasResultStringJavascript()
- {
- $listener = new Horde_Notification_Listener_Javascript();
- $this->assertEquals('javascript', $listener->getName());
- }
-
- public function testMethodNotifyHasNoOutputIfTheMessageStackIsEmpty()
- {
- $listener = new Horde_Notification_Listener_Javascript();
- $messages = array();
- $listener->notify($messages);
- }
-
- public function testMethodNotifyHasOutputEventMessageEmbeddedInScriptElement()
- {
- $listener = new Horde_Notification_Listener_Javascript();
- $event = new Horde_Notification_Event('test', 'javascript');
- $messages = array($event);
- $this->expectOutputString(
- '<script type="text/javascript">//<![CDATA['
- . "\n" . 'test' . "\n" . '//]]></script>' . "\n"
- );
- $listener->notify($messages);
- }
-
- public function testMethodNotifyHasOutputEventMessageNotEmbeddedIfEmbeddingIsDeactivated()
- {
- $listener = new Horde_Notification_Listener_Javascript();
- $event = new Horde_Notification_Event('test', 'javascript');
- $messages = array($event);
- $this->expectOutputString('test');
- $listener->notify($messages, array('noscript' => true));
- }
-
- public function testMethodNotifyHasOutputJavaScriptFileLinkIfTheEventContainedSuchAFileLink()
- {
- $listener = new Horde_Notification_Listener_Javascript();
- $event = new Horde_Notification_Event('test');
- $event->type = 'javascript-file';
- $messages = array($event);
- $this->expectOutputString(
- '<script type="text/javascript" src="test"></script>' . "\n"
- );
- $listener->notify($messages);
- }
-
-}
switch ($form) {
case 'addchild.inc':
- $notification->push('document.add_child.child.focus()', 'javascript');
+ Horde::addInlineScript(array(
+ '$("child").focus()'
+ ), 'dom');
break;
case 'edit.inc':
parent.document.title = document.title;
}
</script>
-<?php $GLOBALS['notification']->notify(array('listeners' => array('audio', 'javascript'))); ?>
+<?php $GLOBALS['notification']->notify(array('listeners' => array('audio'))); ?>
<?php endif; ?>
</body>
</html>
if (typeof(_setHordeTitle) == 'undefined' && document.title && parent.frames.horde_main) parent.document.title = document.title;
// -->
</script>
-<?php if (isset($GLOBALS['notification'])) $GLOBALS['notification']->notify(array('listeners' => array('audio', 'javascript'))); ?>
+<?php if (isset($GLOBALS['notification'])) $GLOBALS['notification']->notify(array('listeners' => array('audio'))); ?>
</body>
</html>
require_once dirname(__FILE__) . '/lib/Application.php';
Horde_Registry::appInit('mnemo');
+Horde::addInlineScript(array(
+ '$("search_pattern").focus()'
+), 'dom');
+
$title = _("Search");
-$notification->push('document.getElementById(\'search_pattern\').focus();', 'javascript');
-Horde::addScriptFile('prototype.js', 'horde', true);
require MNEMO_TEMPLATES . '/common-header.inc';
require MNEMO_TEMPLATES . '/menu.inc';
$notification->notify();
require_once dirname(__FILE__) . '/lib/Application.php';
Horde_Registry::appInit('nag');
+Horde::addInlineScript(array(
+ '$("search_pattern")'
+), 'dom');
+
$title = _("Search");
-$notification->push('document.search.search_pattern.focus()', 'javascript');
-Horde::addScriptFile('prototype.js', 'horde');
require NAG_TEMPLATES . '/common-header.inc';
require NAG_TEMPLATES . '/menu.inc';
require NAG_TEMPLATES . '/search/search.inc';
}
}
-$notification->push('setFocus()', 'javascript');
+Horde::addInlineScript(array(
+ 'setFocus()'
+), 'dom');
+
$title = _("Change Password");
require PASSWD_TEMPLATES . '/common-header.inc';
require PASSWD_TEMPLATES . '/main/main.inc';
htmlspecialchars(_("Absences")) . "</option>\n";
}
+Horde::addInlineScript(array(
+ '$("stext").focus()'
+), 'dom');
+
$title = _("Search");
-$notification->push('document.skoli_searchform.stext.focus();', 'javascript');
Horde::addScriptFile('quickfinder.js', 'horde');
Horde::addScriptFile('effects.js', 'horde');
}
if (Horde_Util::getFormData('popup')) {
- $notification->push('window.focus();', 'javascript');
+ Horde::addInlineScript(array(
+ 'window.focus()'
+ ), 'dom');
}
+
$title = _("New Bookmark");
require TREAN_TEMPLATES . '/common-header.inc';
if (!Horde_Util::getFormData('popup') && !Horde_Util::getFormData('iframe')) {
switch ($_SESSION['turba']['search_mode']) {
case 'basic':
$title = _("Basic Search");
- $notification->push('document.directory_search.val.focus();', 'javascript');
+ Horde::addInlineScript(array(
+ '$("val").focus()'
+ ), 'dom');
break;
+
case 'advanced':
$title = _("Advanced Search");
- $notification->push('document.directory_search.name.focus();', 'javascript');
+ Horde::addInlineScript(array(
+ '$("name").focus()'
+ ), 'dom');
break;
+
case 'duplicate':
$title = _("Duplicate Search");
break;
(Horde_String::lower(Horde_Util::getFormData('wicked_captcha')) != Horde_String::lower(Wicked::getCAPTCHA()))) {
$notification->push(_("Random string did not match."), 'horde.error');
return;
- }
+ }
$text = Horde_Util::getFormData('page_text');
$changelog = Horde_Util::getFormData('changelog');
if ($conf['wicked']['require_change_log'] && empty($changelog)) {
$notification->push(_("You must provide a change log."), 'horde.error');
- $notification->push('if (document.editform && document.editform.changelog) document.editform.changelog.focus();', 'javascript');
+ Horde::addInlineScript(array(
+ 'if (document.editform && document.editform.changelog) document.editform.changelog.focus()'
+ ), 'dom');
return;
}
$minorchange = Horde_Util::getFormData('minor');
*/
function display()
{
- global $notification;
-
// Load the page template.
if ($this->_template) {
$page = Page::getPage($this->_template);
$page_text = '';
}
- $notification->push('if (document.editform && document.editform.page_text) document.editform.page_text.focus();', 'javascript');
+ Horde::addInlineScript(array(
+ 'if (document.editform && document.editform.page_text) document.editform.changelog.page_text()'
+ ), 'dom');
+
require WICKED_TEMPLATES . '/edit/new.inc';
return true;
}