update Piwik to version 2.16 (fixes #91)

This commit is contained in:
oliver 2016-04-10 18:55:57 +02:00
commit d885a4baa9
5833 changed files with 418860 additions and 226988 deletions

View file

@ -0,0 +1,34 @@
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
(function () {
angular.module('piwikApp').controller('NotificationController', NotificationController);
NotificationController.$inject = ['piwikApi'];
function NotificationController(piwikApi) {
/**
* Marks a persistent notification as read so it will not reappear on the next page
* load.
*/
this.markNotificationAsRead = function () {
var notificationId = this.notificationId;
if (!notificationId) {
return;
}
piwikApi.post(
{ // GET params
module: 'CoreHome',
action: 'markNotificationAsRead'
},
{ // POST params
notificationId: notificationId
}
);
};
}
})();

View file

@ -0,0 +1,8 @@
<div class="notification system">
<button type="button" class="close" data-dismiss="alert" ng-if="!noclear" ng-click="notification.markNotificationAsRead()">&times;</button>
<strong ng-if="title">{{ title }}</strong>
<!-- ng-transclude causes directive child elements to be added here -->
<div ng-transclude></div>
</div>

View file

@ -0,0 +1,95 @@
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
/**
* Directive to show a notification.
*
* Note: using this directive is preferred over the Notification class (which uses jquery
* exclusively).
*
* Supports the following attributes:
*
* * **context**: Either 'success', 'error', 'info', 'warning'
* * **type**: Either 'toast', 'persistent', 'transient'
* * **noclear**: If truthy, no clear button is displayed. For persistent notifications, has no effect.
*
* Usage:
*
* <div piwik-notification context="success" type="persistent" noclear="true">
* <strong>Info: </strong>My notification message.
* </div>
*/
(function () {
angular.module('piwikApp').directive('piwikNotification', piwikNotification);
piwikNotification.$inject = ['piwik', '$timeout'];
function piwikNotification(piwik, $timeout) {
return {
restrict: 'A',
scope: {
notificationId: '@?',
title: '@?notificationTitle', // TODO: shouldn't need this since the title can be specified within
// HTML of the node that uses the directive.
context: '@?',
type: '@?',
noclear: '@?'
},
transclude: true,
templateUrl: 'plugins/CoreHome/angularjs/notification/notification.directive.html?cb=' + piwik.cacheBuster,
controller: 'NotificationController',
controllerAs: 'notification',
link: function (scope, element) {
if (scope.notificationId) {
closeExistingNotificationHavingSameIdIfNeeded(scope.notificationId, element);
}
if (scope.context) {
element.children('.notification').addClass('notification-' + scope.context);
}
if (scope.type == 'persistent') {
// otherwise it is never possible to dismiss the notification
scope.noclear = false;
}
if ('toast' == scope.type) {
addToastEvent();
}
if (!scope.noclear) {
addCloseEvent();
}
function addToastEvent() {
$timeout(function () {
element.fadeOut('slow', function() {
element.remove();
});
}, 12 * 1000);
}
function addCloseEvent() {
element.on('click', '.close', function (event) {
if (event && event.delegateTarget) {
angular.element(event.delegateTarget).remove();
}
});
}
function closeExistingNotificationHavingSameIdIfNeeded(id, notificationElement) {
// TODO: instead of doing a global query for notification, there should be a notification-container
// directive that manages notifications.
var existingNode = angular.element('[notification-id=' + id + ']').not(notificationElement);
if (existingNode && existingNode.length) {
existingNode.remove();
}
}
}
};
}
})();

View file

@ -0,0 +1,34 @@
.system.notification {
.alert;
// We have to use !important because the default button style is crazy
.close {
position: relative;
top: -5px;
right: -10px;
padding: 0 !important;
background: transparent !important;
border: none !important;
float: right;
font-size: 20px !important;
font-weight: bold;
line-height: 20px !important;
color: inherit !important;
opacity: 0.3;
filter: alpha(opacity=30);
}
&.notification-success {
.alert-success;
}
&.notification-warning {
.alert-warning;
}
&.notification-danger,
&.notification-error {
.alert-danger;
}
&.notification-info {
.alert-info;
}
}