diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-09-24 13:11:29 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-09-24 13:11:29 +0400 |
commit | 810f07c4048cd77190101786b4d1f8b525464bc0 (patch) | |
tree | cb8d7dc0939e4bbd4664504e95179c5dc1ef4f9c /plugins/Feedback | |
parent | ecb25b4100cb1ebbc3009061a96cc35c66100e47 (diff) |
refs #5983 started to apply the angular style guide. refactored models, use named functions, IIFE
Diffstat (limited to 'plugins/Feedback')
3 files changed, 47 insertions, 35 deletions
diff --git a/plugins/Feedback/angularjs/ratefeature/ratefeature-controller.js b/plugins/Feedback/angularjs/ratefeature/ratefeature-controller.js index b4dbd1a70a..36a1e8c146 100644 --- a/plugins/Feedback/angularjs/ratefeature/ratefeature-controller.js +++ b/plugins/Feedback/angularjs/ratefeature/ratefeature-controller.js @@ -4,20 +4,23 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +(function () { + angular.module('piwikApp').controller('RateFeatureController', RateFeatureController); -angular.module('piwikApp').controller('RateFeatureController', function($scope, rateFeatureModel, $filter){ + function RateFeatureController($scope, rateFeatureModel, $filter){ - $scope.dislikeFeature = function () { - $scope.like = false; - }; + $scope.dislikeFeature = function () { + $scope.like = false; + }; - $scope.likeFeature = function () { - $scope.like = true; - }; + $scope.likeFeature = function () { + $scope.like = true; + }; - $scope.sendFeedback = function (message) { - rateFeatureModel.sendFeedbackForFeature($scope.title, $scope.like, message); - $scope.ratingDone = true; - // alert($filter('translate')('Feedback_ThankYou')); - }; -}); + $scope.sendFeedback = function (message) { + rateFeatureModel.sendFeedbackForFeature($scope.title, $scope.like, message); + $scope.ratingDone = true; + // alert($filter('translate')('Feedback_ThankYou')); + }; + } +})(); diff --git a/plugins/Feedback/angularjs/ratefeature/ratefeature-directive.js b/plugins/Feedback/angularjs/ratefeature/ratefeature-directive.js index c5f4c32a58..0b92956f84 100644 --- a/plugins/Feedback/angularjs/ratefeature/ratefeature-directive.js +++ b/plugins/Feedback/angularjs/ratefeature/ratefeature-directive.js @@ -9,14 +9,18 @@ * Usage: * <div piwik-rate-feature title="My Feature Name"> */ -angular.module('piwikApp').directive('piwikRateFeature', function($document, piwik, $filter){ +(function () { + angular.module('piwikApp').directive('piwikRateFeature', piwikRateFeature); - return { - restrict: 'A', - scope: { - title: '@' - }, - templateUrl: 'plugins/Feedback/angularjs/ratefeature/ratefeature.html?cb=' + piwik.cacheBuster, - controller: 'RateFeatureController' - }; -});
\ No newline at end of file + function piwikRateFeature($document, piwik, $filter){ + + return { + restrict: 'A', + scope: { + title: '@' + }, + templateUrl: 'plugins/Feedback/angularjs/ratefeature/ratefeature.html?cb=' + piwik.cacheBuster, + controller: 'RateFeatureController' + }; + } +})();
\ No newline at end of file diff --git a/plugins/Feedback/angularjs/ratefeature/ratefeature-model.js b/plugins/Feedback/angularjs/ratefeature/ratefeature-model.js index b2c9f9009c..934a437e10 100644 --- a/plugins/Feedback/angularjs/ratefeature/ratefeature-model.js +++ b/plugins/Feedback/angularjs/ratefeature/ratefeature-model.js @@ -5,18 +5,23 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -angular.module('piwikApp').factory('rateFeatureModel', function (piwikApi) { +(function () { + angular.module('piwikApp').factory('rateFeatureModel', rateFeatureModel); - var model = {}; + function rateFeatureModel(piwikApi) { - model.sendFeedbackForFeature = function (featureName, like, message) { - return piwikApi.fetch({ - method: 'Feedback.sendFeedbackForFeature', - featureName: featureName, - like: like ? '1' : '0', - message: message + '' - }); - }; + return { + sendFeedbackForFeature: sendFeedbackForFeature + }; - return model; -}); + function sendFeedbackForFeature (featureName, like, message) { + return piwikApi.fetch({ + method: 'Feedback.sendFeedbackForFeature', + featureName: featureName, + like: like ? '1' : '0', + message: message + '' + }); + }; + + } +})(); |