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

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

/**
 * If the given text or resolved expression matches any text within the element, the matching text will be wrapped
 * with a class.
 *
 * Example:
 * <div piwik-autocomplete-matched="'text'">My text</div> ==> <div>My <span class="autocompleteMatched">text</span></div>
 *
 * <div piwik-autocomplete-matched="searchTerm">{{ name }}</div>
 * <input type="text" ng-model="searchTerm">
 */
(function () {
    angular.module('piwikApp.directive').directive('piwikAttributes', piwikAttributes);

    piwikAttributes.$inject = ['$sanitize'];

    function piwikAttributes(piwik, $sanitize) {

        return {
            link: function (scope, element, attrs) {
                attrs.piwikAttributes = JSON.parse(attrs.piwikAttributes);

                if (angular.isObject(attrs.piwikAttributes)) {
                    angular.forEach(attrs.piwikAttributes, function (value, key) {
                        element.attr(key, value);
                    });
                }
            }
        };
    }
})();