message MDL-22320 assorted message notification improvements
[moodle.git] / message / module.js
CommitLineData
5f3bf83f
PS
1M.core_message = {};
2
e44bc5a1 3M.core_message.init_focus = function(Y, eid) {
5f3bf83f
PS
4 document.getElementById(eid).focus();
5}
6
7M.core_message.init_refresh_parent_frame = function(Y, msgcount, msg) {
5f3bf83f
PS
8 var add_message = function (messagestr) {
9 var messageblock = parent.messages.document.getElementById('messages');
10 var message = document.createElement('div');
11 message.innerHTML = messagestr;
12 messageblock.appendChild(message);
13 }
14
15 if (msgcount>0) {
16 for (var i=0; i < msgcount; i++) {
17 add_message(msg[i])
18 }
19 }
20 parent.messages.scroll(1,5000000);
21 parent.send.focus();
22}
23
24M.core_message.init_refresh_page = function(Y, delay, url) {
25 var delay_callback = function() {
26 document.location.replace(url);
27 }
28 setTimeout(delay_callback, delay);
29}
c8621a02
AD
30
31M.core_message.init_search_page = function(Y, defaultsearchterm) {
32 this.Y = Y;
33 this.defaultsearchterm = defaultsearchterm;
34
35 var combinedsearchbox = this.Y.one('#combinedsearch');
36 combinedsearchbox.on('focus', this.combinedsearchgotfocus, this);
37}
38
39
40M.core_message.combinedsearchgotfocus = function(e) {
41 if (e.target.get('value')==this.defaultsearchterm) {
42 e.target.select();
43 }
b32778c4
AD
44}
45
46M.core_message.init_notification = function(Y, title, content, url) {
47 Y.use('overlay', function() {
48 var o = new Y.Overlay({
49 headerContent : title,
50 bodyContent : content,
51 centered : true
52 });
53 o.render(Y.one(document.body));
54 Y.one('#buttondontreadmessage').on('click', o.hide, o);
55 Y.one('#buttonreadmessage').on('click', function() {
56 window.location.href = url;
57 }, o);
58 });
c8621a02 59}