Merge branch '41214-26' of git://github.com/samhemelryk/moodle
authorDan Poltawski <dan@moodle.com>
Mon, 2 Sep 2013 09:32:08 +0000 (17:32 +0800)
committerDan Poltawski <dan@moodle.com>
Mon, 2 Sep 2013 09:32:08 +0000 (17:32 +0800)
Conflicts:
lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-min.js

lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-debug.js
lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-min.js
lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue.js
lib/yui/src/notification/js/dialogue.js

index c6b624f..74479fe 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-debug.js and b/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-debug.js differ
index 53476bc..692eebf 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-min.js and b/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-min.js differ
index c6b624f..74479fe 100644 (file)
Binary files a/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue.js and b/lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue.js differ
index e6ea2b9..6624784 100644 (file)
@@ -7,16 +7,12 @@
 
 var DIALOGUE_NAME = 'Moodle dialogue',
     DIALOGUE,
-    DIALOGUE_FULLSCREEN_CLASS,
-    DIALOGUE_HIDDEN_CLASS,
-    EXISTING_WINDOW_SELECTOR,
-    NOSCROLLING_CLASS;
-
-DIALOGUE_MODAL_CLASS = 'yui3-widget-modal';
-DIALOGUE_FULLSCREEN_CLASS = DIALOGUE_PREFIX+'-fullscreen';
-DIALOGUE_HIDDEN_CLASS = DIALOGUE_PREFIX+'-hidden';
-EXISTING_WINDOW_SELECTOR = '[role=dialog]';
-NOSCROLLING_CLASS = 'no-scrolling';
+    DIALOGUE_FULLSCREEN_CLASS = DIALOGUE_PREFIX + '-fullscreen',
+    DIALOGUE_HIDDEN_CLASS = DIALOGUE_PREFIX + '-hidden',
+    DIALOGUE_MODAL_CLASS = 'yui3-widget-modal',
+    DIALOGUE_SELECTOR =' [role=dialog]',
+    MENUBAR_SELECTOR = '[role=menubar]',
+    NOSCROLLING_CLASS = 'no-scrolling';
 
 /**
  * A re-usable dialogue box with Moodle classes applied.
@@ -126,39 +122,42 @@ Y.extend(DIALOGUE, Y.Panel, {
      */
     applyZIndex : function() {
         var highestzindex = 0,
-            zindex,
-            bb;
-
-        bb = this.get('boundingBox');
-        if (this.get('zIndex')) {
+            bb = this.get('boundingBox'),
+            zindex = this.get('zIndex');
+        if (zindex) {
             // The zindex was specified so we should use that.
-            bb.setStyle('zIndex', this.get('zIndex'));
+            bb.setStyle('zIndex', zindex);
         } else {
-            // Determine the correct zindex by looking at all existing dialogs in the page.
-            // Get the zindex of the parent of each wrapper node.
-            Y.all(EXISTING_WINDOW_SELECTOR).each(function (node) {
-                zindex = node.getStyle('zIndex');
-
-                // In most cases the zindex is set on the parent of the dialog.
-                if (!zindex) {
-                    zindex = node.get('parentNode').getStyle('zIndex');
-                }
-
-                if (zindex) {
-                    zindex = parseInt(zindex, 10);
-
-                    if (zindex > highestzindex) {
-                        highestzindex = zindex;
-                    }
+            // Determine the correct zindex by looking at all existing dialogs and menubars in the page.
+            Y.all(DIALOGUE_SELECTOR+', '+MENUBAR_SELECTOR).each(function (node) {
+                var zindex = this.findZIndex(node);
+                if (zindex > highestzindex) {
+                    highestzindex = zindex;
                 }
-            });
+            }, this);
             // Only set the zindex if we found a wrapper.
             if (highestzindex > 0) {
-                bb.setStyle('zIndex', highestzindex + 1);
+                bb.setStyle('zIndex', (highestzindex + 1).toString());
             }
         }
     },
 
+    /**
+     * Finds the zIndex of the given node or its parent.
+     *
+     * @method findZIndex
+     * @param Node node
+     * @returns int Return either the zIndex of 0 if one was not found.
+     */
+    findZIndex : function(node) {
+        // In most cases the zindex is set on the parent of the dialog.
+        var zindex = node.getStyle('zIndex') || node.ancestor().getStyle('zIndex');
+        if (zindex) {
+            return parseInt(zindex, 10);
+        }
+        return 0;
+    },
+
     /**
      * Enable or disable document scrolling (see if there are any modal or fullscreen popups).
      *