mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-14 00:07:11 +00:00
fix(mail): Recipients with umlaut (ü) trigerred the end of string
With chrome and edge and a german keyboard, the ü was considered as a separator keycode when adding recipients
This commit is contained in:
1 parent
1df2586745
commit
9c7ef089c2
4 files changed
+98
-92
No files matched your search
@@ -1,2 +1,2 @@
|
||||
!function(){"use strict";function c(e){var t=this;"function"!=typeof e.then&&(angular.extend(this,e),_.forEach(this.identities,function(e){var t;e.fullName&&e.email?e.full=e.fullName+" <"+e.email+">":e.email?e.full="<"+e.email+">":e.full="",e.signature&&(t=angular.element("<div>"+e.signature+"</div>"),e.textSignature=_.map(t.contents(),"textContent").join(" ").trim())}),this.$mailboxes)&&c.$Mailbox.$unwrapCollection(this,c.$q.when({mailboxes:this.$mailboxes})).then(function(e){t.$mailboxes=e})}c.$factory=["$q","$timeout","$log","sgSettings","Resource","Preferences","Mailbox","Message",function(e,t,s,n,i,o,a,r){return angular.extend(c,{$q:e,$timeout:t,$log:s,$$resource:new i(n.activeUser("folderURL")+"Mail",n.activeUser()),$Preferences:o,$Mailbox:a,$Message:r}),c}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").factory("Account",c.$factory),c.$findAll=function(e){return e?c.$unwrapCollection(e):c.$accounts?c.$q.when(c.$accounts):c.$$resource.fetch("","mailAccounts").then(function(e){return c.$unwrapCollection(e)})},c.$unwrapCollection=function(e){var s=[];return angular.forEach(e,function(e,t){e.id=t,s[t]=new c(e)}),c.$accounts=s},c.refreshUnseenCount=function(e){var t,s=1===c.$Preferences.defaults.SOGoMailFetchAllUnseenCountFolders,n=c.$Preferences.defaults.SOGoRefreshViewCheck;if(s)t=[];else{if(!e)throw Error("SOGoMailFetchAllUnseenCountFolders is disabled and no folders list provided");t=e}_.forEach(c.$accounts,function(e){s?_.forEach(e.$$flattenMailboxes,function(e){t.push(e.id)}):(_.includes(t,e.id+"/folderINBOX")||t.push(e.id+"/folderINBOX"),_.forEach(e.$$flattenMailboxes,function(e){angular.isDefined(e.unseenCount)&&!_.includes(t,e.id)&&t.push(e.id)}))}),c.$$resource.post("","unseenCount",{mailboxes:t}).then(function(t){_.forEach(c.$accounts,function(e){_.forEach(e.$$flattenMailboxes,function(e){angular.isDefined(t[e.id])&&(e.unseenCount=t[e.id])})})}),n&&"manually"!=n&&(c.$refreshUnseenCount&&c.$timeout.cancel(c.$refreshUnseenCount),c.$refreshUnseenCount=c.$timeout(angular.bind(this,c.refreshUnseenCount,e),1e3*n.timeInterval()))},c.prototype.getLength=function(){return this.$expanded?this.$flattenMailboxes().length:0},c.prototype.getItemAtIndex=function(e){var t=this.$flattenMailboxes();return 0<=e&&e<t.length?t[e]:null},c.prototype.$getMailboxes=function(e){var o=this,t=e&&e.reload;return this.$mailboxes&&!t?c.$q.when(this.$mailboxes):(!t&&this.$futureMailboxesData||(this.$futureMailboxesData=c.$Mailbox.$find(this,e).then(function(e){function s(e){_.forEach(e,function(e){var t=_.find(n,["id",e.id]);t&&(e.unseenCount=t.unseenCount),e.children&&0<e.children.length&&s(e.children)})}var n=o.$flattenMailboxes({all:!0});o.$mailboxes=e,o.$expanded=!1;s(o.$mailboxes);function t(e){_.forEach(e,function(e){e.$expanded=0<=i.indexOf("/"+e.id),e.children&&0<e.children.length&&t(e.children)})}var i;if(c.$Preferences.settings.Mail.ExpandedFolders){if(angular.isString(c.$Preferences.settings.Mail.ExpandedFolders))try{i=angular.fromJson(c.$Preferences.settings.Mail.ExpandedFolders)}catch(e){c.$log.warn("Can't parse list of expanded folders. String was: "+c.$Preferences.settings.Mail.ExpandedFolders),i=[]}else i=c.$Preferences.settings.Mail.ExpandedFolders;o.$expanded=0<=i.indexOf("/"+o.id),0<i.length&&t(o.$mailboxes)}return c.$accounts&&(o.$expanded|=1==c.$accounts.length),o.$flattenMailboxes({reload:!0}),o.$mailboxes})),this.$futureMailboxesData)},c.prototype.$flattenMailboxes=function(t){function s(e){_.forEach(e,function(e){n.push(e),(t&&t.all||e.$expanded)&&e.children&&0<e.children.length&&s(e.children)})}var n=[],i=[];return!this.$$flattenMailboxes||t&&(t.reload||t.all)?(s(this.$mailboxes),t&&t.all||(this.$$flattenMailboxes=n,t&&t.saveState&&(_.forEach(c.$accounts,function(e){e.$expanded&&i.push("/"+e.id),_.reduce(e.$$flattenMailboxes,function(e,t){return t.$expanded&&e.push("/"+t.id),e},i)}),c.$$resource.post(null,"saveFoldersState",i)))):n=this.$$flattenMailboxes,n},c.prototype.$getMailboxByType=function(s){function n(e){var t=_.find(e,function(e){return e.type==s});return t||angular.forEach(e,function(e){!t&&e.children&&0<e.children.length&&(t=n(e.children))}),t}return n(this.$mailboxes)},c.prototype.$getMailboxByPath=function(s){function n(e){var t=_.find(e,function(e){return e.path==s});return t||angular.forEach(e,function(e){!t&&e.children&&0<e.children.length&&(t=n(e.children))}),t}var e;if(null==(e=n(this.$mailboxes)))throw Error("No mailbox found matching path "+s);return e},c.prototype.$newMailbox=function(e,t){var s=this;return c.$$resource.post(e.toString(),"createFolder",{name:t}).then(function(){s.$getMailboxes({reload:!0})})},c.prototype.getTextSignature=function(e){var t;return e.signature?(t=angular.element("<div>"+e.signature+"</div>"),e.textSignature=_.map(t.contents(),"textContent").join(" ").trim()):e.textSignature="",e.textSignature},c.prototype.$hasCertificate=function(){return this.security&&this.security.hasCLine truncated
|
||||
!function(){"use strict";function c(e){var t=this;"function"!=typeof e.then&&(angular.extend(this,e),_.forEach(this.identities,function(e){var t;e.fullName&&e.email?e.full=e.fullName+" <"+e.email+">":e.email?e.full="<"+e.email+">":e.full="",e.signature&&(t=angular.element("<div>"+e.signature+"</div>"),e.textSignature=_.map(t.contents(),"textContent").join(" ").trim())}),this.$mailboxes)&&c.$Mailbox.$unwrapCollection(this,c.$q.when({mailboxes:this.$mailboxes})).then(function(e){t.$mailboxes=e})}c.$factory=["$q","$timeout","$log","sgSettings","Resource","Preferences","Mailbox","Message",function(e,t,s,n,i,o,a,r){return angular.extend(c,{$q:e,$timeout:t,$log:s,$$resource:new i(n.activeUser("folderURL")+"Mail",n.activeUser()),$Preferences:o,$Mailbox:a,$Message:r}),c}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").factory("Account",c.$factory),c.$findAll=function(e){return e?c.$unwrapCollection(e):c.$accounts?c.$q.when(c.$accounts):c.$$resource.fetch("","mailAccounts").then(function(e){return c.$unwrapCollection(e)})},c.$unwrapCollection=function(e){var s=[];return angular.forEach(e,function(e,t){e.id=t,s[t]=new c(e)}),c.$accounts=s},c.refreshUnseenCount=function(e){var t,s=1===c.$Preferences.defaults.SOGoMailFetchAllUnseenCountFolders,n=c.$Preferences.defaults.SOGoRefreshViewCheck;if(s)t=[];else{if(!e)throw Error("SOGoMailFetchAllUnseenCountFolders is disabled and no folders list provided");t=e}_.forEach(c.$accounts,function(e){s?_.forEach(e.$$flattenMailboxes,function(e){t.push(e.id)}):(_.includes(t,e.id+"/folderINBOX")||t.push(e.id+"/folderINBOX"),_.forEach(e.$$flattenMailboxes,function(e){angular.isDefined(e.unseenCount)&&!_.includes(t,e.id)&&t.push(e.id)}))}),c.$$resource.post("","unseenCount",{mailboxes:t}).then(function(t){_.forEach(c.$accounts,function(e){_.forEach(e.$$flattenMailboxes,function(e){angular.isDefined(t[e.id])&&(e.unseenCount=t[e.id])})})}),n&&"manually"!=n&&(c.$refreshUnseenCount&&c.$timeout.cancel(c.$refreshUnseenCount),c.$refreshUnseenCount=c.$timeout(angular.bind(this,c.refreshUnseenCount,e),1e3*n.timeInterval()))},c.prototype.getLength=function(){return this.$expanded?this.$flattenMailboxes().length:0},c.prototype.getItemAtIndex=function(e){var t=this.$flattenMailboxes();return 0<=e&&e<t.length?t[e]:null},c.prototype.$getMailboxes=function(e){var o=this,t=e&&e.reload;return this.$mailboxes&&!t?c.$q.when(this.$mailboxes):(!t&&this.$futureMailboxesData||(this.$futureMailboxesData=c.$Mailbox.$find(this,e).then(function(e){function s(e){_.forEach(e,function(e){var t=_.find(n,["id",e.id]);t&&(e.unseenCount=t.unseenCount),e.children&&0<e.children.length&&s(e.children)})}var n=o.$flattenMailboxes({all:!0});o.$mailboxes=e,o.$expanded=!1;s(o.$mailboxes);function t(e){_.forEach(e,function(e){e.$expanded=0<=i.indexOf("/"+e.id),e.children&&0<e.children.length&&t(e.children)})}var i;if(c.$Preferences.settings.Mail.ExpandedFolders){if(angular.isString(c.$Preferences.settings.Mail.ExpandedFolders))try{i=angular.fromJson(c.$Preferences.settings.Mail.ExpandedFolders)}catch(e){c.$log.warn("Can't parse list of expanded folders. String was: "+c.$Preferences.settings.Mail.ExpandedFolders),i=[]}else i=c.$Preferences.settings.Mail.ExpandedFolders;o.$expanded=0<=i.indexOf("/"+o.id),0<i.length&&t(o.$mailboxes)}return c.$accounts&&(o.$expanded|=1==c.$accounts.length),o.$flattenMailboxes({reload:!0}),o.$mailboxes})),this.$futureMailboxesData)},c.prototype.$flattenMailboxes=function(t){function s(e){_.forEach(e,function(e){n.push(e),(t&&t.all||e.$expanded)&&e.children&&0<e.children.length&&s(e.children)})}var n=[],i=[];return!this.$$flattenMailboxes||t&&(t.reload||t.all)?(s(this.$mailboxes),t&&t.all||(this.$$flattenMailboxes=n,t&&t.saveState&&(_.forEach(c.$accounts,function(e){e.$expanded&&i.push("/"+e.id),_.reduce(e.$$flattenMailboxes,function(e,t){return t.$expanded&&e.push("/"+t.id),e},i)}),c.$$resource.post(null,"saveFoldersState",i)))):n=this.$$flattenMailboxes,n},c.prototype.$getMailboxByType=function(s){function n(e){var t=_.find(e,function(e){return e.type==s});return t||angular.forEach(e,function(e){!t&&e.children&&0<e.children.length&&(t=n(e.children))}),t}return n(this.$mailboxes)},c.prototype.$getMailboxByPath=function(s){function n(e){var t=_.find(e,function(e){return e.path==s});return t||angular.forEach(e,function(e){!t&&e.children&&0<e.children.length&&(t=n(e.children))}),t}var e;if(null==(e=n(this.$mailboxes)))throw Error("No mailbox found matching path "+s);return e},c.prototype.$newMailbox=function(e,t){var s=this;return c.$$resource.post(e.toString(),"createFolder",{name:t}).then(function(){s.$getMailboxes({reload:!0})})},c.prototype.getTextSignature=function(e){var t;return e.signature?(t=angular.element("<div>"+e.signature+"</div>"),e.textSignature=_.map(t.contents(),"textContent").join(" ").trim()):e.textSignature="",e.textSignature},c.prototype.$hasCertificate=function(){return this.security&&this.security.hasCLine truncated
|
||||
//# sourceMappingURL=Mailer.services.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"Mailer.services.js","sources":["Mailer/Account.service.js","Mailer/Mailbox.service.js","Mailer/Message.service.js","Mailer/sgImageGallery.service.js","Mailer/VirtualMailbox.service.js","Mailer/MailboxController.js","Mailer/MailboxesController.js","Mailer/MessageController.js","Mailer/MessageEditorController.js","Mailer/sgAccountSection.directive.js","Mailer/sgIMIP.directive.js","Mailer/sgMailboxListItem.directive.js","Mailer/sgMessageListItem.directive.js","Mailer/sgMessageListItemMain.directive.js","Mailer/sgZoomableImage.directive.js"],"names":["Account","futureAccountData","_this","this","then","angular","extend","_","forEach","identities","identity","element","fullName","email","full","signature","textSignature","map","contents","join","trim","$mailboxes","$Mailbox","$unwrapCollection","$q","when","mailboxes","collection","$factory","$timeout","$log","Settings","Resource","Preferences","Mailbox","Message","$$resource","activeUser","$Preferences","$Message","module","e","factory","$findAll","data","$accounts","fetch","o","i","id","refreshUnseenCount","folders","unseenCountFolders","fetchAllUnseenCountFolders","defaults","SOGoMailFetchAllUnseenCountFolders","refreshViewCheck","SOGoRefreshViewCheck","Error","account","$$flattenMailboxes","mailbox","push","includes","isDefined","unseenCount","post","$refreshUnseenCount","cancel","bind","timeInterval","prototype","getLength","$expanded","$flattenMailboxes","length","getItemAtIndex","index","expandedMailboxes","$getMailboxes","options","reload","$futureMailboxesData","$find","_visitForUnseencount","previousMailbox","find","previousMailboxes","children","all","_visitForExpanded","expandedFolders","indexOf","settings","Mail","ExpandedFolders","isString","fromJson","warn","_visit","allMailboxes","saveState","reduce","$getMailboxByType","type","_find","$getMailboxByPath","path","$newMailbox","name","toString","getTextSignature","$hasCertificate","security","hasCertificate","$certificate","$$certificate","reject","$removeCertificate","updateQuota","percent","description","maxQuota","Math","round","usedSpace","l","formatted","maxMessages","messagesCount","$quota","$newMessage","debug","JSON","stringify","undefined","accountId","mailboxPath","message","$absolutePath","asDraft","accountDefaults","AuxiliaryMailAccounts","alwaysSign","sign","alwaysEncrypt","encrypt","editable","isNew","mailto","isObject","$parseMailto","$addDelegate","user","deferred","defer","param","uid","delegates","resolve","users","status","promise","$removeDelegate","splice","$omit","deep","defaultIdentity","value","key","copy","isReadOnly","pick","isDefault","forceDefaultIdentity","futureMailboxData","$account","init","newMailboxData","create","$unwrap","Acl","PRELOAD","BATCH_DELETE_LIMIT","$$Acl","$query","sort","asc","selectedFolder","$refreshTimeout","$virtualMode","$virtualPath","SortingState","parseInt","constant","LOOKAHEAD","SIZE","createMailboxes","level","isSentFolder","isDraftsFolder","quotas","split","component","asCSSIdentifier","isUndefined","uidsMap","headers","$isLoading","$messages","$visibleMessages","$selectedMessages","$id","$acl","threaded","$collapsedThreads","threadsCollapsed","$displayName","$isEditable","isEditable","$isSpecial","$icon","$isNoInferiors","isNoInferiors","$shadowData","selectFolder","$lastVisibleIndex","max","$loadMessage","selectedMessages","updateCache","filter","selected","selectedCount","$unselectMessages","isSelectedMessage","messageId","$selectedMessage","selectedMessage","$selectedMessageIndex","hasSelectedMessage","$filter","sortingAttributes","filters","action","labels","searchInput","match","searchBy","secondFilter","$flaggedOnly","$unseenOnly","$syncToken","syncToken","unseenOnly","flaggedOnly","keys","$filteredLabels","k","f","endIndex","uids","startIndex","loaded","subject","min","loading","futureHeadersData","$unwrapHeaders","flags","isNoSelect","isWritable","getClassName","base","$rename","findParent","parent","parentMailbox","$save","_updateChildren","child","replace","pathRE","oldPath","sibling","localeCompare","RegExp","$compact","$canFolderAs","$setFolderAs","$empty","capitalize","substring","$markAsRead","isread","getLabels","$labels","filteredByLabel","$flagMessages","messages","operation","msgUIDs","forwardMessages","saveSelectedMessages","selectedUIDs","download","exportFolder","filename","open","$delete","$_deleteMessages","firstIndex","forEachRight","selectedIndex","findIndex","updateVisibleMessages","$deleteMessages","batchSize","_deleteMessages","start","end","currentUids","slice","$markOrUnMarkMessagesAsJunk","method","$copyMessages","folder","$moveMessages","$move","parentPath","finally","save","response","error","$reset","childrenArray","collapsedThread","msg","first","collapsed","$futureMailboxData","headersFields","msgObject","hasNewMessages","$topIndex","deleted","j","changed","msgs","zipObject","count","isNaN","threadMember","invokeMap","isError","messageHeaders","$updateSubscribe","subscribed","futureLine truncated
|
||||
{"version":3,"file":"Mailer.services.js","sources":["Mailer/Account.service.js","Mailer/Mailbox.service.js","Mailer/Message.service.js","Mailer/sgImageGallery.service.js","Mailer/VirtualMailbox.service.js","Mailer/MailboxController.js","Mailer/MailboxesController.js","Mailer/MessageController.js","Mailer/MessageEditorController.js","Mailer/sgAccountSection.directive.js","Mailer/sgIMIP.directive.js","Mailer/sgMailboxListItem.directive.js","Mailer/sgMessageListItem.directive.js","Mailer/sgMessageListItemMain.directive.js","Mailer/sgZoomableImage.directive.js"],"names":["Account","futureAccountData","_this","this","then","angular","extend","_","forEach","identities","identity","element","fullName","email","full","signature","textSignature","map","contents","join","trim","$mailboxes","$Mailbox","$unwrapCollection","$q","when","mailboxes","collection","$factory","$timeout","$log","Settings","Resource","Preferences","Mailbox","Message","$$resource","activeUser","$Preferences","$Message","module","e","factory","$findAll","data","$accounts","fetch","o","i","id","refreshUnseenCount","folders","unseenCountFolders","fetchAllUnseenCountFolders","defaults","SOGoMailFetchAllUnseenCountFolders","refreshViewCheck","SOGoRefreshViewCheck","Error","account","$$flattenMailboxes","mailbox","push","includes","isDefined","unseenCount","post","$refreshUnseenCount","cancel","bind","timeInterval","prototype","getLength","$expanded","$flattenMailboxes","length","getItemAtIndex","index","expandedMailboxes","$getMailboxes","options","reload","$futureMailboxesData","$find","_visitForUnseencount","previousMailbox","find","previousMailboxes","children","all","_visitForExpanded","expandedFolders","indexOf","settings","Mail","ExpandedFolders","isString","fromJson","warn","_visit","allMailboxes","saveState","reduce","$getMailboxByType","type","_find","$getMailboxByPath","path","$newMailbox","name","toString","getTextSignature","$hasCertificate","security","hasCertificate","$certificate","$$certificate","reject","$removeCertificate","updateQuota","percent","description","maxQuota","Math","round","usedSpace","l","formatted","maxMessages","messagesCount","$quota","$newMessage","debug","JSON","stringify","undefined","accountId","mailboxPath","message","$absolutePath","asDraft","accountDefaults","AuxiliaryMailAccounts","alwaysSign","sign","alwaysEncrypt","encrypt","editable","isNew","mailto","isObject","$parseMailto","$addDelegate","user","deferred","defer","param","uid","delegates","resolve","users","status","promise","$removeDelegate","splice","$omit","deep","defaultIdentity","value","key","copy","isReadOnly","pick","isDefault","forceDefaultIdentity","futureMailboxData","$account","init","newMailboxData","create","$unwrap","Acl","PRELOAD","BATCH_DELETE_LIMIT","$$Acl","$query","sort","asc","selectedFolder","$refreshTimeout","$virtualMode","$virtualPath","SortingState","parseInt","constant","LOOKAHEAD","SIZE","createMailboxes","level","isSentFolder","isDraftsFolder","quotas","split","component","asCSSIdentifier","isUndefined","uidsMap","headers","$isLoading","$messages","$visibleMessages","$selectedMessages","$id","$acl","threaded","$collapsedThreads","threadsCollapsed","$displayName","$isEditable","isEditable","$isSpecial","$icon","$isNoInferiors","isNoInferiors","$shadowData","selectFolder","$lastVisibleIndex","max","$loadMessage","selectedMessages","updateCache","filter","selected","selectedCount","$unselectMessages","isSelectedMessage","messageId","$selectedMessage","selectedMessage","$selectedMessageIndex","hasSelectedMessage","$filter","sortingAttributes","filters","action","labels","searchInput","match","searchBy","secondFilter","$flaggedOnly","$unseenOnly","$syncToken","syncToken","unseenOnly","flaggedOnly","keys","$filteredLabels","k","f","endIndex","uids","startIndex","loaded","subject","min","loading","futureHeadersData","$unwrapHeaders","flags","isNoSelect","isWritable","getClassName","base","$rename","findParent","parent","parentMailbox","$save","_updateChildren","child","replace","pathRE","oldPath","sibling","localeCompare","RegExp","$compact","$canFolderAs","$setFolderAs","$empty","capitalize","substring","$markAsRead","isread","getLabels","$labels","filteredByLabel","$flagMessages","messages","operation","msgUIDs","forwardMessages","saveSelectedMessages","selectedUIDs","download","exportFolder","filename","open","$delete","$_deleteMessages","firstIndex","forEachRight","selectedIndex","findIndex","updateVisibleMessages","$deleteMessages","batchSize","_deleteMessages","start","end","currentUids","slice","$markOrUnMarkMessagesAsJunk","method","$copyMessages","folder","$moveMessages","$move","parentPath","finally","save","response","error","$reset","childrenArray","collapsedThread","msg","first","collapsed","$futureMailboxData","headersFields","msgObject","hasNewMessages","$topIndex","deleted","j","changed","msgs","zipObject","count","isNaN","threadMember","invokeMap","isError","messageHeaders","$updateSubscribe","subscribed","futureLine truncated
|
||||
@@ -12,10 +12,10 @@
|
||||
|
||||
this.$onInit = function() {
|
||||
$scope.isPopup = stateParent.isPopup;
|
||||
|
||||
this.account = stateAccount;
|
||||
this.autocomplete = {to: {}, cc: {}, bcc: {}};
|
||||
this.autosave = null;
|
||||
|
||||
this.isFullscreen = false;
|
||||
this.hideBcc = (stateMessage.editable.bcc.length === 0);
|
||||
this.hideCc = (stateMessage.editable.cc.length === 0);
|
||||
@@ -218,6 +218,12 @@
|
||||
$event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
if ($event.keyCode == 186 && $event.key == 'ü') { //Key code for separator ';' but is keycode for ü in german keyboard
|
||||
$event.stopPropagation();
|
||||
$event.preventDefault();
|
||||
let element = $window.document.getElementById($event.target.id);
|
||||
element.value = element.value + 'ü'
|
||||
}
|
||||
};
|
||||
|
||||
this.save = function (options) {
|
||||
|
||||
+89
-89
@@ -6135,95 +6135,95 @@ function InterimElementProvider() {
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* @ngdoc module
|
||||
* @name material.core.liveannouncer
|
||||
* @description
|
||||
* AngularJS Material Live Announcer to provide accessibility for Voice Readers.
|
||||
*/
|
||||
MdLiveAnnouncer.$inject = ["$timeout"];
|
||||
angular
|
||||
.module('material.core')
|
||||
.service('$mdLiveAnnouncer', MdLiveAnnouncer);
|
||||
|
||||
/**
|
||||
* @ngdoc service
|
||||
* @name $mdLiveAnnouncer
|
||||
* @module material.core.liveannouncer
|
||||
*
|
||||
* @description
|
||||
*
|
||||
* Service to announce messages to supported screenreaders.
|
||||
*
|
||||
* > The `$mdLiveAnnouncer` service is internally used for components to provide proper accessibility.
|
||||
*
|
||||
* <hljs lang="js">
|
||||
* module.controller('AppCtrl', function($mdLiveAnnouncer) {
|
||||
* // Basic announcement (Polite Mode)
|
||||
* $mdLiveAnnouncer.announce('Hey Google');
|
||||
*
|
||||
* // Custom announcement (Assertive Mode)
|
||||
* $mdLiveAnnouncer.announce('Hey Google', 'assertive');
|
||||
* });
|
||||
* </hljs>
|
||||
*
|
||||
*/
|
||||
function MdLiveAnnouncer($timeout) {
|
||||
/** @private @const @type {!angular.$timeout} */
|
||||
this._$timeout = $timeout;
|
||||
|
||||
/** @private @const @type {!HTMLElement} */
|
||||
this._liveElement = this._createLiveElement();
|
||||
|
||||
/** @private @const @type {!number} */
|
||||
this._announceTimeout = 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name $mdLiveAnnouncer#announce
|
||||
* @description Announces messages to supported screenreaders.
|
||||
* @param {string} message Message to be announced to the screenreader
|
||||
* @param {'off'|'polite'|'assertive'} politeness The politeness of the announcer element.
|
||||
*/
|
||||
MdLiveAnnouncer.prototype.announce = function(message, politeness) {
|
||||
if (!politeness) {
|
||||
politeness = 'polite';
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
self._liveElement.textContent = '';
|
||||
self._liveElement.setAttribute('aria-live', politeness);
|
||||
|
||||
// This 100ms timeout is necessary for some browser + screen-reader combinations:
|
||||
// - Both JAWS and NVDA over IE11 will not announce anything without a non-zero timeout.
|
||||
// - With Chrome and IE11 with NVDA or JAWS, a repeated (identical) message won't be read a
|
||||
// second time without clearing and then using a non-zero delay.
|
||||
// (using JAWS 17 at time of this writing).
|
||||
self._$timeout(function() {
|
||||
self._liveElement.textContent = message;
|
||||
}, self._announceTimeout, false);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a live announcer element, which listens for DOM changes and announces them
|
||||
* to the screenreaders.
|
||||
* @returns {!HTMLElement}
|
||||
* @private
|
||||
*/
|
||||
MdLiveAnnouncer.prototype._createLiveElement = function() {
|
||||
var liveEl = document.createElement('div');
|
||||
|
||||
liveEl.classList.add('md-visually-hidden');
|
||||
liveEl.setAttribute('role', 'status');
|
||||
liveEl.setAttribute('aria-atomic', 'true');
|
||||
liveEl.setAttribute('aria-live', 'polite');
|
||||
|
||||
document.body.appendChild(liveEl);
|
||||
|
||||
return liveEl;
|
||||
};
|
||||
/**
|
||||
* @ngdoc module
|
||||
* @name material.core.liveannouncer
|
||||
* @description
|
||||
* AngularJS Material Live Announcer to provide accessibility for Voice Readers.
|
||||
*/
|
||||
MdLiveAnnouncer.$inject = ["$timeout"];
|
||||
angular
|
||||
.module('material.core')
|
||||
.service('$mdLiveAnnouncer', MdLiveAnnouncer);
|
||||
|
||||
/**
|
||||
* @ngdoc service
|
||||
* @name $mdLiveAnnouncer
|
||||
* @module material.core.liveannouncer
|
||||
*
|
||||
* @description
|
||||
*
|
||||
* Service to announce messages to supported screenreaders.
|
||||
*
|
||||
* > The `$mdLiveAnnouncer` service is internally used for components to provide proper accessibility.
|
||||
*
|
||||
* <hljs lang="js">
|
||||
* module.controller('AppCtrl', function($mdLiveAnnouncer) {
|
||||
* // Basic announcement (Polite Mode)
|
||||
* $mdLiveAnnouncer.announce('Hey Google');
|
||||
*
|
||||
* // Custom announcement (Assertive Mode)
|
||||
* $mdLiveAnnouncer.announce('Hey Google', 'assertive');
|
||||
* });
|
||||
* </hljs>
|
||||
*
|
||||
*/
|
||||
function MdLiveAnnouncer($timeout) {
|
||||
/** @private @const @type {!angular.$timeout} */
|
||||
this._$timeout = $timeout;
|
||||
|
||||
/** @private @const @type {!HTMLElement} */
|
||||
this._liveElement = this._createLiveElement();
|
||||
|
||||
/** @private @const @type {!number} */
|
||||
this._announceTimeout = 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name $mdLiveAnnouncer#announce
|
||||
* @description Announces messages to supported screenreaders.
|
||||
* @param {string} message Message to be announced to the screenreader
|
||||
* @param {'off'|'polite'|'assertive'} politeness The politeness of the announcer element.
|
||||
*/
|
||||
MdLiveAnnouncer.prototype.announce = function(message, politeness) {
|
||||
if (!politeness) {
|
||||
politeness = 'polite';
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
self._liveElement.textContent = '';
|
||||
self._liveElement.setAttribute('aria-live', politeness);
|
||||
|
||||
// This 100ms timeout is necessary for some browser + screen-reader combinations:
|
||||
// - Both JAWS and NVDA over IE11 will not announce anything without a non-zero timeout.
|
||||
// - With Chrome and IE11 with NVDA or JAWS, a repeated (identical) message won't be read a
|
||||
// second time without clearing and then using a non-zero delay.
|
||||
// (using JAWS 17 at time of this writing).
|
||||
self._$timeout(function() {
|
||||
self._liveElement.textContent = message;
|
||||
}, self._announceTimeout, false);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a live announcer element, which listens for DOM changes and announces them
|
||||
* to the screenreaders.
|
||||
* @returns {!HTMLElement}
|
||||
* @private
|
||||
*/
|
||||
MdLiveAnnouncer.prototype._createLiveElement = function() {
|
||||
var liveEl = document.createElement('div');
|
||||
|
||||
liveEl.classList.add('md-visually-hidden');
|
||||
liveEl.setAttribute('role', 'status');
|
||||
liveEl.setAttribute('aria-atomic', 'true');
|
||||
liveEl.setAttribute('aria-live', 'polite');
|
||||
|
||||
document.body.appendChild(liveEl);
|
||||
|
||||
return liveEl;
|
||||
};
|
||||
|
||||
})();
|
||||
(function(){
|
||||
|
||||
Reference in new issue
Block a user