MDL-40678 JavaScript: Split out moodle-core-notification into submodules
authorAndrew Nicols <andrew@nicols.co.uk>
Mon, 15 Jul 2013 22:44:17 +0000 (23:44 +0100)
committerAndrew Nicols <andrew@nicols.co.uk>
Sat, 20 Jul 2013 19:21:31 +0000 (20:21 +0100)
28 files changed:
lib/upgrade.txt
lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-debug.js [new file with mode: 0644]
lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-min.js [new file with mode: 0644]
lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception.js [new file with mode: 0644]
lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js [new file with mode: 0644]
lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-min.js [new file with mode: 0644]
lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js [new file with mode: 0644]
lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js [new file with mode: 0644]
lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-min.js [new file with mode: 0644]
lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js [new file with mode: 0644]
lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-debug.js [new file with mode: 0644]
lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-min.js [new file with mode: 0644]
lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue.js [new file with mode: 0644]
lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception-debug.js [new file with mode: 0644]
lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception-min.js [new file with mode: 0644]
lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception.js [new file with mode: 0644]
lib/yui/build/moodle-core-notification/moodle-core-notification-debug.js
lib/yui/build/moodle-core-notification/moodle-core-notification-min.js
lib/yui/build/moodle-core-notification/moodle-core-notification.js
lib/yui/src/notification/build.json
lib/yui/src/notification/js/ajaxexception.js [new file with mode: 0644]
lib/yui/src/notification/js/alert.js [new file with mode: 0644]
lib/yui/src/notification/js/confirm.js [new file with mode: 0644]
lib/yui/src/notification/js/dialogue.js [new file with mode: 0644]
lib/yui/src/notification/js/exception.js [new file with mode: 0644]
lib/yui/src/notification/js/notification.js
lib/yui/src/notification/js/shared.js [new file with mode: 0644]
lib/yui/src/notification/meta/notification.json

index 4c865c0..4430ab3 100644 (file)
@@ -78,6 +78,16 @@ Misc:
     * detect_munged_arguments()     -> clean_param([...], PARAM_FILE)
     * mygroupid()                   -> groups_get_all_groups()
 
+YUI:
+    * moodle-core-notification has been deprecated with a recommendation of
+      using its subclasses intead. This is to allow for reduced page
+      transport costs. Current subclasses include:
+      * dialogue
+      * alert
+      * confirm
+      * exception
+      * ajaxexception
+
 === 2.5.1 ===
 
 * New get_course() function for use when obtaining the course record from database. Will
diff --git a/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-debug.js b/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-debug.js
new file mode 100644 (file)
index 0000000..10c9edf
Binary files /dev/null and b/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-debug.js differ
diff --git a/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-min.js b/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-min.js
new file mode 100644 (file)
index 0000000..21c6f27
Binary files /dev/null and b/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception-min.js differ
diff --git a/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception.js b/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception.js
new file mode 100644 (file)
index 0000000..10c9edf
Binary files /dev/null and b/lib/yui/build/moodle-core-notification-ajaxexception/moodle-core-notification-ajaxexception.js differ
diff --git a/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js
new file mode 100644 (file)
index 0000000..2d90867
Binary files /dev/null and b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-debug.js differ
diff --git a/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-min.js b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-min.js
new file mode 100644 (file)
index 0000000..18a0282
Binary files /dev/null and b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert-min.js differ
diff --git a/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js
new file mode 100644 (file)
index 0000000..2d90867
Binary files /dev/null and b/lib/yui/build/moodle-core-notification-alert/moodle-core-notification-alert.js differ
diff --git a/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js
new file mode 100644 (file)
index 0000000..cf8103c
Binary files /dev/null and b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-debug.js differ
diff --git a/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-min.js b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-min.js
new file mode 100644 (file)
index 0000000..cdef098
Binary files /dev/null and b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm-min.js differ
diff --git a/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js
new file mode 100644 (file)
index 0000000..cf8103c
Binary files /dev/null and b/lib/yui/build/moodle-core-notification-confirm/moodle-core-notification-confirm.js differ
diff --git a/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-debug.js b/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-debug.js
new file mode 100644 (file)
index 0000000..639aaee
Binary files /dev/null and b/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-debug.js differ
diff --git a/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-min.js b/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-min.js
new file mode 100644 (file)
index 0000000..c48c7c7
Binary files /dev/null and b/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-min.js differ
diff --git a/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue.js b/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue.js
new file mode 100644 (file)
index 0000000..639aaee
Binary files /dev/null and b/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue.js differ
diff --git a/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception-debug.js b/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception-debug.js
new file mode 100644 (file)
index 0000000..065a4e2
Binary files /dev/null and b/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception-debug.js differ
diff --git a/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception-min.js b/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception-min.js
new file mode 100644 (file)
index 0000000..731bf9f
Binary files /dev/null and b/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception-min.js differ
diff --git a/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception.js b/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception.js
new file mode 100644 (file)
index 0000000..065a4e2
Binary files /dev/null and b/lib/yui/build/moodle-core-notification-exception/moodle-core-notification-exception.js differ
index d12a077..3a22245 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification/moodle-core-notification-debug.js and b/lib/yui/build/moodle-core-notification/moodle-core-notification-debug.js differ
index 738909e..9a0ca2a 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification/moodle-core-notification-min.js and b/lib/yui/build/moodle-core-notification/moodle-core-notification-min.js differ
index d12a077..0de3353 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification/moodle-core-notification.js and b/lib/yui/build/moodle-core-notification/moodle-core-notification.js differ
index dfc25ad..bd7cc1d 100644 (file)
@@ -5,6 +5,36 @@
       "jsfiles": [
         "notification.js"
       ]
