Merge branch 'MDL-54121-master' of git://github.com/damyon/moodle
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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"]});
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+5
-7
@@ -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);
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+5
-7
@@ -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);
|
||||
|
||||
+41
-8
@@ -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,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.
|
||||
*
|
||||
@@ -103,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;
|
||||
@@ -115,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);
|
||||
}
|
||||
|
||||
+5
-7
@@ -302,6 +302,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.
|
||||
@@ -358,13 +363,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);
|
||||
|
||||
Reference in New Issue
Block a user