mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
Merge branch 'MDL-65788-35' of git://github.com/Chocolate-lightning/moodle into MOODLE_35_STABLE
This commit is contained in:
commit
4ce08a765d
6 changed files with 14 additions and 22 deletions
|
@ -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=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}}});
|
define(["jquery","core/ajax","core/notification","core/modal_factory","core/modal_events"],function(a,b,c,d,e){var f=function(a){this.registerEvents(a)};return f.prototype.registerEvents=function(f){f.on("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(b){return b=a(b),new f(b)}}});
|
|
@ -29,27 +29,18 @@ define([
|
||||||
'core/modal_events'],
|
'core/modal_events'],
|
||||||
function($, Ajax, Notification, ModalFactory, ModalEvents) {
|
function($, Ajax, Notification, ModalFactory, ModalEvents) {
|
||||||
|
|
||||||
/**
|
|
||||||
* List of action selectors.
|
|
||||||
*
|
|
||||||
* @type {{VIEW_POLICY: string}}
|
|
||||||
*/
|
|
||||||
var ACTIONS = {
|
|
||||||
VIEW_POLICY: '[data-action="view"]'
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PolicyActions class.
|
* PolicyActions class.
|
||||||
*/
|
*/
|
||||||
var PolicyActions = function() {
|
var PolicyActions = function(root) {
|
||||||
this.registerEvents();
|
this.registerEvents(root);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register event listeners.
|
* Register event listeners.
|
||||||
*/
|
*/
|
||||||
PolicyActions.prototype.registerEvents = function() {
|
PolicyActions.prototype.registerEvents = function(root) {
|
||||||
$(ACTIONS.VIEW_POLICY).click(function(e) {
|
root.on("click", function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var versionid = $(this).data('versionid');
|
var versionid = $(this).data('versionid');
|
||||||
|
@ -127,8 +118,9 @@ function($, Ajax, Notification, ModalFactory, ModalEvents) {
|
||||||
* @method init
|
* @method init
|
||||||
* @return {PolicyActions}
|
* @return {PolicyActions}
|
||||||
*/
|
*/
|
||||||
'init': function() {
|
'init': function(root) {
|
||||||
return new PolicyActions();
|
root = $(root);
|
||||||
|
return new PolicyActions(root);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -97,7 +97,7 @@ class accept_policy extends \moodleform {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$PAGE->requires->js_call_amd('tool_policy/policyactions', 'init');
|
$PAGE->requires->js_call_amd('tool_policy/policyactions', 'init', ['[data-action="view"]']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -58,7 +58,7 @@ require(['jquery', 'tool_policy/jquery-eu-cookie-law-popup', 'tool_policy/policy
|
||||||
"<ul>{{#policies}}" +
|
"<ul>{{#policies}}" +
|
||||||
"<li>" +
|
"<li>" +
|
||||||
"<a href=\"{{pluginbaseurl}}/view.php?versionid={{id}}{{#returnurl}}&returnurl={{.}}{{/returnurl}}\" " +
|
"<a href=\"{{pluginbaseurl}}/view.php?versionid={{id}}{{#returnurl}}&returnurl={{.}}{{/returnurl}}\" " +
|
||||||
" data-action=\"view\" data-versionid=\"{{id}}\" data-behalfid=\"1\" >" +
|
" data-action=\"view-guest\" data-versionid=\"{{id}}\" data-behalfid=\"1\" >" +
|
||||||
"{{{name}}}" +
|
"{{{name}}}" +
|
||||||
"</a>" +
|
"</a>" +
|
||||||
"</li>" +
|
"</li>" +
|
||||||
|
@ -81,7 +81,7 @@ require(['jquery', 'tool_policy/jquery-eu-cookie-law-popup', 'tool_policy/policy
|
||||||
{{/haspolicies}}
|
{{/haspolicies}}
|
||||||
|
|
||||||
// Initialise the JS for the modal window which displays the policy versions.
|
// Initialise the JS for the modal window which displays the policy versions.
|
||||||
ActionsMod.init();
|
ActionsMod.init('[data-action="view-guest"]');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,6 @@
|
||||||
{{#js}}
|
{{#js}}
|
||||||
// Initialise the JS for the modal window which displays the policy versions.
|
// Initialise the JS for the modal window which displays the policy versions.
|
||||||
require(['tool_policy/policyactions'], function(ActionsMod) {
|
require(['tool_policy/policyactions'], function(ActionsMod) {
|
||||||
ActionsMod.init();
|
ActionsMod.init('[data-action="view"]');
|
||||||
});
|
});
|
||||||
{{/js}}
|
{{/js}}
|
||||||
|
|
|
@ -73,6 +73,6 @@
|
||||||
{{#js}}
|
{{#js}}
|
||||||
// Initialise the JS for the modal window which displays the policy versions.
|
// Initialise the JS for the modal window which displays the policy versions.
|
||||||
require(['tool_policy/policyactions'], function(ActionsMod) {
|
require(['tool_policy/policyactions'], function(ActionsMod) {
|
||||||
ActionsMod.init();
|
ActionsMod.init('[data-action="view"]');
|
||||||
});
|
});
|
||||||
{{/js}}
|
{{/js}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue