Skip to content

Commit b01f619

Browse files
committed
MOBILE-1987 utils: Add icons to error messages
1 parent 2cdb171 commit b01f619

File tree

2 files changed

+41
-21
lines changed

2 files changed

+41
-21
lines changed

www/core/lib/util.js

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,6 @@ angular.module('mm.core')
664664
* If not defined, modal won't be automatically closed.
665665
*/
666666
self.showErrorModal = function(errorMessage, needsTranslate, autocloseTime) {
667-
var errorKey = 'mm.core.error',
668-
langKeys = [errorKey],
669-
matches;
670-
671667
if (angular.isObject(errorMessage)) {
672668
// We received an object instead of a string. Search for common properties.
673669
if (typeof errorMessage.content != 'undefined') {
@@ -684,31 +680,33 @@ angular.module('mm.core')
684680
}
685681

686682
// Try to remove tokens from the contents.
687-
matches = errorMessage.match(/token"?[=|:]"?(\w*)/, '');
683+
var matches = errorMessage.match(/token"?[=|:]"?(\w*)/, '');
688684
if (matches && matches[1]) {
689685
errorMessage = errorMessage.replace(new RegExp(matches[1], 'g'), 'secret');
690686
}
691687
}
692688

693-
if (needsTranslate) {
694-
langKeys.push(errorMessage);
695-
}
696-
697-
$translate(langKeys).then(function(translations) {
698-
var message = $mmText.decodeHTML(needsTranslate ? translations[errorMessage] : errorMessage),
699-
popup = $ionicPopup.alert({
700-
title: $mmText.decodeHTML(translations[errorKey]),
701-
template: addFormatTextIfNeeded(message) // Add format-text to handle links.
702-
});
689+
var message = $mmText.decodeHTML(needsTranslate ? $translate.instant(errorMessage) : errorMessage),
690+
popup = $ionicPopup.alert({
691+
title: getErrorTitle(message),
692+
template: addFormatTextIfNeeded(message) // Add format-text to handle links.
693+
});
703694

704-
if (typeof autocloseTime != 'undefined' && !isNaN(parseInt(autocloseTime))) {
705-
$timeout(function() {
706-
popup.close();
707-
}, parseInt(autocloseTime));
708-
}
709-
});
695+
if (typeof autocloseTime != 'undefined' && !isNaN(parseInt(autocloseTime))) {
696+
$timeout(function() {
697+
popup.close();
698+
}, parseInt(autocloseTime));
699+
}
710700
};
711701

702+
function getErrorTitle(message) {
703+
if (message == $translate.instant('mm.core.networkerrormsg')) {
704+
return '<span class="mm-icon-with-badge"><i class="icon ion-wifi"></i>\
705+
<i class="icon ion-alert-circled mm-icon-badge"></i></span>';
706+
}
707+
return $mmText.decodeHTML($translate.instant('mm.core.error'));
708+
}
709+
712710
/**
713711
* Show a modal with an error message specifying a default message if error is empty.
714712
*

www/core/scss/styles.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,28 @@ mm-timer {
694694
max-width: 100%;
695695
}
696696

697+
.popup-container .popup-title
698+
699+
700+
.mm-icon-with-badge {
701+
position: relative;
702+
703+
.icon {
704+
font-size: $button-large-icon-size;
705+
}
706+
707+
.mm-icon-badge {
708+
width: auto;
709+
height: auto;
710+
margin: 0;
711+
position: absolute;
712+
top: -18px;
713+
right: -8px;
714+
color: red;
715+
font-size: $button-large-icon-size / 2;
716+
}
717+
}
718+
697719
.popup-container.mm-nohead .popup-head {
698720
display: none;
699721
}

0 commit comments

Comments
 (0)