fixed docs
[moodle.git] / message / module.js
CommitLineData
8a811c56 1M.core_message = M.core_message || {};
5f3bf83f 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,
8a811c56 50 bodyContent : content
b32778c4
AD
51 });
52 o.render(Y.one(document.body));
78e873c8 53
8a811c56
AD
54 if (Y.UA.ie > 0 && Y.UA.ie < 7) {
55 // Adjust for IE 6 (can't handle fixed pos)
56 //align the bottom right corner of the overlay with the bottom right of the viewport
57 o.set("align", {
58 points:[Y.WidgetPositionAlign.BR, Y.WidgetPositionAlign.BR]
59 });
60 }
78e873c8
AD
61
62 Y.one('#notificationyes').on('click', function(e) {
b32778c4
AD
63 window.location.href = url;
64 }, o);
78e873c8
AD
65 Y.one('#notificationno').on('click', function(e) {
66 o.hide();
67 e.preventDefault();
68 return false;
69 }, o);
b32778c4 70 });
c8621a02 71}