MDL-63915 core_message: add namespacing to messaging widget
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
define(["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"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n={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"]'},o=function(a,b){var c=a.children(),d=c.filter(n.HEADER_CONTAINER).find(b),e=c.filter(n.BODY_CONTAINER).find(b),f=c.filter(n.FOOTER_CONTAINER).find(b),g=[d,e,f].filter(function(a){return a.length});return g},p=[[l.VIEW_CONTACT,n.VIEW_CONTACT,d.show,d.description],[l.VIEW_CONTACTS,n.VIEW_CONTACTS,e.show,e.description],[l.VIEW_CONVERSATION,n.VIEW_CONVERSATION,f.show,f.description],[l.VIEW_GROUP_INFO,n.VIEW_GROUP_INFO,g.show,g.description],[l.VIEW_OVERVIEW,n.VIEW_OVERVIEW,h.show,h.description],[l.VIEW_SEARCH,n.VIEW_SEARCH,i.show,i.description],[l.VIEW_SETTINGS,n.VIEW_SETTINGS,j.show,j.description]],q=function(a){p.forEach(function(b){k.add(b[0],o(a,b[1]),b[2],b[3])})},r=function(a){a.attr("data-shown")||(k.go(l.VIEW_OVERVIEW),a.attr("data-shown",!0)),a.removeClass("hidden"),a.attr("aria-expanded",!0),a.attr("aria-hidden",!1)},s=function(a){a.addClass("hidden"),a.attr("aria-expanded",!1),a.attr("aria-hidden",!0)},t=function(a){return!a.hasClass("hidden")},u=function(d){b.define(d,[b.events.activate]);var e=/^data-route-param-?(\d*)$/;d.on(b.events.activate,n.ROUTES,function(b,c){for(var d=a(b.target).closest(n.ROUTES),f=d.attr("data-route"),g=[],h=0;h<d[0].attributes.length;h++)g.push(d[0].attributes[h]);var i=g.filter(function(a){var b=a.nodeName,c=e.test(b);return c});i.sort(function(a,b){var c=e.exec(a.nodeName),d=e.exec(b.nodeName),f=c.length>1?c[1]:0,g=d.length>1?d[1]:0;return f<g?-1:g<f?1:0});var j=i.map(function(a){return a.nodeValue}),l=[f].concat(j);k.go.apply(null,l),c.originalEvent.preventDefault()}),d.on(b.events.activate,n.ROUTES_BACK,function(a,b){k.back(),b.originalEvent.preventDefault()}),c.subscribe(m.SHOW,function(){r(d)}),c.subscribe(m.HIDE,function(){s(d)}),c.subscribe(m.TOGGLE_VISIBILITY,function(){t(d)?s(d):r(d)}),c.subscribe(m.SHOW_CONVERSATION,function(a){r(d),k.go(l.VIEW_CONVERSATION,a)}),c.subscribe(m.CREATE_CONVERSATION_WITH_USER,function(a){r(d),k.go(l.VIEW_CONVERSATION,null,"create",a)}),c.subscribe(m.SHOW_SETTINGS,function(){r(d),k.go(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 e=d.find(n.FOOTER_CONTAINER).find(n.VIEW_CONVERSATION);e.attr("data-enter-to-send",c.value)}})},v=function(b){b=a(b),q(b),u(b)};return{init:v}});
|
||||
define(["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"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n={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"]'},o=function(a,b,c){var d=b.children(),e=d.filter(n.HEADER_CONTAINER).find(c),f=d.filter(n.BODY_CONTAINER).find(c),g=d.filter(n.FOOTER_CONTAINER).find(c);return[a,e.length?e:null,f.length?f:null,g.length?g:null]},p=[[l.VIEW_CONTACT,n.VIEW_CONTACT,d.show,d.description],[l.VIEW_CONTACTS,n.VIEW_CONTACTS,e.show,e.description],[l.VIEW_CONVERSATION,n.VIEW_CONVERSATION,f.show,f.description],[l.VIEW_GROUP_INFO,n.VIEW_GROUP_INFO,g.show,g.description],[l.VIEW_OVERVIEW,n.VIEW_OVERVIEW,h.show,h.description],[l.VIEW_SEARCH,n.VIEW_SEARCH,i.show,i.description],[l.VIEW_SETTINGS,n.VIEW_SETTINGS,j.show,j.description]],q=function(a,b){p.forEach(function(c){k.add(a,c[0],o(a,b,c[1]),c[2],c[3])})},r=function(a,b){b.attr("data-shown")||(k.go(a,l.VIEW_OVERVIEW),b.attr("data-shown",!0)),b.removeClass("hidden"),b.attr("aria-expanded",!0),b.attr("aria-hidden",!1)},s=function(a){a.addClass("hidden"),a.attr("aria-expanded",!1),a.attr("aria-hidden",!0)},t=function(a){return!a.hasClass("hidden")},u=function(d,e){b.define(e,[b.events.activate]);var f=/^data-route-param-?(\d*)$/;e.on(b.events.activate,n.ROUTES,function(b,c){for(var e=a(b.target).closest(n.ROUTES),g=e.attr("data-route"),h=[],i=0;i<e[0].attributes.length;i++)h.push(e[0].attributes[i]);var j=h.filter(function(a){var b=a.nodeName,c=f.test(b);return c});j.sort(function(a,b){var c=f.exec(a.nodeName),d=f.exec(b.nodeName),e=c.length>1?c[1]:0,g=d.length>1?d[1]:0;return e<g?-1:g<e?1:0});var l=j.map(function(a){return a.nodeValue}),m=[d,g].concat(l);k.go.apply(null,m),c.originalEvent.preventDefault()}),e.on(b.events.activate,n.ROUTES_BACK,function(a,b){k.back(d),b.originalEvent.preventDefault()}),c.subscribe(m.SHOW,function(){r(d,e)}),c.subscribe(m.HIDE,function(){s(e)}),c.subscribe(m.TOGGLE_VISIBILITY,function(){t(e)?s(e):r(d,e)}),c.subscribe(m.SHOW_CONVERSATION,function(a){r(d,e),k.go(d,l.VIEW_CONVERSATION,a)}),c.subscribe(m.CREATE_CONVERSATION_WITH_USER,function(a){r(d,e),k.go(d,l.VIEW_CONVERSATION,null,"create",a)}),c.subscribe(m.SHOW_SETTINGS,function(){r(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(n.FOOTER_CONTAINER).find(n.VIEW_CONVERSATION);d.attr("data-enter-to-send",c.value)}})},v=function(b,c){b=a(b),q(c,b),u(c,b)};return{init:v}});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/pubsub","core/str","core_message/message_drawer_events"],function(a,b,c,d){var e={},f=[],g={CAN_RECEIVE_FOCUS:'input:not([type="hidden"]), a[href], button, textarea, select, [tabindex]',ROUTES_BACK:"[data-route-back]"},h=function(a,b,c,d){e[a]={elements:b,onGo:c,getDescription:d}},i=function(c){var f,h=[].slice.call(arguments,1),i=a.Deferred().resolve().promise();if(Object.keys(e).forEach(function(a){var b=e[a],d=a===c;d&&(f=b),b.elements.forEach(function(a){a.removeClass("previous"),d?(a.removeClass("hidden"),a.attr("aria-hidden",!1)):(a.addClass("hidden"),a.attr("aria-hidden",!0))})}),f&&f.onGo){i=f.onGo.apply(void 0,f.elements.concat(h));for(var j=a(document.activeElement),k=!1,l=0;l<f.elements.length;l++){var m=f.elements[l];if(m.has(j).length){k=!0;break}}k||f.elements[0].find(g.CAN_RECEIVE_FOCUS).filter(":visible").first().focus()}var n={route:c,params:h,renderPromise:i};return b.publish(d.ROUTE_CHANGED,n),n},j=function(){var b=a(document.activeElement),d=i.apply(null,arguments),h=!1;f=f.reduce(function(a,b){return b.route===d.route&&(h=!0),h||a.push(b),a},[]);var j=f.length?f[f.length-1]:null;if(j){var k=e[j.route];k.elements.forEach(function(a){a.addClass("previous")}),j.focusElement=b,k.getDescription&&k.getDescription.apply(null,k.elements.concat(j.params)).then(function(a){return c.get_string("backto","core_message",a)}).then(function(a){return d.renderPromise.then(function(){e[d.route].elements.forEach(function(b){b.find(g.ROUTES_BACK).attr("aria-label",a)})})})["catch"](function(){})}return f.push(d),d},k=function(){if(f.length){f.pop();var a=f.pop();a&&(j.apply(void 0,[a.route].concat(a.params)),window.setTimeout(function(){a.focusElement.focus()},50))}};return{add:h,go:j,back:k}});
|
||||
define(["jquery","core/pubsub","core/str","core_message/message_drawer_events"],function(a,b,c,d){var e={},f={},g={CAN_RECEIVE_FOCUS:'input:not([type="hidden"]), a[href], button, textarea, select, [tabindex]',ROUTES_BACK:"[data-route-back]"},h=function(a,b,c,d,f){e[a]||(e[a]=[]),e[a][b]={parameters:c,onGo:d,getDescription:f}},i=function(c,f){var h,i=[].slice.call(arguments,2),j=a.Deferred().resolve().promise();if(Object.keys(e[c]).forEach(function(a){var b=e[c][a],d=a===f;d&&(h=b),b.parameters.forEach(function(a){"object"==typeof a&&null!==a&&(a.removeClass("previous"),d?(a.removeClass("hidden"),a.attr("aria-hidden",!1)):(a.addClass("hidden"),a.attr("aria-hidden",!0)))})}),h&&h.onGo){j=h.onGo.apply(void 0,h.parameters.concat(i));for(var k=a(document.activeElement),l=!1,m=null,n=1;n<h.parameters.length;n++){var o=h.parameters[n];if("object"==typeof o&&null!==o&&(m||(m=o),o.has(k).length)){l=!0;break}}l||m.find(g.CAN_RECEIVE_FOCUS).filter(":visible").first().focus()}var p={route:f,params:i,renderPromise:j};return b.publish(d.ROUTE_CHANGED,p),p},j=function(b){var d=a(document.activeElement),h=i.apply(null,arguments),j=!1;f[b]||(f[b]=[]),f[b]=f[b].reduce(function(a,b){return b.route===h.route&&(j=!0),j||a.push(b),a},[]);var k=f[b].length,l=k?f[b][k-1]:null;if(l){for(var m=e[b][l.route],n=m.parameters,o=1;o<n.length;o++)"object"==typeof n[o]&&null!==n[o]&&n[o].addClass("previous");l.focusElement=d,m.getDescription&&m.getDescription.apply(null,m.parameters.concat(l.params)).then(function(a){return c.get_string("backto","core_message",a)}).then(function(a){return h.renderPromise.then(function(){e[b][h.route].parameters.forEach(function(b){"object"==typeof b&&b&&b.find(g.ROUTES_BACK).attr("aria-label",a)})})})["catch"](function(){})}return f[b].push(h),h},k=function(a){if(f[a].length){f[a].pop();var b=f[a].pop();b&&(j.apply(void 0,[a,b.route].concat(b.params)),window.setTimeout(function(){b.focusElement.focus()},50))}};return{add:h,go:j,back:k}});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/str","core/templates"],function(a,b,c){var d={CONTENT_CONTAINER:'[data-region="content-container"]'},e={CONTENT:"core_message/message_drawer_view_contact_body_content"},f=function(a){return a.find(d.CONTENT_CONTAINER)},g=function(a,b){return c.render(e.CONTENT,b).then(function(b){return f(a).append(b),b})},h=function(b,c){return b=a(b),f(b).empty(),g(b,c)},i=function(a,c){return b.get_string("messagedrawerviewcontact","core_message",c.fullname)};return{show:h,description:i}});
|
||||
define(["jquery","core/str","core/templates"],function(a,b,c){var d={CONTENT_CONTAINER:'[data-region="content-container"]'},e={CONTENT:"core_message/message_drawer_view_contact_body_content"},f=function(a){return a.find(d.CONTENT_CONTAINER)},g=function(a,b){return c.render(e.CONTENT,b).then(function(b){return f(a).append(b),b})},h=function(b,c,d,e,h){var i=a(d);return f(i).empty(),g(i,h)},i=function(a,c){return b.get_string("messagedrawerviewcontact","core_message",c.fullname)};return{show:h,description:i}});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/pubsub","core/str","core_message/message_drawer_events","core_message/message_drawer_view_contacts_section_contacts","core_message/message_drawer_view_contacts_section_requests"],function(a,b,c,d,e,f){var g={ACTION_SHOW_CONTACTS_SECTION:'[data-action="show-contacts-section"]',ACTION_SHOW_REQUESTS_SECTION:'[data-action="show-requests-section"]',CONTACT_REQUEST_COUNT:'[data-region="contact-request-count"]',CONTACTS_SECTION_CONTAINER:'[data-section="contacts"]',REQUESTS_SECTION_CONTAINER:'[data-section="requests"]'},h=function(a){return a.find(g.CONTACTS_SECTION_CONTAINER)},i=function(a){return a.find(g.REQUESTS_SECTION_CONTAINER)},j=function(a){return a.hasClass("active")},k=function(a){return function(){var b=a.find(g.CONTACT_REQUEST_COUNT),c=parseInt(b.text(),10);c=isNaN(c)?0:c-1,c<=0?b.addClass("hidden"):b.text(c)}},l=function(a){var c=h(a),j=i(a),l=a.find(g.ACTION_SHOW_CONTACTS_SECTION),m=a.find(g.ACTION_SHOW_REQUESTS_SECTION);l.on("show.bs.tab",function(){e.show(c)}),m.on("show.bs.tab",function(){f.show(j)}),b.subscribe(d.CONTACT_REQUEST_ACCEPTED,k(a)),b.subscribe(d.CONTACT_REQUEST_DECLINED,k(a))},m=function(b,c){c=a(c),c.attr("data-contacts-init")||(l(c),c.attr("data-contacts-init",!0));var d=h(c),g=i(c);return j(d)?e.show(d):f.show(g),a.Deferred().resolve().promise()},n=function(){return c.get_string("messagedrawerviewcontacts","core_message")};return{show:m,description:n}});
|
||||
define(["jquery","core/pubsub","core/str","core_message/message_drawer_events","core_message/message_drawer_view_contacts_section_contacts","core_message/message_drawer_view_contacts_section_requests"],function(a,b,c,d,e,f){var g={ACTION_SHOW_CONTACTS_SECTION:'[data-action="show-contacts-section"]',ACTION_SHOW_REQUESTS_SECTION:'[data-action="show-requests-section"]',CONTACT_REQUEST_COUNT:'[data-region="contact-request-count"]',CONTACTS_SECTION_CONTAINER:'[data-section="contacts"]',REQUESTS_SECTION_CONTAINER:'[data-section="requests"]'},h=function(a){return a.find(g.CONTACTS_SECTION_CONTAINER)},i=function(a){return a.find(g.REQUESTS_SECTION_CONTAINER)},j=function(a){return a.hasClass("active")},k=function(a){return function(){var b=a.find(g.CONTACT_REQUEST_COUNT),c=parseInt(b.text(),10);c=isNaN(c)?0:c-1,c<=0?b.addClass("hidden"):b.text(c)}},l=function(a){var c=h(a),j=i(a),l=a.find(g.ACTION_SHOW_CONTACTS_SECTION),m=a.find(g.ACTION_SHOW_REQUESTS_SECTION);l.on("show.bs.tab",function(){e.show(c)}),m.on("show.bs.tab",function(){f.show(j)}),b.subscribe(d.CONTACT_REQUEST_ACCEPTED,k(a)),b.subscribe(d.CONTACT_REQUEST_DECLINED,k(a))},m=function(b,c,d){d=a(d),d.attr("data-contacts-init")||(l(d),d.attr("data-contacts-init",!0));var g=h(d),k=i(d);return j(g)?e.show(g):f.show(k),a.Deferred().resolve().promise()},n=function(){return c.get_string("messagedrawerviewcontacts","core_message")};return{show:m,description:n}});
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/str","core/templates","core_message/message_repository","core_message/message_drawer_lazy_load_list"],function(a,b,c,d,e){var f=50,g={CONTENT_CONTAINER:'[data-region="group-info-content-container"]',MEMBERS_LIST:'[data-region="members-list"]'},h={CONTENT:"core_message/message_drawer_view_group_info_body_content",MEMBERS_LIST:"core_message/message_drawer_view_group_info_participants_list"},i=function(a){return a.find(g.CONTENT_CONTAINER)},j=function(a,b,d){var e=b.totalMemberCount>50?50:b.totalMemberCount,f=Array.apply(null,Array(e)).map(function(){return!0}),g={name:b.name,subname:b.subname,imageurl:b.imageUrl,placeholders:f,loggedinuser:{id:d}};return c.render(h.CONTENT,g).then(function(b){return i(a).append(b),b})},k=function(a,b,c){return function(f,g){return d.getConversationMembers(a.id,g,b+1,c).then(function(a){return a.length>b?a=a.slice(0,-1):e.setLoadedAll(f,!0),c+=b,a.filter(function(a){return a.id!=g})})}},l=function(a,b){return c.render(h.MEMBERS_LIST,{contacts:b}).then(function(b){return a.append(b),b})},m=function(b,c,d){return b=a(b),i(b).empty(),j(b,c,d).then(function(){var a=e.getRoot(b);e.show(a,k(c,f,0),l)})},n=function(a,c){return b.get_string("messagedrawerviewgroupinfo","core_message",c.name)};return{show:m,description:n}});
|
||||
define(["jquery","core/str","core/templates","core_message/message_repository","core_message/message_drawer_lazy_load_list"],function(a,b,c,d,e){var f=50,g={CONTENT_CONTAINER:'[data-region="group-info-content-container"]',MEMBERS_LIST:'[data-region="members-list"]'},h={CONTENT:"core_message/message_drawer_view_group_info_body_content",MEMBERS_LIST:"core_message/message_drawer_view_group_info_participants_list"},i=function(a){return a.find(g.CONTENT_CONTAINER)},j=function(a,b,d){var e=b.totalMemberCount>50?50:b.totalMemberCount,f=Array.apply(null,Array(e)).map(function(){return!0}),g={name:b.name,subname:b.subname,imageurl:b.imageUrl,placeholders:f,loggedinuser:{id:d}};return c.render(h.CONTENT,g).then(function(b){return i(a).append(b),b})},k=function(a,b,c){return function(f,g){return d.getConversationMembers(a.id,g,b+1,c).then(function(a){return a.length>b?a=a.slice(0,-1):e.setLoadedAll(f,!0),c+=b,a.filter(function(a){return a.id!=g})})}},l=function(a,b){return c.render(h.MEMBERS_LIST,{contacts:b}).then(function(b){return a.append(b),b})},m=function(b,c,d,g,h,m){var n=a(d);return i(n).empty(),j(n,h,m).then(function(){var a=e.getRoot(n);e.show(a,k(h,f,0),l)})},n=function(a,c){return b.get_string("messagedrawerviewgroupinfo","core_message",c.name)};return{show:m,description:n}});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/key_codes","core/pubsub","core/str","core_message/message_drawer_router","core_message/message_drawer_routes","core_message/message_drawer_events","core_message/message_drawer_view_overview_section","core_message/message_repository"],function(a,b,c,d,e,f,g,h,i){var j={CONTACT_REQUEST_COUNT:'[data-region="contact-request-count"]',FAVOURITES:'[data-region="view-overview-favourites"]',GROUP_MESSAGES:'[data-region="view-overview-group-messages"]',MESSAGES:'[data-region="view-overview-messages"]',SEARCH_INPUT:'[data-region="view-overview-search-input"]',SECTION_TOGGLE_BUTTON:"[data-toggle]"},k={PRIVATE:1,PUBLIC:2,FAVOURITE:null},l=null,m=function(a){return null===l&&(l=i.getAllConversationCounts(a)),l},n=function(a,b){return b===k.FAVOURITE?a.favourites:a.types[b]},o=function(a){var b=a.some(function(a){var b=a[0];return h.isVisible(b)});if(!b){a.sort(function(a,b){var c=a[1],d=a[2],e=b[1],f=b[2];return d>0&&0==f?-1:0==d&&f>0?1:c>0&&0==e?-1:0==c&&e>0?1:0});var c=a[0][0],d=c.find(j.SECTION_TOGGLE_BUTTON);d.click()}},p=function(a){return a.find(j.SEARCH_INPUT)},q=function(a){return a.attr("data-user-id")},r=function(a){return function(){var b=a.find(j.CONTACT_REQUEST_COUNT),c=parseInt(b.text(),10);c=isNaN(c)?0:c-1,c<=0?b.addClass("hidden"):b.text(c)}},s=function(a){var d=p(a),h=[b.tab,b.shift,b.ctrl,b.alt];d.on("click",function(){e.go(f.VIEW_SEARCH)}),d.on("keydown",function(a){h.indexOf(a.keyCode)<0&&"Meta"!=a.key&&e.go(f.VIEW_SEARCH)}),c.subscribe(g.CONTACT_REQUEST_ACCEPTED,r(a)),c.subscribe(g.CONTACT_REQUEST_DECLINED,r(a))},t=function(a,b){a.attr("data-init")||(s(a),a.attr("data-init",!0)),p(a).val("");var c=q(b),d=m(c),e=[[b.find(j.FAVOURITES),k.FAVOURITE,!0],[b.find(j.GROUP_MESSAGES),k.PUBLIC,!1],[b.find(j.MESSAGES),k.PRIVATE,!1]];return e.forEach(function(a){var b=a[0],c=a[1],e=a[2],f=d.then(function(a){return n(a.total,c)}),g=d.then(function(a){return n(a.unread,c)});h.show(b,c,e,f,g)}),d.then(function(a){var b=e.map(function(b){var c=b[0],d=b[1],e=n(a.total,d),f=n(a.unread,d);return[c,e,f]});return o(b)})},u=function(){return d.get_string("messagedrawerviewoverview","core_message")};return{show:t,description:u}});
|
||||
define(["jquery","core/key_codes","core/pubsub","core/str","core_message/message_drawer_router","core_message/message_drawer_routes","core_message/message_drawer_events","core_message/message_drawer_view_overview_section","core_message/message_repository"],function(a,b,c,d,e,f,g,h,i){var j={CONTACT_REQUEST_COUNT:'[data-region="contact-request-count"]',FAVOURITES:'[data-region="view-overview-favourites"]',GROUP_MESSAGES:'[data-region="view-overview-group-messages"]',MESSAGES:'[data-region="view-overview-messages"]',SEARCH_INPUT:'[data-region="view-overview-search-input"]',SECTION_TOGGLE_BUTTON:"[data-toggle]"},k={PRIVATE:1,PUBLIC:2,FAVOURITE:null},l=null,m=function(a){return null===l&&(l=i.getAllConversationCounts(a)),l},n=function(a,b){return b===k.FAVOURITE?a.favourites:a.types[b]},o=function(a){var b=a.some(function(a){var b=a[0];return h.isVisible(b)});if(!b){a.sort(function(a,b){var c=a[1],d=a[2],e=b[1],f=b[2];return d>0&&0==f?-1:0==d&&f>0?1:c>0&&0==e?-1:0==c&&e>0?1:0});var c=a[0][0],d=c.find(j.SECTION_TOGGLE_BUTTON);d.click()}},p=function(a){return a.find(j.SEARCH_INPUT)},q=function(a){return a.attr("data-user-id")},r=function(a){return function(){var b=a.find(j.CONTACT_REQUEST_COUNT),c=parseInt(b.text(),10);c=isNaN(c)?0:c-1,c<=0?b.addClass("hidden"):b.text(c)}},s=function(a,d){var h=p(d),i=[b.tab,b.shift,b.ctrl,b.alt];h.on("click",function(){e.go(a,f.VIEW_SEARCH)}),h.on("keydown",function(b){i.indexOf(b.keyCode)<0&&"Meta"!=b.key&&e.go(a,f.VIEW_SEARCH)}),c.subscribe(g.CONTACT_REQUEST_ACCEPTED,r(d)),c.subscribe(g.CONTACT_REQUEST_DECLINED,r(d))},t=function(a,b,c){b.attr("data-init")||(s(a,b),b.attr("data-init",!0)),p(b).val("");var d=q(c),e=m(d),f=[[c.find(j.FAVOURITES),k.FAVOURITE,!0],[c.find(j.GROUP_MESSAGES),k.PUBLIC,!1],[c.find(j.MESSAGES),k.PRIVATE,!1]];return f.forEach(function(b){var c=b[0],d=b[1],f=b[2],g=e.then(function(a){return n(a.total,d)}),i=e.then(function(a){return n(a.unread,d)});h.show(a,null,c,null,d,f,g,i)}),e.then(function(a){var b=f.map(function(b){var c=b[0],d=b[1],e=n(a.total,d),f=n(a.unread,d);return[c,e,f]});return o(b)})},u=function(){return d.get_string("messagedrawerviewoverview","core_message")};return{show:t,description:u}});
|
||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/notification","core/str","core/pubsub","core/templates","core_message/message_repository","core/custom_interaction_events","core_message/message_drawer_events"],function(a,b,c,d,e,f,g,h){var i={CHECKBOX:'input[type="checkbox"]',SETTINGS:'[data-region="settings"]',PRIVACY_PREFERENCE:'[data-preference="blocknoncontacts"] input[type="radio"]',NOTIFICATIONS_PREFERENCE:'[data-preference="notifications"] input[type="checkbox"]',ENTER_TO_SEND_PREFERENCE:'[data-preference="entertosend"] input[type="checkbox"]',NOTIFICATION_PREFERENCES_CONTAINER:'[data-region="notification-preference-container"]',CONTENT_CONTAINER:'[data-region="content-container"]',PLACEHOLDER_CONTAINER:'[data-region="placeholder-container"]'},j={NOTIFICATION_PREFERENCES:"core_message/message_drawer_view_settings_body_content_notification_preferences"},k="message_provider_moodle_instantmessage",l=function(b,c){var d=b.find(i.PRIVACY_PREFERENCE);d.each(function(b,d){d=a(d),d.val()==c?d.prop("checked",!0):d.prop("checked",!1)})},m=function(a,b){var c=a.find(i.ENTER_TO_SEND_PREFERENCE);b?c.prop("checked",!0):c.prop("checked",!1)},n=function(a,c){return f.savePreferences(a,c).then(function(){d.publish(h.PREFERENCES_UPDATED,c)})["catch"](b.exception)},o=function(b,c){var d=b.find(i.SETTINGS);g.define(d,[g.events.activate]),d.on(g.events.activate,i.NOTIFICATIONS_PREFERENCE,function(b){var d=a(b.target).closest(i.NOTIFICATION_PREFERENCES_CONTAINER),e=d.find(i.CHECKBOX);if(e.length){var f=e.toArray().reduce(function(b,c){return c=a(c),c.prop("checked")&&b.push(c.attr("data-name")),b},[]),g=f.length?f.join(","):"none",h=[{type:"message_provider_moodle_instantmessage_loggedoff",value:g},{type:"message_provider_moodle_instantmessage_loggedin",value:g}];n(c,h)}}),d.on(g.events.activate,i.PRIVACY_PREFERENCE,function(b){var d=a(b.target).val(),e=[{type:"message_blocknoncontacts",value:d}];n(c,e)}),d.on(g.events.activate,i.ENTER_TO_SEND_PREFERENCE,function(b){var d=a(b.target).prop("checked"),e=[{type:"message_entertosend",value:d}];n(c,e)})},p=function(a,c){f.getUserMessagePreferences(c).then(function(b){l(a,b.blocknoncontacts),m(a,b.entertosend);var c=[];b.preferences.components.length&&b.preferences.components.forEach(function(a){if(a.notifications.length){var b=a.notifications.filter(function(a){return a.preferencekey==k});if(b.length){var d=a.notifications[0];c=d.processors.map(function(a){var b=a.loggedin.checked||a.loggedoff.checked;return{displayname:a.displayname,name:a.name,checked:b,locked:a.locked,lockedmessage:a.lockedmessage||null}})}}});var d=a.find(i.NOTIFICATION_PREFERENCES_CONTAINER);return!c.length||(d.removeClass("hidden"),e.render(j.NOTIFICATION_PREFERENCES,{processors:c}).then(function(a){return d.append(a),a}))}).then(function(){a.find(i.CONTENT_CONTAINER).removeClass("hidden"),a.find(i.PLACEHOLDER_CONTAINER).addClass("hidden"),o(a,c)})["catch"](b.exception)},q=function(b,c,d){return c.attr("data-init")||(p(c,d),c.attr("data-init",!0)),a.Deferred().resolve().promise()},r=function(){return c.get_string("messagedrawerviewsettings","core_message")};return{show:q,description:r}});
|
||||
define(["jquery","core/notification","core/str","core/pubsub","core/templates","core_message/message_repository","core/custom_interaction_events","core_message/message_drawer_events"],function(a,b,c,d,e,f,g,h){var i={CHECKBOX:'input[type="checkbox"]',SETTINGS:'[data-region="settings"]',PRIVACY_PREFERENCE:'[data-preference="blocknoncontacts"] input[type="radio"]',NOTIFICATIONS_PREFERENCE:'[data-preference="notifications"] input[type="checkbox"]',ENTER_TO_SEND_PREFERENCE:'[data-preference="entertosend"] input[type="checkbox"]',NOTIFICATION_PREFERENCES_CONTAINER:'[data-region="notification-preference-container"]',CONTENT_CONTAINER:'[data-region="content-container"]',PLACEHOLDER_CONTAINER:'[data-region="placeholder-container"]'},j={NOTIFICATION_PREFERENCES:"core_message/message_drawer_view_settings_body_content_notification_preferences"},k="message_provider_moodle_instantmessage",l=function(b,c){var d=b.find(i.PRIVACY_PREFERENCE);d.each(function(b,d){d=a(d),d.val()==c?d.prop("checked",!0):d.prop("checked",!1)})},m=function(a,b){var c=a.find(i.ENTER_TO_SEND_PREFERENCE);b?c.prop("checked",!0):c.prop("checked",!1)},n=function(a,c){return f.savePreferences(a,c).then(function(){d.publish(h.PREFERENCES_UPDATED,c)})["catch"](b.exception)},o=function(b,c){var d=b.find(i.SETTINGS);g.define(d,[g.events.activate]),d.on(g.events.activate,i.NOTIFICATIONS_PREFERENCE,function(b){var d=a(b.target).closest(i.NOTIFICATION_PREFERENCES_CONTAINER),e=d.find(i.CHECKBOX);if(e.length){var f=e.toArray().reduce(function(b,c){return c=a(c),c.prop("checked")&&b.push(c.attr("data-name")),b},[]),g=f.length?f.join(","):"none",h=[{type:"message_provider_moodle_instantmessage_loggedoff",value:g},{type:"message_provider_moodle_instantmessage_loggedin",value:g}];n(c,h)}}),d.on(g.events.activate,i.PRIVACY_PREFERENCE,function(b){var d=a(b.target).val(),e=[{type:"message_blocknoncontacts",value:d}];n(c,e)}),d.on(g.events.activate,i.ENTER_TO_SEND_PREFERENCE,function(b){var d=a(b.target).prop("checked"),e=[{type:"message_entertosend",value:d}];n(c,e)})},p=function(a,c){f.getUserMessagePreferences(c).then(function(b){l(a,b.blocknoncontacts),m(a,b.entertosend);var c=[];b.preferences.components.length&&b.preferences.components.forEach(function(a){if(a.notifications.length){var b=a.notifications.filter(function(a){return a.preferencekey==k});if(b.length){var d=a.notifications[0];c=d.processors.map(function(a){var b=a.loggedin.checked||a.loggedoff.checked;return{displayname:a.displayname,name:a.name,checked:b,locked:a.locked,lockedmessage:a.lockedmessage||null}})}}});var d=a.find(i.NOTIFICATION_PREFERENCES_CONTAINER);return!c.length||(d.removeClass("hidden"),e.render(j.NOTIFICATION_PREFERENCES,{processors:c}).then(function(a){return d.append(a),a}))}).then(function(){a.find(i.CONTENT_CONTAINER).removeClass("hidden"),a.find(i.PLACEHOLDER_CONTAINER).addClass("hidden"),o(a,c)})["catch"](b.exception)},q=function(b,c,d,e,f){return d.attr("data-init")||(p(d,f),d.attr("data-init",!0)),a.Deferred().resolve().promise()},r=function(){return c.get_string("messagedrawerviewsettings","core_message")};return{show:q,description:r}});
|
||||
@@ -70,21 +70,24 @@ function(
|
||||
/**
|
||||
* Get elements for route.
|
||||
*
|
||||
* @param {String} namespace Unique identifier for the Routes
|
||||
* @param {Object} root The message drawer container.
|
||||
* @param {string} selector The route container.
|
||||
*
|
||||
* @return {array} elements Found route container objects.
|
||||
*/
|
||||
var getElementsForRoute = function(root, selector) {
|
||||
var getParametersForRoute = function(namespace, root, selector) {
|
||||
var candidates = root.children();
|
||||
var header = candidates.filter(SELECTORS.HEADER_CONTAINER).find(selector);
|
||||
var body = candidates.filter(SELECTORS.BODY_CONTAINER).find(selector);
|
||||
var footer = candidates.filter(SELECTORS.FOOTER_CONTAINER).find(selector);
|
||||
var elements = [header, body, footer].filter(function(element) {
|
||||
return element.length;
|
||||
});
|
||||
|
||||
return elements;
|
||||
return [
|
||||
namespace,
|
||||
header.length ? header : null,
|
||||
body.length ? body : null,
|
||||
footer.length ? footer : null
|
||||
];
|
||||
};
|
||||
|
||||
var routes = [
|
||||
@@ -94,28 +97,30 @@ function(
|
||||
[Routes.VIEW_GROUP_INFO, SELECTORS.VIEW_GROUP_INFO, ViewGroupInfo.show, ViewGroupInfo.description],
|
||||
[Routes.VIEW_OVERVIEW, SELECTORS.VIEW_OVERVIEW, ViewOverview.show, ViewOverview.description],
|
||||
[Routes.VIEW_SEARCH, SELECTORS.VIEW_SEARCH, ViewSearch.show, ViewSearch.description],
|
||||
[Routes.VIEW_SETTINGS, SELECTORS.VIEW_SETTINGS, ViewSettings.show, ViewSettings.description],
|
||||
[Routes.VIEW_SETTINGS, SELECTORS.VIEW_SETTINGS, ViewSettings.show, ViewSettings.description]
|
||||
];
|
||||
|
||||
/**
|
||||
* Create routes.
|
||||
*
|
||||
* @param {String} namespace Unique identifier for the Routes
|
||||
* @param {Object} root The message drawer container.
|
||||
*/
|
||||
var createRoutes = function(root) {
|
||||
var createRoutes = function(namespace, root) {
|
||||
routes.forEach(function(route) {
|
||||
Router.add(route[0], getElementsForRoute(root, route[1]), route[2], route[3]);
|
||||
Router.add(namespace, route[0], getParametersForRoute(namespace, root, route[1]), route[2], route[3]);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Show the message drawer.
|
||||
*
|
||||
* @param {string} namespace The route namespace.
|
||||
* @param {Object} root The message drawer container.
|
||||
*/
|
||||
var show = function(root) {
|
||||
var show = function(namespace, root) {
|
||||
if (!root.attr('data-shown')) {
|
||||
Router.go(Routes.VIEW_OVERVIEW);
|
||||
Router.go(namespace, Routes.VIEW_OVERVIEW);
|
||||
root.attr('data-shown', true);
|
||||
}
|
||||
|
||||
@@ -148,9 +153,10 @@ function(
|
||||
/**
|
||||
* Listen to and handle events for routing, showing and hiding the message drawer.
|
||||
*
|
||||
* @param {string} namespace The route namespace.
|
||||
* @param {Object} root The message drawer container.
|
||||
*/
|
||||
var registerEventListeners = function(root) {
|
||||
var registerEventListeners = function(namespace, root) {
|
||||
CustomEvents.define(root, [CustomEvents.events.activate]);
|
||||
var paramRegex = /^data-route-param-?(\d*)$/;
|
||||
|
||||
@@ -186,7 +192,7 @@ function(
|
||||
var params = paramAttributes.map(function(attribute) {
|
||||
return attribute.nodeValue;
|
||||
});
|
||||
var routeParams = [route].concat(params);
|
||||
var routeParams = [namespace, route].concat(params);
|
||||
|
||||
Router.go.apply(null, routeParams);
|
||||
|
||||
@@ -194,13 +200,13 @@ function(
|
||||
});
|
||||
|
||||
root.on(CustomEvents.events.activate, SELECTORS.ROUTES_BACK, function(e, data) {
|
||||
Router.back();
|
||||
Router.back(namespace);
|
||||
|
||||
data.originalEvent.preventDefault();
|
||||
});
|
||||
|
||||
PubSub.subscribe(Events.SHOW, function() {
|
||||
show(root);
|
||||
show(namespace, root);
|
||||
});
|
||||
|
||||
PubSub.subscribe(Events.HIDE, function() {
|
||||
@@ -211,23 +217,23 @@ function(
|
||||
if (isVisible(root)) {
|
||||
hide(root);
|
||||
} else {
|
||||
show(root);
|
||||
show(namespace, root);
|
||||
}
|
||||
});
|
||||
|
||||
PubSub.subscribe(Events.SHOW_CONVERSATION, function(conversationId) {
|
||||
show(root);
|
||||
Router.go(Routes.VIEW_CONVERSATION, conversationId);
|
||||
show(namespace, root);
|
||||
Router.go(namespace, Routes.VIEW_CONVERSATION, conversationId);
|
||||
});
|
||||
|
||||
PubSub.subscribe(Events.CREATE_CONVERSATION_WITH_USER, function(userId) {
|
||||
show(root);
|
||||
Router.go(Routes.VIEW_CONVERSATION, null, 'create', userId);
|
||||
show(namespace, root);
|
||||
Router.go(namespace, Routes.VIEW_CONVERSATION, null, 'create', userId);
|
||||
});
|
||||
|
||||
PubSub.subscribe(Events.SHOW_SETTINGS, function() {
|
||||
show(root);
|
||||
Router.go(Routes.VIEW_SETTINGS);
|
||||
show(namespace, root);
|
||||
Router.go(namespace, Routes.VIEW_SETTINGS);
|
||||
});
|
||||
|
||||
PubSub.subscribe(Events.PREFERENCES_UPDATED, function(preferences) {
|
||||
@@ -247,11 +253,12 @@ function(
|
||||
* Initialise the message drawer.
|
||||
*
|
||||
* @param {Object} root The message drawer container.
|
||||
* @param {String} uniqueId Unique identifier for the Routes
|
||||
*/
|
||||
var init = function(root) {
|
||||
var init = function(root, uniqueId) {
|
||||
root = $(root);
|
||||
createRoutes(root);
|
||||
registerEventListeners(root);
|
||||
createRoutes(uniqueId, root);
|
||||
registerEventListeners(uniqueId, root);
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -41,8 +41,8 @@ function(
|
||||
/* @var {object} routes Message drawer route elements and callbacks. */
|
||||
var routes = {};
|
||||
|
||||
/* @var {array} history Store for route objects history. */
|
||||
var history = [];
|
||||
/* @var {object} history Store for route objects history. */
|
||||
var history = {};
|
||||
|
||||
var SELECTORS = {
|
||||
CAN_RECEIVE_FOCUS: 'input:not([type="hidden"]), a[href], button, textarea, select, [tabindex]',
|
||||
@@ -52,40 +52,52 @@ function(
|
||||
/**
|
||||
* Add a route.
|
||||
*
|
||||
* @param {String} namespace Unique identifier for the Routes
|
||||
* @param {string} route Route config name.
|
||||
* @param {array} elements Route container objects.
|
||||
* @param {array} parameters Route parameters.
|
||||
* @param {callback} onGo Route initialization function.
|
||||
* @param {callback} getDescription Route initialization function.
|
||||
*/
|
||||
var add = function(route, elements, onGo, getDescription) {
|
||||
routes[route] = {
|
||||
elements: elements,
|
||||
onGo: onGo,
|
||||
getDescription: getDescription
|
||||
};
|
||||
var add = function(namespace, route, parameters, onGo, getDescription) {
|
||||
if (!routes[namespace]) {
|
||||
routes[namespace] = [];
|
||||
}
|
||||
|
||||
routes[namespace][route] =
|
||||
{
|
||||
parameters: parameters,
|
||||
onGo: onGo,
|
||||
getDescription: getDescription
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Go to a defined route and run the route callbacks.
|
||||
*
|
||||
* @param {String} namespace Unique identifier for the Routes
|
||||
* @param {string} newRoute Route config name.
|
||||
* @return {object} record Current route record with route config name and parameters.
|
||||
*/
|
||||
var changeRoute = function(newRoute) {
|
||||
var changeRoute = function(namespace, newRoute) {
|
||||
var newConfig;
|
||||
// Get the rest of the arguments, if any.
|
||||
var args = [].slice.call(arguments, 1);
|
||||
var args = [].slice.call(arguments, 2);
|
||||
var renderPromise = $.Deferred().resolve().promise();
|
||||
|
||||
Object.keys(routes).forEach(function(route) {
|
||||
var config = routes[route];
|
||||
Object.keys(routes[namespace]).forEach(function(route) {
|
||||
var config = routes[namespace][route];
|
||||
var isMatch = route === newRoute;
|
||||
|
||||
if (isMatch) {
|
||||
newConfig = config;
|
||||
}
|
||||
|
||||
config.elements.forEach(function(element) {
|
||||
config.parameters.forEach(function(element) {
|
||||
// Some parameters may be null, or not an element.
|
||||
if (typeof element !== 'object' || element === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
element.removeClass('previous');
|
||||
|
||||
if (isMatch) {
|
||||
@@ -100,12 +112,23 @@ function(
|
||||
|
||||
if (newConfig) {
|
||||
if (newConfig.onGo) {
|
||||
renderPromise = newConfig.onGo.apply(undefined, newConfig.elements.concat(args));
|
||||
renderPromise = newConfig.onGo.apply(undefined, newConfig.parameters.concat(args));
|
||||
var currentFocusElement = $(document.activeElement);
|
||||
var hasFocus = false;
|
||||
var firstFocusable = null;
|
||||
|
||||
for (var i = 0; i < newConfig.elements.length; i++) {
|
||||
var element = newConfig.elements[i];
|
||||
// No need to start at 0 as we know that is the namespace.
|
||||
for (var i = 1; i < newConfig.parameters.length; i++) {
|
||||
var element = newConfig.parameters[i];
|
||||
|
||||
// Some parameters may be null, or not an element.
|
||||
if (typeof element !== 'object' || element === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!firstFocusable) {
|
||||
firstFocusable = element;
|
||||
}
|
||||
|
||||
if (element.has(currentFocusElement).length) {
|
||||
hasFocus = true;
|
||||
@@ -116,7 +139,7 @@ function(
|
||||
if (!hasFocus) {
|
||||
// This page doesn't have focus yet so focus the first focusable
|
||||
// element in the new view.
|
||||
newConfig.elements[0].find(SELECTORS.CAN_RECEIVE_FOCUS).filter(':visible').first().focus();
|
||||
firstFocusable.find(SELECTORS.CAN_RECEIVE_FOCUS).filter(':visible').first().focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,18 +158,23 @@ function(
|
||||
/**
|
||||
* Go to a defined route and store the route history.
|
||||
*
|
||||
* @param {string} newRoute Route config name.
|
||||
* @param {String} namespace Unique identifier for the Routes
|
||||
* @return {object} record Current route record with route config name and parameters.
|
||||
*/
|
||||
var go = function() {
|
||||
var go = function(namespace) {
|
||||
var currentFocusElement = $(document.activeElement);
|
||||
var record = changeRoute.apply(null, arguments);
|
||||
var inHistory = false;
|
||||
|
||||
if (!history[namespace]) {
|
||||
history[namespace] = [];
|
||||
}
|
||||
|
||||
// History stores a unique list of routes. Check to see if the new route
|
||||
// is already in the history, if it is then forget all history after it.
|
||||
// This ensures there are no duplicate routes in history and that it represents
|
||||
// a linear path of routes (it never stores something like [foo, bar, foo])/
|
||||
history = history.reduce(function(carry, previous) {
|
||||
// a linear path of routes (it never stores something like [foo, bar, foo])).
|
||||
history[namespace] = history[namespace].reduce(function(carry, previous) {
|
||||
if (previous.route === record.route) {
|
||||
inHistory = true;
|
||||
}
|
||||
@@ -158,20 +186,29 @@ function(
|
||||
return carry;
|
||||
}, []);
|
||||
|
||||
var previousRecord = history.length ? history[history.length - 1] : null;
|
||||
var historylength = history[namespace].length;
|
||||
var previousRecord = historylength ? history[namespace][historylength - 1] : null;
|
||||
|
||||
if (previousRecord) {
|
||||
var prevConfig = routes[previousRecord.route];
|
||||
prevConfig.elements.forEach(function(element) {
|
||||
element.addClass('previous');
|
||||
});
|
||||
var prevConfig = routes[namespace][previousRecord.route];
|
||||
var elements = prevConfig.parameters;
|
||||
|
||||
// The first one will be the namespace, skip it.
|
||||
for (var i = 1; i < elements.length; i++) {
|
||||
// Some parameters may be null, or not an element.
|
||||
if (typeof elements[i] !== 'object' || elements[i] === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
elements[i].addClass('previous');
|
||||
}
|
||||
|
||||
previousRecord.focusElement = currentFocusElement;
|
||||
|
||||
if (prevConfig.getDescription) {
|
||||
// If the route has a description then set it on the back button for
|
||||
// the new page we're displaying.
|
||||
prevConfig.getDescription.apply(null, prevConfig.elements.concat(previousRecord.params))
|
||||
prevConfig.getDescription.apply(null, prevConfig.parameters.concat(previousRecord.params))
|
||||
.then(function(description) {
|
||||
return Str.get_string('backto', 'core_message', description);
|
||||
})
|
||||
@@ -180,12 +217,15 @@ function(
|
||||
// that the back button is visible.
|
||||
return record.renderPromise.then(function() {
|
||||
// Find the elements for the new route we displayed.
|
||||
routes[record.route].elements.forEach(function(element) {
|
||||
routes[namespace][record.route].parameters.forEach(function(element) {
|
||||
// Some parameters may be null, or not an element.
|
||||
if (typeof element !== 'object' || !element) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the aria label for the back button.
|
||||
element.find(SELECTORS.ROUTES_BACK).attr('aria-label', label);
|
||||
});
|
||||
|
||||
return;
|
||||
});
|
||||
})
|
||||
.catch(function() {
|
||||
@@ -193,23 +233,24 @@ function(
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
history.push(record);
|
||||
history[namespace].push(record);
|
||||
return record;
|
||||
};
|
||||
|
||||
/**
|
||||
* Go back to the previous route record stored in history.
|
||||
*
|
||||
* @param {String} namespace Unique identifier for the Routes
|
||||
*/
|
||||
var back = function() {
|
||||
if (history.length) {
|
||||
var back = function(namespace) {
|
||||
if (history[namespace].length) {
|
||||
// Remove the current route.
|
||||
history.pop();
|
||||
var previous = history.pop();
|
||||
history[namespace].pop();
|
||||
var previous = history[namespace].pop();
|
||||
|
||||
if (previous) {
|
||||
// If we have a previous route then show it.
|
||||
go.apply(undefined, [previous.route].concat(previous.params));
|
||||
go.apply(undefined, [namespace, previous.route].concat(previous.params));
|
||||
// Delay the focus 50 milliseconds otherwise it doesn't correctly
|
||||
// focus the element for some reason...
|
||||
window.setTimeout(function() {
|
||||
|
||||
@@ -68,12 +68,15 @@ function(
|
||||
/**
|
||||
* Setup the contact page.
|
||||
*
|
||||
* @param {Object} root Contact container element.
|
||||
* @param {string} namespace The route namespace.
|
||||
* @param {Object} header Contact header element.
|
||||
* @param {Object} body Contact body container element.
|
||||
* @param {Object} footer Contact footer container element.
|
||||
* @param {Object} contact The contact object.
|
||||
* @returns {Object} jQuery promise
|
||||
*/
|
||||
var show = function(root, contact) {
|
||||
root = $(root);
|
||||
var show = function(namespace, header, body, footer, contact) {
|
||||
var root = $(body);
|
||||
|
||||
getContentContainer(root).empty();
|
||||
return render(root, contact);
|
||||
|
||||
@@ -123,11 +123,12 @@ function(
|
||||
/**
|
||||
* Setup the contact page.
|
||||
*
|
||||
* @param {string} namespace The route namespace.
|
||||
* @param {Object} header Contacts header container element.
|
||||
* @param {Object} body Contacts body container element.
|
||||
* @return {Object} jQuery promise
|
||||
*/
|
||||
var show = function(header, body) {
|
||||
var show = function(namespace, header, body) {
|
||||
body = $(body);
|
||||
|
||||
if (!body.attr('data-contacts-init')) {
|
||||
|
||||
@@ -1154,14 +1154,16 @@ function(
|
||||
/**
|
||||
* Show the view contact page.
|
||||
*
|
||||
* @param {Object} e Element this event handler is called on.
|
||||
* @param {Object} data Data for this event.
|
||||
* @param {String} namespace Unique identifier for the Routes
|
||||
* @return {Function} View contact handler.
|
||||
*/
|
||||
var handleViewContact = function(e, data) {
|
||||
var otherUserId = getOtherUserId();
|
||||
var otherUser = viewState.members[otherUserId];
|
||||
MessageDrawerRouter.go(MessageDrawerRoutes.VIEW_CONTACT, otherUser);
|
||||
data.originalEvent.preventDefault();
|
||||
var generateHandleViewContact = function(namespace) {
|
||||
return function(e, data) {
|
||||
var otherUserId = getOtherUserId();
|
||||
var otherUser = viewState.members[otherUserId];
|
||||
MessageDrawerRouter.go(namespace, MessageDrawerRoutes.VIEW_CONTACT, otherUser);
|
||||
data.originalEvent.preventDefault();
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1187,68 +1189,71 @@ function(
|
||||
};
|
||||
|
||||
/**
|
||||
* Show the view contact page.
|
||||
* Show the view group info page.
|
||||
*
|
||||
* @param {Object} e Element this event handler is called on.
|
||||
* @param {Object} data Data for this event.
|
||||
* @param {String} namespace Unique identifier for the Routes
|
||||
* @return {Function} View group info handler.
|
||||
*/
|
||||
var handleViewGroupInfo = function(e, data) {
|
||||
MessageDrawerRouter.go(
|
||||
MessageDrawerRoutes.VIEW_GROUP_INFO,
|
||||
{
|
||||
id: viewState.id,
|
||||
name: viewState.name,
|
||||
subname: viewState.subname,
|
||||
imageUrl: viewState.imageUrl,
|
||||
totalMemberCount: viewState.totalMemberCount
|
||||
},
|
||||
viewState.loggedInUserId
|
||||
);
|
||||
data.originalEvent.preventDefault();
|
||||
var generateHandleViewGroupInfo = function(namespace) {
|
||||
return function(e, data) {
|
||||
MessageDrawerRouter.go(
|
||||
namespace,
|
||||
MessageDrawerRoutes.VIEW_GROUP_INFO,
|
||||
{
|
||||
id: viewState.id,
|
||||
name: viewState.name,
|
||||
subname: viewState.subname,
|
||||
imageUrl: viewState.imageUrl,
|
||||
totalMemberCount: viewState.totalMemberCount
|
||||
},
|
||||
viewState.loggedInUserId
|
||||
);
|
||||
data.originalEvent.preventDefault();
|
||||
};
|
||||
};
|
||||
|
||||
var headerActivateHandlers = [
|
||||
[SELECTORS.ACTION_REQUEST_BLOCK, generateConfirmActionHandler(requestBlockUser)],
|
||||
[SELECTORS.ACTION_REQUEST_UNBLOCK, generateConfirmActionHandler(requestUnblockUser)],
|
||||
[SELECTORS.ACTION_REQUEST_ADD_CONTACT, generateConfirmActionHandler(requestAddContact)],
|
||||
[SELECTORS.ACTION_REQUEST_REMOVE_CONTACT, generateConfirmActionHandler(requestRemoveContact)],
|
||||
[SELECTORS.ACTION_REQUEST_DELETE_CONVERSATION, generateConfirmActionHandler(requestDeleteConversation)],
|
||||
[SELECTORS.ACTION_CANCEL_EDIT_MODE, handleCancelEditMode],
|
||||
[SELECTORS.ACTION_VIEW_CONTACT, handleViewContact],
|
||||
[SELECTORS.ACTION_VIEW_GROUP_INFO, handleViewGroupInfo],
|
||||
[SELECTORS.ACTION_CONFIRM_FAVOURITE, handleSetFavourite],
|
||||
[SELECTORS.ACTION_CONFIRM_UNFAVOURITE, handleUnsetFavourite],
|
||||
];
|
||||
var bodyActivateHandlers = [
|
||||
[SELECTORS.ACTION_CANCEL_CONFIRM, generateConfirmActionHandler(cancelRequest)],
|
||||
[SELECTORS.ACTION_CONFIRM_BLOCK, generateConfirmActionHandler(blockUser)],
|
||||
[SELECTORS.ACTION_CONFIRM_UNBLOCK, generateConfirmActionHandler(unblockUser)],
|
||||
[SELECTORS.ACTION_CONFIRM_ADD_CONTACT, generateConfirmActionHandler(addContact)],
|
||||
[SELECTORS.ACTION_CONFIRM_REMOVE_CONTACT, generateConfirmActionHandler(removeContact)],
|
||||
[SELECTORS.ACTION_CONFIRM_DELETE_SELECTED_MESSAGES, generateConfirmActionHandler(deleteSelectedMessages)],
|
||||
[SELECTORS.ACTION_CONFIRM_DELETE_CONVERSATION, generateConfirmActionHandler(deleteConversation)],
|
||||
[SELECTORS.ACTION_REQUEST_ADD_CONTACT, generateConfirmActionHandler(requestAddContact)],
|
||||
[SELECTORS.ACTION_ACCEPT_CONTACT_REQUEST, generateConfirmActionHandler(acceptContactRequest)],
|
||||
[SELECTORS.ACTION_DECLINE_CONTACT_REQUEST, generateConfirmActionHandler(declineContactRequest)],
|
||||
[SELECTORS.MESSAGE, handleSelectMessage]
|
||||
];
|
||||
var footerActivateHandlers = [
|
||||
[SELECTORS.SEND_MESSAGE_BUTTON, handleSendMessage],
|
||||
[SELECTORS.ACTION_REQUEST_DELETE_SELECTED_MESSAGES, generateConfirmActionHandler(requestDeleteSelectedMessages)],
|
||||
[SELECTORS.ACTION_REQUEST_ADD_CONTACT, generateConfirmActionHandler(requestAddContact)],
|
||||
[SELECTORS.ACTION_REQUEST_UNBLOCK, generateConfirmActionHandler(requestUnblockUser)],
|
||||
];
|
||||
|
||||
/**
|
||||
* Listen to, and handle events for conversations.
|
||||
*
|
||||
* @param {string} namespace The route namespace.
|
||||
* @param {Object} header Conversation header container element.
|
||||
* @param {Object} body Conversation body container element.
|
||||
* @param {Object} footer Conversation footer container element.
|
||||
*/
|
||||
var registerEventListeners = function(header, body, footer) {
|
||||
var registerEventListeners = function(namespace, header, body, footer) {
|
||||
var isLoadingMoreMessages = false;
|
||||
var messagesContainer = getMessagesContainer(body);
|
||||
var headerActivateHandlers = [
|
||||
[SELECTORS.ACTION_REQUEST_BLOCK, generateConfirmActionHandler(requestBlockUser)],
|
||||
[SELECTORS.ACTION_REQUEST_UNBLOCK, generateConfirmActionHandler(requestUnblockUser)],
|
||||
[SELECTORS.ACTION_REQUEST_ADD_CONTACT, generateConfirmActionHandler(requestAddContact)],
|
||||
[SELECTORS.ACTION_REQUEST_REMOVE_CONTACT, generateConfirmActionHandler(requestRemoveContact)],
|
||||
[SELECTORS.ACTION_REQUEST_DELETE_CONVERSATION, generateConfirmActionHandler(requestDeleteConversation)],
|
||||
[SELECTORS.ACTION_CANCEL_EDIT_MODE, handleCancelEditMode],
|
||||
[SELECTORS.ACTION_VIEW_CONTACT, generateHandleViewContact(namespace)],
|
||||
[SELECTORS.ACTION_VIEW_GROUP_INFO, generateHandleViewGroupInfo(namespace)],
|
||||
[SELECTORS.ACTION_CONFIRM_FAVOURITE, handleSetFavourite],
|
||||
[SELECTORS.ACTION_CONFIRM_UNFAVOURITE, handleUnsetFavourite],
|
||||
];
|
||||
var bodyActivateHandlers = [
|
||||
[SELECTORS.ACTION_CANCEL_CONFIRM, generateConfirmActionHandler(cancelRequest)],
|
||||
[SELECTORS.ACTION_CONFIRM_BLOCK, generateConfirmActionHandler(blockUser)],
|
||||
[SELECTORS.ACTION_CONFIRM_UNBLOCK, generateConfirmActionHandler(unblockUser)],
|
||||
[SELECTORS.ACTION_CONFIRM_ADD_CONTACT, generateConfirmActionHandler(addContact)],
|
||||
[SELECTORS.ACTION_CONFIRM_REMOVE_CONTACT, generateConfirmActionHandler(removeContact)],
|
||||
[SELECTORS.ACTION_CONFIRM_DELETE_SELECTED_MESSAGES, generateConfirmActionHandler(deleteSelectedMessages)],
|
||||
[SELECTORS.ACTION_CONFIRM_DELETE_CONVERSATION, generateConfirmActionHandler(deleteConversation)],
|
||||
[SELECTORS.ACTION_REQUEST_ADD_CONTACT, generateConfirmActionHandler(requestAddContact)],
|
||||
[SELECTORS.ACTION_ACCEPT_CONTACT_REQUEST, generateConfirmActionHandler(acceptContactRequest)],
|
||||
[SELECTORS.ACTION_DECLINE_CONTACT_REQUEST, generateConfirmActionHandler(declineContactRequest)],
|
||||
[SELECTORS.MESSAGE, handleSelectMessage]
|
||||
];
|
||||
var footerActivateHandlers = [
|
||||
[SELECTORS.SEND_MESSAGE_BUTTON, handleSendMessage],
|
||||
[SELECTORS.ACTION_REQUEST_DELETE_SELECTED_MESSAGES, generateConfirmActionHandler(requestDeleteSelectedMessages)],
|
||||
[SELECTORS.ACTION_REQUEST_ADD_CONTACT, generateConfirmActionHandler(requestAddContact)],
|
||||
[SELECTORS.ACTION_REQUEST_UNBLOCK, generateConfirmActionHandler(requestUnblockUser)],
|
||||
];
|
||||
|
||||
AutoRows.init(footer);
|
||||
|
||||
@@ -1503,6 +1508,7 @@ function(
|
||||
* 2.) A conversation id with no action or other user id (e.g. from the contacts page)
|
||||
* 3.) No conversation/id with an action and other other user id. (e.g. from contact page)
|
||||
*
|
||||
* @param {string} namespace The route namespace.
|
||||
* @param {Object} header Conversation header container element.
|
||||
* @param {Object} body Conversation body container element.
|
||||
* @param {Object} footer Conversation footer container element.
|
||||
@@ -1511,7 +1517,7 @@ function(
|
||||
* @param {Number} otherUserId The other user id for a private conversation
|
||||
* @return {Object} jQuery promise
|
||||
*/
|
||||
var show = function(header, body, footer, conversationOrId, action, otherUserId) {
|
||||
var show = function(namespace, header, body, footer, conversationOrId, action, otherUserId) {
|
||||
var conversation = null;
|
||||
var conversationId = null;
|
||||
|
||||
@@ -1535,7 +1541,7 @@ function(
|
||||
// Generate the render function to bind the header, body, and footer
|
||||
// elements to it so that we don't need to pass them around this module.
|
||||
render = generateRenderFunction(header, body, footer);
|
||||
registerEventListeners(header, body, footer);
|
||||
registerEventListeners(namespace, header, body, footer);
|
||||
body.attr('data-init', true);
|
||||
}
|
||||
|
||||
|
||||
@@ -134,13 +134,16 @@ function(
|
||||
/**
|
||||
* Setup the contact page.
|
||||
*
|
||||
* @param {Object} root Contact container element.
|
||||
* @param {string} namespace The route namespace.
|
||||
* @param {Object} header Contact header container element.
|
||||
* @param {Object} body Contact body container element.
|
||||
* @param {Object} footer Contact body container element.
|
||||
* @param {Number} conversation The conversation
|
||||
* @param {Number} loggedInUserId The logged in user id
|
||||
* @return {Object} jQuery promise
|
||||
*/
|
||||
var show = function(root, conversation, loggedInUserId) {
|
||||
root = $(root);
|
||||
var show = function(namespace, header, body, footer, conversation, loggedInUserId) {
|
||||
var root = $(body);
|
||||
|
||||
getContentContainer(root).empty();
|
||||
return render(root, conversation, loggedInUserId)
|
||||
|
||||
@@ -186,18 +186,19 @@ function(
|
||||
/**
|
||||
* Listen to, and handle event in the overview header.
|
||||
*
|
||||
* @param {String} namespace Unique identifier for the Routes
|
||||
* @param {Object} header Conversation header container element.
|
||||
*/
|
||||
var registerEventListeners = function(header) {
|
||||
var registerEventListeners = function(namespace, header) {
|
||||
var searchInput = getSearchInput(header);
|
||||
var ignoredKeys = [KeyCodes.tab, KeyCodes.shift, KeyCodes.ctrl, KeyCodes.alt];
|
||||
|
||||
searchInput.on('click', function() {
|
||||
Router.go(Routes.VIEW_SEARCH);
|
||||
Router.go(namespace, Routes.VIEW_SEARCH);
|
||||
});
|
||||
searchInput.on('keydown', function(e) {
|
||||
if (ignoredKeys.indexOf(e.keyCode) < 0 && e.key != 'Meta') {
|
||||
Router.go(Routes.VIEW_SEARCH);
|
||||
Router.go(namespace, Routes.VIEW_SEARCH);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -208,13 +209,14 @@ function(
|
||||
/**
|
||||
* Setup the overview page.
|
||||
*
|
||||
* @param {String} namespace Unique identifier for the Routes
|
||||
* @param {Object} header Overview header container element.
|
||||
* @param {Object} body Overview body container element.
|
||||
* @return {Object} jQuery promise
|
||||
*/
|
||||
var show = function(header, body) {
|
||||
var show = function(namespace, header, body) {
|
||||
if (!header.attr('data-init')) {
|
||||
registerEventListeners(header);
|
||||
registerEventListeners(namespace, header);
|
||||
header.attr('data-init', true);
|
||||
}
|
||||
|
||||
@@ -242,7 +244,8 @@ function(
|
||||
return filterCountsByType(result.unread, sectionType);
|
||||
});
|
||||
|
||||
Section.show(sectionRoot, sectionType, includeFavourites, totalCountPromise, unreadCountPromise);
|
||||
Section.show(namespace, null, sectionRoot, null, sectionType, includeFavourites,
|
||||
totalCountPromise, unreadCountPromise);
|
||||
});
|
||||
|
||||
return allCounts.then(function(result) {
|
||||
|
||||
@@ -212,7 +212,7 @@ function(
|
||||
* Build the callback to load conversations.
|
||||
*
|
||||
* @param {Number} type The conversation type.
|
||||
* @param {Bool} includeFavourites Include/exclude favourites.
|
||||
* @param {bool} includeFavourites Include/exclude favourites.
|
||||
* @param {Number} offset Result offset
|
||||
* @return {Function}
|
||||
*/
|
||||
@@ -483,12 +483,13 @@ function(
|
||||
/**
|
||||
* Listen to, and handle events in this section.
|
||||
*
|
||||
* @param {String} namespace Unique identifier for the Routes
|
||||
* @param {Object} root The section container element.
|
||||
* @param {Function} loadCallback The callback to load items.
|
||||
* @param {Number} type The conversation type for this section
|
||||
* @param {Bool} includeFavourites If this section includes favourites
|
||||
* @param {bool} includeFavourites If this section includes favourites
|
||||
*/
|
||||
var registerEventListeners = function(root, loadCallback, type, includeFavourites) {
|
||||
var registerEventListeners = function(namespace, root, loadCallback, type, includeFavourites) {
|
||||
var listRoot = LazyLoadList.getRoot(root);
|
||||
|
||||
// Set the minimum height of the section to the height of the toggle. This
|
||||
@@ -586,7 +587,7 @@ function(
|
||||
var conversationElement = $(e.target).closest(SELECTORS.CONVERSATION);
|
||||
var conversationId = conversationElement.attr('data-conversation-id');
|
||||
var conversation = loadedConversationsById[conversationId];
|
||||
MessageDrawerRouter.go(MessageDrawerRoutes.VIEW_CONVERSATION, conversation);
|
||||
MessageDrawerRouter.go(namespace, MessageDrawerRoutes.VIEW_CONVERSATION, conversation);
|
||||
|
||||
data.originalEvent.preventDefault();
|
||||
});
|
||||
@@ -595,18 +596,21 @@ function(
|
||||
/**
|
||||
* Setup the section.
|
||||
*
|
||||
* @param {Object} root The section container element.
|
||||
* @param {String} namespace Unique identifier for the Routes
|
||||
* @param {Object} header The header container element.
|
||||
* @param {Object} body The section container element.
|
||||
* @param {Object} footer The footer container element.
|
||||
* @param {Number} type The conversation type for this section
|
||||
* @param {Bool} includeFavourites If this section includes favourites
|
||||
* @param {bool} includeFavourites If this section includes favourites
|
||||
* @param {Object} totalCountPromise Resolves wth the total conversations count
|
||||
* @param {Object} unreadCountPromise Resolves wth the unread conversations count
|
||||
*/
|
||||
var show = function(root, type, includeFavourites, totalCountPromise, unreadCountPromise) {
|
||||
root = $(root);
|
||||
var show = function(namespace, header, body, footer, type, includeFavourites, totalCountPromise, unreadCountPromise) {
|
||||
var root = $(body);
|
||||
|
||||
if (!root.attr('data-init')) {
|
||||
var loadCallback = getLoadCallback(type, includeFavourites, 0);
|
||||
registerEventListeners(root, loadCallback, type, includeFavourites);
|
||||
registerEventListeners(namespace, root, loadCallback, type, includeFavourites);
|
||||
|
||||
if (isVisible(root)) {
|
||||
setExpanded(root);
|
||||
|
||||
@@ -935,11 +935,12 @@ function(
|
||||
/**
|
||||
* Setup the search page.
|
||||
*
|
||||
* @param {string} namespace The route namespace.
|
||||
* @param {Object} header Contacts header container element.
|
||||
* @param {Object} body Contacts body container element.
|
||||
* @return {Object} jQuery promise
|
||||
*/
|
||||
var show = function(header, body) {
|
||||
var show = function(namespace, header, body) {
|
||||
if (!body.attr('data-init')) {
|
||||
registerEventListeners(header, body);
|
||||
body.attr('data-init', true);
|
||||
|
||||
@@ -264,12 +264,14 @@ function(
|
||||
* Initialise the settings page by adding event listeners to
|
||||
* the checkboxes.
|
||||
*
|
||||
* @param {string} namespace The route namespace.
|
||||
* @param {Object} header The settings header element.
|
||||
* @param {Object} body The settings body element.
|
||||
* @param {Object} footer The footer body element.
|
||||
* @param {Number} loggedInUserId The logged in user id.
|
||||
* @return {Object} jQuery promise
|
||||
*/
|
||||
var show = function(header, body, loggedInUserId) {
|
||||
var show = function(namespace, header, body, footer, loggedInUserId) {
|
||||
if (!body.attr('data-init')) {
|
||||
init(body, loggedInUserId);
|
||||
body.attr('data-init', true);
|
||||
|
||||
@@ -65,6 +65,6 @@
|
||||
{{#js}}
|
||||
require(['jquery', 'core_message/message_drawer'], function($, MessageDrawer) {
|
||||
var root = $('#message-drawer-{{uniqid}}');
|
||||
MessageDrawer.init(root);
|
||||
MessageDrawer.init(root, '{{uniqid}}');
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
@@ -85,7 +85,7 @@ function(
|
||||
) {
|
||||
|
||||
var root = $('#message-drawer-{{uniqid}}');
|
||||
MessageDrawer.init(root);
|
||||
MessageDrawer.init(root, '{{uniqid}}');
|
||||
|
||||
var toggle = $('#message-drawer-close-{{uniqid}}');
|
||||
Popover.init(toggle);
|
||||
|
||||
Reference in New Issue
Block a user