mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
Merge branch 'MDL-67881-master' of git://github.com/bmbrands/moodle
This commit is contained in:
commit
7be118e265
@ -38,7 +38,7 @@
|
||||
{{^show}}aria-hidden="true"{{/show}}
|
||||
data-region="right-hand-drawer"
|
||||
role="region"
|
||||
tabindex="-1"
|
||||
tabindex="0"
|
||||
>
|
||||
{{$drawercontent}}{{/drawercontent}}
|
||||
</div>
|
||||
|
2
message/amd/build/message_drawer.min.js
vendored
2
message/amd/build/message_drawer.min.js
vendored
@ -1,2 +1,2 @@
|
||||
define ("core_message/message_drawer",["jquery","core/custom_interaction_events","core/pubsub","core_message/message_drawer_view_contact","core_message/message_drawer_view_contacts","core_message/message_drawer_view_conversation","core_message/message_drawer_view_group_info","core_message/message_drawer_view_overview","core_message/message_drawer_view_search","core_message/message_drawer_view_settings","core_message/message_drawer_router","core_message/message_drawer_routes","core_message/message_drawer_events","core/pending","core/drawer"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p={PANEL_BODY_CONTAINER:"[data-region=\"panel-body-container\"]",PANEL_HEADER_CONTAINER:"[data-region=\"panel-header-container\"]",VIEW_CONTACT:"[data-region=\"view-contact\"]",VIEW_CONTACTS:"[data-region=\"view-contacts\"]",VIEW_CONVERSATION:"[data-region=\"view-conversation\"]",VIEW_GROUP_INFO:"[data-region=\"view-group-info\"]",VIEW_OVERVIEW:"[data-region=\"view-overview\"]",VIEW_SEARCH:"[data-region=\"view-search\"]",VIEW_SETTINGS:"[data-region=\"view-settings\"]",ROUTES:"[data-route]",ROUTES_BACK:"[data-route-back]",HEADER_CONTAINER:"[data-region=\"header-container\"]",BODY_CONTAINER:"[data-region=\"body-container\"]",FOOTER_CONTAINER:"[data-region=\"footer-container\"]"},q=function(a,b,c){var d=b.find(p.HEADER_CONTAINER).find(c);if(!d.length){d=b.find(p.PANEL_HEADER_CONTAINER).find(c)}var e=b.find(p.BODY_CONTAINER).find(c);if(!e.length){e=b.find(p.PANEL_BODY_CONTAINER).find(c)}var f=b.find(p.FOOTER_CONTAINER).find(c);return[a,d.length?d:null,e.length?e:null,f.length?f:null]},r=[[l.VIEW_CONTACT,p.VIEW_CONTACT,d.show,d.description],[l.VIEW_CONTACTS,p.VIEW_CONTACTS,e.show,e.description],[l.VIEW_CONVERSATION,p.VIEW_CONVERSATION,f.show,f.description],[l.VIEW_GROUP_INFO,p.VIEW_GROUP_INFO,g.show,g.description],[l.VIEW_OVERVIEW,p.VIEW_OVERVIEW,h.show,h.description],[l.VIEW_SEARCH,p.VIEW_SEARCH,i.show,i.description],[l.VIEW_SETTINGS,p.VIEW_SETTINGS,j.show,j.description]],s=function(a,b){r.forEach(function(c){k.add(a,c[0],q(a,b,c[1]),c[2],c[3])})},t=function(a,b){if(!b.attr("data-shown")){k.go(a,l.VIEW_OVERVIEW);b.attr("data-shown",!0)}var c=o.getDrawerRoot(b);if(c.length){o.show(c)}},u=function(a){var b=o.getDrawerRoot(a);if(b.length){o.hide(b)}},v=function(a){var b=o.getDrawerRoot(a);if(b.length){return o.isVisible(b)}return!0},w=function(d,e,f){b.define(e,[b.events.activate]);var g=/^data-route-param-?(\d*)$/;e.on(b.events.activate,p.ROUTES,function(b,c){for(var e=a(b.target).closest(p.ROUTES),f=e.attr("data-route"),h=[],j=0;j<e[0].attributes.length;j++){h.push(e[0].attributes[j])}var l=h.filter(function(a){var b=a.nodeName,c=g.test(b);return c});l.sort(function(c,a){var b=g.exec(c.nodeName),d=g.exec(a.nodeName),e=1<b.length?b[1]:0,f=1<d.length?d[1]:0;if(e<f){return-1}else if(f<e){return 1}else{return 0}});var m=l.map(function(a){return a.nodeValue}),n=[d,f].concat(m);k.go.apply(null,n);c.originalEvent.preventDefault()});e.on(b.events.activate,p.ROUTES_BACK,function(a,b){k.back(d);b.originalEvent.preventDefault()});e.on("hide.bs.collapse",".collapse",function(b){var c=new n;a(b.target).one("hidden.bs.collapse",function(){c.resolve()})});e.on("show.bs.collapse",".collapse",function(b){var c=new n;a(b.target).one("shown.bs.collapse",function(){c.resolve()})});if(!f){c.subscribe(m.SHOW,function(){t(d,e)});c.subscribe(m.HIDE,function(){u(e)});c.subscribe(m.TOGGLE_VISIBILITY,function(){if(v(e)){u(e)}else{t(d,e)}})}c.subscribe(m.SHOW_CONVERSATION,function(a){t(d,e);k.go(d,l.VIEW_CONVERSATION,a)});c.subscribe(m.CREATE_CONVERSATION_WITH_USER,function(a){t(d,e);k.go(d,l.VIEW_CONVERSATION,null,"create",a)});c.subscribe(m.SHOW_SETTINGS,function(){t(d,e);k.go(d,l.VIEW_SETTINGS)});c.subscribe(m.PREFERENCES_UPDATED,function(a){var b=a.filter(function(a){return"message_entertosend"==a.type}),c=b.length?b[0]:null;if(c){var d=e.find(p.FOOTER_CONTAINER).find(p.VIEW_CONVERSATION);d.attr("data-enter-to-send",c.value)}})};return{init:function init(b,c,d,e){b=a(b);s(c,b);w(c,b,d);if(d){t(c,b);if(e){var f=e.params||[];f=[c,e.path].concat(f);k.go.apply(null,f)}}}}});
|
||||
define ("core_message/message_drawer",["jquery","core/custom_interaction_events","core/pubsub","core_message/message_drawer_view_contact","core_message/message_drawer_view_contacts","core_message/message_drawer_view_conversation","core_message/message_drawer_view_group_info","core_message/message_drawer_view_overview","core_message/message_drawer_view_search","core_message/message_drawer_view_settings","core_message/message_drawer_router","core_message/message_drawer_routes","core_message/message_drawer_events","core/pending","core/drawer"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p={DRAWER:"[data-region=\"right-hand-drawer\"]",JUMPTO:".popover-region [data-region=\"jumpto\"]",PANEL_BODY_CONTAINER:"[data-region=\"panel-body-container\"]",PANEL_HEADER_CONTAINER:"[data-region=\"panel-header-container\"]",VIEW_CONTACT:"[data-region=\"view-contact\"]",VIEW_CONTACTS:"[data-region=\"view-contacts\"]",VIEW_CONVERSATION:"[data-region=\"view-conversation\"]",VIEW_GROUP_INFO:"[data-region=\"view-group-info\"]",VIEW_OVERVIEW:"[data-region=\"view-overview\"]",VIEW_SEARCH:"[data-region=\"view-search\"]",VIEW_SETTINGS:"[data-region=\"view-settings\"]",ROUTES:"[data-route]",ROUTES_BACK:"[data-route-back]",HEADER_CONTAINER:"[data-region=\"header-container\"]",BODY_CONTAINER:"[data-region=\"body-container\"]",FOOTER_CONTAINER:"[data-region=\"footer-container\"]"},q=function(a,b,c){var d=b.find(p.HEADER_CONTAINER).find(c);if(!d.length){d=b.find(p.PANEL_HEADER_CONTAINER).find(c)}var e=b.find(p.BODY_CONTAINER).find(c);if(!e.length){e=b.find(p.PANEL_BODY_CONTAINER).find(c)}var f=b.find(p.FOOTER_CONTAINER).find(c);return[a,d.length?d:null,e.length?e:null,f.length?f:null]},r=[[l.VIEW_CONTACT,p.VIEW_CONTACT,d.show,d.description],[l.VIEW_CONTACTS,p.VIEW_CONTACTS,e.show,e.description],[l.VIEW_CONVERSATION,p.VIEW_CONVERSATION,f.show,f.description],[l.VIEW_GROUP_INFO,p.VIEW_GROUP_INFO,g.show,g.description],[l.VIEW_OVERVIEW,p.VIEW_OVERVIEW,h.show,h.description],[l.VIEW_SEARCH,p.VIEW_SEARCH,i.show,i.description],[l.VIEW_SETTINGS,p.VIEW_SETTINGS,j.show,j.description]],s=function(a,b){r.forEach(function(c){k.add(a,c[0],q(a,b,c[1]),c[2],c[3])})},t=function(a,b){if(!b.attr("data-shown")){k.go(a,l.VIEW_OVERVIEW);b.attr("data-shown",!0)}var c=o.getDrawerRoot(b);if(c.length){o.show(c)}},u=function(a){var b=o.getDrawerRoot(a);if(b.length){o.hide(b)}},v=function(a){var b=o.getDrawerRoot(a);if(b.length){return o.isVisible(b)}return!0},w=function(b){a(p.DRAWER).attr("data-origin",b)},x=function(d,e,f){b.define(e,[b.events.activate]);var g=/^data-route-param-?(\d*)$/;e.on(b.events.activate,p.ROUTES,function(b,c){for(var e=a(b.target).closest(p.ROUTES),f=e.attr("data-route"),h=[],j=0;j<e[0].attributes.length;j++){h.push(e[0].attributes[j])}var l=h.filter(function(a){var b=a.nodeName,c=g.test(b);return c});l.sort(function(c,a){var b=g.exec(c.nodeName),d=g.exec(a.nodeName),e=1<b.length?b[1]:0,f=1<d.length?d[1]:0;if(e<f){return-1}else if(f<e){return 1}else{return 0}});var m=l.map(function(a){return a.nodeValue}),n=[d,f].concat(m);k.go.apply(null,n);c.originalEvent.preventDefault()});e.on(b.events.activate,p.ROUTES_BACK,function(a,b){k.back(d);b.originalEvent.preventDefault()});e.on("hide.bs.collapse",".collapse",function(b){var c=new n;a(b.target).one("hidden.bs.collapse",function(){c.resolve()})});e.on("show.bs.collapse",".collapse",function(b){var c=new n;a(b.target).one("shown.bs.collapse",function(){c.resolve()})});a(p.JUMPTO).focus(function(){var b=a(p.HEADER_CONTAINER).find("input:visible");if(b.length){b.focus()}else{a(p.HEADER_CONTAINER).find(p.ROUTES_BACK).focus()}});a(p.DRAWER).focus(function(){var b=a(this).attr("data-origin");if(b){a("#"+b).focus()}});if(!f){c.subscribe(m.SHOW,function(){t(d,e)});c.subscribe(m.HIDE,function(){u(e)});c.subscribe(m.TOGGLE_VISIBILITY,function(b){if(v(e)){u(e);a(p.JUMPTO).attr("tabindex",-1)}else{t(d,e);w(b);a(p.JUMPTO).attr("tabindex",0)}})}c.subscribe(m.SHOW_CONVERSATION,function(a){w(a.buttonid);t(d,e);k.go(d,l.VIEW_CONVERSATION,a.conversationid)});c.subscribe(m.CREATE_CONVERSATION_WITH_USER,function(a){w(a.buttonid);t(d,e);k.go(d,l.VIEW_CONVERSATION,null,"create",a.userid)});c.subscribe(m.SHOW_SETTINGS,function(){t(d,e);k.go(d,l.VIEW_SETTINGS)});c.subscribe(m.PREFERENCES_UPDATED,function(a){var b=a.filter(function(a){return"message_entertosend"==a.type}),c=b.length?b[0]:null;if(c){var d=e.find(p.FOOTER_CONTAINER).find(p.VIEW_CONVERSATION);d.attr("data-enter-to-send",c.value)}})};return{init:function init(b,c,d,e){b=a(b);s(c,b);x(c,b,d);if(d){t(c,b);if(e){var f=e.params||[];f=[c,e.path].concat(f);k.go.apply(null,f)}}}}});
|
||||
//# sourceMappingURL=message_drawer.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@
|
||||
define ("core_message/message_drawer_helper",["core/pubsub","core_message/message_drawer_events"],function(a,b){return{createConversationWithUser:function createConversationWithUser(c){a.publish(b.CREATE_CONVERSATION_WITH_USER,c)},show:function show(){a.publish(b.SHOW)},showConversation:function showConversation(c){a.publish(b.SHOW_CONVERSATION,c)},showSettings:function showSettings(){a.publish(b.SHOW_SETTINGS)}}});
|
||||
define ("core_message/message_drawer_helper",["core/pubsub","core_message/message_drawer_events"],function(a,b){return{createConversationWithUser:function createConversationWithUser(c){a.publish(b.CREATE_CONVERSATION_WITH_USER,c)},hide:function hide(){a.publish(b.HIDE)},show:function show(){a.publish(b.SHOW)},showConversation:function showConversation(c){a.publish(b.SHOW_CONVERSATION,c)},showSettings:function showSettings(){a.publish(b.SHOW_SETTINGS)}}});
|
||||
//# sourceMappingURL=message_drawer_helper.min.js.map
|
||||
|
@ -1 +1 @@
|
||||
{"version":3,"sources":["../src/message_drawer_helper.js"],"names":["define","PubSub","MessageDrawerEvents","createConversationWithUser","userId","publish","CREATE_CONVERSATION_WITH_USER","show","SHOW","showConversation","conversationId","SHOW_CONVERSATION","showSettings","SHOW_SETTINGS"],"mappings":"AAuBAA,OAAM,sCACN,CACI,aADJ,CAEI,oCAFJ,CADM,CAKN,SACIC,CADJ,CAEIC,CAFJ,CAGE,CAkCE,MAAO,CACHC,0BAA0B,CA5BG,QAA7BA,CAAAA,0BAA6B,CAASC,CAAT,CAAiB,CAC9CH,CAAM,CAACI,OAAP,CAAeH,CAAmB,CAACI,6BAAnC,CAAkEF,CAAlE,CACH,CAyBM,CAEHG,IAAI,CAtBG,QAAPA,CAAAA,IAAO,EAAW,CAClBN,CAAM,CAACI,OAAP,CAAeH,CAAmB,CAACM,IAAnC,CACH,CAkBM,CAGHC,gBAAgB,CAdG,QAAnBA,CAAAA,gBAAmB,CAASC,CAAT,CAAyB,CAC5CT,CAAM,CAACI,OAAP,CAAeH,CAAmB,CAACS,iBAAnC,CAAsDD,CAAtD,CACH,CASM,CAIHE,YAAY,CARG,QAAfA,CAAAA,YAAe,EAAW,CAC1BX,CAAM,CAACI,OAAP,CAAeH,CAAmB,CAACW,aAAnC,CACH,CAEM,CAMV,CAhDK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Provides some helper functions to trigger actions in the message drawer.\n *\n * @module core_message/message_drawer_helper\n * @package message\n * @copyright 2018 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n[\n 'core/pubsub',\n 'core_message/message_drawer_events'\n],\nfunction(\n PubSub,\n MessageDrawerEvents\n) {\n\n /**\n * Trigger an event to create a new conversation in the message drawer.\n *\n * @param {Number} userId The user id to start a conversation.\n */\n var createConversationWithUser = function(userId) {\n PubSub.publish(MessageDrawerEvents.CREATE_CONVERSATION_WITH_USER, userId);\n };\n\n /**\n * Trigger an event to show the message drawer.\n */\n var show = function() {\n PubSub.publish(MessageDrawerEvents.SHOW);\n };\n\n /**\n * Trigger an event to show the given conversation.\n *\n * @param {int} conversationId Id for the conversation to show.\n */\n var showConversation = function(conversationId) {\n PubSub.publish(MessageDrawerEvents.SHOW_CONVERSATION, conversationId);\n };\n\n /**\n * Trigger an event to show messaging settings.\n */\n var showSettings = function() {\n PubSub.publish(MessageDrawerEvents.SHOW_SETTINGS);\n };\n\n return {\n createConversationWithUser: createConversationWithUser,\n show: show,\n showConversation: showConversation,\n showSettings: showSettings\n };\n});\n"],"file":"message_drawer_helper.min.js"}
|
||||
{"version":3,"sources":["../src/message_drawer_helper.js"],"names":["define","PubSub","MessageDrawerEvents","createConversationWithUser","args","publish","CREATE_CONVERSATION_WITH_USER","hide","HIDE","show","SHOW","showConversation","SHOW_CONVERSATION","showSettings","SHOW_SETTINGS"],"mappings":"AAuBAA,OAAM,sCACN,CACI,aADJ,CAEI,oCAFJ,CADM,CAKN,SACIC,CADJ,CAEIC,CAFJ,CAGE,CAyCE,MAAO,CACHC,0BAA0B,CAnCG,QAA7BA,CAAAA,0BAA6B,CAASC,CAAT,CAAe,CAC5CH,CAAM,CAACI,OAAP,CAAeH,CAAmB,CAACI,6BAAnC,CAAkEF,CAAlE,CACH,CAgCM,CAEHG,IAAI,CA7BG,QAAPA,CAAAA,IAAO,EAAW,CAClBN,CAAM,CAACI,OAAP,CAAeH,CAAmB,CAACM,IAAnC,CACH,CAyBM,CAGHC,IAAI,CAvBG,QAAPA,CAAAA,IAAO,EAAW,CAClBR,CAAM,CAACI,OAAP,CAAeH,CAAmB,CAACQ,IAAnC,CACH,CAkBM,CAIHC,gBAAgB,CAfG,QAAnBA,CAAAA,gBAAmB,CAASP,CAAT,CAAe,CAClCH,CAAM,CAACI,OAAP,CAAeH,CAAmB,CAACU,iBAAnC,CAAsDR,CAAtD,CACH,CASM,CAKHS,YAAY,CATG,QAAfA,CAAAA,YAAe,EAAW,CAC1BZ,CAAM,CAACI,OAAP,CAAeH,CAAmB,CAACY,aAAnC,CACH,CAEM,CAOV,CAxDK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Provides some helper functions to trigger actions in the message drawer.\n *\n * @module core_message/message_drawer_helper\n * @package message\n * @copyright 2018 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n[\n 'core/pubsub',\n 'core_message/message_drawer_events'\n],\nfunction(\n PubSub,\n MessageDrawerEvents\n) {\n\n /**\n * Trigger an event to create a new conversation in the message drawer.\n *\n * @param {Number} userId The user id to start a conversation.\n */\n var createConversationWithUser = function(args) {\n PubSub.publish(MessageDrawerEvents.CREATE_CONVERSATION_WITH_USER, args);\n };\n\n /**\n * Trigger an event to hide the message drawer.\n */\n var hide = function() {\n PubSub.publish(MessageDrawerEvents.HIDE);\n };\n\n /**\n * Trigger an event to show the message drawer.\n */\n var show = function() {\n PubSub.publish(MessageDrawerEvents.SHOW);\n };\n\n /**\n * Trigger an event to show the given conversation.\n *\n * @param {int} conversationId Id for the conversation to show.\n */\n var showConversation = function(args) {\n PubSub.publish(MessageDrawerEvents.SHOW_CONVERSATION, args);\n };\n\n /**\n * Trigger an event to show messaging settings.\n */\n var showSettings = function() {\n PubSub.publish(MessageDrawerEvents.SHOW_SETTINGS);\n };\n\n return {\n createConversationWithUser: createConversationWithUser,\n hide: hide,\n show: show,\n showConversation: showConversation,\n showSettings: showSettings\n };\n});\n"],"file":"message_drawer_helper.min.js"}
|
2
message/amd/build/message_popover.min.js
vendored
2
message/amd/build/message_popover.min.js
vendored
@ -1,2 +1,2 @@
|
||||
define ("core_message/message_popover",["jquery","core/custom_interaction_events","core/pubsub","core_message/message_drawer_events"],function(a,b,c,d){var e={COUNT_CONTAINER:"[data-region=\"count-container\"]"},f=function(){c.publish(d.TOGGLE_VISIBILITY)},g=function(a){return function(){var b=a.find(e.COUNT_CONTAINER),c=parseInt(b.text(),10);if(isNaN(c)){b.addClass("hidden")}else if(!c||2>c){b.addClass("hidden")}else{c=c-1;b.text(c)}}},h=function(a){b.define(a,[b.events.activate]);a.on(b.events.activate,function(a,b){f();b.originalEvent.preventDefault()});c.subscribe(d.CONVERSATION_READ,g(a));c.subscribe(d.CONTACT_REQUEST_ACCEPTED,g(a));c.subscribe(d.CONTACT_REQUEST_DECLINED,g(a))};return{init:function init(b){b=a(b);h(b)}}});
|
||||
define ("core_message/message_popover",["jquery","core/custom_interaction_events","core/pubsub","core_message/message_drawer_events"],function(a,b,c,d){var e={COUNT_CONTAINER:"[data-region=\"count-container\"]"},f=function(a){c.publish(d.TOGGLE_VISIBILITY,a)},g=function(a){return function(){var b=a.find(e.COUNT_CONTAINER),c=parseInt(b.text(),10);if(isNaN(c)){b.addClass("hidden")}else if(!c||2>c){b.addClass("hidden")}else{c=c-1;b.text(c)}}},h=function(a){b.define(a,[b.events.activate]);a.on(b.events.activate,function(b,c){f(a.attr("id"));a.focus();c.originalEvent.preventDefault()});c.subscribe(d.CONVERSATION_READ,g(a));c.subscribe(d.CONTACT_REQUEST_ACCEPTED,g(a));c.subscribe(d.CONTACT_REQUEST_DECLINED,g(a))};return{init:function init(b){b=a(b);h(b)}}});
|
||||
//# sourceMappingURL=message_popover.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
2
message/amd/build/message_user_button.min.js
vendored
2
message/amd/build/message_user_button.min.js
vendored
@ -1,2 +1,2 @@
|
||||
define ("core_message/message_user_button",["jquery","core/custom_interaction_events","core_message/message_drawer_helper"],function(a,b,c){var d=function(a){return parseInt(a.attr("data-userid"))},f=function(a){return parseInt(a.attr("data-conversationid"))};return{send:function send(g){g=a(g);b.define(g,[b.events.activate]);g.on(b.events.activate,function(a,b){var e=f(g);if(e){c.showConversation(e)}else{c.createConversationWithUser(d(g))}a.preventDefault();b.originalEvent.preventDefault()})}}});
|
||||
define ("core_message/message_user_button",["jquery","core/custom_interaction_events","core_message/message_drawer_helper","core/templates"],function(a,b,c,d){var e={MESSAGE_TEXTAREA:"[data-region=\"send-message-txt\"]",MESSAGE_USER_BUTTON:"#message-user-button",MESSAGE_JUMP:"[data-region=\"jumpto\"]"},f={CONTENT:"core_message/message_jumpto"},g=function(a){return parseInt(a.attr("data-userid"))},h=function(a){return parseInt(a.attr("data-conversationid"))};return{send:function send(i){i=a(i);var j={conversationid:h(i),buttonid:a(i).attr("id"),userid:g(i)};d.render(f.CONTENT,{}).then(function(a){i.after(a)}).then(function(){a(e.MESSAGE_USER_BUTTON).next().focus(function(){a(e.MESSAGE_TEXTAREA).focus()})});b.define(i,[b.events.activate]);i.on(b.events.activate,function(b,d){if(a(b.target).hasClass("active")){c.hide();a(e.MESSAGE_USER_BUTTON).next().attr("tabindex",-1)}else{a(e.MESSAGE_USER_BUTTON).next().attr("tabindex",0);if(j.conversationid){c.showConversation(j)}else{c.createConversationWithUser(j)}}a(b.target).focus();a(b.target).toggleClass("active");b.preventDefault();d.originalEvent.preventDefault()})}}});
|
||||
//# sourceMappingURL=message_user_button.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@ -57,6 +57,8 @@ function(
|
||||
) {
|
||||
|
||||
var SELECTORS = {
|
||||
DRAWER: '[data-region="right-hand-drawer"]',
|
||||
JUMPTO: '.popover-region [data-region="jumpto"]',
|
||||
PANEL_BODY_CONTAINER: '[data-region="panel-body-container"]',
|
||||
PANEL_HEADER_CONTAINER: '[data-region="panel-header-container"]',
|
||||
VIEW_CONTACT: '[data-region="view-contact"]',
|
||||
@ -168,6 +170,15 @@ function(
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set Jump from button
|
||||
*
|
||||
* @param {String} buttonid The originating button id
|
||||
*/
|
||||
var setJumpFrom = function(buttonid) {
|
||||
$(SELECTORS.DRAWER).attr('data-origin', buttonid);
|
||||
};
|
||||
|
||||
/**
|
||||
* Listen to and handle events for routing, showing and hiding the message drawer.
|
||||
*
|
||||
@ -241,6 +252,22 @@ function(
|
||||
});
|
||||
});
|
||||
|
||||
$(SELECTORS.JUMPTO).focus(function() {
|
||||
var firstInput = $(SELECTORS.HEADER_CONTAINER).find('input:visible');
|
||||
if (firstInput.length) {
|
||||
firstInput.focus();
|
||||
} else {
|
||||
$(SELECTORS.HEADER_CONTAINER).find(SELECTORS.ROUTES_BACK).focus();
|
||||
}
|
||||
});
|
||||
|
||||
$(SELECTORS.DRAWER).focus(function() {
|
||||
var button = $(this).attr('data-origin');
|
||||
if (button) {
|
||||
$('#' + button).focus();
|
||||
}
|
||||
});
|
||||
|
||||
if (!alwaysVisible) {
|
||||
PubSub.subscribe(Events.SHOW, function() {
|
||||
show(namespace, root);
|
||||
@ -250,23 +277,28 @@ function(
|
||||
hide(root);
|
||||
});
|
||||
|
||||
PubSub.subscribe(Events.TOGGLE_VISIBILITY, function() {
|
||||
PubSub.subscribe(Events.TOGGLE_VISIBILITY, function(buttonid) {
|
||||
if (isVisible(root)) {
|
||||
hide(root);
|
||||
$(SELECTORS.JUMPTO).attr('tabindex', -1);
|
||||
} else {
|
||||
show(namespace, root);
|
||||
setJumpFrom(buttonid);
|
||||
$(SELECTORS.JUMPTO).attr('tabindex', 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
PubSub.subscribe(Events.SHOW_CONVERSATION, function(conversationId) {
|
||||
PubSub.subscribe(Events.SHOW_CONVERSATION, function(args) {
|
||||
setJumpFrom(args.buttonid);
|
||||
show(namespace, root);
|
||||
Router.go(namespace, Routes.VIEW_CONVERSATION, conversationId);
|
||||
Router.go(namespace, Routes.VIEW_CONVERSATION, args.conversationid);
|
||||
});
|
||||
|
||||
PubSub.subscribe(Events.CREATE_CONVERSATION_WITH_USER, function(userId) {
|
||||
PubSub.subscribe(Events.CREATE_CONVERSATION_WITH_USER, function(args) {
|
||||
setJumpFrom(args.buttonid);
|
||||
show(namespace, root);
|
||||
Router.go(namespace, Routes.VIEW_CONVERSATION, null, 'create', userId);
|
||||
Router.go(namespace, Routes.VIEW_CONVERSATION, null, 'create', args.userid);
|
||||
});
|
||||
|
||||
PubSub.subscribe(Events.SHOW_SETTINGS, function() {
|
||||
|
@ -36,8 +36,15 @@ function(
|
||||
*
|
||||
* @param {Number} userId The user id to start a conversation.
|
||||
*/
|
||||
var createConversationWithUser = function(userId) {
|
||||
PubSub.publish(MessageDrawerEvents.CREATE_CONVERSATION_WITH_USER, userId);
|
||||
var createConversationWithUser = function(args) {
|
||||
PubSub.publish(MessageDrawerEvents.CREATE_CONVERSATION_WITH_USER, args);
|
||||
};
|
||||
|
||||
/**
|
||||
* Trigger an event to hide the message drawer.
|
||||
*/
|
||||
var hide = function() {
|
||||
PubSub.publish(MessageDrawerEvents.HIDE);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -52,8 +59,8 @@ function(
|
||||
*
|
||||
* @param {int} conversationId Id for the conversation to show.
|
||||
*/
|
||||
var showConversation = function(conversationId) {
|
||||
PubSub.publish(MessageDrawerEvents.SHOW_CONVERSATION, conversationId);
|
||||
var showConversation = function(args) {
|
||||
PubSub.publish(MessageDrawerEvents.SHOW_CONVERSATION, args);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -65,6 +72,7 @@ function(
|
||||
|
||||
return {
|
||||
createConversationWithUser: createConversationWithUser,
|
||||
hide: hide,
|
||||
show: show,
|
||||
showConversation: showConversation,
|
||||
showSettings: showSettings
|
||||
|
@ -39,21 +39,23 @@ function(
|
||||
|
||||
/**
|
||||
* Toggle the message drawer visibility.
|
||||
*
|
||||
* @param {String} button The button id for the popover.
|
||||
*/
|
||||
var toggleMessageDrawerVisibility = function() {
|
||||
PubSub.publish(MessageDrawerEvents.TOGGLE_VISIBILITY);
|
||||
var toggleMessageDrawerVisibility = function(buttonid) {
|
||||
PubSub.publish(MessageDrawerEvents.TOGGLE_VISIBILITY, buttonid);
|
||||
};
|
||||
|
||||
/**
|
||||
* Decrement the unread conversation count in the nav bar if a conversation
|
||||
* is read. When there are no unread conversations then hide the counter.
|
||||
*
|
||||
* @param {Object} root The root element for the popover.
|
||||
* @param {Object} button The button element for the popover.
|
||||
* @return {Function}
|
||||
*/
|
||||
var handleDecrementConversationCount = function(root) {
|
||||
var handleDecrementConversationCount = function(button) {
|
||||
return function() {
|
||||
var countContainer = root.find(SELECTORS.COUNT_CONTAINER);
|
||||
var countContainer = button.find(SELECTORS.COUNT_CONTAINER);
|
||||
var count = parseInt(countContainer.text(), 10);
|
||||
|
||||
if (isNaN(count)) {
|
||||
@ -71,29 +73,30 @@ function(
|
||||
* Add events listeners for when the popover icon is clicked and when conversations
|
||||
* are read.
|
||||
*
|
||||
* @param {Object} root The root element for the popover.
|
||||
* @param {Object} button The button element for the popover.
|
||||
*/
|
||||
var registerEventListeners = function(root) {
|
||||
CustomEvents.define(root, [CustomEvents.events.activate]);
|
||||
var registerEventListeners = function(button) {
|
||||
CustomEvents.define(button, [CustomEvents.events.activate]);
|
||||
|
||||
root.on(CustomEvents.events.activate, function(e, data) {
|
||||
toggleMessageDrawerVisibility();
|
||||
button.on(CustomEvents.events.activate, function(e, data) {
|
||||
toggleMessageDrawerVisibility(button.attr('id'));
|
||||
button.focus();
|
||||
data.originalEvent.preventDefault();
|
||||
});
|
||||
|
||||
PubSub.subscribe(MessageDrawerEvents.CONVERSATION_READ, handleDecrementConversationCount(root));
|
||||
PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_ACCEPTED, handleDecrementConversationCount(root));
|
||||
PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_DECLINED, handleDecrementConversationCount(root));
|
||||
PubSub.subscribe(MessageDrawerEvents.CONVERSATION_READ, handleDecrementConversationCount(button));
|
||||
PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_ACCEPTED, handleDecrementConversationCount(button));
|
||||
PubSub.subscribe(MessageDrawerEvents.CONTACT_REQUEST_DECLINED, handleDecrementConversationCount(button));
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialise the message popover.
|
||||
*
|
||||
* @param {Object} root The root element for the popover.
|
||||
* @param {Object} button The button element for the popover.
|
||||
*/
|
||||
var init = function(root) {
|
||||
root = $(root);
|
||||
registerEventListeners(root);
|
||||
var init = function(button) {
|
||||
button = $(button);
|
||||
registerEventListeners(button);
|
||||
};
|
||||
|
||||
return {
|
||||
|
@ -20,8 +20,19 @@
|
||||
* @copyright 2019 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/custom_interaction_events', 'core_message/message_drawer_helper'],
|
||||
function($, CustomEvents, MessageDrawerHelper) {
|
||||
define(['jquery', 'core/custom_interaction_events', 'core_message/message_drawer_helper', 'core/templates'],
|
||||
function($, CustomEvents, MessageDrawerHelper, Templates) {
|
||||
|
||||
|
||||
var SELECTORS = {
|
||||
MESSAGE_TEXTAREA: '[data-region="send-message-txt"]',
|
||||
MESSAGE_USER_BUTTON: '#message-user-button',
|
||||
MESSAGE_JUMP: '[data-region="jumpto"]'
|
||||
};
|
||||
|
||||
var TEMPLATES = {
|
||||
CONTENT: 'core_message/message_jumpto'
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the id for the user being messaged.
|
||||
@ -53,15 +64,38 @@ define(['jquery', 'core/custom_interaction_events', 'core_message/message_drawer
|
||||
var send = function(element) {
|
||||
element = $(element);
|
||||
|
||||
var args = {
|
||||
conversationid: getConversationId(element),
|
||||
buttonid: $(element).attr('id'),
|
||||
userid: getUserId(element)
|
||||
};
|
||||
|
||||
Templates.render(TEMPLATES.CONTENT, {})
|
||||
.then(function(html) {
|
||||
element.after(html);
|
||||
})
|
||||
.then(function() {
|
||||
$(SELECTORS.MESSAGE_USER_BUTTON).next().focus(function() {
|
||||
$(SELECTORS.MESSAGE_TEXTAREA).focus();
|
||||
});
|
||||
});
|
||||
|
||||
CustomEvents.define(element, [CustomEvents.events.activate]);
|
||||
|
||||
element.on(CustomEvents.events.activate, function(e, data) {
|
||||
var conversationid = getConversationId(element);
|
||||
if (conversationid) {
|
||||
MessageDrawerHelper.showConversation(conversationid);
|
||||
if ($(e.target).hasClass('active')) {
|
||||
MessageDrawerHelper.hide();
|
||||
$(SELECTORS.MESSAGE_USER_BUTTON).next().attr('tabindex', -1);
|
||||
} else {
|
||||
MessageDrawerHelper.createConversationWithUser(getUserId(element));
|
||||
$(SELECTORS.MESSAGE_USER_BUTTON).next().attr('tabindex', 0);
|
||||
if (args.conversationid) {
|
||||
MessageDrawerHelper.showConversation(args);
|
||||
} else {
|
||||
MessageDrawerHelper.createConversationWithUser(args);
|
||||
}
|
||||
}
|
||||
$(e.target).focus();
|
||||
$(e.target).toggleClass('active');
|
||||
e.preventDefault();
|
||||
data.originalEvent.preventDefault();
|
||||
});
|
||||
|
27
message/templates/message_jumpto.mustache
Normal file
27
message/templates/message_jumpto.mustache
Normal file
@ -0,0 +1,27 @@
|
||||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_message/message_jump_botton
|
||||
|
||||
This template will render the jump button used for keyboard navigation.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
}
|
||||
|
||||
}}
|
||||
<span class="sr-only sr-only-focusable" data-region="jumpto" tabindex="-1"></span>
|
@ -42,6 +42,7 @@
|
||||
<div class="count-container {{^unreadcount}}hidden{{/unreadcount}}" data-region="count-container"
|
||||
aria-label="{{#str}} unreadconversations, core_message, {{unreadcount}} {{/str}}">{{unreadcount}}</div>
|
||||
</a>
|
||||
{{> core_message/message_jumpto }}
|
||||
</div>
|
||||
|
||||
{{#js}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user