Merge branch 'MDL-59858-32' of git://github.com/junpataleta/moodle into MOODLE_32_STABLE

This commit is contained in:
Damyon Wiese
2017-11-06 11:15:14 +08:00
2 changed files with 8 additions and 2 deletions
+1 -1
View File
@@ -1 +1 @@
define(["jquery","core/modal_events","core/modal","core/modal_save_cancel","core/modal_confirm","core/modal_cancel","core/templates","core/notification","core/custom_interaction_events"],function(a,b,c,d,e,f,g,h,i){var j={DEFAULT:"core/modal",SAVE_CANCEL:"core/modal_save_cancel",CONFIRM:"core/modal_confirm",CANCEL:"core/modal_cancel"},k={DEFAULT:c,SAVE_CANCEL:d,CONFIRM:e,CANCEL:f},l={DEFAULT:"DEFAULT",SAVE_CANCEL:"SAVE_CANCEL",CONFIRM:"CONFIRM",CANCEL:"CANCEL"},m=function(a,c){"undefined"!=typeof c&&(i.define(c,[i.events.activate]),c.on(i.events.activate,function(b,c){a.then(function(a){return a.show(),a}),c.originalEvent.preventDefault()}),a.then(function(a){return a.getRoot().on(b.hidden,function(){c.focus()}),a}))},n=function(b,c){c=a(c);var d=k[b],e=new d(c);return e},o=function(b,c){var d=j[b],e=g.render(d,{}).then(function(c){var d=a(c);return n(b,d)}).fail(h.exception);return m(e,c),e},p=function(a,b){var c=a.type||l.DEFAULT,d=!!a.large;return l[c]||(c=l.DEFAULT),o(c,b).then(function(b){return"undefined"!=typeof a.title&&b.setTitle(a.title),"undefined"!=typeof a.body&&b.setBody(a.body),"undefined"!=typeof a.footer&&b.setFooter(a.footer),d&&b.setLarge(),b})};return{create:p,types:l}});
define(["jquery","core/modal_events","core/modal","core/modal_save_cancel","core/modal_confirm","core/modal_cancel","core/templates","core/notification","core/custom_interaction_events"],function(a,b,c,d,e,f,g,h,i){var j={DEFAULT:"core/modal",SAVE_CANCEL:"core/modal_save_cancel",CONFIRM:"core/modal_confirm",CANCEL:"core/modal_cancel"},k={DEFAULT:c,SAVE_CANCEL:d,CONFIRM:e,CANCEL:f},l={DEFAULT:"DEFAULT",SAVE_CANCEL:"SAVE_CANCEL",CONFIRM:"CONFIRM",CANCEL:"CANCEL"},m=function(a,c){if("undefined"!=typeof c){var d=null;i.define(c,[i.events.activate]),c.on(i.events.activate,function(b,c){d=b.currentTarget,a.then(function(a){return a.show(),a}),c.originalEvent.preventDefault()}),a.then(function(a){return a.getRoot().on(b.hidden,function(){null!==d&&d.focus()}),a})}},n=function(b,c){c=a(c);var d=k[b],e=new d(c);return e},o=function(b,c){var d=j[b],e=g.render(d,{}).then(function(c){var d=a(c);return n(b,d)}).fail(h.exception);return m(e,c),e},p=function(a,b){var c=a.type||l.DEFAULT,d=!!a.large;return l[c]||(c=l.DEFAULT),o(c,b).then(function(b){return"undefined"!=typeof a.title&&b.setTitle(a.title),"undefined"!=typeof a.body&&b.setBody(a.body),"undefined"!=typeof a.footer&&b.setFooter(a.footer),d&&b.setLarge(),b})};return{create:p,types:l}});
+7 -1
View File
@@ -60,8 +60,11 @@ define(['jquery', 'core/modal_events', 'core/modal', 'core/modal_save_cancel', '
*/
var setUpTrigger = function(modalPromise, triggerElement) {
if (typeof triggerElement != 'undefined') {
// The element that actually shows the modal.
var actualTriggerElement = null;
CustomEvents.define(triggerElement, [CustomEvents.events.activate]);
triggerElement.on(CustomEvents.events.activate, function(e, data) {
actualTriggerElement = e.currentTarget;
modalPromise.then(function(modal) {
modal.show();
@@ -72,7 +75,10 @@ define(['jquery', 'core/modal_events', 'core/modal', 'core/modal_save_cancel', '
modalPromise.then(function(modal) {
modal.getRoot().on(ModalEvents.hidden, function() {
triggerElement.focus();
// Focus on the trigger element that actually launched the modal.
if (actualTriggerElement !== null) {
actualTriggerElement.focus();
}
});
return modal;