add icons for Character groups

This commit is contained in:
coderkun 2014-04-29 14:18:04 +02:00
commit 2d9a41a5fe
3461 changed files with 594457 additions and 0 deletions

View file

@ -0,0 +1,31 @@
/*!
* Piwik - Web Analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
var Overlay_Helper = {
/** Encode the iframe url to put it behind the hash in sidebar mode */
encodeFrameUrl: function (url) {
// url encode + replace % with $ to make sure that browsers don't break the encoding
return encodeURIComponent(url).replace(/%/g, '$')
},
/** Decode the url after reading it from the hash */
decodeFrameUrl: function (url) {
// reverse encodeFrameUrl()
return decodeURIComponent(url.replace(/\$/g, '%'));
},
/** Get the url to launch overlay */
getOverlayLink: function (idSite, period, date, link) {
var url = 'index.php?module=Overlay&period=' + period + '&date=' + date + '&idSite=' + idSite;
if (link) {
url += '#l=' + Overlay_Helper.encodeFrameUrl(link);
}
return url;
}
};

View file

@ -0,0 +1,252 @@
/*!
* Piwik - Web Analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
var Piwik_Overlay = (function () {
var $body, $iframe, $sidebar, $main, $location, $loading, $errorNotLoading;
var $rowEvolutionLink, $transitionsLink, $fullScreenLink;
var idSite, period, date;
var iframeSrcBase;
var iframeDomain = '';
var iframeCurrentPage = '';
var iframeCurrentPageNormalized = '';
var iframeCurrentActionLabel = '';
var updateComesFromInsideFrame = false;
/** Load the sidebar for a url */
function loadSidebar(currentUrl) {
showLoading();
$location.html(' ').unbind('mouseenter').unbind('mouseleave');
iframeCurrentPage = currentUrl;
iframeDomain = currentUrl.match(/http(s)?:\/\/(www\.)?([^\/]*)/i)[3];
globalAjaxQueue.abort();
var ajaxRequest = new ajaxHelper();
ajaxRequest.addParams({
module: 'Overlay',
action: 'renderSidebar',
currentUrl: currentUrl
}, 'get');
ajaxRequest.setCallback(
function (response) {
hideLoading();
var $response = $(response);
var $responseLocation = $response.find('.Overlay_Location');
var $url = $responseLocation.find('span');
iframeCurrentPageNormalized = $url.data('normalizedUrl');
iframeCurrentActionLabel = $url.data('label');
$url.html(piwikHelper.addBreakpointsToUrl($url.text()));
$location.html($responseLocation.html()).show();
$responseLocation.remove();
var $locationSpan = $location.find('span');
$locationSpan.html(piwikHelper.addBreakpointsToUrl($locationSpan.text()));
if (iframeDomain) {
// use addBreakpointsToUrl because it also encoded html entities
$locationSpan.tooltip({
track: true,
items: '*',
tooltipClass: 'Overlay_Tooltip',
content: '<strong>' + Piwik_Overlay_Translations.domain + ':</strong> ' +
piwikHelper.addBreakpointsToUrl(iframeDomain),
show: false,
hide: false
});
}
$sidebar.empty().append($response).show();
if ($sidebar.find('.Overlay_NoData').size() == 0) {
$rowEvolutionLink.show();
$transitionsLink.show()
}
}
);
ajaxRequest.setErrorCallback(function () {
hideLoading();
$errorNotLoading.show();
});
ajaxRequest.setFormat('html');
ajaxRequest.send(false);
}
/** Adjust the dimensions of the iframe */
function adjustDimensions() {
$iframe.height($(window).height());
$iframe.width($body.width() - $iframe.offset().left - 2); // -2 because of 2px border
}
/** Display the loading message and hide other containers */
function showLoading() {
$loading.show();
$sidebar.hide();
$location.hide();
$fullScreenLink.hide();
$rowEvolutionLink.hide();
$transitionsLink.hide();
$errorNotLoading.hide();
}
/** Hide the loading message */
function hideLoading() {
$loading.hide();
$fullScreenLink.show();
}
/** $.history callback for hash change */
function hashChangeCallback(urlHash) {
var location = broadcast.getParamValue('l', urlHash);
location = Overlay_Helper.decodeFrameUrl(location);
if (!updateComesFromInsideFrame) {
var iframeUrl = iframeSrcBase;
if (location) {
iframeUrl += '#' + location;
}
$iframe.attr('src', iframeUrl);
showLoading();
} else {
loadSidebar(location);
}
updateComesFromInsideFrame = false;
}
return {
/** This method is called when Overlay loads */
init: function (iframeSrc, pIdSite, pPeriod, pDate) {
iframeSrcBase = iframeSrc;
idSite = pIdSite;
period = pPeriod;
date = pDate;
$body = $('body');
$iframe = $('#Overlay_Iframe');
$sidebar = $('#Overlay_Sidebar');
$location = $('#Overlay_Location');
$main = $('#Overlay_Main');
$loading = $('#Overlay_Loading');
$errorNotLoading = $('#Overlay_Error_NotLoading');
$rowEvolutionLink = $('#Overlay_RowEvolution');
$transitionsLink = $('#Overlay_Transitions');
$fullScreenLink = $('#Overlay_FullScreen');
adjustDimensions();
showLoading();
// apply initial dimensions
window.setTimeout(function () {
adjustDimensions();
}, 50);
// handle window resize
// we manipulate broadcast.pageload because it unbinds all resize events on window
var originalPageload = broadcast.pageload;
broadcast.pageload = function (hash) {
originalPageload(hash);
$(window).resize(function () {
adjustDimensions();
});
};
$(window).resize(function () {
adjustDimensions();
});
// handle hash change
broadcast.loadAjaxContent = hashChangeCallback;
broadcast.init();
if (window.location.href.split('#').length == 1) {
// if there's no hash, broadcast won't trigger the callback - we have to do it here
hashChangeCallback('');
}
// handle date selection
var $select = $('select#Overlay_DateRangeSelect').change(function () {
var parts = $(this).val().split(';');
if (parts.length == 2) {
period = parts[0];
date = parts[1];
window.location.href = Overlay_Helper.getOverlayLink(idSite, period, date, iframeCurrentPage);
}
});
var optionMatchFound = false;
$select.find('option').each(function () {
if ($(this).val() == period + ';' + date) {
$(this).prop('selected', true);
optionMatchFound = true;
}
});
if (!optionMatchFound) {
$select.prepend('<option selected="selected">');
}
// handle transitions link
$transitionsLink.click(function () {
DataTable_RowActions_Transitions.launchForUrl(iframeCurrentPageNormalized);
return false;
});
// handle row evolution link
$rowEvolutionLink.click(function () {
DataTable_RowActions_RowEvolution.launch('Actions.getPageUrls', iframeCurrentActionLabel);
return false;
});
// handle full screen link
$fullScreenLink.click(function () {
var href = iframeSrcBase;
if (iframeCurrentPage) {
href += '#' + iframeCurrentPage.replace(/#/g, '%23');
}
window.location.href = href;
return false;
});
},
/** This callback is used from within the iframe */
setCurrentUrl: function (currentUrl) {
showLoading();
var locationParts = location.href.split('#');
var currentLocation = '';
if (locationParts.length > 1) {
currentLocation = broadcast.getParamValue('l', locationParts[1]);
}
var newLocation = Overlay_Helper.encodeFrameUrl(currentUrl);
if (newLocation != currentLocation) {
updateComesFromInsideFrame = true;
// put the current iframe url in the main url to enable refresh and deep linking.
// use disableHistory=true to make sure that the back and forward buttons can be
// used on the iframe (which in turn notifies the parent about the location change)
broadcast.propagateAjax('l=' + newLocation, true);
} else {
// happens when the url is changed by hand or when the l parameter is there on page load
loadSidebar(currentUrl);
}
}
};
})();

