MDL-59383 core_modal: trigger event on modal module

This commit is contained in:
Simey Lameze
2017-07-12 18:28:11 +08:00
parent e1c811609b
commit f02e119afd
4 changed files with 7 additions and 12 deletions

View File

@@ -1 +1 @@
define(["jquery","core/ajax","core/str","core/templates","core/notification","core/custom_interaction_events","core/modal_factory","core_calendar/summary_modal","core_calendar/calendar_repository"],function(a,b,c,d,e,f,g,h,i){var j={ROOT:"[data-region='calendar']",EVENT_LINK:"[data-action='view-event']"},k=null,l=function(a){var b="type"+a;return c.get_string(b,"core_calendar").then(function(a){return a}).fail(e.exception)},m=function(a){var b=i.getEventById(a);return b.then(function(a){return a.event?a.event:void b.fail(e.exception)}).then(function(a){return l(a.eventtype).then(function(b){return a.eventtype=b,a})}).then(function(a){return k.done(function(b){b.setTitle(a.name),d.render("core_calendar/event_summary_body",a).done(function(a,c){d.replaceNodeContents(b.getBody(),a,c)}),0==a.caneditevent&&b.setFooter(""),b.show()})})},n=function(b){b=a(b);var c=!1;b.on("click",j.EVENT_LINK,function(b){if(!c){c=!0,b.preventDefault();var d=a(b.target).closest(j.EVENT_LINK),e=d.attr("data-event-id");m(e).done(function(){c=!1})}})};return{init:function(){k=g.create({type:h.TYPE}),n(j.ROOT)}}});
define(["jquery","core/ajax","core/str","core/templates","core/notification","core/custom_interaction_events","core/modal_factory","core_calendar/summary_modal","core_calendar/calendar_repository"],function(a,b,c,d,e,f,g,h,i){var j={ROOT:"[data-region='calendar']",EVENT_LINK:"[data-action='view-event']"},k=null,l=function(a){var b="type"+a;return c.get_string(b,"core_calendar").then(function(a){return a}).fail(e.exception)},m=function(a){var b=i.getEventById(a);return b.then(function(a){return a.event?a.event:void b.fail(e.exception)}).then(function(a){return l(a.eventtype).then(function(b){return a.eventtype=b,a})}).then(function(a){return k.done(function(b){b.setTitle(a.name),b.setBody(d.render("core_calendar/event_summary_body",a)),0==a.caneditevent&&b.setFooter(""),b.show()})})},n=function(b){b=a(b);var c=!1;b.on("click",j.EVENT_LINK,function(b){if(!c){c=!0,b.preventDefault();var d=a(b.target).closest(j.EVENT_LINK),e=d.attr("data-event-id");m(e).done(function(){c=!1})}})};return{init:function(){k=g.create({type:h.TYPE}),n(j.ROOT)}}});

View File

@@ -69,14 +69,7 @@ define(['jquery', 'core/ajax', 'core/str', 'core/templates', 'core/notification'
}).then(function(eventdata) {
return modalPromise.done(function(modal) {
modal.setTitle(eventdata.name);
Templates.render(
'core_calendar/event_summary_body',
eventdata
).done(function(html, js) {
Templates.replaceNodeContents(modal.getBody(), html, js);
});
modal.setBody(Templates.render('core_calendar/event_summary_body', eventdata));
// Hide edit and delete buttons if I don't have permission.
if (eventdata.caneditevent == false) {
modal.setFooter('');

File diff suppressed because one or more lines are too long

View File

@@ -23,8 +23,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define(['jquery', 'core/templates', 'core/notification', 'core/key_codes',
'core/custom_interaction_events', 'core/modal_backdrop', 'core/modal_events'],
function($, Templates, Notification, KeyCodes, CustomEvents, ModalBackdrop, ModalEvents) {
'core/custom_interaction_events', 'core/modal_backdrop', 'core/event', 'core/modal_events'],
function($, Templates, Notification, KeyCodes, CustomEvents, ModalBackdrop, Event, ModalEvents) {
var SELECTORS = {
CONTAINER: '[data-region="modal-container"]',
@@ -239,6 +239,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core/key_codes',
if (typeof value === 'string') {
// Just set the value if it's a string.
body.html(value);
Event.notifyFilterContentUpdated(body);
} else {
// Otherwise we assume it's a promise to be resolved with
// html and javascript.
@@ -257,6 +258,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core/key_codes',
this.bodyJS = js;
}
}
Event.notifyFilterContentUpdated(body);
}.bind(this));
}.bind(this));
}