MDL-41188 javascript: Prevent scrolling to top
authorDamyon Wiese <damyon@moodle.com>
Wed, 18 Sep 2013 12:21:34 +0000 (20:21 +0800)
committerDamyon Wiese <damyon@moodle.com>
Wed, 18 Sep 2013 12:21:34 +0000 (20:21 +0800)
This fix is for dialogues that are not created until some time after the page
has loaded.

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 bc92a5c..e502495 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 7a067ee..d9fd2f4 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 bc92a5c..e502495 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 c9e905b..178f2fb 100644 (file)
@@ -89,14 +89,11 @@ Y.extend(DIALOGUE, Y.Panel, {
         var bb;
 
         this.render();
-        this.show();
+        this.makeResponsive();
         this.after('visibleChange', this.visibilityChanged, this);
         if (config.center) {
             this.centerDialogue();
         }
-        if (!config.visible) {
-            this.hide();
-        }
         this.set('COUNT', COUNT);
 
         // Workaround upstream YUI bug http://yuilibrary.com/projects/yui3/ticket/2532507
@@ -109,6 +106,13 @@ Y.extend(DIALOGUE, Y.Panel, {
         if (config.visible) {
             this.applyZIndex();
         }
+        // We must show - after the dialogue has been positioned,
+        // either by centerDialogue or makeResonsive. This is because the show() will trigger
+        // a focus on the dialogue, which will scroll the page. If the dialogue has not
+        // been positioned it will scroll back to the top of the page.
+        if (config.visible) {
+            this.show();
+        }
     },
 
     /**