This commit is contained in:
MaysWind 2016-05-23 21:57:58 +08:00
parent b7f7959df5
commit 62ee432fd5
5 changed files with 18 additions and 11 deletions

View file

@ -1,7 +1,7 @@
(function () {
'use strict';
angular.module('ariaNg').controller('Aria2SettingsController', ['$scope', '$location', '$timeout', 'SweetAlert', 'translateFilter', 'ariaNgConstants', 'aria2AvailableOptions', 'aria2RpcService', function ($scope, $location, $timeout, SweetAlert, translateFilter, ariaNgConstants, aria2AvailableOptions, aria2RpcService) {
angular.module('ariaNg').controller('Aria2SettingsController', ['$scope', '$location', '$timeout', 'ariaNgConstants', 'aria2AvailableOptions', 'aria2RpcService', 'utils', function ($scope, $location, $timeout, ariaNgConstants, aria2AvailableOptions, aria2RpcService, utils) {
var location = $location.path().substring($location.path().lastIndexOf('/') + 1);
var pendingSaveRequest = {};
@ -25,12 +25,7 @@
} else if (location == 'advanced') {
return aria2AvailableOptions.advancedOptions;
} else {
SweetAlert.swal({
title: translateFilter('Error'),
text: translateFilter('Type is illegal!'),
type: 'error',
confirmButtonText: translateFilter('OK')
});
utils.alert('Type is illegal!');
}
};

View file

@ -37,12 +37,15 @@
});
};
$rootScope.$on('$locationChangeStart', function (event) {
SweetAlert.close();
});
$rootScope.$on('$routeChangeStart', function (event, next, current) {
var location = $location.path();
setNavbarSelected(location);
$document.unbind('keypress');
SweetAlert.close();
});
}]);
})();

View file

@ -1,7 +1,7 @@
(function () {
'use strict';
angular.module('ariaNg').factory('utils', ['$location', '$base64', 'ariaNgConstants', function ($location, $base64, ariaNgConstants) {
angular.module('ariaNg').factory('utils', ['$location', '$timeout', '$base64', 'SweetAlert', 'translateFilter', 'ariaNgConstants', function ($location, $timeout, $base64, SweetAlert, translateFilter, ariaNgConstants) {
return {
generateUniqueId: function () {
var sourceId = ariaNgConstants.appPrefix + '_' + Math.round(new Date().getTime() / 1000) + '_' + Math.random();
@ -9,6 +9,16 @@
return hashedId;
},
alert: function (text) {
$timeout(function () {
SweetAlert.swal({
title: translateFilter('Error'),
text: translateFilter(text),
type: 'error',
confirmButtonText: translateFilter('OK')
});
}, 100);
},
replaceArray: function (sourceArray, targetArray, keyProperty) {
if (!targetArray || !sourceArray || sourceArray.length != targetArray.length) {
return false;

View file

@ -8,7 +8,7 @@
overflow-y: hidden;
}
.skin-aria-ng, h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
.skin-aria-ng, h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6, .sweet-alert {
font-family: 'Hiragino Sans GB', 'Microsoft YaHei', 'STHeiti', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

View file

@ -67,6 +67,5 @@
</div>
</div>
</div>
<div class="row tip"></div>
</div>
</section>