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

dialog.js « directives « common « angularjs « CoreHome « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 86762db83f4b3b624ad880a9e9344a93882eece5 (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
/*!
 * Piwik - free/libre analytics platform
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

/**
 * Usage:
 * <div piwik-dialog="showDialog">...</div>
 * Will show dialog once showDialog evaluates to true.
 *
 * <div piwik-dialog="showDialog" yes="executeMyFunction();">
 * ... <input type="button" role="yes" value="button">
 * </div>
 * Will execute the "executeMyFunction" function in the current scope once the yes button is pressed.
 */
angular.module('piwikApp.directive').directive('piwikDialog', function(piwik) {

    return {
        restrict: 'A',
        link: function(scope, element, attrs) {

            element.css('display', 'none');

            element.on( "dialogclose", function() {
                scope.$eval(attrs.piwikDialog+'=false');
            });

            scope.$watch(attrs.piwikDialog, function(newValue, oldValue) {
                if (newValue) {
                    piwik.helper.modalConfirm(element, {yes: function() {
                        if (attrs.yes) {
                            scope.$eval(attrs.yes);
                        }
                    }});
                }
            });
        }
    };
});