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

marketplace.directive.js « marketplace « angularjs « Marketplace « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7801e8870d17c4f8198f2ef53052c302a58ca9c1 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*!
 * Matomo - free/libre analytics platform
 *
 * @link https://matomo.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

/**
 * Usage:
 * <div piwik-marketplace>
 */
(function () {

    angular.module('piwikApp').directive('piwikMarketplace', piwikMarketplace);

    piwikMarketplace.$inject = ['piwik', '$timeout'];

    function piwikMarketplace(piwik, $timeout){

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

                return function (scope, element, attrs) {

                    $timeout(function () {


                        $('.installAllPaidPlugins').click(function (event) {
                            event.preventDefault();

                            piwikHelper.modalConfirm('#installAllPaidPluginsAtOnce');
                        });

                        // Keeps the plugin descriptions the same height
                        $('.marketplace .plugin .description').dotdotdot({
                            after: 'a.more',
                            watch: 'window'
                        });

                        function syncMaxHeight2 (selector) {

                            if (!selector) {
                                return;
                            }

                            var $nodes = $(selector);

                            if (!$nodes || !$nodes.length) {
                                return;
                            }

                            var maxh3 = null;
                            var maxMeta = null;
                            var maxFooter = null;
                            var nodesToUpdate = [];
                            var lastTop = 0;
                            $nodes.each(function (index, node) {
                                var $node = $(node);
                                var top   = $node.offset().top;

                                if (lastTop !== top) {
                                    nodesToUpdate = [];
                                    lastTop = top;
                                    maxh3 = null;
                                    maxMeta = null;
                                    maxFooter = null;
                                }

                                nodesToUpdate.push($node);

                                var heightH3 = $node.find('h3').height();
                                var heightMeta = $node.find('.metadata').height();
                                var heightFooter = $node.find('.footer').height();

                                if (!maxh3) {
                                    maxh3 = heightH3;
                                } else if (maxh3 < heightH3) {
                                    maxh3 = heightH3;
                                }

                                if (!maxMeta) {
                                    maxMeta = heightMeta;
                                } else if (maxMeta < heightMeta) {
                                    maxMeta = heightMeta;
                                }

                                if (!maxFooter) {
                                    maxFooter = heightFooter;
                                } else if (maxFooter < heightFooter) {
                                    maxFooter = heightFooter;
                                }

                                $.each(nodesToUpdate, function (index, $node) {
                                    if (maxh3) {
                                        $node.find('h3').height(maxh3 + 'px');
                                    }
                                    if (maxMeta) {
                                        $node.find('.metadata').height(maxMeta + 'px');
                                    }
                                    if (maxFooter) {
                                        $node.find('.footer').height(maxFooter + 'px');
                                    }
                                });
                            });
                        }
                        syncMaxHeight2('.marketplace .plugin');

                    });
                };
            }
        };
    }
})();