View file

@ -0,0 +1,65 @@
/*!
* Piwik - Web Analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
/**
* This file registers the Overlay row action on the pages report.
*/
function DataTable_RowActions_Overlay(dataTable) {
this.dataTable = dataTable;
}
DataTable_RowActions_Overlay.prototype = new DataTable_RowAction;
DataTable_RowActions_Overlay.prototype.onClick = function (actionA, tr, e) {
if (!actionA.data('overlay-manipulated')) {
actionA.data('overlay-manipulated', 1);
var link = tr.find('> td:first > a').attr('href');
link = $('<textarea>').html(link).val(); // remove html entities
actionA.attr({
target: '_blank',
href: Overlay_Helper.getOverlayLink(this.dataTable.param.idSite, 'month', 'today', link)
});
}
return true;
};
DataTable_RowActions_Registry.register({
name: 'Overlay',
dataTableIcon: 'plugins/Overlay/images/overlay_icon.png',
dataTableIconHover: 'plugins/Overlay/images/overlay_icon_hover.png',
order: 30,
dataTableIconTooltip: [
_pk_translate('General_OverlayRowActionTooltipTitle'),
_pk_translate('General_OverlayRowActionTooltip')
],
createInstance: function (dataTable) {
return new DataTable_RowActions_Overlay(dataTable);
},
isAvailableOnReport: function (dataTableParams) {
// Overlay plugin only works when Transitions plugin is enabled
if (!window.DataTable_RowActions_Transitions) {
return false;
}
return DataTable_RowActions_Transitions.isPageUrlReport(dataTableParams.module, dataTableParams.action);
},
isAvailableOnRow: function (dataTableParams, tr) {
var transitions = DataTable_RowActions_Registry.getActionByName('Transitions');
return transitions.isAvailableOnRow(dataTableParams, tr);
}
});