Merge branch 'MDL-43232-master' of git://github.com/andrewnicols/moodle
authorSam Hemelryk <sam@moodle.com>
Mon, 9 Dec 2013 20:06:54 +0000 (09:06 +1300)
committerSam Hemelryk <sam@moodle.com>
Mon, 9 Dec 2013 20:06:54 +0000 (09:06 +1300)
backup/util/ui/base_moodleform.class.php
backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-debug.js [new file with mode: 0644]
backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-min.js [new file with mode: 0644]
backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel.js [new file with mode: 0644]
backup/util/ui/yui/confirmcancel/confirmcancel.js [deleted file]
backup/util/ui/yui/src/confirmcancel/build.json [new file with mode: 0644]
backup/util/ui/yui/src/confirmcancel/js/confirmcancel.js [new file with mode: 0644]
backup/util/ui/yui/src/confirmcancel/meta/confirmcancel.json [new file with mode: 0644]

index 762ea70..9866705 100644 (file)
@@ -348,7 +348,7 @@ abstract class base_moodleform extends moodleform {
         $config->yesLabel = get_string('confirmcancelyes', 'backup');
         $config->noLabel = get_string('confirmcancelno', 'backup');
         $config->closeButtonTitle = get_string('close', 'editor');
-        $PAGE->requires->yui_module('moodle-backup-confirmcancel', 'M.core_backup.watch_cancel_buttons', array($config));
+        $PAGE->requires->yui_module('moodle-backup-confirmcancel', 'M.core_backup.confirmcancel.watch_cancel_buttons', array($config));
 
         // Get list of module types on course.
         $modinfo = get_fast_modinfo($COURSE);
diff --git a/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-debug.js b/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-debug.js
new file mode 100644 (file)
index 0000000..173f290
Binary files /dev/null and b/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-debug.js differ
diff --git a/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-min.js b/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-min.js
new file mode 100644 (file)
index 0000000..f19f1a9
Binary files /dev/null and b/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-min.js differ
diff --git a/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel.js b/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel.js
new file mode 100644 (file)
index 0000000..173f290
Binary files /dev/null and b/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel.js differ
diff --git a/backup/util/ui/yui/confirmcancel/confirmcancel.js b/backup/util/ui/yui/confirmcancel/confirmcancel.js
deleted file mode 100644 (file)
index 77deaf1..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-YUI.add('moodle-backup-confirmcancel', function(Y) {
-
-// Namespace for the backup
-M.core_backup = M.core_backup || {};
-/**
- * Adds confirmation dialogues to the cancel buttons on the page.
- *
- * @param {object} config
- */
-M.core_backup.watch_cancel_buttons = function(config) {
-    Y.all('.confirmcancel').each(function(){
-        this._confirmationListener = this._confirmationListener || this.on('click', function(e){
-            // Prevent the default event (sumbit) from firing
-            e.preventDefault();
-            // Create the confirm box
-            var confirm = new M.core.confirm(config);
-            // If the user clicks yes
-            confirm.on('complete-yes', function(e){
-                // Detach the listener for the confirm box so it doesn't fire again.
-                this._confirmationListener.detach();
-                // Simulate the original cancel button click
-                this.simulate('click');
-            }, this);
-            // Show the confirm box
-            confirm.show();
-        }, this);
-    });
-}
-
-}, '@VERSION@', {'requires':['base','node','node-event-simulate','moodle-core-notification']});
diff --git a/backup/util/ui/yui/src/confirmcancel/build.json b/backup/util/ui/yui/src/confirmcancel/build.json
new file mode 100644 (file)
index 0000000..603210c
--- /dev/null
@@ -0,0 +1,10 @@
+{
+    "name": "moodle-backup-confirmcancel",
+    "builds": {
+        "moodle-backup-confirmcancel": {
+            "jsfiles": [
+                "confirmcancel.js"
+            ]
+        }
+    }
+}
diff --git a/backup/util/ui/yui/src/confirmcancel/js/confirmcancel.js b/backup/util/ui/yui/src/confirmcancel/js/confirmcancel.js
new file mode 100644 (file)
index 0000000..ddaeb52
--- /dev/null
@@ -0,0 +1,77 @@
+/**
+ * Add a confirmation dialogue when cancelling a backup.
+ *
+ * @module moodle-backup-confirmcancel
+ */
+
+/**
+ * Add a confirmation dialogue when cancelling a backup.
+ *
+ * @class M.core_backup.confirmcancel
+ */
+
+
+// Namespace for the backup.
+M.core_backup = M.core_backup || {};
+
+M.core_backup.confirmcancel = {
+    /**
+     * An array of EventHandlers which call the confirm_cancel dialogue.
+     *
+     * @property listeners
+     * @protected
+     * @type Array
+     */
+    listeners: [],
+
+    /**
+     * The configuration supplied to this instance.
+     *
+     * @property config
+     * @protected
+     * @type Object
+     */
+    config: {},
+
+    /**
+     * Initializer to watch all cancel buttons.
+     *
+     * @method watch_cancel_buttons
+     * @param {Object} config The configuration for the confirmation dialogue.
+     */
+    watch_cancel_buttons: function(config) {
+        this.config = config;
+
+        this.listeners.push(
+            Y.one(Y.config.doc.body).delegate('click', this.confirm_cancel, '.confirmcancel', this)
+        );
+    },
+
+    /**
+     * Display the confirmation dialogue.
+     *
+     * @method confirm_cancel
+     * @protected
+     * @param {EventFacade} e
+     */
+    confirm_cancel: function(e) {
+        // Prevent the default event (submit) from firing.
+        e.preventDefault();
+
+        // Create the confirmation dialogue.
+        var confirm = new M.core.confirm(this.config);
+
+        // If the user clicks yes.
+        confirm.on('complete-yes', function(){
+            // Detach the listeners for the confirm box so they don't fire again.
+            new Y.EventHandle(M.core_backup.confirmcancel.listeners).detach();
+
+            // Simulate the original cancel button click.
+            c.currentTarget.simulate('click');
+        }, this);
+
+
+        // Show the confirm box.
+        confirm.show();
+    }
+};
diff --git a/backup/util/ui/yui/src/confirmcancel/meta/confirmcancel.json b/backup/util/ui/yui/src/confirmcancel/meta/confirmcancel.json
new file mode 100644 (file)
index 0000000..e352bdf
--- /dev/null
@@ -0,0 +1,9 @@
+{
+    "moodle-backup-confirmcancel": {
+        "requires": [
+            "node",
+            "node-event-simulate",
+            "moodle-core-notification-confirm"
+        ]
+    }
+}