Permalink
Browse files

Merge branch 'MDL-24521' of git://github.com/samhemelryk/moodle

  • Loading branch information...
2 parents a9af868 + 712b55e commit ff14fd71fd6ac9f3d473ee2fd8cf0bf3bcb0d89b @stronk7 stronk7 committed Jan 10, 2011
Showing with 10 additions and 8 deletions.
  1. +10 −8 lib/javascript-static.js
View
18 lib/javascript-static.js
@@ -262,15 +262,17 @@ M.util.show_confirm_dialog = function(e, args) {
return;
}
- if (target.get('tagName').toLowerCase() == 'a') {
+ var targetancestor = null,
+ targetform = null;
+
+ if (target.test('a')) {
window.location = target.get('href');
- } else if (target.get('tagName').toLowerCase() == 'input') {
- var parentelement = target.get('parentNode');
- while (parentelement.get('tagName').toLowerCase() != 'form' && parentelement.get('tagName').toLowerCase() != 'body') {
- parentelement = parentelement.get('parentNode');
- }
- if (parentelement.get('tagName').toLowerCase() == 'form') {
- parentelement.submit();
+ } else if ((targetancestor = target.ancestor('a')) !== null) {
+ window.location = targetancestor.get('href');
+ } else if (target.test('input')) {
+ targetform = target.ancestor('form');
+ if (targetform && targetform.submit) {
+ targetform.submit();
}
} else if (M.cfg.developerdebug) {
alert("Element of type " + target.get('tagName') + " is not supported by the M.util.show_confirm_dialog function. Use A or INPUT");

0 comments on commit ff14fd7

Please sign in to comment.