diff --git a/lib/yui/build/moodle-core-lockscroll/moodle-core-lockscroll-debug.js b/lib/yui/build/moodle-core-lockscroll/moodle-core-lockscroll-debug.js index c5b7e404c0f..d79fed4a423 100644 --- a/lib/yui/build/moodle-core-lockscroll/moodle-core-lockscroll-debug.js +++ b/lib/yui/build/moodle-core-lockscroll/moodle-core-lockscroll-debug.js @@ -57,12 +57,7 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, [] return; } - var dialogueHeight = this.get('host').get('boundingBox').get('region').height, - // Most modern browsers use win.innerHeight, but some older versions of IE use documentElement.clientHeight. - // We fall back to 0 if neither can be found which has the effect of disabling scroll locking. - windowHeight = Y.config.win.innerHeight || Y.config.doc.documentElement.clientHeight || 0; - - if (!forceOnSmallWindow && dialogueHeight > (windowHeight - 10)) { + if (!this.shouldLockScroll(forceOnSmallWindow)) { Y.log('Dialogue height greater than window height. Ignoring enable request.', 'warn', 'moodle-core-lockscroll'); return; } @@ -96,6 +91,44 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, [] return this; }, + /** + * Recalculate whether lock scrolling should be on or off. + * + * @method shouldLockScroll + * @param {Boolean} forceOnSmallWindow Whether to enable the scroll lock, even for small window sizes. + * @return boolean + */ + shouldLockScroll: function(forceOnSmallWindow) { + var dialogueHeight = this.get('host').get('boundingBox').get('region').height, + // Most modern browsers use win.innerHeight, but some older versions of IE use documentElement.clientHeight. + // We fall back to 0 if neither can be found which has the effect of disabling scroll locking. + windowHeight = Y.config.win.innerHeight || Y.config.doc.documentElement.clientHeight || 0; + + if (!forceOnSmallWindow && dialogueHeight > (windowHeight - 10)) { + return false; + } else { + return true; + } + }, + + /** + * Recalculate whether lock scrolling should be on or off because the size of the dialogue changed. + * + * @method updateScrollLock + * @param {Boolean} forceOnSmallWindow Whether to enable the scroll lock, even for small window sizes. + * @chainable + */ + updateScrollLock: function(forceOnSmallWindow) { + // Both these functions already check if scroll lock is active and do the right thing. + if (this.shouldLockScroll(forceOnSmallWindow)) { + this.enableScrollLock(forceOnSmallWindow); + } else { + this.disableScrollLock(true); + } + + return this; + }, + /** * Stop locking the page scroll. * @@ -105,7 +138,7 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, [] * @method disableScrollLock * @chainable */ - disableScrollLock: function() { + disableScrollLock: function(force) { if (this.isActive()) { Y.log('Disabling LockScroll.', 'debug', 'moodle-core-lockscroll'); this._enabled = false; @@ -117,7 +150,7 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, [] var currentCount = parseInt(body.getAttribute('data-activeScrollLocks'), 10) || 1, newCount = currentCount - 1; - if (currentCount === 1) { + if (force || currentCount === 1) { body.removeClass('lockscroll'); body.setStyle('maxWidth', null); } diff --git a/lib/yui/build/moodle-core-lockscroll/moodle-core-lockscroll-min.js b/lib/yui/build/moodle-core-lockscroll/moodle-core-lockscroll-min.js index 5207360b5d0..e7d7c8ab861 100644 --- a/lib/yui/build/moodle-core-lockscroll/moodle-core-lockscroll-min.js +++ b/lib/yui/build/moodle-core-lockscroll/moodle-core-lockscroll-min.js @@ -1 +1 @@ -YUI.add("moodle-core-lockscroll",function(e,t){e.namespace("M.core").LockScroll=e.Base.create("lockScroll",e.Plugin.Base,[],{_enabled:!1,destructor:function(){this.disableScrollLock()},enableScrollLock:function(t){if(this.isActive())return;var n=this.get("host").get("boundingBox").get("region").height,r=e.config.win.innerHeight||e.config.doc.documentElement.clientHeight||0;if(!t&&n>r-10)return;this._enabled=!0;var i=e.one(e.config.doc.body),s=i.getComputedStyle("width");i.addClass("lockscroll");var o=parseInt(i.getAttribute("data-activeScrollLocks"),10)||0,u=o+1;return i.setAttribute("data-activeScrollLocks",u),o===0&&i.setStyle("maxWidth",s),this},disableScrollLock:function(){if(this.isActive()){this._enabled=!1;var t=e.one(e.config.doc.body),n=parseInt(t.getAttribute("data-activeScrollLocks"),10)||1,r=n-1;n===1&&(t.removeClass("lockscroll"),t.setStyle("maxWidth",null)),t.setAttribute("data-activeScrollLocks",n-1)}return this},isActive:function(){return this._enabled}},{NS:"lockScroll",ATTRS:{}})},"@VERSION@",{requires:["plugin","base-build"]}); +YUI.add("moodle-core-lockscroll",function(e,t){e.namespace("M.core").LockScroll=e.Base.create("lockScroll",e.Plugin.Base,[],{_enabled:!1,destructor:function(){this.disableScrollLock()},enableScrollLock:function(t){if(this.isActive())return;if(!this.shouldLockScroll(t))return;this._enabled=!0;var n=e.one(e.config.doc.body),r=n.getComputedStyle("width");n.addClass("lockscroll");var i=parseInt(n.getAttribute("data-activeScrollLocks"),10)||0,s=i+1;return n.setAttribute("data-activeScrollLocks",s),i===0&&n.setStyle("maxWidth",r),this},shouldLockScroll:function(t){var n=this.get("host").get("boundingBox").get("region").height,r=e.config.win.innerHeight||e.config.doc.documentElement.clientHeight||0;return!t&&n>r-10?!1:!0},updateScrollLock:function(e){return this.shouldLockScroll(e)?this.enableScrollLock(e):this.disableScrollLock(!0),this},disableScrollLock:function(t){if(this.isActive()){this._enabled=!1;var n=e.one(e.config.doc.body),r=parseInt(n.getAttribute("data-activeScrollLocks"),10)||1,i=r-1;if(t||r===1)n.removeClass("lockscroll"),n.setStyle("maxWidth",null);n.setAttribute("data-activeScrollLocks",r-1)}return this},isActive:function(){return this._enabled}},{NS:"lockScroll",ATTRS:{}})},"@VERSION@",{requires:["plugin","base-build"]}); diff --git a/lib/yui/build/moodle-core-lockscroll/moodle-core-lockscroll.js b/lib/yui/build/moodle-core-lockscroll/moodle-core-lockscroll.js index c15b74eabc0..e447cd16871 100644 --- a/lib/yui/build/moodle-core-lockscroll/moodle-core-lockscroll.js +++ b/lib/yui/build/moodle-core-lockscroll/moodle-core-lockscroll.js @@ -56,12 +56,7 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, [] return; } - var dialogueHeight = this.get('host').get('boundingBox').get('region').height, - // Most modern browsers use win.innerHeight, but some older versions of IE use documentElement.clientHeight. - // We fall back to 0 if neither can be found which has the effect of disabling scroll locking. - windowHeight = Y.config.win.innerHeight || Y.config.doc.documentElement.clientHeight || 0; - - if (!forceOnSmallWindow && dialogueHeight > (windowHeight - 10)) { + if (!this.shouldLockScroll(forceOnSmallWindow)) { return; } @@ -91,6 +86,44 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, [] return this; }, + /** + * Recalculate whether lock scrolling should be on or off. + * + * @method shouldLockScroll + * @param {Boolean} forceOnSmallWindow Whether to enable the scroll lock, even for small window sizes. + * @return boolean + */ + shouldLockScroll: function(forceOnSmallWindow) { + var dialogueHeight = this.get('host').get('boundingBox').get('region').height, + // Most modern browsers use win.innerHeight, but some older versions of IE use documentElement.clientHeight. + // We fall back to 0 if neither can be found which has the effect of disabling scroll locking. + windowHeight = Y.config.win.innerHeight || Y.config.doc.documentElement.clientHeight || 0; + + if (!forceOnSmallWindow && dialogueHeight > (windowHeight - 10)) { + return false; + } else { + return true; + } + }, + + /** + * Recalculate whether lock scrolling should be on or off because the size of the dialogue changed. + * + * @method updateScrollLock + * @param {Boolean} forceOnSmallWindow Whether to enable the scroll lock, even for small window sizes. + * @chainable + */ + updateScrollLock: function(forceOnSmallWindow) { + // Both these functions already check if scroll lock is active and do the right thing. + if (this.shouldLockScroll(forceOnSmallWindow)) { + this.enableScrollLock(forceOnSmallWindow); + } else { + this.disableScrollLock(true); + } + + return this; + }, + /** * Stop locking the page scroll. * @@ -100,7 +133,7 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, [] * @method disableScrollLock * @chainable */ - disableScrollLock: function() { + disableScrollLock: function(force) { if (this.isActive()) { this._enabled = false; @@ -111,7 +144,7 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, [] var currentCount = parseInt(body.getAttribute('data-activeScrollLocks'), 10) || 1, newCount = currentCount - 1; - if (currentCount === 1) { + if (force || currentCount === 1) { body.removeClass('lockscroll'); body.setStyle('maxWidth', null); } 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 index b94fdf9bd92..86f372cba1c 100644 --- 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 @@ -331,6 +331,11 @@ Y.extend(DIALOGUE, Y.Panel, { 'height' : this.get('height')}); } } + + // Update Lock scroll if the plugin is present. + if (this.lockScroll) { + this.lockScroll.updateScrollLock(this.shouldResizeFullscreen()); + } }, /** * Center the dialog on the screen. @@ -387,13 +392,6 @@ Y.extend(DIALOGUE, Y.Panel, { this.get('boundingBox').setXY(this._originalPosition); } - // Lock scroll if the plugin is present. - if (this.lockScroll) { - // We need to force the scroll locking for full screen dialogues, even if they have a small vertical size to - // prevent the background scrolling while the dialogue is open. - this.lockScroll.enableScrollLock(this.shouldResizeFullscreen()); - } - // Try and find a node to focus on using the focusOnShowSelector attribute. if (focusSelector !== null) { focusNode = this.get('boundingBox').one(focusSelector); 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 index db5eca8027c..bdbf8f36a79 100644 --- 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 @@ -1,2 +1,2 @@ -YUI.add("moodle-core-notification-dialogue",function(e,t){var n,r,i,s,o,u,a;n="moodle-dialogue",r="notificationBase",i="yesLabel",s="noLabel",o="title",u="question",a={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"},M.core=M.core||{};var f="Moodle dialogue",l,c=n+"-fullscreen",h=n+"-hidden",p=" [role=dialog]",d="[role=menubar]",v=".",m="moodle-has-zindex",g='input:not([type="hidden"]), a[href], button, textarea, select, [tabindex]';l=function(t){var n=e.clone(t);n.COUNT=e.stamp(this);var r="moodle-dialogue-"+n.COUNT;n.notificationBase=e.Node.create('