Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'MDL-61388-master' of git://github.com/damyon/moodle
  • Loading branch information
David Monllao committed Oct 22, 2018
2 parents 7e5f0fa + ede1e4a commit 64a00df
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 14 deletions.
15 changes: 13 additions & 2 deletions lib/outputrenderers.php
Expand Up @@ -1951,12 +1951,23 @@ public function confirm($message, $continue, $cancel) {
throw new coding_exception('The cancel param to $OUTPUT->confirm() must be either a URL (string/moodle_url) or a single_button instance.');
}

$output = $this->box_start('generalbox modal modal-dialog modal-in-page show', 'notice');
$attributes = [
'role'=>'alertdialog',
'aria-labelledby'=>'modal-header',
'aria-describedby'=>'modal-body',
'aria-modal'=>'true'
];

$output = $this->box_start('generalbox modal modal-dialog modal-in-page show', 'notice', $attributes);
$output .= $this->box_start('modal-content', 'modal-content');
$output .= $this->box_start('modal-header p-x-1', 'modal-header');
$output .= html_writer::tag('h4', get_string('confirm'));
$output .= $this->box_end();
$output .= $this->box_start('modal-body', 'modal-body');
$attributes = [
'role'=>'alert',
'data-aria-autofocus'=>'true'
];
$output .= $this->box_start('modal-body', 'modal-body', $attributes);
$output .= html_writer::tag('p', $message);
$output .= $this->box_end();
$output .= $this->box_start('modal-footer', 'modal-footer');
Expand Down
1 change: 1 addition & 0 deletions mod/forum/lang/en/forum.php
Expand Up @@ -148,6 +148,7 @@
$string['discussionpin'] = 'Pin';
$string['discussionpinned'] = 'Pinned';
$string['discussionpinned_help'] = 'Pinned discussions will appear at the top of a forum.';
$string['discussionsplit'] = 'Discussion has been split';
$string['discussionsubscribestop'] = 'I don\'t want to be notified of new posts in this discussion';
$string['discussionsubscribestart'] = 'Send me notifications of new posts in this discussion';
$string['discussionsubscription'] = 'Discussion subscription';
Expand Down
25 changes: 21 additions & 4 deletions mod/forum/post.php
Expand Up @@ -349,7 +349,13 @@
$event->add_record_snapshot('forum_discussions', $discussion);
$event->trigger();

redirect(new moodle_url('/mod/forum/view.php', ['f' => $discussion->forum]));
$message = get_string('eventdiscussiondeleted', 'forum');
redirect(
new moodle_url('/mod/forum/view.php', ['f' => $discussion->forum]),
$message,
null,
\core\output\notification::NOTIFY_SUCCESS
);

} else if (forum_delete_post($post, has_capability('mod/forum:deleteanypost', $modcontext),
$course, $cm, $forum)) {
Expand All @@ -363,7 +369,13 @@
$discussionurl = new moodle_url("/mod/forum/discuss.php", array('d' => $discussion->id));
}

redirect(forum_go_back_to($discussionurl));
$message = get_string('eventpostdeleted', 'forum');
redirect(
forum_go_back_to($discussionurl),
$message,
null,
\core\output\notification::NOTIFY_SUCCESS
);
} else {
print_error('errorwhiledelete', 'forum');
}
Expand Down Expand Up @@ -506,8 +518,13 @@
$event->add_record_snapshot('forum_discussions', $discussion);
$event->trigger();

redirect(forum_go_back_to(new moodle_url("/mod/forum/discuss.php", array('d' => $newid))));

$message = get_string('discussionsplit', 'forum');
redirect(
forum_go_back_to(new moodle_url("/mod/forum/discuss.php", array('d' => $newid))),
$message,
null,
\core\output\notification::NOTIFY_SUCCESS
);
} else {
// Display the prune form.
$course = $DB->get_record('course', array('id' => $forum->course));
Expand Down
2 changes: 1 addition & 1 deletion theme/boost/amd/build/aria.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions theme/boost/amd/src/aria.js
Expand Up @@ -183,6 +183,17 @@ define(['jquery'], function($) {
shiftFocus(trigger);
}
});

