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

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2014-09-11 23:46:44 +0400
committerdiosmosis <benaka@piwik.pro>2014-09-11 23:46:44 +0400
commit541c4e1a2c696e9169553d686d33d626ef1733fb (patch)
treecd78f13cda5aea2fae55a0d62a65525e92f12ff3 /plugins
parentf8ab11c547898f4f7acd57fc605373bd24465a8c (diff)
Allow piwik-siteselector angularjs directive to be used w/ ng-model for databinding.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/CoreHome/angularjs/siteselector/siteselector-directive.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/plugins/CoreHome/angularjs/siteselector/siteselector-directive.js b/plugins/CoreHome/angularjs/siteselector/siteselector-directive.js
index a5ebd0f061..7936cbfc96 100644
--- a/plugins/CoreHome/angularjs/siteselector/siteselector-directive.js
+++ b/plugins/CoreHome/angularjs/siteselector/siteselector-directive.js
@@ -45,18 +45,24 @@ angular.module('piwikApp').directive('piwikSiteselector', function($document, pi
allSitesText: '@',
allSitesLocation: '@'
},
+ require: "?ngModel",
templateUrl: 'plugins/CoreHome/angularjs/siteselector/siteselector.html?cb=' + piwik.cacheBuster,
controller: 'SiteSelectorController',
compile: function (element, attrs) {
for (var index in defaults) {
- if (!attrs[index]) { attrs[index] = defaults[index]; }
+ if (attrs[index] === undefined) {
+ attrs[index] = defaults[index];
+ }
}
- return function (scope, element, attrs) {
+ return function (scope, element, attrs, ngModel) {
+ if (ngModel) {
+ scope.selectedSite.id = ngModel.$viewValue;
+ }
// selectedSite.id|.name + model is hard-coded but actually the directive should not know about this
- scope.selectedSite.id = attrs.siteid;
+ scope.selectedSite.id = scope.selectedSite.id || attrs.siteid;
scope.selectedSite.name = attrs.sitename;
if (!attrs.siteid || !attrs.sitename) {
@@ -67,6 +73,10 @@ angular.module('piwikApp').directive('piwikSiteselector', function($document, pi
if (newValue != oldValue) {
element.attr('siteid', newValue);
element.trigger('change', scope.selectedSite);
+
+ if (ngModel) {
+ ngModel.$setViewValue(newValue);
+ }
}
});