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,90 @@
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
/**
* AngularJS service that handles the popover query parameter for Piwik's angular code.
*
* If the popover parameter's first part is the name of an existing AngularJS directive,
* a dialog is created using ngDialog with the contents being an element with that directive.
* The other parts of the parameter are treated as attributes for the element, eg,
* `"mydirective:myparam=val:myotherparam=val2"`.
*
* It should not be necessary to use this service directly, instead the piwik-dialogtoggler
* directive should be used.
*
* TODO: popover as a query parameter refers less to dialogs and more to any popup window
* (ie, not necessarily modal). should replace it w/ 'dialog' or maybe 'modal'.
*/
(function () {
angular.module('piwikApp').factory('piwikDialogtogglerUrllistener', piwikDialogtogglerUrllistener);
piwikDialogtogglerUrllistener.$inject = ['$rootScope', '$location', '$injector', '$rootElement', 'ngDialog'];
function piwikDialogtogglerUrllistener($rootScope, $location, $injector, $rootElement, ngDialog) {
var service = {},
dialogQueryParamName = 'popover';
function getHtmlFromDialogQueryParam(paramValue) {
var info = paramValue.split(':'),
directiveName = info.shift(),
dialogContent = '';
dialogContent += '<div ' + directiveName;
angular.forEach(info, function (argumentAssignment) {
var pair = argumentAssignment.split('='),
key = pair[0],
value = pair[1];
dialogContent += ' ' + key + '="' + decodeURIComponent(value) + '"';
});
dialogContent += '/>';
return dialogContent;
}
function directiveExists(directiveAttributeString) {
// NOTE: directiveNormalize is not exposed by angularjs and the devs don't seem to want to expose it:
// https://github.com/angular/angular.js/issues/7955
// so logic is duplicated here.
var PREFIX_REGEXP = /^(x[\:\-_]|data[\:\-_])/i,
directiveName = angular.element.camelCase(directiveAttributeString.replace(PREFIX_REGEXP, ''));
return $injector.has(directiveName + 'Directive');
}
service.checkUrlForDialog = function () {
var dialogParamValue = $location.search()[dialogQueryParamName];
if (dialogParamValue && directiveExists(dialogParamValue)) {
var dialog = ngDialog.open({
template: getHtmlFromDialogQueryParam(dialogParamValue),
plain: true,
className: ''
});
dialog.closePromise.then(function () {
$location.search(dialogQueryParamName, null);
});
}
};
service.propagatePersistedDialog = function (directive, attributes) {
var paramValue = directive;
angular.forEach(attributes, function (value, name) {
paramValue += ':' + name + '=' + encodeURIComponent(value);
});
$location.search(dialogQueryParamName, paramValue);
};
$rootScope.$on('$locationChangeSuccess', function () {
service.checkUrlForDialog();
});
service.checkUrlForDialog(); // check on initial page load
return service;
}
})();

View file

@ -0,0 +1,68 @@
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
/**
* Controller for the piwikDialogToggler directive. Adds a couple methods to the
* scope allowing elements to open and close dialogs.
*/
(function () {
angular.module('piwikApp').controller('DialogTogglerController', DialogTogglerController);
DialogTogglerController.$inject = ['$scope', 'piwik', 'ngDialog', 'piwikDialogtogglerUrllistener'];
function DialogTogglerController($scope, piwik, ngDialog, piwikDialogtogglerUrllistener) {
/**
* Open a new dialog window using ngDialog.
*
* @param {object|string} contentsInfo If an object, it is assumed to be ngDialog open(...) config and is
* passed to ngDialog.open unaltered.
* If a string that beings with '#', we assume it is an ID of an element
* with the dialog contents. (Note: ngDialog doesn't appear to support arbitrary
* selectors).
* If a string that ends with .html, we assume it is a link to a an angular
* template.
* Otherwise we assume it is a raw angular
* @return {object} Returns the result of ngDialog.open. Can be used to close the dialog or listen for
* when the dialog is closed.
*/
$scope.open = function (contentsInfo) {
var ngDialogInfo;
if (typeof(contentsInfo) == 'object') { // is info to pass directly to ngDialog
ngDialogInfo = contentsInfo;
} else if (contentsInfo.substr(0, 1) == '#') { // is ID of an element
ngDialogInfo = {template: contentsInfo.substr(1)};
} else if (contentsInfo.substr(-4) == '.html') { // is a link to an .html file
ngDialogInfo = {template: contentsInfo};
} else { // is a raw HTML string
ngDialogInfo = {template: contentsInfo, plain: true};
}
return ngDialog.open(ngDialogInfo);
};
/**
* Opens a persisted dialog. Persisted dialogs are dialogs that will be launched on reload
* of the current URL. They are accomplished by modifying the URL and adding a 'popover'
* query parameter.
*
* @param {string} directive The denormalized name of an angularjs directive. An element with
* this directive will be the contents of the dialog.
* @param {object} attributes Key value mapping of the HTML attributes to add to the dialog's
* contents element.
*/
$scope.persist = function (directive, attributes) {
piwikDialogtogglerUrllistener.propagatePersistedDialog(directive, attributes);
};
/**
* Closes the currently open dialog window.
*/
$scope.close = function () {
ngDialog.close();
};
}
})();

View file

@ -0,0 +1,30 @@
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
/**
* Directive for an element (such as a link) that creates and/or closes dialogs.
*
* Usage:
* <a piwik-dialogtoggler href="#" ng-click="open(...)" />
*
* or:
*
* <div piwik-dialogtoggler>
* <a href="#" ng-click="open(...)">Open</a>
* <a href="#" ng-click="close()">Close</a>
* </div>
*/
(function () {
angular.module('piwikApp').directive('piwikDialogtoggler', piwikDialogtoggler);
function piwikDialogtoggler() {
return {
restrict: 'A',
controller: 'DialogTogglerController'
};
}
})();

View file

@ -0,0 +1,70 @@
.ngdialog {
position:absolute;
}
.ngdialog-overlay {
opacity: 0.6;
background: none #000;
position: fixed;
z-index: 1000;
}
.ngdialog-content {
z-index: 1001;
width: 950px;
border-radius: 4px;
margin: 0 auto;
max-width: 100%;
background-color: @theme-color-background-base;
padding: 1em 18px;
position: relative;
top: 100px;
h2:first-of-type {
line-height:24px;
padding:0 0 1em;
}
}
// remove some ngdialog animations (the remaining one is required for closing the dialog)
.ngdialog-overlay, .ngdialog.ngdialog-closing .ngdialog-overlay,.ngdialog-content {
-webkit-animation: none;
animation: none;
}
.ngdialog-close {
// close button should be styled the same as other buttons
.submit;
position: absolute;
right: 9px;
top: 18px;
width: 21px;
margin: 0 0 0 0;
height: 20px;
&:before {
font-family:inherit;
content:'';
display:inline-block;
// center in div
position:absolute;
top: 50%;
left: 50%;
margin-top: -8px;
margin-left: -8px;
// from jquery-ui css
background-image: url(libs/jquery/themes/base/images/ui-icons_888888_256x240.png);
background-position: -96px -128px;
width: 16px;
height: 16px;
opacity:0.5;
}
&:hover:before {
background-image: url(libs/jquery/themes/base/images/ui-icons_454545_256x240.png);
}
}