diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2016-03-10 00:55:45 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2016-04-11 05:11:33 +0300 |
commit | b52ae4e7e488e0474d67c54578e1d6c1aa066bff (patch) | |
tree | f94b02f774cbc24faaa18f29ee1e19fef8b338af /plugins/CoreHome/angularjs/common/directives | |
parent | 6ba622a68a26792af8cc22131f488f7ff5189d2c (diff) |
refs #7983 let plugins add or remove fields to websites and better settings api
Diffstat (limited to 'plugins/CoreHome/angularjs/common/directives')
-rw-r--r-- | plugins/CoreHome/angularjs/common/directives/attributes.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/plugins/CoreHome/angularjs/common/directives/attributes.js b/plugins/CoreHome/angularjs/common/directives/attributes.js new file mode 100644 index 0000000000..c8285d9e8e --- /dev/null +++ b/plugins/CoreHome/angularjs/common/directives/attributes.js @@ -0,0 +1,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); + }); + } + } + }; + } +})(); |