You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
2.2 KiB
1 lines
2.2 KiB
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).some(function(a){return"frompanel"==a}),j=[].slice.call(arguments,2),k=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"),a.attr("data-from-panel",!1),d?(i&&a.attr("data-from-panel",!0),a.removeClass("hidden"),a.attr("aria-hidden",!1)):a.attr("data-in-panel")?"view-search"!=f&&"view-overview"!=f||(a.addClass("hidden"),a.attr("aria-hidden",!0)):(a.addClass("hidden"),a.attr("aria-hidden",!0)))})}),h&&h.onGo){k=h.onGo.apply(void 0,h.parameters.concat(j));for(var l=a(document.activeElement),m=!1,n=null,o=1;o<h.parameters.length;o++){var p=h.parameters[o];if("object"==typeof p&&null!==p&&(n||(n=p),p.has(l).length)){m=!0;break}}m||n.find(g.CAN_RECEIVE_FOCUS).filter(":visible").first().focus()}var q={route:f,params:j,renderPromise:k};return b.publish(d.ROUTE_CHANGED,q),q},j=function(b){var d=a(document.activeElement),h=i.apply(b,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}});
|