From: Michael M Slusarz Date: Fri, 6 Aug 2010 20:07:48 +0000 (-0600) Subject: Move user update javascript out of template file X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=fc9c5270a3dd06382b30bc34c07fa5c8364a5c64;p=horde.git Move user update javascript out of template file --- diff --git a/horde/admin/user.php b/horde/admin/user.php index eb9bd5b16..d85db6e4d 100644 --- a/horde/admin/user.php +++ b/horde/admin/user.php @@ -210,8 +210,15 @@ case 'removequeued': break; } -$title = _("User Administration"); Horde::addScriptFile('stripe.js', 'horde'); +if (isset($update_form) && $auth->hasCapability('list')) { + Horde::addScriptFile('userupdate.js', 'horde'); + Horde::addInlineScript(array( + 'HordeAdminUserUpdate.pass_error = ' . Horde_Serialize::serialize(_("Passwords must match."), Horde_Serialize::JSON, $registry->getCharset()) + )); +} + +$title = _("User Administration"); require HORDE_TEMPLATES . '/common-header.inc'; require HORDE_TEMPLATES . '/admin/menu.inc'; diff --git a/horde/js/userupdate.js b/horde/js/userupdate.js new file mode 100644 index 000000000..7987fc009 --- /dev/null +++ b/horde/js/userupdate.js @@ -0,0 +1,29 @@ +/** + * Provides the javascript for the admin user update page. + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + */ + +var HordeAdminUserUpdate = { + + // Set in admin/user.php: pass_error + + onSubmit: function(e) + { + if ($('user_pass_1') && + $F('user_pass_1') != $F('user_pass_2')) { + $('user_pass_1', 'user_pass_2').invoke('setValue', ''); + window.alert(this.pass_error); + e.stop(); + } + }, + + onDomLoad: function() + { + $('updateuser').observe('submit', this.onSubmit.bindAsEventListener(this)); + } + +}; + +document.observe('dom:loaded', HordeAdminUserUpdate.onDomLoad.bind(HordeAdminUserUpdate)); diff --git a/horde/templates/admin/user/update.inc b/horde/templates/admin/user/update.inc index c60bdcdd2..7a45f4a95 100644 --- a/horde/templates/admin/user/update.inc +++ b/horde/templates/admin/user/update.inc @@ -1,28 +1,4 @@ - - -
+ @@ -74,7 +50,7 @@ function validate_update() - " /> + " /> " />