Welcome to mirror list, hosted at ThFree Co, Russian Federation.

DialogService.js « services « scripts « ngax « webroot « Server « Duplicati - github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 88d270e972e4d484a4479e9b1953981eb965bbcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
backupApp.service('DialogService', function() {
    var state = this.state = {
    	CurrentItem: null,
    	Queue: []
    };

    var self = this;

    this.watch = function(scope, m) {
        scope.$on('dialogservicechanged', function() {
            if (m) m();

            $timeout(function() {
                scope.$digest();
            });
        });

        if (m) $timeout(m);
        return state;
    };


    this.enqueueDialog = function(config) {
    	if (config == null || config.message == null)
    		return;

    	config.title = config.title || 'Information';
    	config.buttons = config.buttons || ['OK'];    	

		state.Queue.push(config);
		if (state.CurrentItem == null)
			this.dismissCurrent();

    	config.dismiss = function() {
    		if (state.CurrentItem == this)
    			self.dismissCurrent();
    	};

    	return config;
    };

    this.alert = function(message) {
    	return this.enqueueDialog({'message': message});
    };

    this.confirm = function(message, callback) {
    	return this.enqueueDialog({
    		'message': message, 
    		'callback': callback, 
    		'buttons': ['Cancel', 'OK']
    	});
    };

    this.accept = function(message, callback) {
    	return this.enqueueDialog({
    		'message': message, 
    		'callback': callback, 
    		'buttons': ['OK']
    	});
    };

    this.dialog = function(title, message, buttons, callback, onshow) {
    	return this.enqueueDialog({
    		'message': message, 
    		'title': title,
    		'callback': callback, 
    		'buttons': buttons,
    		'onshow': onshow
    	});
    };

    this.dismissCurrent = function() {
    	if (state.CurrentItem != null) {
    		if (state.CurrentItem.ondismiss)
    			state.CurrentItem.ondismiss();

    		state.CurrentItem = null;
    	}

    	if (state.Queue.length > 0) {
    		state.CurrentItem = state.Queue[0];
    		state.Queue.shift();

    		if (state.CurrentItem.onshow)
    			state.CurrentItem.onshow();
    	}
    };

    this.dismissAll = function() {
		while (state.CurrentItem != null){
			this.dismissCurrent();
		}
    };

});