// After page load, focus on any element with special autofocus attribute.
$(function() {
window.setTimeout(function() {
var alerts = $('[role="alert"][data-aria-autofocus="true"]');
if (alerts.length > 0) {
$(alerts[0]).attr('tabindex', '0');
$(alerts[0]).focus();
}
}, 300);
});
}
};
});
Expand Up @@ -40,7 +40,7 @@
<hr>
</div>
{{#error}}
<div class="alert alert-danger" role="alert">
<div class="alert alert-danger" role="alert" data-aria-autofocus="true">
{{{error}}}
</div>
{{/error}}
Expand Down
2 changes: 1 addition & 1 deletion theme/boost/templates/core/loginform.mustache
Expand Up @@ -112,7 +112,7 @@
{{#error}}
<div class="loginerrors mt-3">
<a href="#" id="loginerrormessage" class="accesshide">{{error}}</a>
<div class="alert alert-danger" role="alert">{{error}}</div>
<div class="alert alert-danger" role="alert" data-aria-autofocus="true">{{error}}</div>
</div>
{{/error}}

Expand Down
2 changes: 1 addition & 1 deletion theme/boost/templates/core/notification_error.mustache
Expand Up @@ -37,7 +37,7 @@
{ "message": "Your pants are on fire!", "closebutton": 1, "announce": 1, "extraclasses": "foo bar"}
}}
<div class="alert alert-danger alert-block fade in {{ extraclasses }}" {{!
}}{{# announce }} role="alert"{{/ announce }}{{!
}}{{# announce }} role="alert" data-aria-autofocus="true"{{/ announce }}{{!
}}>
{{# closebutton }}<button type="button" class="close" data-dismiss="alert">&times;</button>{{/ closebutton }}
{{{ message }}}
Expand Down
2 changes: 1 addition & 1 deletion theme/boost/templates/core/notification_info.mustache
Expand Up @@ -37,7 +37,7 @@
{ "message": "Your pants are on fire!", "closebutton": 1, "announce": 1, "extraclasses": "foo bar"}
}}
<div class="alert alert-info alert-block fade in {{ extraclasses }}" {{!
}}{{# announce }} role="alert"{{/ announce }}{{!
}}{{# announce }} role="alert" data-aria-autofocus="true"{{/ announce }}{{!
}}>
{{# closebutton }}<button type="button" class="close" data-dismiss="alert">&times;</button>{{/ closebutton }}
{{{ message }}}
Expand Down
2 changes: 1 addition & 1 deletion theme/boost/templates/core/notification_success.mustache
Expand Up @@ -37,7 +37,7 @@
{ "message": "Your pants are on fire!", "closebutton": 1, "announce": 1, "extraclasses": "foo bar"}
}}
<div class="alert alert-success alert-block fade in {{ extraclasses }}" {{!
}}{{# announce }} role="alert"{{/ announce }}{{!
}}{{# announce }} role="alert" data-aria-autofocus="true"{{/ announce }}{{!
}}>
{{# closebutton }}<button type="button" class="close" data-dismiss="alert">&times;</button>{{/ closebutton }}
{{{ message }}}
Expand Down
4 changes: 2 additions & 2 deletions theme/boost/templates/core/notification_warning.mustache
Expand Up @@ -37,8 +37,8 @@
{ "message": "Your pants are on fire!", "closebutton": 1, "announce": 1, "extraclasses": "foo bar"}
}}
<div class="alert alert-warning alert-block fade in {{ extraclasses }}" {{!
}}{{# announce }} role="alert"{{/ announce }}{{!
}}{{# announce }} role="alert" data-aria-autofocus="true"{{/ announce }}{{!
}}>
{{# closebutton }}<button type="button" class="close" data-dismiss="alert">&times;</button>{{/ closebutton }}
{{{ message }}}
</div>
</div>

0 comments on commit 64a00df

Please sign in to comment.