+    },
+    "moodle-core-notification-dialogue": {
+      "jsfiles": [
+        "shared.js",
+        "dialogue.js"
+      ]
+    },
+    "moodle-core-notification-alert": {
+      "jsfiles": [
+        "shared.js",
+        "alert.js"
+      ]
+    },
+    "moodle-core-notification-confirm": {
+      "jsfiles": [
+        "shared.js",
+        "confirm.js"
+      ]
+    },
+    "moodle-core-notification-exception": {
+      "jsfiles": [
+        "shared.js",
+        "exception.js"
+      ]
+    },
+    "moodle-core-notification-ajaxexception": {
+      "jsfiles": [
+        "shared.js",
+        "ajaxexception.js"
+      ]
     }
   }
 }
diff --git a/lib/yui/src/notification/js/ajaxexception.js b/lib/yui/src/notification/js/ajaxexception.js
new file mode 100644 (file)
index 0000000..19b4441
--- /dev/null
@@ -0,0 +1,136 @@
+/**
+ * A dialogue type designed to display an appropriate error when an error
+ * thrown in the Moodle codebase was reported during an AJAX request.
+ *
+ * @module moodle-core-notification
+ * @submodule moodle-core-notification-ajaxexception
+ */
+
+var AJAXEXCEPTION_NAME = 'Moodle AJAX exception',
+    AJAXEXCEPTION;
+
+/**
+ * Extends core Dialogue to show the exception dialogue.
+ *
+ * @param {Object} config Object literal specifying the dialogue configuration properties.
+ * @constructor
+ * @class M.core.ajaxException
+ * @extends M.core.dialogue
+ */
+AJAXEXCEPTION = function(config) {
+    config.name = config.name || 'Error';
+    config.closeButton = true;
+    AJAXEXCEPTION.superclass.constructor.apply(this, [config]);
+};
+Y.extend(AJAXEXCEPTION, M.core.dialogue, {
+    _keypress : null,
+    initializer : function(config) {
+        var content,
+            self = this,
+            delay = this.get('hideTimeoutDelay');
+        this.get(BASE).addClass('moodle-dialogue-exception');
+        this.setStdModContent(Y.WidgetStdMod.HEADER,
+                '<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + config.name + '</h1>', Y.WidgetStdMod.REPLACE);
+        content = Y.Node.create('<div class="moodle-ajaxexception"></div>')
+                .append(Y.Node.create('<div class="moodle-exception-message">'+this.get('error')+'</div>'))
+                .append(Y.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>URL:</label> ' +
+                        this.get('reproductionlink')+'</div>'))
+                .append(Y.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>Debug info:</label> ' +
+                        this.get('debuginfo')+'</div>'))
+                .append(Y.Node.create('<div class="moodle-exception-param hidden param-stacktrace"><label>Stack trace:</label> <pre>' +
+                        this.get('stacktrace')+'</pre></div>'));
+        if (M.cfg.developerdebug) {
+            content.all('.moodle-exception-param').removeClass('hidden');
+        }
+        this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
+
+        if (delay) {
+            this._hideTimeout = setTimeout(function(){self.hide();}, delay);
+        }
+        this.after('visibleChange', this.visibilityChanged, this);
+        this._keypress = Y.on('key', this.hide, window, 'down:13, 27', this);
+        this.centerDialogue();
+    },
+    visibilityChanged : function(e) {
+        if (e.attrName === 'visible' && e.prevVal && !e.newVal) {
+            var self = this;
+            this._keypress.detach();
+            setTimeout(function(){self.destroy();}, 1000);
+        }
+    }
+}, {
+    NAME : AJAXEXCEPTION_NAME,
+    CSS_PREFIX : DIALOGUE_PREFIX,
+    ATTRS : {
+
+        /**
+         * The error message given in the exception.
+         *
+         * @attribute error
+         * @type String
+         * @default 'Unknown error'
+         * @optional
+         */
+        error : {
+            validator : Y.Lang.isString,
+            value : 'Unknown error'
+        },
+
+        /**
+         * Any additional debug information given in the exception.
+         *
+         * @attribute stacktrace
+         * @type String|null
+         * @default null
+         * @optional
+         */
+        debuginfo : {
+            value : null
+        },
+
+        /**
+         * The complete stack trace provided in the exception.
+         *
+         * @attribute stacktrace
+         * @type String|null
+         * @default null
+         * @optional
+         */
+        stacktrace : {
+            value : null
+        },
+
+        /**
+         * A link which may be used by support staff to replicate the issue.
+         *
+         * @attribute reproductionlink
+         * @type String
+         * @default null
+         * @optional
+         */
+        reproductionlink : {
+            setter : function(link) {
+                if (link !== null) {
+                    link = '<a href="'+link+'">'+link.replace(M.cfg.wwwroot, '')+'</a>';
+                }
+                return link;
+            },
+            value : null
+        },
+
+        /**
+         * If set, the dialogue is hidden after the specified timeout period.
+         *
+         * @attribute hideTimeoutDelay
+         * @type Number
+         * @default null
+         * @optional
+         */
+        hideTimeoutDelay : {
+            validator : Y.Lang.isNumber,
+            value : null
+        }
+    }
+});
+
+M.core.ajaxException = AJAXEXCEPTION;
diff --git a/lib/yui/src/notification/js/alert.js b/lib/yui/src/notification/js/alert.js
new file mode 100644 (file)
index 0000000..f51c20b
--- /dev/null
@@ -0,0 +1,95 @@
+/**
+ * A dialogue type designed to display an alert to the user.
+ *
+ * @module moodle-core-notification
+ * @submodule moodle-core-notification-alert
+ */
+
+var ALERT_NAME = 'Moodle alert',
+    ALERT;
+
+/**
+ * Extends core Dialogue to show the alert dialogue.
+ *
+ * @param {Object} config Object literal specifying the dialogue configuration properties.
+ * @constructor
+ * @class M.core.alert
+ * @extends M.core.dialogue
+ */
+ALERT = function(config) {
+    config.closeButton = false;
+    ALERT.superclass.constructor.apply(this, [config]);
+};
+Y.extend(ALERT, M.core.dialogue, {
+    _enterKeypress : null,
+    initializer : function() {
+        this.publish('complete');
+        var yes = Y.Node.create('<input type="button" id="id_yuialertconfirm-' + this.get('COUNT') + '" value="'+this.get(CONFIRMYES)+'" />'),
+            content = Y.Node.create('<div class="confirmation-dialogue"></div>')
+                    .append(Y.Node.create('<div class="confirmation-message">'+this.get('message')+'</div>'))
+                    .append(Y.Node.create('<div class="confirmation-buttons"></div>')
+                            .append(yes));
+        this.get(BASE).addClass('moodle-dialogue-confirm');
+        this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
+        this.setStdModContent(Y.WidgetStdMod.HEADER,
+                '<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
+        this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
+        this._enterKeypress = Y.on('key', this.submit, window, 'down:13', this);
+        yes.on('click', this.submit, this);
+    },
+    submit : function() {
+        this._enterKeypress.detach();
+        this.fire('complete');
+        this.hide();
+        this.destroy();
+    }
+}, {
+    NAME : ALERT_NAME,
+    CSS_PREFIX : DIALOGUE_PREFIX,
+    ATTRS : {
+
+        /**
+         * The title of the alert.
+         *
+         * @attribute title
+         * @type String
+         * @default 'Alert'
+         */
+        title : {
+            validator : Y.Lang.isString,
+            value : 'Alert'
+        },
+
+        /**
+         * The message of the alert.
+         *
+         * @attribute message
+         * @type String
+         * @default 'Confirm'
+         */
+        message : {
+            validator : Y.Lang.isString,
+            value : 'Confirm'
+        },
+
+        /**
+         * The button text to use to accept the alert.
+         *
+         * @attribute yesLabel
+         * @type String
+         * @default 'Ok'
+         */
+        yesLabel : {
+            validator : Y.Lang.isString,
+            setter : function(txt) {
+                if (!txt) {
+                    txt = 'Ok';
+                }
+                return txt;
+            },
+            value : 'Ok'
+        }
+    }
+});
+
+M.core.alert = ALERT;
diff --git a/lib/yui/src/notification/js/confirm.js b/lib/yui/src/notification/js/confirm.js
new file mode 100644 (file)
index 0000000..fe80edc
--- /dev/null
@@ -0,0 +1,114 @@
+/**
+ * A dialogue type designed to display a confirmation to the user.
+ *
+ * @module moodle-core-notification
+ * @submodule moodle-core-notification-confirm
+ */
+
+var CONFIRM_NAME = 'Moodle confirmation dialogue',
+    CONFIRM;
+
+/**
+ * Extends core Dialogue to show the confirmation dialogue.
+ *
+ * @param {Object} config Object literal specifying the dialogue configuration properties.
+ * @constructor
+ * @class M.core.confirm
+ * @extends M.core.dialogue
+ */
+CONFIRM = function(config) {
+    CONFIRM.superclass.constructor.apply(this, [config]);
+};
+Y.extend(CONFIRM, M.core.dialogue, {
+    _enterKeypress : null,
+    _escKeypress : null,
+    initializer : function() {
+        this.publish('complete');
+        this.publish('complete-yes');
+        this.publish('complete-no');
+        var yes = Y.Node.create('<input type="button" id="id_yuiconfirmyes-' + this.get('COUNT') + '" value="'+this.get(CONFIRMYES)+'" />'),
+            no = Y.Node.create('<input type="button" id="id_yuiconfirmno-' + this.get('COUNT') + '" value="'+this.get(CONFIRMNO)+'" />'),
+            content = Y.Node.create('<div class="confirmation-dialogue"></div>')
+                        .append(Y.Node.create('<div class="confirmation-message">'+this.get(QUESTION)+'</div>'))
+                        .append(Y.Node.create('<div class="confirmation-buttons"></div>')
+                            .append(yes)
+                            .append(no));
+        this.get(BASE).addClass('moodle-dialogue-confirm');
+        this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
+        this.setStdModContent(Y.WidgetStdMod.HEADER,
+                '<h1 id="moodle-dialogue-'+this.get('COUNT')+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
+        this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
+        this._enterKeypress = Y.on('key', this.submit, window, 'down:13', this, true);
+        this._escKeypress = Y.on('key', this.submit, window, 'down:27', this, false);
+        yes.on('click', this.submit, this, true);
+        no.on('click', this.submit, this, false);
+    },
+    submit : function(e, outcome) {
+        this._enterKeypress.detach();
+        this._escKeypress.detach();
+        this.fire('complete', outcome);
+        if (outcome) {
+            this.fire('complete-yes');
+        } else {
+            this.fire('complete-no');
+        }
+        this.hide();
+        this.destroy();
+    }
+}, {
+    NAME : CONFIRM_NAME,
+    CSS_PREFIX : DIALOGUE_PREFIX,
+    ATTRS : {
+
+        /**
+         * The button text to use to accept the confirmation.
+         *
+         * @attribute yesLabel
+         * @type String
+         * @default 'Yes'
+         */
+        yesLabel : {
+            validator : Y.Lang.isString,
+            value : 'Yes'
+        },
+
+        /**
+         * The button text to use to reject the confirmation.
+         *
+         * @attribute noLabel
+         * @type String
+         * @default 'No'
+         */
+        noLabel : {
+            validator : Y.Lang.isString,
+            value : 'No'
+        },
+
+        /**
+         * The title of the dialogue.
+         *
+         * @attribute title
+         * @type String
+         * @default 'Confirm'
+         */
+        title : {
+            validator : Y.Lang.isString,
+            value : 'Confirm'
+        },
+
+        /**
+         * The question posed by the dialogue.
+         *
+         * @attribute question
+         * @type String
+         * @default 'Are you sure?'
+         */
+        question : {
+            validator : Y.Lang.isString,
+            value : 'Are you sure?'
+        }
+    }
+});
+Y.augment(CONFIRM, Y.EventTarget);
+
+M.core.confirm = CONFIRM;
diff --git a/lib/yui/src/notification/js/dialogue.js b/lib/yui/src/notification/js/dialogue.js
new file mode 100644 (file)
index 0000000..0a2bf7c
--- /dev/null
@@ -0,0 +1,180 @@
+/**
+ * The generic dialogue class for use in Moodle.
+ *
+ * @module moodle-core-notification
+ * @submodule moodle-core-notification-dialogue
+ */
+
+var DIALOGUE_NAME = 'Moodle dialogue',
+    DIALOGUE;
+
+/**
+ * A re-usable dialogue box with Moodle classes applied.
+ *
+ * @param {Object} config Object literal specifying the dialogue configuration properties.
+ * @constructor
+ * @class M.core.dialogue
+ * @extends Y.Panel
+ */
+DIALOGUE = function(config) {
+    COUNT++;
+    var id = 'moodle-dialogue-'+COUNT;
+    config.notificationBase =
+        Y.Node.create('<div class="'+CSS.BASE+'">')
+              .append(Y.Node.create('<div id="'+id+'" role="dialog" aria-labelledby="'+id+'-header-text" class="'+CSS.WRAP+'"></div>')
+              .append(Y.Node.create('<div class="'+CSS.HEADER+' yui3-widget-hd"></div>'))
+              .append(Y.Node.create('<div class="'+CSS.BODY+' yui3-widget-bd"></div>'))
+              .append(Y.Node.create('<div class="'+CSS.FOOTER+' yui3-widget-ft"></div>')));
+    Y.one(document.body).append(config.notificationBase);
+    config.srcNode =    '#'+id;
+    config.width =      config.width || '400px';
+    config.visible =    config.visible || false;
+    config.center =     config.centered || true;
+    config.centered =   false;
+    config.COUNT = COUNT;
+
+    // lightbox param to keep the stable versions API.
+    if (config.lightbox !== false) {
+        config.modal = true;
+    }
+    delete config.lightbox;
+
+    // closeButton param to keep the stable versions API.
+    if (config.closeButton === false) {
+        config.buttons = null;
+    } else {
+        config.buttons = [
+            {
+                section: Y.WidgetStdMod.HEADER,
+                classNames: 'closebutton',
+                action: function () {
+                    this.hide();
+                }
+            }
+        ];
+    }
+    DIALOGUE.superclass.constructor.apply(this, [config]);
+
+    if (config.closeButton !== false) {
+        // The buttons constructor does not allow custom attributes
+        this.get('buttons').header[0].setAttribute('title', this.get('closeButtonTitle'));
+    }
+};
+Y.extend(DIALOGUE, Y.Panel, {
+    initializer : function() {
+        this.after('visibleChange', this.visibilityChanged, this);
+        this.render();
+        this.show();
+        this.set('COUNT', COUNT);
+
+        // Workaround upstream YUI bug http://yuilibrary.com/projects/yui3/ticket/2532507
+        // and allow setting of z-index in theme.
+        this.get('boundingBox').setStyle('zIndex', null);
+    },
+    visibilityChanged : function(e) {
+        var titlebar;
+        if (e.attrName === 'visible') {
+            this.get('maskNode').addClass(CSS.LIGHTBOX);
+            if (this.get('center') && !e.prevVal && e.newVal) {
+                this.centerDialogue();
+            }
+            if (this.get('draggable')) {
+                titlebar = '#' + this.get('id') + ' .' + CSS.HEADER;
+                this.plug(Y.Plugin.Drag, {handles : [titlebar]});
+                Y.one(titlebar).setStyle('cursor', 'move');
+            }
+        }
+    },
+    centerDialogue : function() {
+        var bb = this.get('boundingBox'),
+            hidden = bb.hasClass(DIALOGUE_PREFIX+'-hidden'),
+            x, y;
+        if (hidden) {
+            bb.setStyle('top', '-1000px').removeClass(DIALOGUE_PREFIX+'-hidden');
+        }
+        x = Math.max(Math.round((bb.get('winWidth') - bb.get('offsetWidth'))/2), 15);
+        y = Math.max(Math.round((bb.get('winHeight') - bb.get('offsetHeight'))/2), 15) + Y.one(window).get('scrollTop');
+
+        if (hidden) {
+            bb.addClass(DIALOGUE_PREFIX+'-hidden');
+        }
+        bb.setStyle('left', x).setStyle('top', y);
+    }
+}, {
+    NAME : DIALOGUE_NAME,
+    CSS_PREFIX : DIALOGUE_PREFIX,
+    ATTRS : {
+        notificationBase : {
+
+        },
+
+        /**
+         * Whether to display the dialogue modally and with a
+         * lightbox style.
+         *
+         * @attribute lightbox
+         * @type Boolean
+         * @default true
+         */
+        lightbox : {
+            validator : Y.Lang.isBoolean,
+            value : true
+        },
+
+        /**
+         * Whether to display a close button on the dialogue.
+         *
+         * Note, we do not recommend hiding the close button as this has
+         * potential accessibility concerns.
+         *
+         * @attribute closeButton
+         * @type Boolean
+         * @default true
+         */
+        closeButton : {
+            validator : Y.Lang.isBoolean,
+            value : true
+        },
+
+        /**
+         * The title for the close button if one is to be shown.
+         *
+         * @attribute closeButtonTitle
+         * @type String
+         * @default 'Close'
+         */
+        closeButtonTitle : {
+            validator : Y.Lang.isString,
+            value : 'Close'
+        },
+
+        /**
+         * Whether to display the dialogue centrally on the screen.
+         *
+         * @attribute center
+         * @type Boolean
+         * @default true
+         */
+        center : {
+            validator : Y.Lang.isBoolean,
+            value : true
+        },
+
+        /**
+         * Whether to make the dialogue movable around the page.
+         *
+         * @attribute draggable
+         * @type Boolean
+         * @default false
+         */
+        draggable : {
+            validator : Y.Lang.isBoolean,
+            value : false
+        },
+        COUNT: {
+            value: 0
+        }
+    }
+});
+
+M.core.dialogue = DIALOGUE;
diff --git a/lib/yui/src/notification/js/exception.js b/lib/yui/src/notification/js/exception.js
new file mode 100644 (file)
index 0000000..ed4324c
--- /dev/null
@@ -0,0 +1,149 @@
+/**
+ * A dialogue type designed to display an appropriate error when a generic
+ * javascript error was thrown and caught.
+ *
+ * @module moodle-core-notification
+ * @submodule moodle-core-notification-exception
+ */
+
+var EXCEPTION_NAME = 'Moodle exception',
+    EXCEPTION;
+
+/**
+ * Extends core Dialogue to show the exception dialogue.
+ *
+ * @param {Object} config Object literal specifying the dialogue configuration properties.
+ * @constructor
+ * @class M.core.exception
+ * @extends M.core.dialogue
+ */
+EXCEPTION = function(config) {
+    config.width = config.width || (M.cfg.developerdebug)?Math.floor(Y.one(document.body).get('winWidth')/3)+'px':null;
+    config.closeButton = true;
+    EXCEPTION.superclass.constructor.apply(this, [config]);
+};
+Y.extend(EXCEPTION, M.core.dialogue, {
+    _hideTimeout : null,
+    _keypress : null,
+    initializer : function(config) {
+        var content,
+            self = this,
+            delay = this.get('hideTimeoutDelay');
+        this.get(BASE).addClass('moodle-dialogue-exception');
+        this.setStdModContent(Y.WidgetStdMod.HEADER,
+                '<h1 id="moodle-dialogue-'+COUNT+'-header-text">' + config.name + '</h1>', Y.WidgetStdMod.REPLACE);
+        content = Y.Node.create('<div class="moodle-exception"></div>')
+                .append(Y.Node.create('<div class="moodle-exception-message">'+this.get('message')+'</div>'))
+                .append(Y.Node.create('<div class="moodle-exception-param hidden param-filename"><label>File:</label> ' +
+                        this.get('fileName')+'</div>'))
+                .append(Y.Node.create('<div class="moodle-exception-param hidden param-linenumber"><label>Line:</label> ' +
+                        this.get('lineNumber')+'</div>'))
+                .append(Y.Node.create('<div class="moodle-exception-param hidden param-stacktrace"><label>Stack trace:</label> <pre>' +
+                        this.get('stack')+'</pre></div>'));
+        if (M.cfg.developerdebug) {
+            content.all('.moodle-exception-param').removeClass('hidden');
+        }
+        this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
+
+        if (delay) {
+            this._hideTimeout = setTimeout(function(){self.hide();}, delay);
+        }
+        this.after('visibleChange', this.visibilityChanged, this);
+        this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
+        this._keypress = Y.on('key', this.hide, window, 'down:13,27', this);
+        this.centerDialogue();
+    },
+    visibilityChanged : function(e) {
+        if (e.attrName === 'visible' && e.prevVal && !e.newVal) {
+            if (this._keypress) {
+                this._keypress.detach();
+            }
+            var self = this;
+            setTimeout(function(){self.destroy();}, 1000);
+        }
+    }
+}, {
+    NAME : EXCEPTION_NAME,
+    CSS_PREFIX : DIALOGUE_PREFIX,
+    ATTRS : {
+        /**
+         * The message of the alert.
+         *
+         * @attribute message
+         * @type String
+         * @default ''
+         */
+        message : {
+            value : ''
+        },
+
+        /**
+         * The name of the alert.
+         *
+         * @attribute title
+         * @type String
+         * @default ''
+         */
+        name : {
+            value : ''
+        },
+
+        /**
+         * The name of the file where the error was thrown.
+         *
+         * @attribute fileName
+         * @type String
+         * @default ''
+         */
+        fileName : {
+            value : ''
+        },
+
+        /**
+         * The line number where the error was thrown.
+         *
+         * @attribute lineNumber
+         * @type String
+         * @default ''
+         */
+        lineNumber : {
+            value : ''
+        },
+
+        /**
+         * The backtrace from the error
+         *
+         * @attribute lineNumber
+         * @type String
+         * @default ''
+         */
+        stack : {
+            setter : function(str) {
+                var lines = str.split("\n"),
+                    pattern = new RegExp('^(.+)@('+M.cfg.wwwroot+')?(.{0,75}).*:(\\d+)$'),
+                    i;
+                for (i in lines) {
+                    lines[i] = lines[i].replace(pattern,
+                            "<div class='stacktrace-line'>ln: $4</div><div class='stacktrace-file'>$3</div><div class='stacktrace-call'>$1</div>");
+                }
+                return lines.join('');
+            },
+            value : ''
+        },
+
+        /**
+         * If set, the dialogue is hidden after the specified timeout period.
+         *
+         * @attribute hideTimeoutDelay
+         * @type Number
+         * @default null
+         * @optional
+         */
+        hideTimeoutDelay : {
+            validator : Y.Lang.isNumber,
+            value : null
+        }
+    }
+});
+
+M.core.exception = EXCEPTION;
index e15286d..86559ed 100644 (file)
-var DIALOGUE_NAME = 'Moodle dialogue',
-    DIALOGUE_PREFIX = 'moodle-dialogue',
-    CONFIRM_NAME = 'Moodle confirmation dialogue',
-    EXCEPTION_NAME = 'Moodle exception',
-    AJAXEXCEPTION_NAME = 'Moodle AJAX exception',
-    ALERT_NAME = 'Moodle alert',
-    BASE = 'notificationBase',
-    COUNT = 0,
-    CONFIRMYES = 'yesLabel',
-    CONFIRMNO = 'noLabel',
-    TITLE = 'title',
-    QUESTION = 'question',
-    CSS = {
-        BASE : 'moodle-dialogue-base',
-        WRAP : 'moodle-dialogue-wrap',
-        HEADER : 'moodle-dialogue-hd',
-        BODY : 'moodle-dialogue-bd',
-        CONTENT : 'moodle-dialogue-content',
-        FOOTER : 'moodle-dialogue-ft',
-        HIDDEN : 'hidden',
-        LIGHTBOX : 'moodle-dialogue-lightbox'
-    },
-    EXCEPTION,
-    ALERT,
-    CONFIRM,
-    AJAXEXCEPTION,
-    DIALOGUE;
-
-DIALOGUE = function(config) {
-    COUNT++;
-    var id = 'moodle-dialogue-'+COUNT;
-    config.notificationBase =
-        Y.Node.create('<div class="'+CSS.BASE+'">')
-              .append(Y.Node.create('<div id="'+id+'" role="dialog" aria-labelledby="'+id+'-header-text" class="'+CSS.WRAP+'"></div>')
-              .append(Y.Node.create('<div class="'+CSS.HEADER+' yui3-widget-hd"></div>'))
-              .append(Y.Node.create('<div class="'+CSS.BODY+' yui3-widget-bd"></div>'))
-              .append(Y.Node.create('<div class="'+CSS.FOOTER+' yui3-widget-ft"></div>')));
-    Y.one(document.body).append(config.notificationBase);
-    config.srcNode =    '#'+id;
-    config.width =      config.width || '400px';
-    config.visible =    config.visible || false;
-    config.center =     config.centered || true;
-    config.centered =   false;
-
-    // lightbox param to keep the stable versions API.
-    if (config.lightbox !== false) {
-        config.modal = true;
-    }
-    delete config.lightbox;
-
-    // closeButton param to keep the stable versions API.
-    if (config.closeButton === false) {
-        config.buttons = null;
-    } else {
-        config.buttons = [
-            {
-                section: Y.WidgetStdMod.HEADER,
-                classNames: 'closebutton',
-                action: function () {
-                    this.hide();
-                }
-            }
-        ];
-    }
-    DIALOGUE.superclass.constructor.apply(this, [config]);
-
-    if (config.closeButton !== false) {
-        // The buttons constructor does not allow custom attributes
-        this.get('buttons').header[0].setAttribute('title', this.get('closeButtonTitle'));
-    }
-};
-Y.extend(DIALOGUE, Y.Panel, {
-    initializer : function() {
-        this.after('visibleChange', this.visibilityChanged, this);
-        this.render();
-        this.show();
-
-        // Workaround upstream YUI bug http://yuilibrary.com/projects/yui3/ticket/2532507
-        // and allow setting of z-index in theme.
-        this.get('boundingBox').setStyle('zIndex', null);
-    },
-    visibilityChanged : function(e) {
-        var titlebar;
-        if (e.attrName === 'visible') {
-            this.get('maskNode').addClass(CSS.LIGHTBOX);
-            if (this.get('center') && !e.prevVal && e.newVal) {
-                this.centerDialogue();
-            }
-            if (this.get('draggable')) {
-                titlebar = '#' + this.get('id') + ' .' + CSS.HEADER;
-                this.plug(Y.Plugin.Drag, {handles : [titlebar]});
-                Y.one(titlebar).setStyle('cursor', 'move');
-            }
-        }
-    },
-    centerDialogue : function() {
-        var bb = this.get('boundingBox'),
-            hidden = bb.hasClass(DIALOGUE_PREFIX+'-hidden'),
-            x, y;
-        if (hidden) {
-            bb.setStyle('top', '-1000px').removeClass(DIALOGUE_PREFIX+'-hidden');
-        }
-        x = Math.max(Math.round((bb.get('winWidth') - bb.get('offsetWidth'))/2), 15);
-        y = Math.max(Math.round((bb.get('winHeight') - bb.get('offsetHeight'))/2), 15) + Y.one(window).get('scrollTop');
-
-        if (hidden) {
-            bb.addClass(DIALOGUE_PREFIX+'-hidden');
-        }
-        bb.setStyle('left', x).setStyle('top', y);
-    }
-}, {
-    NAME : DIALOGUE_NAME,
-    CSS_PREFIX : DIALOGUE_PREFIX,
-    ATTRS : {
-        notificationBase : {
-
-        },
-        lightbox : {
-            validator : Y.Lang.isBoolean,
-            value : true
-        },
-        closeButton : {
-            validator : Y.Lang.isBoolean,
-            value : true
-        },
-        closeButtonTitle : {
-            validator : Y.Lang.isString,
-            value : 'Close'
-        },
-        center : {
-            validator : Y.Lang.isBoolean,
-            value : true
-        },
-        draggable : {
-            validator : Y.Lang.isBoolean,
-            value : false
-        }
-    }
-});
-
-ALERT = function(config) {
-    config.closeButton = false;
-    ALERT.superclass.constructor.apply(this, [config]);
-};
-Y.extend(ALERT, DIALOGUE, {
-    _enterKeypress : null,
-    initializer : function() {
-        this.publish('complete');
-        var yes = Y.Node.create('<input type="button" id="id_yuialertconfirm-' + this.COUNT + '" value="'+this.get(CONFIRMYES)+'" />'),
-            content = Y.Node.create('<div class="confirmation-dialogue"></div>')
-                    .append(Y.Node.create('<div class="confirmation-message">'+this.get('message')+'</div>'))
-                    .append(Y.Node.create('<div class="confirmation-buttons"></div>')
-                            .append(yes));
-        this.get(BASE).addClass('moodle-dialogue-confirm');
-        this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
-        this.setStdModContent(Y.WidgetStdMod.HEADER, '<h1 id="moodle-dialogue-'+COUNT+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
-        this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
-        this._enterKeypress = Y.on('key', this.submit, window, 'down:13', this);
-        yes.on('click', this.submit, this);
-    },
-    submit : function() {
-        this._enterKeypress.detach();
-        this.fire('complete');
-        this.hide();
-        this.destroy();
-    }
-}, {
-    NAME : ALERT_NAME,
-    CSS_PREFIX : DIALOGUE_PREFIX,
-    ATTRS : {
-        title : {
-            validator : Y.Lang.isString,
-            value : 'Alert'
-        },
-        message : {
-            validator : Y.Lang.isString,
-            value : 'Confirm'
-        },
-        yesLabel : {
-            validator : Y.Lang.isString,
-            setter : function(txt) {
-                if (!txt) {
-                    txt = 'Ok';
-                }
-                return txt;
-            },
-            value : 'Ok'
-        }
-    }
-});
-
-CONFIRM = function(config) {
-    CONFIRM.superclass.constructor.apply(this, [config]);
-};
-Y.extend(CONFIRM, DIALOGUE, {
-    _enterKeypress : null,
-    _escKeypress : null,
-    initializer : function() {
-        this.publish('complete');
-        this.publish('complete-yes');
-        this.publish('complete-no');
-        var yes = Y.Node.create('<input type="button" id="id_yuiconfirmyes-' + this.COUNT + '" value="'+this.get(CONFIRMYES)+'" />'),
-            no = Y.Node.create('<input type="button" id="id_yuiconfirmno-' + this.COUNT + '" value="'+this.get(CONFIRMNO)+'" />'),
-            content = Y.Node.create('<div class="confirmation-dialogue"></div>')
-                        .append(Y.Node.create('<div class="confirmation-message">'+this.get(QUESTION)+'</div>'))
-                        .append(Y.Node.create('<div class="confirmation-buttons"></div>')
-                            .append(yes)
-                            .append(no));
-        this.get(BASE).addClass('moodle-dialogue-confirm');
-        this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
-        this.setStdModContent(Y.WidgetStdMod.HEADER, '<h1 id="moodle-dialogue-'+COUNT+'-header-text">' + this.get(TITLE) + '</h1>', Y.WidgetStdMod.REPLACE);
-        this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
-        this._enterKeypress = Y.on('key', this.submit, window, 'down:13', this, true);
-        this._escKeypress = Y.on('key', this.submit, window, 'down:27', this, false);
-        yes.on('click', this.submit, this, true);
-        no.on('click', this.submit, this, false);
-    },
-    submit : function(e, outcome) {
-        this._enterKeypress.detach();
-        this._escKeypress.detach();
-        this.fire('complete', outcome);
-        if (outcome) {
-            this.fire('complete-yes');
-        } else {
-            this.fire('complete-no');
-        }
-        this.hide();
-        this.destroy();
-    }
-}, {
-    NAME : CONFIRM_NAME,
-    CSS_PREFIX : DIALOGUE_PREFIX,
-    ATTRS : {
-        yesLabel : {
-            validator : Y.Lang.isString,
-            value : 'Yes'
-        },
-        noLabel : {
-            validator : Y.Lang.isString,
-            value : 'No'
-        },
-        title : {
-            validator : Y.Lang.isString,
-            value : 'Confirm'
-        },
-        question : {
-            validator : Y.Lang.isString,
-            value : 'Are you sure?'
-        }
-    }
-});
-Y.augment(CONFIRM, Y.EventTarget);
-
-EXCEPTION = function(config) {
-    config.width = config.width || (M.cfg.developerdebug)?Math.floor(Y.one(document.body).get('winWidth')/3)+'px':null;
-    config.closeButton = true;
-    EXCEPTION.superclass.constructor.apply(this, [config]);
-};
-Y.extend(EXCEPTION, DIALOGUE, {
-    _hideTimeout : null,
-    _keypress : null,
-    initializer : function(config) {
-        var content,
-            self = this,
-            delay = this.get('hideTimeoutDelay');
-        this.get(BASE).addClass('moodle-dialogue-exception');
-        this.setStdModContent(Y.WidgetStdMod.HEADER, '<h1 id="moodle-dialogue-'+COUNT+'-header-text">' + config.name + '</h1>', Y.WidgetStdMod.REPLACE);
-        content = Y.Node.create('<div class="moodle-exception"></div>')
-                .append(Y.Node.create('<div class="moodle-exception-message">'+this.get('message')+'</div>'))
-                .append(Y.Node.create('<div class="moodle-exception-param hidden param-filename"><label>File:</label> '+this.get('fileName')+'</div>'))
-                .append(Y.Node.create('<div class="moodle-exception-param hidden param-linenumber"><label>Line:</label> '+this.get('lineNumber')+'</div>'))
-                .append(Y.Node.create('<div class="moodle-exception-param hidden param-stacktrace"><label>Stack trace:</label> <pre>'+this.get('stack')+'</pre></div>'));
-        if (M.cfg.developerdebug) {
-            content.all('.moodle-exception-param').removeClass('hidden');
-        }
-        this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
-
-        if (delay) {
-            this._hideTimeout = setTimeout(function(){self.hide();}, delay);
-        }
-        this.after('visibleChange', this.visibilityChanged, this);
-        this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
-        this._keypress = Y.on('key', this.hide, window, 'down:13,27', this);
-        this.centerDialogue();
-    },
-    visibilityChanged : function(e) {
-        if (e.attrName === 'visible' && e.prevVal && !e.newVal) {
-            if (this._keypress) {
-                this._keypress.detach();
-            }
-            var self = this;
-            setTimeout(function(){self.destroy();}, 1000);
-        }
-    }
-}, {
-    NAME : EXCEPTION_NAME,
-    CSS_PREFIX : DIALOGUE_PREFIX,
-    ATTRS : {
-        message : {
-            value : ''
-        },
-        name : {
-            value : ''
-        },
-        fileName : {
-            value : ''
-        },
-        lineNumber : {
-            value : ''
-        },
-        stack : {
-            setter : function(str) {
-                var lines = str.split("\n"),
-                    pattern = new RegExp('^(.+)@('+M.cfg.wwwroot+')?(.{0,75}).*:(\\d+)$'),
-                    i;
-                for (i in lines) {
-                    lines[i] = lines[i].replace(pattern,
-                            "<div class='stacktrace-line'>ln: $4</div><div class='stacktrace-file'>$3</div><div class='stacktrace-call'>$1</div>");
-                }
-                return lines.join('');
-            },
-            value : ''
-        },
-        hideTimeoutDelay : {
-            validator : Y.Lang.isNumber,
-            value : null
-        }
-    }
-});
-
-AJAXEXCEPTION = function(config) {
-    config.name = config.name || 'Error';
-    config.closeButton = true;
-    AJAXEXCEPTION.superclass.constructor.apply(this, [config]);
-};
-Y.extend(AJAXEXCEPTION, DIALOGUE, {
-    _keypress : null,
-    initializer : function(config) {
-        var content,
-            self = this,
-            delay = this.get('hideTimeoutDelay');
-        this.get(BASE).addClass('moodle-dialogue-exception');
-        this.setStdModContent(Y.WidgetStdMod.HEADER, '<h1 id="moodle-dialogue-'+COUNT+'-header-text">' + config.name + '</h1>', Y.WidgetStdMod.REPLACE);
-        content = Y.Node.create('<div class="moodle-ajaxexception"></div>')
-                .append(Y.Node.create('<div class="moodle-exception-message">'+this.get('error')+'</div>'))
-                .append(Y.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>URL:</label> '+this.get('reproductionlink')+'</div>'))
-                .append(Y.Node.create('<div class="moodle-exception-param hidden param-debuginfo"><label>Debug info:</label> '+this.get('debuginfo')+'</div>'))
-                .append(Y.Node.create('<div class="moodle-exception-param hidden param-stacktrace"><label>Stack trace:</label> <pre>'+this.get('stacktrace')+'</pre></div>'));
-        if (M.cfg.developerdebug) {
-            content.all('.moodle-exception-param').removeClass('hidden');
-        }
-        this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
-
-        if (delay) {
-            this._hideTimeout = setTimeout(function(){self.hide();}, delay);
-        }
-        this.after('visibleChange', this.visibilityChanged, this);
-        this._keypress = Y.on('key', this.hide, window, 'down:13, 27', this);
-        this.centerDialogue();
-    },
-    visibilityChanged : function(e) {
-        if (e.attrName === 'visible' && e.prevVal && !e.newVal) {
-            var self = this;
-            this._keypress.detach();
-            setTimeout(function(){self.destroy();}, 1000);
-        }
-    }
-}, {
-    NAME : AJAXEXCEPTION_NAME,
-    CSS_PREFIX : DIALOGUE_PREFIX,
-    ATTRS : {
-        error : {
-            validator : Y.Lang.isString,
-            value : 'Unknown error'
-        },
-        debuginfo : {
-            value : null
-        },
-        stacktrace : {
-            value : null
-        },
-        reproductionlink : {
-            setter : function(link) {
-                if (link !== null) {
-                    link = '<a href="'+link+'">'+link.replace(M.cfg.wwwroot, '')+'</a>';
-                }
-                return link;
-            },
-            value : null
-        },
-        hideTimeoutDelay : {
-            validator : Y.Lang.isNumber,
-            value : null
-        }
-    }
-});
-
-M.core = M.core || {};
-M.core.dialogue = DIALOGUE;
-M.core.alert = ALERT;
-M.core.confirm = CONFIRM;
-M.core.exception = EXCEPTION;
-M.core.ajaxException = AJAXEXCEPTION;
+/**
+ * The notification module provides a standard set of dialogues for use
+ * within Moodle.
+ *
+ * @module moodle-core-notification
+ * @main
+ */
+
+/**
+ * To avoid bringing moodle-core-notification into modules in it's
+ * entirety, we now recommend using on of the subclasses of
+ * moodle-core-notification. These include:
+ * <dl>
+ *  <dt> moodle-core-notification-dialogue</dt>
+ *  <dt> moodle-core-notification-alert</dt>
+ *  <dt> moodle-core-notification-confirm</dt>
+ *  <dt> moodle-core-notification-exception</dt>
+ *  <dt> moodle-core-notification-ajaxexception</dt>
+ * </dl>
+ *
+ * @class M.core.notification
+ * @deprecated
+ */
+Y.log("The moodle-core-notification parent module has been deprecated. " +
+        "Please use one of its' subclasses instead.", 'moodle-core-notification', 'warn');
diff --git a/lib/yui/src/notification/js/shared.js b/lib/yui/src/notification/js/shared.js
new file mode 100644 (file)
index 0000000..6f7bc10
--- /dev/null
@@ -0,0 +1,29 @@
+var DIALOGUE_PREFIX,
+    BASE,
+    COUNT,
+    CONFIRMYES,
+    CONFIRMNO,
+    TITLE,
+    QUESTION,
+    CSS;
+
+DIALOGUE_PREFIX = 'moodle-dialogue',
+BASE = 'notificationBase',
+COUNT = 0,
+CONFIRMYES = 'yesLabel',
+CONFIRMNO = 'noLabel',
+TITLE = 'title',
+QUESTION = 'question',
+CSS = {
+    BASE : 'moodle-dialogue-base',
+    WRAP : 'moodle-dialogue-wrap',
+    HEADER : 'moodle-dialogue-hd',
+    BODY : 'moodle-dialogue-bd',
+    CONTENT : 'moodle-dialogue-content',
+    FOOTER : 'moodle-dialogue-ft',
+    HIDDEN : 'hidden',
+    LIGHTBOX : 'moodle-dialogue-lightbox'
+};
+
+// Set up the namespace once.
+M.core = M.core || {};
index 739c827..ef33211 100644 (file)
@@ -1,5 +1,14 @@
 {
   "moodle-core-notification": {
+    "requires": [
+        "moodle-core-notification-dialogue",
+        "moodle-core-notification-alert",
+        "moodle-core-notification-confirm",
+        "moodle-core-notification-exception",
+        "moodle-core-notification-ajaxexception"
+    ]
+  },
+  "moodle-core-notification-dialogue": {
     "requires": [
         "base",
         "node",
@@ -7,5 +16,25 @@
         "event-key",
         "dd-plugin"
     ]
+  },
+  "moodle-core-notification-alert": {
+    "requires": [
+        "moodle-core-notification-dialogue"
+    ]
+  },
+  "moodle-core-notification-confirm": {
+    "requires": [
+        "moodle-core-notification-dialogue"
+    ]
+  },
+  "moodle-core-notification-exception": {
+    "requires": [
+        "moodle-core-notification-dialogue"
+    ]
+  },
+  "moodle-core-notification-ajaxexception": {
+    "requires": [
+        "moodle-core-notification-dialogue"
+    ]
   }
 }