From f068cac195c8fadbf42133bcbb1d963e8c612a62 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Thu, 20 Sep 2012 12:42:25 +0800 Subject: [PATCH] MDL-30899 moodle-core-notification Adding focus to non modal windows --- blocks/community/yui/comments/comments.js | 3 +++ .../yui/imagegallery/imagegallery.js | 4 +++- .../yui/quickenrolment/quickenrolment.js | 20 +++++++++++++++---- .../yui/quickenrolment/quickenrolment.js | 9 +++++++-- filter/glossary/yui/autolinker/autolinker.js | 3 ++- lib/yui/notification/notification.js | 6 +++--- 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/blocks/community/yui/comments/comments.js b/blocks/community/yui/comments/comments.js index 9d57acd2d63..0fa8601e23c 100644 --- a/blocks/community/yui/comments/comments.js +++ b/blocks/community/yui/comments/comments.js @@ -55,6 +55,9 @@ YUI.add('moodle-block_community-comments', function(Y) { this.event = Y.one(document.body).on('click', this.hide, this, commentid); // We add a new event on the panel in order to hide the panel for the next click (touch device). this.panelevent = Y.one("#commentoverlay-"+commentid).on('click', this.hide, this, commentid); + + // Focus on the close button + this.panels[commentid].get('buttons').header[0].focus(); }, hide : function (e, commentid) { diff --git a/blocks/community/yui/imagegallery/imagegallery.js b/blocks/community/yui/imagegallery/imagegallery.js index 2f0c65ccabc..a4cb4570577 100644 --- a/blocks/community/yui/imagegallery/imagegallery.js +++ b/blocks/community/yui/imagegallery/imagegallery.js @@ -93,7 +93,6 @@ YUI.add('moodle-block_community-imagegallery', function(Y) { var panel = Y.one('#imageoverlay'); panel.setContent(''); - panel.append(Y.Node.create('
')); this.panel.destroy(); @@ -132,6 +131,9 @@ YUI.add('moodle-block_community-imagegallery', function(Y) { this.panel.set("centered", true); this.panel.show(); + // Focus on the close button + this.panel.get('buttons').header[0].focus(); + }, this, url); var previousnumber = screennumber - 1; diff --git a/enrol/cohort/yui/quickenrolment/quickenrolment.js b/enrol/cohort/yui/quickenrolment/quickenrolment.js index 6c22963ef33..52727e64ecc 100644 --- a/enrol/cohort/yui/quickenrolment/quickenrolment.js +++ b/enrol/cohort/yui/quickenrolment/quickenrolment.js @@ -20,6 +20,7 @@ YUI.add('moodle-enrol_cohort-quickenrolment', function(Y) { AJAXURL = 'ajaxurl', MANUALENROLMENT = 'manualEnrolment', CSS = { + CLOSEBTN : 'close-button', COHORT : 'qce-cohort', COHORTS : 'qce-cohorts', COHORTBUTTON : 'qce-cohort-button', @@ -52,13 +53,16 @@ YUI.add('moodle-enrol_cohort-quickenrolment', function(Y) { this.publish('cohortsloaded'); this.publish('defaultcohortroleloaded', {fireOnce:true}); + var finishbutton = Y.Node.create('
') + .append(Y.Node.create('')); var base = Y.Node.create('
') .append(Y.Node.create('
')) .append(Y.Node.create('
')) .append(Y.Node.create('
') - .append(Y.Node.create('
') + .append(Y.Node.create('
') .append(Y.Node.create('')) ) + .append(finishbutton) ) .append(Y.Node.create('
') .append(Y.Node.create('loading') @@ -99,6 +103,7 @@ YUI.add('moodle-enrol_cohort-quickenrolment', function(Y) { this.on('defaultcohortroleloaded', this.updateContent, this, panel); Y.on('key', this.hide, document.body, 'down:27', this); close.on('click', this.hide, this); + finishbutton.on('click', this.hide, this); Y.all('.enrol_cohort_plugin input').each(function(node){ if (node.getAttribute('type', 'submit')) { @@ -117,6 +122,11 @@ YUI.add('moodle-enrol_cohort-quickenrolment', function(Y) { this.getCohorts(e, false); this.getAssignableRoles(); this.fire('show'); + + var rolesselect = Y.one('#id_enrol_cohort_assignable_roles'); + if (rolesselect) { + rolesselect.focus(); + } }, updateContent : function(e, panel) { var content, i, roles, cohorts, count=0, supportmanual = this.get(MANUALENROLMENT), defaultrole; @@ -154,13 +164,14 @@ YUI.add('moodle-enrol_cohort-quickenrolment', function(Y) { break; case 'assignablerolesloaded': roles = this.get(ASSIGNABLEROLES); - content = Y.Node.create(''); + content = Y.Node.create(''); for (i in roles) { content.append(Y.Node.create('')); } - panel.get('contentBox').one('.'+CSS.PANELROLES).setContent(Y.Node.create('
').append(content)); + panel.get('contentBox').one('.'+CSS.PANELROLES).setContent(Y.Node.create('
').append(content)); this.getDefaultCohortRole(); + Y.one('#id_enrol_cohort_assignable_roles').focus(); break; case 'defaultcohortroleloaded': defaultrole = this.get(DEFAULTCOHORTROLE); @@ -280,7 +291,8 @@ YUI.add('moodle-enrol_cohort-quickenrolment', function(Y) { new M.core.ajaxException(result); } else { if (result.response && result.response.message) { - new M.core.alert(result.response); + var alertpanel = new M.core.alert(result.response); + Y.Node.one('#id_yuialertconfirm-' + alertpanel.COUNT).focus(); } var enrolled = Y.Node.create('
'+M.str.enrol.synced+'
'); node.one('.'+CSS.COHORT+' #cohortid_'+cohort.get(COHORTID)).replace(enrolled); diff --git a/enrol/manual/yui/quickenrolment/quickenrolment.js b/enrol/manual/yui/quickenrolment/quickenrolment.js index c047999b18f..1b51b99fb48 100644 --- a/enrol/manual/yui/quickenrolment/quickenrolment.js +++ b/enrol/manual/yui/quickenrolment/quickenrolment.js @@ -89,8 +89,8 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) { .append(create('

'+M.str.enrol.enrolusers+'

'))) .append(create('
') .append(create('
') - .append(create('
'+M.str.role.assignroles+'
') - .append(create('')) + .append(create('
') + .append(create('')) ) .append(create('
') .append(create('
'+M.str.enrol.enrolmentoptions+'
')) @@ -178,6 +178,7 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) { s.append(option); } s.set('selectedIndex', index); + Y.one('#id_enrol_manual_assignable_roles').focus(); }, this); this.getAssignableRoles(); }, @@ -268,6 +269,10 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) { } this._escCloseEvent = Y.on('key', this.hide, document.body, 'down:27', this); + var rolesselect = Y.one('#id_enrol_manual_assignable_roles'); + if (rolesselect) { + rolesselect.focus(); + } }, hide : function(e) { if (this._escCloseEvent) { diff --git a/filter/glossary/yui/autolinker/autolinker.js b/filter/glossary/yui/autolinker/autolinker.js index 1a1586df4a2..cb4129c2f2e 100644 --- a/filter/glossary/yui/autolinker/autolinker.js +++ b/filter/glossary/yui/autolinker/autolinker.js @@ -70,7 +70,8 @@ YUI.add('moodle-filter_glossary-autolinker', function(Y) { for (key in data.entries) { definition = data.entries[key].definition + data.entries[key].attachments - new M.core.alert({title:data.entries[key].concept, message:definition, lightbox:false}); + var alertpanel = new M.core.alert({title:data.entries[key].concept, message:definition, lightbox:false}); + Y.Node.one('#id_yuialertconfirm-' + alertpanel.COUNT).focus(); } return true; diff --git a/lib/yui/notification/notification.js b/lib/yui/notification/notification.js index 2881b90bac3..8cc168f2a51 100644 --- a/lib/yui/notification/notification.js +++ b/lib/yui/notification/notification.js @@ -130,7 +130,7 @@ Y.extend(ALERT, DIALOGUE, { _enterKeypress : null, initializer : function(config) { this.publish('complete'); - var yes = C(''), + var yes = C(''), content = C('
') .append(C('
'+this.get('message')+'
')) .append(C('
') @@ -183,8 +183,8 @@ Y.extend(CONFIRM, DIALOGUE, { this.publish('complete'); this.publish('complete-yes'); this.publish('complete-no'); - var yes = C(''), - no = C(''), + var yes = C(''), + no = C(''), content = C('
') .append(C('
'+this.get(QUESTION)+'
')) .append(C('
') -- 2.43.0