summaryrefslogtreecommitdiffstats
path: root/src/main/resources/controllers/locationFieldController.js
blob: 8117ed799711373b418ff63212d8042634f3ce42 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
angular.module('location').controller('locationFieldController', ['$scope', '$window',
    function locationFieldController($scope, $window) {

    $scope.data = { id: 0, password: '' }

    $scope.$watch('data', function(newValue) {
        $scope.model = JSON.stringify(newValue);
    }, true);

    $scope.selectLocation = function selectLocation($event, id) {
        if (angular.element($event.target).hasClass('bwlp-password-input')) return;
        $scope.data.password = '';
        if ($scope.data.id === id) {
            $scope.data.id = 0;
            angular.element('.selected-location').removeClass('selected-location');
            return;
        }
        $scope.data.id = id;
        angular.element('.selected-location').removeClass('selected-location');
        angular.element($event.currentTarget).addClass('selected-location');
    };

}]);