gui: Use one instead of on to have callbacks fire one (#5085)

This commit is contained in:
Audrius Butkevicius 2018-07-29 20:15:24 +01:00 committed by Jakob Borg
parent 93fdd1c012
commit 24d307531d

View File

@ -1099,10 +1099,10 @@ angular.module('syncthing.core')
$scope.logging.timer = $timeout($scope.logging.fetch); $scope.logging.timer = $timeout($scope.logging.fetch);
var textArea = $('#logViewerText'); var textArea = $('#logViewerText');
textArea.on("scroll", $scope.logging.onScroll); textArea.on("scroll", $scope.logging.onScroll);
$('#logViewer').modal().on('shown.bs.modal', function() { $('#logViewer').modal().one('shown.bs.modal', function() {
// Scroll to bottom. // Scroll to bottom.
textArea.scrollTop(textArea[0].scrollHeight); textArea.scrollTop(textArea[0].scrollHeight);
}).on('hidden.bs.modal', function () { }).one('hidden.bs.modal', function () {
$timeout.cancel($scope.logging.timer); $timeout.cancel($scope.logging.timer);
textArea.off("scroll", $scope.logging.onScroll); textArea.off("scroll", $scope.logging.onScroll);
$scope.logging.timer = null; $scope.logging.timer = null;
@ -1178,7 +1178,7 @@ angular.module('syncthing.core')
$scope.tmpOptions.upgrades = "candidate"; $scope.tmpOptions.upgrades = "candidate";
} }
$scope.tmpGUI = angular.copy($scope.config.gui); $scope.tmpGUI = angular.copy($scope.config.gui);
$('#settings').modal().on('hidden.bs.modal', function () { $('#settings').modal().one('hidden.bs.modal', function () {
window.location.hash = ""; window.location.hash = "";
}); });
}; };
@ -1560,15 +1560,12 @@ angular.module('syncthing.core')
$scope.editFolderModal = function () { $scope.editFolderModal = function () {
$scope.folderPathErrors = {}; $scope.folderPathErrors = {};
$scope.folderEditor.$setPristine(); $scope.folderEditor.$setPristine();
$('#editFolder').modal().on({ $('#editFolder').modal().one('shown.bs.tab', function (e) {
'shown.bs.tab': function (e) { if (e.target.attributes.href.value === "#folder-ignores") {
if (e.target.attributes.href.value === "#folder-ignores") { $('#folder-ignores textarea').focus();
$('#folder-ignores textarea').focus();
}
},
'hidden.bs.modal': function () {
window.location.hash = "";
} }
}).one('hidden.bs.modal', function () {
window.location.hash = "";
}); });
}; };
@ -1884,10 +1881,10 @@ angular.module('syncthing.core')
var closed = false; var closed = false;
var modalShown = $q.defer(); var modalShown = $q.defer();
$('#restoreVersions').modal().on('hidden.bs.modal', function () { $('#restoreVersions').modal().one('hidden.bs.modal', function () {
closed = true; closed = true;
resetRestoreVersions(); resetRestoreVersions();
}).on('shown.bs.modal', function() { }).one('shown.bs.modal', function() {
modalShown.resolve(); modalShown.resolve();
}); });
@ -2060,7 +2057,7 @@ angular.module('syncthing.core')
$scope.showNeed = function (folder) { $scope.showNeed = function (folder) {
$scope.neededFolder = folder; $scope.neededFolder = folder;
refreshNeed(folder); refreshNeed(folder);
$('#needed').modal().on('hidden.bs.modal', function () { $('#needed').modal().one('hidden.bs.modal', function () {
$scope.neededFolder = undefined; $scope.neededFolder = undefined;
$scope.needed = undefined; $scope.needed = undefined;
$scope.neededCurrentPage = 1; $scope.neededCurrentPage = 1;
@ -2078,7 +2075,7 @@ angular.module('syncthing.core')
$scope.remoteNeedFolders.push(folder); $scope.remoteNeedFolders.push(folder);
$scope.refreshRemoteNeed(folder, 1, 10); $scope.refreshRemoteNeed(folder, 1, 10);
}); });
$('#remoteNeed').modal().on('hidden.bs.modal', function () { $('#remoteNeed').modal().one('hidden.bs.modal', function () {
resetRemoteNeed(); resetRemoteNeed();
}); });
}; };
@ -2086,7 +2083,7 @@ angular.module('syncthing.core')
$scope.showFailed = function (folder) { $scope.showFailed = function (folder) {
$scope.failed.folder = folder; $scope.failed.folder = folder;
$scope.failed = $scope.refreshFailed(1, 10); $scope.failed = $scope.refreshFailed(1, 10);
$('#failed').modal().on('hidden.bs.modal', function () { $('#failed').modal().one('hidden.bs.modal', function () {
$scope.failed = {}; $scope.failed = {};
}); });
}; };