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

enrichedheadline-directive.js « enrichedheadline « angularjs « CoreHome « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6a809cd7deef6b97a9e5522c9f4d25782ad7437c (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
/*!
 * Piwik - Web Analytics
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

/**
 * Usage:
 *
 * <h2 piwik-enriched-headline>All Websites Dashboard</h2>
 * -> uses "All Websites Dashboard" as featurename
 *
 * <h2 piwik-enriched-headline feature-name="All Websites Dashboard">All Websites Dashboard (Total: 309 Visits)</h2>
 * -> custom featurename
 *
 * <h2 piwik-enriched-headline help-url="http://piwik.org/guide">All Websites Dashboard</h2>
 * -> shows help icon and links to external url
 *
 * <h2 piwik-enriched-headline>All Websites Dashboard
 *     <div class="inlineHelp>My <strong>inline help</strong></div>
 * </h2>
 * -> shows help icon to display inline help on click. Note: You can combine inlinehelp and help-url
 */
angular.module('piwikApp').directive('piwikEnrichedHeadline', function($document, piwik, $filter){
    var defaults = {
        helpUrl: ''
    };

    return {
        transclude: true,
        restrict: 'A',
        scope: {
            helpUrl: '@',
            featureName: '@'
        },
        templateUrl: 'plugins/CoreHome/angularjs/enrichedheadline/enrichedheadline.html?cb=' + piwik.cacheBuster,
        compile: function (element, attrs) {

            for (var index in defaults) {
               if (!attrs[index]) { attrs[index] = defaults[index]; }
            }

            return function (scope, element, attrs) {

                var helpNode = $('[ng-transclude] .inlineHelp', element);

                if ((!helpNode || !helpNode.length) && element.next()) {
                    // hack for reports :(
                    helpNode = element.next().find('.reportDocumentation');
                }

                if (helpNode && helpNode.length) {
                    if ($.trim(helpNode.text())) {
                        scope.inlineHelp = $.trim(helpNode.html());
                    }
                    helpNode.remove();
                }

                if (!attrs.featureName) {
                    attrs.featureName = $.trim(element.text());
                }
            };
        }
    };
});