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 f04887640d4..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,26 @@ 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. * @@ -104,22 +119,13 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, [] * @chainable */ updateScrollLock: function(forceOnSmallWindow) { - var shouldBeEnabled = true, - 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)) { - shouldBeEnabled = false; - } - // Both these functions already check if scroll lock is active and do the right thing. - if (shouldBeEnabled) { + if (this.shouldLockScroll(forceOnSmallWindow)) { this.enableScrollLock(forceOnSmallWindow); } else { - this.disableScrollLock(); + this.disableScrollLock(true); } + return this; }, @@ -132,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; @@ -144,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 6f5faeee91c..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},updateScrollLock:function(t){var n=!0,r=this.get("host").get("boundingBox").get("region").height,i=e.config.win.innerHeight||e.config.doc.documentElement.clientHeight||0;return!t&&r>i-10&&(n=!1),n?this.enableScrollLock(t):this.disableScrollLock(),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 a024bd7a6bc..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,26 @@ 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. * @@ -99,22 +114,13 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, [] * @chainable */ updateScrollLock: function(forceOnSmallWindow) { - var shouldBeEnabled = true, - 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)) { - shouldBeEnabled = false; - } - // Both these functions already check if scroll lock is active and do the right thing. - if (shouldBeEnabled) { + if (this.shouldLockScroll(forceOnSmallWindow)) { this.enableScrollLock(forceOnSmallWindow); } else { - this.disableScrollLock(); + this.disableScrollLock(true); } + return this; }, @@ -127,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; @@ -138,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/src/lockscroll/js/lockscroll.js b/lib/yui/src/lockscroll/js/lockscroll.js index 1f1212b6292..226b30f4ee4 100644 --- a/lib/yui/src/lockscroll/js/lockscroll.js +++ b/lib/yui/src/lockscroll/js/lockscroll.js @@ -55,12 +55,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; } @@ -94,6 +89,26 @@ 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. * @@ -102,22 +117,13 @@ Y.namespace('M.core').LockScroll = Y.Base.create('lockScroll', Y.Plugin.Base, [] * @chainable */ updateScrollLock: function(forceOnSmallWindow) { - var shouldBeEnabled = true, - 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)) { - shouldBeEnabled = false; - } - // Both these functions already check if scroll lock is active and do the right thing. - if (shouldBeEnabled) { + if (this.shouldLockScroll(forceOnSmallWindow)) { this.enableScrollLock(forceOnSmallWindow); } else { - this.disableScrollLock(); + this.disableScrollLock(true); } + return this; }, @@ -130,7 +136,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; @@ -142,7 +148,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); }