mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
MDL-37415 Fix JSHint issues for moodle-core-chooserdialogue
This commit is contained in:
parent
9da506c2a3
commit
a6d96f27e8
47
lib/yui/chooserdialogue/chooserdialogue.js
vendored
47
lib/yui/chooserdialogue/chooserdialogue.js
vendored
@ -2,7 +2,7 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
|
||||
|
||||
var CHOOSERDIALOGUE = function() {
|
||||
CHOOSERDIALOGUE.superclass.constructor.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
Y.extend(CHOOSERDIALOGUE, Y.Base, {
|
||||
// The panel widget
|
||||
@ -36,7 +36,8 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
|
||||
}
|
||||
|
||||
// Set Default options
|
||||
var params = {
|
||||
var paramkey,
|
||||
params = {
|
||||
bodyContent : this.bodycontent.get('innerHTML'),
|
||||
headerContent : this.headercontent.get('innerHTML'),
|
||||
width : '540px',
|
||||
@ -79,13 +80,14 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
|
||||
* @return void
|
||||
*/
|
||||
display_chooser : function (e) {
|
||||
var bb, dialogue, thisevent;
|
||||
this.prepare_chooser();
|
||||
|
||||
// Stop the default event actions before we proceed
|
||||
e.preventDefault();
|
||||
|
||||
var bb = this.panel.get('boundingBox');
|
||||
var dialogue = this.container.one('.alloptions');
|
||||
bb = this.panel.get('boundingBox');
|
||||
dialogue = this.container.one('.alloptions');
|
||||
|
||||
// Get the overflow setting when the chooser was opened - we
|
||||
// may need this later
|
||||
@ -95,16 +97,14 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
|
||||
this.initialoverflow = Y.one('body').getStyle('overflow');
|
||||
}
|
||||
|
||||
var thisevent;
|
||||
|
||||
// This will detect a change in orientation and retrigger centering
|
||||
thisevent = Y.one('document').on('orientationchange', function(e) {
|
||||
thisevent = Y.one('document').on('orientationchange', function() {
|
||||
this.center_dialogue(dialogue);
|
||||
}, this);
|
||||
this.listenevents.push(thisevent);
|
||||
|
||||
// Detect window resizes (most browsers)
|
||||
thisevent = Y.one('window').on('resize', function(e) {
|
||||
thisevent = Y.one('window').on('resize', function() {
|
||||
this.center_dialogue(dialogue);
|
||||
}, this);
|
||||
this.listenevents.push(thisevent);
|
||||
@ -128,7 +128,7 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
|
||||
}, this);
|
||||
this.listenevents.push(thisevent);
|
||||
|
||||
this.container.one('form').on('submit', function(e) {
|
||||
this.container.one('form').on('submit', function() {
|
||||
// Prevent duplicate submissions on submit
|
||||
this.submitbutton.setAttribute('disabled', 'disabled');
|
||||
this.options.setAttribute('disabled', 'disabled');
|
||||
@ -181,7 +181,8 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
|
||||
cancel_listenevents : function () {
|
||||
// Detach all listen events to prevent duplicate triggers
|
||||
var thisevent;
|
||||
while (thisevent = this.listenevents.shift()) {
|
||||
while (this.listenevents.length) {
|
||||
thisevent = this.listenevents.shift();
|
||||
thisevent.detach();
|
||||
}
|
||||
},
|
||||
@ -196,15 +197,15 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
|
||||
* @return void
|
||||
*/
|
||||
center_dialogue : function(dialogue) {
|
||||
var bb = this.panel.get('boundingBox');
|
||||
|
||||
var winheight = bb.get('winHeight');
|
||||
var winwidth = bb.get('winWidth');
|
||||
var offsettop = 0;
|
||||
var bb = this.panel.get('boundingBox'),
|
||||
winheight = bb.get('winHeight'),
|
||||
winwidth = bb.get('winWidth'),
|
||||
offsettop = 0,
|
||||
newheight, totalheight, dialoguetop, dialoguewidth, dialogueleft;
|
||||
|
||||
// Try and set a sensible max-height -- this must be done before setting the top
|
||||
// Set a default height of 640px
|
||||
var newheight = this.get('maxheight');
|
||||
newheight = this.get('maxheight');
|
||||
if (winheight <= newheight) {
|
||||
// Deal with smaller window sizes
|
||||
if (winheight <= this.get('minheight')) {
|
||||
@ -236,13 +237,13 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
|
||||
|
||||
// Take off 15px top and bottom for borders, plus 40px each for the title and button area before setting the
|
||||
// new max-height
|
||||
var totalheight = newheight;
|
||||
totalheight = newheight;
|
||||
newheight = newheight - (15 + 15 + 40 + 40);
|
||||
dialogue.setStyle('max-height', newheight + 'px');
|
||||
dialogue.setStyle('height', newheight + 'px');
|
||||
|
||||
// Re-calculate the location now that we've changed the size
|
||||
var dialoguetop = Math.max(12, ((winheight - totalheight) / 2)) + offsettop;
|
||||
dialoguetop = Math.max(12, ((winheight - totalheight) / 2)) + offsettop;
|
||||
|
||||
// We need to set the height for the yui3-widget - can't work
|
||||
// out what we're setting at present -- shoud be the boudingBox
|
||||
@ -251,13 +252,13 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
|
||||
// Calculate the left location of the chooser
|
||||
// We don't set a minimum width in the same way as we do height as the width would be far lower than the
|
||||
// optimal width for moodle anyway.
|
||||
var dialoguewidth = bb.get('offsetWidth');
|
||||
var dialogueleft = (winwidth - dialoguewidth) / 2;
|
||||
dialoguewidth = bb.get('offsetWidth');
|
||||
dialogueleft = (winwidth - dialoguewidth) / 2;
|
||||
bb.setStyle('left', dialogueleft + 'px');
|
||||
},
|
||||
|
||||
handle_key_press : function(e) {
|
||||
if (e.keyCode == 27) {
|
||||
if (e.keyCode === 27) {
|
||||
this.cancel_popup(e);
|
||||
}
|
||||
},
|
||||
@ -283,7 +284,7 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
|
||||
this.panel.hide();
|
||||
},
|
||||
|
||||
check_options : function(e) {
|
||||
check_options : function() {
|
||||
// Check which options are set, and change the parent class
|
||||
// to show/hide help as required
|
||||
this.options.each(function(thisoption) {
|
||||
@ -305,7 +306,7 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
|
||||
}, this);
|
||||
},
|
||||
|
||||
option_selected : function(e) {
|
||||
option_selected : function() {
|
||||
}
|
||||
},
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user