mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
Merge branch 'MDL-63094-master' of git://github.com/andrewnicols/moodle
This commit is contained in:
commit
1766184e97
@ -1 +1 @@
|
||||
define(["jquery","core/ajax","core/notification","core/modal_factory","core/modal_events"],function(a,b,c,d,e){var f={VIEW_POLICY:'[data-action="view"]'},g=function(){this.registerEvents()};return g.prototype.registerEvents=function(){a(f.VIEW_POLICY).click(function(f){f.preventDefault();var g=a(this).data("versionid"),h=a(this).data("behalfid"),i={versionid:g,behalfid:h},j={methodname:"tool_policy_get_policy_version",args:i},k=b.call([j]),l="",m=d.types.DEFAULT;a.when(k[0]).then(function(a){return a.result.policy?(l=a.result.policy.name,a.result.policy.content):(c.addNotification({message:a.warnings[0].message,type:"error"}),!1)}).then(function(a){return 0!=a&&d.create({title:l,body:a,type:m,large:!0}).then(function(a){return a.getRoot().on(e.hidden,function(){a.destroy()}),a})}).done(function(a){a.show()}).fail(c.exception)})},{init:function(){return new g}}});
|
||||
define(["jquery","core/ajax","core/notification","core/modal_factory","core/modal_events"],function(a,b,c,d,e){var f={VIEW_POLICY:'[data-action="view"]'},g=function(){this.registerEvents()};return g.prototype.registerEvents=function(){a(f.VIEW_POLICY).click(function(f){f.preventDefault();var g=a(this).data("versionid"),h=a(this).data("behalfid"),i={versionid:g,behalfid:h},j={methodname:"tool_policy_get_policy_version",args:i},k=a.Deferred(),l=a.Deferred(),m=d.create({title:k,body:l,large:!0}).then(function(a){return a.getRoot().on(e.hidden,function(){a.destroy()}),a}).then(function(a){return a.show(),a})["catch"](c.exception),n=b.call([j]);a.when(n[0]).then(function(a){if(a.result.policy)return k.resolve(a.result.policy.name),l.resolve(a.result.policy.content),a;throw new Error(a.warnings[0].message)})["catch"](function(a){return m.then(function(a){return a.hide(),a.destroy(),a})["catch"](c.exception),c.addNotification({message:a,type:"error"})})})},{init:function(){return new g}}});
|
@ -65,43 +65,55 @@ function($, Ajax, Notification, ModalFactory, ModalEvents) {
|
||||
args: params
|
||||
};
|
||||
|
||||
var modalTitle = $.Deferred();
|
||||
var modalBody = $.Deferred();
|
||||
|
||||
var modal = ModalFactory.create({
|
||||
title: modalTitle,
|
||||
body: modalBody,
|
||||
large: true
|
||||
})
|
||||
.then(function(modal) {
|
||||
// Handle hidden event.
|
||||
modal.getRoot().on(ModalEvents.hidden, function() {
|
||||
// Destroy when hidden.
|
||||
modal.destroy();
|
||||
});
|
||||
|
||||
return modal;
|
||||
})
|
||||
.then(function(modal) {
|
||||
modal.show();
|
||||
|
||||
return modal;
|
||||
})
|
||||
.catch(Notification.exception);
|
||||
|
||||
// Make the request now that the modal is configured.
|
||||
var promises = Ajax.call([request]);
|
||||
var modalTitle = '';
|
||||
var modalType = ModalFactory.types.DEFAULT;
|
||||
$.when(promises[0]).then(function(data) {
|
||||
if (data.result.policy) {
|
||||
modalTitle = data.result.policy.name;
|
||||
return data.result.policy.content;
|
||||
modalTitle.resolve(data.result.policy.name);
|
||||
modalBody.resolve(data.result.policy.content);
|
||||
|
||||
return data;
|
||||
} else {
|
||||
throw new Error(data.warnings[0].message);
|
||||
}
|
||||
// Fail.
|
||||
Notification.addNotification({
|
||||
message: data.warnings[0].message,
|
||||
}).catch(function(message) {
|
||||
modal.then(function(modal) {
|
||||
modal.hide();
|
||||
modal.destroy();
|
||||
|
||||
return modal;
|
||||
})
|
||||
.catch(Notification.exception);
|
||||
|
||||
return Notification.addNotification({
|
||||
message: message,
|
||||
type: 'error'
|
||||
});
|
||||
return false;
|
||||
|
||||
}).then(function(html) {
|
||||
if (html != false) {
|
||||
return ModalFactory.create({
|
||||
title: modalTitle,
|
||||
body: html,
|
||||
type: modalType,
|
||||
large: true
|
||||
}).then(function(modal) {
|
||||
// Handle hidden event.
|
||||
modal.getRoot().on(ModalEvents.hidden, function() {
|
||||
// Destroy when hidden.
|
||||
modal.destroy();
|
||||
});
|
||||
|
||||
return modal;
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}).done(function(modal) {
|
||||
// Show the modal.
|
||||
modal.show();
|
||||
}).fail(Notification.exception);
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
@ -10,6 +10,10 @@
|
||||
z-index: 9999999;
|
||||
}
|
||||
|
||||
.behat-site .eupopup-container-bottom {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.eupopup-container-bottom {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
|
@ -460,7 +460,6 @@ Feature: User must accept policy managed by this plugin when logging in and sign
|
||||
| This privacy policy | 1 | | full text3 | short text3 | active | loggedin |
|
||||
| This guests policy | 0 | | full text4 | short text4 | active | guest |
|
||||
And I am on site homepage
|
||||
And I change window size to "large"
|
||||
And I follow "Log in"
|
||||
When I press "Log in as a guest"
|
||||
Then I should see "If you continue browsing this website, you agree to our policies"
|
||||
|
2
lib/amd/build/modal.min.js
vendored
2
lib/amd/build/modal.min.js
vendored
File diff suppressed because one or more lines are too long
@ -577,10 +577,6 @@ define(['jquery', 'core/templates', 'core/notification', 'core/key_codes',
|
||||
* @method hide
|
||||
*/
|
||||
Modal.prototype.hide = function() {
|
||||
if (!this.isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.getBackdrop().done(function(backdrop) {
|
||||
if (!this.countOtherVisibleModals()) {
|
||||
// Hide the backdrop if we're the last open modal.
|
||||
|
Loading…
x
Reference in New Issue
Block a user