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:
-rw-r--r--core/Menu/Abstract.php7
-rw-r--r--lang/en.php30
-rw-r--r--plugins/CoreAdminHome/Controller.php25
-rw-r--r--plugins/CoreAdminHome/CoreAdminHome.php5
-rw-r--r--plugins/CoreAdminHome/templates/jsTrackingGenerator.css76
-rw-r--r--plugins/CoreAdminHome/templates/jsTrackingGenerator.js364
-rw-r--r--plugins/CoreAdminHome/templates/jsTrackingGenerator.tpl232
-rw-r--r--plugins/CoreHome/templates/autocomplete.js390
-rwxr-xr-xplugins/CoreHome/templates/misc.js63
-rw-r--r--plugins/CoreHome/templates/sites_selection.tpl27
-rw-r--r--plugins/UsersManager/templates/UsersManager.js10
-rw-r--r--plugins/UsersManager/templates/UsersManager.tpl8
-rw-r--r--themes/default/ajaxHelper.js21
-rw-r--r--themes/default/common.css2
14 files changed, 1056 insertions, 204 deletions
diff --git a/core/Menu/Abstract.php b/core/Menu/Abstract.php
index 981f6bd0f2..3a0b49c62b 100644
--- a/core/Menu/Abstract.php
+++ b/core/Menu/Abstract.php
@@ -19,6 +19,7 @@ abstract class Piwik_Menu_Abstract
protected $menuEntries = array();
protected $edits = array();
protected $renames = array();
+ protected $orderingApplied = false;
/*
* Can't enforce static function in 5.2.
@@ -198,10 +199,12 @@ abstract class Piwik_Menu_Abstract
*/
private function applyOrdering()
{
- if(empty($this->menu))
+ if (empty($this->menu)
+ || $this->orderingApplied)
{
return;
}
+
uasort($this->menu, array($this, 'menuCompare'));
foreach ($this->menu as $key => &$element)
{
@@ -214,6 +217,8 @@ abstract class Piwik_Menu_Abstract
uasort($element, array($this, 'menuCompare'));
}
}
+
+ $this->orderingApplied = true;
}
/**
diff --git a/lang/en.php b/lang/en.php
index f07cc66dd5..cea349aba0 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -364,6 +364,7 @@ $translations = array(
'General_Donate' => 'Donate',
'General_MoreDetails' => 'More Details',
'General_Source' => 'Source',
+ 'General_Options' => 'Options',
'Actions_PluginDescription' => 'Reports about the page views, the outlinks and downloads. Outlinks and Downloads tracking is automatic! You can also track your internal website\'s Search Engine.',
'Actions_Actions' => 'Actions',
'Actions_SubmenuPages' => 'Pages',
@@ -469,6 +470,35 @@ $translations = array(
'CoreAdminHome_PiwikIsInstalledAt' => 'Piwik is installed at',
'CoreAdminHome_ValidPiwikHostname' => 'Valid Piwik Hostname',
'CoreAdminHome_MissingPluginsWarning' => 'The following plugins were not loaded because they could not be found in the \'plugins\' directory: %1$s. You can disable these plugins on the %2$sManage Plugins%3$s page.',
+ 'CoreAdminHome_JSTrackingIntro1' => 'You can track visitors to your website many different ways. The recommended way to do it is through JavaScript. To use this method you must make sure every webpage of your website has some JavaScript code, which you can generate here.',
+ 'CoreAdminHome_JSTrackingIntro2' => 'Once you have the JavaScript tracking code for your website, copy and paste it to all the pages you want to track with Piwik. In most websites, blogs, CMS, etc. you can use a pre-made plugin to do the technical work for you. (See our %1$slist of plugins used to integrate Piwik%2$s.) If no plugin exists you can edit your website templates and add this code in the "footer" file.',
+ 'CoreAdminHome_JSTrackingIntro3' => 'If you don\'t want to use JavaScript to track visitors, %1$sgenerate an image tracking link below%2$s.',
+ 'CoreAdminHome_JSTrackingIntro4' => 'If you want to do more than tracking a page view, please check out the %1$sPiwik Javascript Tracking documentation%2$s for the list of available functions (for example: Tracking Goals, Custom Variables, Ecommerce orders, products and abandoned carts, etc.).',
+ 'CoreAdminHome_JSTracking_MergeSubdomains' => 'Track visitors across all subdomains of',
+ 'CoreAdminHome_JSTracking_MergeSubdomainsDesc' => 'So visitors to %1$s will not be treated as new if they visit %2$s for the first time.',
+ 'CoreAdminHome_JSTracking_MergeAliases' => 'Track visitors across all alias URLs of',
+ 'CoreAdminHome_JSTracking_MergeAliasesDesc' => 'So visitors to the main URL will not be treated as new if they visit an alias URL for the first time.',
+ 'CoreAdminHome_JSTracking_GroupPageTitlesByDomain' => 'Prepend the site domain to the page title when tracking',
+ 'CoreAdminHome_JSTracking_GroupPageTitlesByDomainDesc' => 'So if someone visits the \'About\' page on blog.example.com it will be recorded as \'blog / About\'. This is the easiest way to get an overview of your traffic by sub-domain.',
+ 'CoreAdminHome_JSTracking_VisitorCustomVars' => 'Track custom variables for this visitor',
+ 'CoreAdminHome_JSTracking_VisitorCustomVarsDesc' => 'For example, with variable name "Type" and value "Customer".',
+ 'CoreAdminHome_JSTracking_PageCustomVars' => 'Track a custom variable for each page view',
+ 'CoreAdminHome_JSTracking_PageCustomVarsDesc' => 'For example, with variable name "Category" and value "White Papers".',
+ 'CoreAdminHome_JSTracking_EnableDoNotTrack' => 'Enable DoNotTrack support',
+ 'CoreAdminHome_JSTracking_EnableDoNotTrackDesc' => 'So visitors that do not wish to be tracked will not be tracked.',
+ 'CoreAdminHome_JSTracking_CustomCampaignQueryParam' => 'Use custom query parameter names for the campaign name & keyword',
+ 'CoreAdminHome_JSTracking_CampaignNameParam' => 'Campaign Name parameter',
+ 'CoreAdminHome_JSTracking_CampaignKwdParam' => 'Campaign Keyword parameter',
+ 'CoreAdminHome_JSTracking_CodeNote' => 'Make sure this code is on every page of your website before the %1$s tag.',
+ 'CoreAdminHome_ImageTrackingIntro1' => 'When a visitor has disabled JavaScript, or when JavaScript cannot be used, you can use an image tracking link to track visitors. Generate the link below and copy-paste the generated HTML to the page. If you\'re using this as a fallback for JavaScript tracking, you can surround it in %1$s tags.',
+ 'CoreAdminHome_ImageTrackingIntro2' => 'For the whole list of options you can use with an image tracking link, see the %1$sTracking API Documentation%2$s.',
+ 'CoreAdminHome_ImageTracking' => 'Image Tracking',
+ 'CoreAdminHome_TrackAGoal' => 'Track a goal',
+ 'CoreAdminHome_WithOptionalRevenue' => 'with optional revenue',
+ 'CoreAdminHome_ImageTrackingLink' => 'Image Tracking Link',
+ 'CoreAdminHome_ImportingServerLogs' => 'Importing Server Logs',
+ 'CoreAdminHome_ImportingServerLogsDesc' => 'An alternative to tracking visitors through the browser (either via JavaScript or an image link) is to continuously import server logs. Learn more about %1$sServer Log File Analytics%2$s.',
+ 'CoreAdminHome_JavaScriptTracking' => 'JavaScript Tracking',
'CoreHome_InjectedHostWarningIntro' => 'You are now accessing Piwik from %1$s, but Piwik has been configured to run at this address: %2$s.',
'CoreHome_InjectedHostSuperUserWarning' => 'Piwik may be misconfigured (for example, if Piwik was recently moved to a new server or URL). You can either %1$sclick here and add %2$s as the valid Piwik hostname (if you trust it)%3$s, or %4$sclick here and go to %5$s to access Piwik safely%6$s.',
'CoreHome_InjectedHostNonSuperUserWarning' => '%1$sClick here to access Piwik safely%2$s and remove this warning. You may also want to contact your Piwik administrator and notify them about this issue (%3$sclick here to email%4$s).',
diff --git a/plugins/CoreAdminHome/Controller.php b/plugins/CoreAdminHome/Controller.php
index 661b01d824..338f3100ec 100644
--- a/plugins/CoreAdminHome/Controller.php
+++ b/plugins/CoreAdminHome/Controller.php
@@ -115,6 +115,31 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller_Admin
}
/**
+ * Renders and echo's an admin page that lets users generate custom JavaScript
+ * tracking code and custom image tracker links.
+ */
+ public function trackingCodeGenerator()
+ {
+ $view = Piwik_View::factory('jsTrackingGenerator');
+ $this->setBasicVariablesView($view);
+ $view->topMenu = Piwik_GetTopMenu();
+ $view->menu = Piwik_GetAdminMenu();
+
+ $viewableIdSites = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess();
+
+ $defaultIdSite = reset($viewableIdSites);
+ $view->idSite = Piwik_Common::getRequestVar('idSite', $defaultIdSite, 'int');
+
+ $view->defaultReportSiteName = Piwik_Site::getNameFor($view->idSite);
+ $view->defaultSiteRevenue = Piwik::getCurrency($view->idSite);
+
+ // get currencies for each viewable site
+ $view->currencySymbols = Piwik_SitesManager_API::getInstance()->getCurrencySymbols();
+
+ echo $view->render();
+ }
+
+ /**
* Shows the "Track Visits" checkbox.
*/
public function optOut()
diff --git a/plugins/CoreAdminHome/CoreAdminHome.php b/plugins/CoreAdminHome/CoreAdminHome.php
index bc107a5c8d..4abff049f5 100644
--- a/plugins/CoreAdminHome/CoreAdminHome.php
+++ b/plugins/CoreAdminHome/CoreAdminHome.php
@@ -101,6 +101,11 @@ class Piwik_CoreAdminHome extends Piwik_Plugin
array('module' => 'CoreAdminHome', 'action' => 'generalSettings'),
Piwik::isUserHasSomeAdminAccess(),
$order = 6);
+ Piwik_AddAdminSubMenu('General_Settings', 'Installation_JsTag',
+ array('module' => 'CoreAdminHome', 'action' => 'trackingCodeGenerator'),
+ Piwik::isUserHasSomeAdminAccess(),
+ $order = 9);
+
}
function purgeOutdatedArchives()
diff --git a/plugins/CoreAdminHome/templates/jsTrackingGenerator.css b/plugins/CoreAdminHome/templates/jsTrackingGenerator.css
new file mode 100644
index 0000000000..48f2340663
--- /dev/null
+++ b/plugins/CoreAdminHome/templates/jsTrackingGenerator.css
@@ -0,0 +1,76 @@
+#javascript-output-section textarea,#image-link-output-section textarea {
+ width:100%;
+ display: block;
+ color: #111;
+ font-family: "courier";
+
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+#javascript-output-section textarea {
+ height: 256px;
+}
+
+#image-link-output-section textarea {
+ height: 128px;
+}
+
+label {
+ margin-right: .35em;
+ display:inline-block;
+}
+
+#optional-js-tracking-options>tbody>tr>td,#image-tracking-section>tbody>tr>td {
+ width:488px;
+ max-width:488px;
+}
+
+.custom-variable-name,.custom-variable-value {
+ width:100px;
+}
+
+h3 {
+ margin-top:0;
+}
+
+.small-form-description {
+ color:#666;
+ font-size:1em;
+ font-style:italic;
+ margin-left:4em;
+}
+
+.tracking-option-section {
+ margin-bottom:1.5em;
+}
+
+#javascript-output-section,#image-link-output-section {
+ padding-top:1em;
+}
+
+#optional-js-tracking-options th,#image-tracking-section th {
+ text-align:left;
+}
+
+#js-visitor-cv-extra,#js-page-cv-extra,#js-campaign-query-param-extra {
+ margin-left:1em;
+}
+#js-visitor-cv-extra td,#js-page-cv-extra td,#js-campaign-query-param-extra td {
+ vertical-align:middle;
+}
+
+.revenue {
+ width:32px;
+}
+.goal-picker {
+ height:1.2em;
+}
+.goal-picker select {
+ width:128px;
+}
+
+#js-campaign-query-param-extra input {
+ width:72px;
+}
diff --git a/plugins/CoreAdminHome/templates/jsTrackingGenerator.js b/plugins/CoreAdminHome/templates/jsTrackingGenerator.js
new file mode 100644
index 0000000000..46e5a20afe
--- /dev/null
+++ b/plugins/CoreAdminHome/templates/jsTrackingGenerator.js
@@ -0,0 +1,364 @@
+/*!
+ * Piwik - Web Analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+(function($) {
+
+$(document).ready(function() {
+
+ var piwikHost = window.location.host;
+
+ //
+ // utility methods
+ //
+
+ // returns JavaScript code for tracking custom variables based on an array of
+ // custom variable name-value pairs (so an array of 2-element arrays) and
+ // a scope (either 'visit' or 'page')
+ var getCustomVariableJS = function(customVariables, scope)
+ {
+ var result = '';
+ for (var i = 0; i != 5; ++i)
+ {
+ if (customVariables[i])
+ {
+ var key = customVariables[i][0],
+ value = customVariables[i][1];
+ result += '_paq.push(["setCustomVariable", ' + (i + 1) + ', ' + JSON.stringify(key) + ', '
+ + JSON.stringify(value) + ', ' + JSON.stringify(scope) + ']);\n';
+ }
+ }
+ return result;
+ };
+
+ // gets the list of custom variables entered by the user in a custom variable
+ // section
+ var getCustomVariables = function (sectionId)
+ {
+ var customVariableNames = $('.custom-variable-name', '#' + sectionId),
+ customVariableValues = $('.custom-variable-value', '#' + sectionId);
+
+ var result = [];
+ if ($('.section-toggler-link', '#' + sectionId).is(':checked'))
+ {
+ for (var i = 0; i != customVariableNames.length; ++i)
+ {
+ var name = $(customVariableNames[i]).val();
+
+ result[i] = null;
+ if (name)
+ {
+ result[i] = [name, $(customVariableValues[i]).val()];
+ }
+ }
+ }
+ return result;
+ };
+
+ // quickly gets the host + port from a url
+ var getHostNameFromUrl = function(url)
+ {
+ var element = $('<a></a>')[0];
+ element.href = url;
+ return element.hostname;
+ };
+
+ // get preloaded server-side data necessary for code generation
+ var dataElement = $('#js-tracking-generator-data'),
+ currencySymbols = JSON.parse(dataElement.attr('data-currencies')),
+ siteUrls = {},
+ siteCurrencies = {},
+ allGoals = {},
+ noneText = $('#image-tracker-goal>option').text();
+
+ // queries Piwik for needed site info for one site
+ var getSiteData = function (idSite, sectionSelect, callback)
+ {
+ // if data is already loaded, don't do an AJAX request
+ if (siteUrls[idSite]
+ && siteCurrencies[idSite]
+ && typeof allGoals[idSite] !== 'undefined')
+ {
+ callback();
+ return;
+ }
+
+ // disable section
+ $(sectionSelect).find('input,select,textarea').attr('disabled', 'disabled');
+
+ var ajaxRequest = new ajaxHelper();
+ ajaxRequest.setBulkRequests(
+ // get site info (for currency)
+ {
+ module: 'API',
+ method: 'SitesManager.getSiteFromId',
+ idSite: idSite
+ },
+
+ // get site urls
+ {
+ module: 'API',
+ method: 'SitesManager.getSiteUrlsFromId',
+ idSite: idSite
+ },
+
+ // get site goals
+ {
+ module: 'API',
+ method: 'Goals.getGoals',
+ idSite: idSite
+ }
+ );
+ ajaxRequest.setCallback(function (data) {
+ for (var i = 0; i != data.length; ++i)
+ {
+ data[i] = JSON.parse(data[i]);
+ }
+
+ // set data
+ var currency = data[0][0].currency || '';
+ siteCurrencies[idSite] = currencySymbols[currency.toUpperCase()];
+ siteUrls[idSite] = data[1] || [];
+ allGoals[idSite] = data[2] || [];
+
+ // re-enable controls
+ $(sectionSelect).find('input,select,textarea').removeAttr('disabled');
+
+ callback();
+ });
+ ajaxRequest.setFormat('json');
+ ajaxRequest.send(false);
+ };
+
+ // resets the select options of a goal select using a site ID
+ var resetGoalSelectItems = function (idsite, id)
+ {
+ var newOptions = '<option value="">' + noneText + '</option>';
+
+ var goals = allGoals[idsite] || [];
+ for (var key in goals)
+ {
+ var goal = goals[key];
+ newOptions += '<option value="' + goal.idgoal + '">' + goal.name + '</option>';
+ }
+
+ // set goal select items
+ $('#' + id).html(newOptions);
+
+ // set currency string
+ $('#' + id).parent().find('.currency').text(siteCurrencies[idsite]);
+ };
+
+ // function that generates JS code
+ var generateJsCode = function()
+ {
+ // get data
+ var idSite = $('#js-tracker-website .custom_select_main_link').attr('siteid'),
+ groupPageTitlesByDomain = $('#javascript-tracking-group-by-domain').is(':checked'),
+ mergeSubdomains = $('#javascript-tracking-all-subdomains').is(':checked'),
+ mergeAliasUrls = $('#javascript-tracking-all-aliases').is(':checked'),
+ visitorCustomVariables = getCustomVariables('javascript-tracking-visitor-cv'),
+ pageCustomVariables = getCustomVariables('javascript-tracking-page-cv'),
+ customCampaignNameQueryParam = null,
+ customCampaignKeywordParam = null,
+ doNotTrack = $('#javascript-tracking-do-not-track').is(':checked');
+
+ if ($('#custom-campaign-query-params-check').is(':checked'))
+ {
+ customCampaignNameQueryParam = $('#custom-campaign-name-query-param').val();
+ customCampaignKeywordParam = $('#custom-campaign-keyword-query-param').val();
+ }
+
+ // generate JS
+ var result = '<!-- Piwik -->\n\
+<script type="text/javascript">\n\
+var _paq = _paq || [];\n\
+(function(){ var u=(("https:" == document.location.protocol) ? "https://' + piwikHost + '/" : "http://' + piwikHost + '/");\n\
+_paq.push(["setSiteId", ' + JSON.stringify(idSite) + ']);\n';
+
+ if (groupPageTitlesByDomain)
+ {
+ result += '_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);\n';
+ }
+
+ if (mergeSubdomains)
+ {
+ var mainHostAllSub = '*.' + getHostNameFromUrl(siteUrls[idSite][0]);
+ result += '_paq.push(["setCookieDomain", ' + JSON.stringify(mainHostAllSub) + ']);\n';
+ }
+
+ if (mergeAliasUrls)
+ {
+ var siteHosts = [];
+ for (var i = 0; i != siteUrls[idSite].length; ++i)
+ {
+ siteHosts[i] = '*.' + getHostNameFromUrl(siteUrls[idSite][i]);
+ }
+ result += '_paq.push(["setDomains", ' + JSON.stringify(siteHosts) + ']);\n';
+ }
+
+ if (visitorCustomVariables.length)
+ {
+ result += '// you can set up to 5 custom variables for each visitor\n';
+ result += getCustomVariableJS(visitorCustomVariables, 'visit');
+ }
+
+ if (pageCustomVariables.length)
+ {
+ result += '// you can set up to 5 custom variables for each action (page view, ' +
+ 'download, click, site search)\n';
+ result += getCustomVariableJS(pageCustomVariables, 'page');
+ }
+
+ if (customCampaignNameQueryParam)
+ {
+ result += '_paq.push(["setCampaignNameKey", ' + JSON.stringify(customCampaignNameQueryParam) + ']);\n';
+ }
+
+ if (customCampaignKeywordParam)
+ {
+ result += '_paq.push(["setCampaignKeywordKey", ' + JSON.stringify(customCampaignKeywordParam) + ']);\n';
+ }
+
+ if (doNotTrack)
+ {
+ result += '_paq.push(["setDoNotTrack", true]);\n';
+ }
+
+ result += 'var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0];\n\
+g.type="text/javascript"; g.defer=true; g.async=true; g.src=u+"piwik.js";\n\
+s.parentNode.insertBefore(g,s); })();\n\
+</script>\n\
+<!-- End Piwik Code -->';
+
+ var ta = $('#javascript-text textarea');
+ ta.val(result)
+ };
+
+ // function that generates image tracker link
+ var generateImageTrackerLink = function()
+ {
+ // get data ( (("https:" == document.location.protocol)?"https://' + piwikHost + '":"http://' + piwikHost + '") )
+ var idSite = $('#image-tracker-website .custom_select_main_link').attr('siteid'),
+ piwikURL = "https:" == document.location.protocol ? "https://" + piwikHost : "http://" + piwikHost,
+ actionName = $('#image-tracker-action-name').val(),
+ idGoal = null,
+ revenue = null;
+
+ if ($('#image-tracking-goal-check').is(':checked'))
+ {
+ idGoal = $('#image-tracker-goal').val();
+ if (idGoal)
+ {
+ revenue = $('#image-tracker-advanced-options .revenue').val();
+ }
+ }
+
+ // generate link HTML
+ var params = {
+ idsite: idSite,
+ rec: 1
+ };
+
+ if (actionName)
+ {
+ params.action_name = actionName;
+ }
+
+ if (idGoal)
+ {
+ params.idGoal = idGoal;
+ if (revenue)
+ {
+ params.revenue = revenue;
+ }
+ }
+
+ var result = '<!-- Piwik Image Tracker -->\n\
+<img src="' + piwikURL + '/?' + $.param(params) + '" style="border:0" alt="" />\n\
+<!-- End Piwik -->';
+
+ var ta = $('#image-tracking-link textarea');
+ ta.val(result);
+ };
+
+ // on image link tracker site change, change available goals
+ $('#image-tracker-website').bind('piwik:siteSelected', function(e, site) {
+ getSiteData(site.id, '#image-tracking-code-options', function() {
+ resetGoalSelectItems(site.id, 'image-tracker-goal');
+ generateImageTrackerLink();
+ });
+ });
+
+ // on js link tracker site change, change available goals
+ $('#js-tracker-website').bind('piwik:siteSelected', function(e, site) {
+ getSiteData(site.id, '#js-code-options', function() {
+ resetGoalSelectItems(site.id, 'js-tracker-goal');
+
+ $('.current-site-name', '#javascript-tracking-options').each(function() {
+ $(this).text(site.name);
+ });
+
+ generateJsCode();
+ });
+ });
+
+ // on click 'add' link in custom variable section, add a new row, but only
+ // allow 5 custom variable entry rows
+ $('.add-custom-variable').click(function(e) {
+ e.preventDefault();
+
+ var newRow = '<tr>\
+ <td>&nbsp;</td>\
+ <td><input type="textbox" class="custom-variable-name"/></td>\
+ <td>&nbsp;</td>\
+ <td><input type="textbox" class="custom-variable-value"/></td>\
+ </tr>',
+ row = $(this).closest('tr');
+
+ row.before(newRow);
+
+ // hide add button if max # of custom variables has been reached
+ // (5 custom variables + 1 row for add new row)
+ if ($('tr', row.parent()).length == 6)
+ {
+ $(this).hide();
+ }
+
+ return false;
+ });
+
+ // when any input in the JS tracking options section changes, regenerate JS code
+ $('#optional-js-tracking-options').on('change', 'input', function() {
+ generateJsCode();
+ });
+
+ // when any input/select in the image tracking options section changes, regenerate
+ // image tracker link
+ $('#image-tracking-section').on('change', 'input,select', function() {
+ generateImageTrackerLink();
+ });
+
+ // on click generated code textareas, select the text so it can be easily copied
+ $('#javascript-text>textarea,#image-tracking-link>textarea').click(function() {
+ $(this).select();
+ });
+
+ // initial generation
+ getSiteData($(
+ '#js-tracker-website .custom_select_main_link').attr('siteid'),
+ '#js-code-options,#image-tracking-code-options',
+ function() {
+ var imageTrackerSiteId = $('#image-tracker-website .custom_select_main_link').attr('siteid');
+ resetGoalSelectItems(imageTrackerSiteId, 'image-tracker-goal');
+
+ generateJsCode();
+ generateImageTrackerLink();
+ }
+ );
+});
+
+}(jQuery));
diff --git a/plugins/CoreAdminHome/templates/jsTrackingGenerator.tpl b/plugins/CoreAdminHome/templates/jsTrackingGenerator.tpl
new file mode 100644
index 0000000000..4e46cf3ec4
--- /dev/null
+++ b/plugins/CoreAdminHome/templates/jsTrackingGenerator.tpl
@@ -0,0 +1,232 @@
+{include file="CoreAdminHome/templates/header.tpl"}
+<link rel="stylesheet" href="plugins/CoreAdminHome/templates/jsTrackingGenerator.css"></link>
+<script type="text/javascript" src="plugins/CoreAdminHome/templates/jsTrackingGenerator.js"></script>
+
+<div id="js-tracking-generator-data"
+ data-currencies = "{$currencySymbols|@json_encode|escape:'html'}"/>
+
+<h2>{'CoreAdminHome_JavaScriptTracking'|translate}</h2>
+
+<div id="js-code-options" class="adminTable">
+
+<p>
+ {'CoreAdminHome_JSTrackingIntro1'|translate}
+ <br/><br/>
+ {'CoreAdminHome_JSTrackingIntro2'|translate:'<a href="http://piwik.org/integrate/">':'</a>'}
+ <br/><br/>
+ {'CoreAdminHome_JSTrackingIntro3'|translate:'<a href="#image-tracking-link">':'</a>'}
+ <br/><br/>
+ {'CoreAdminHome_JSTrackingIntro4'|translate:'<a target="_blank" href="http://piwik.org/docs/javascript-tracking/">':'</a>'}
+</p>
+
+<div>
+ {* website *}
+ <label class="website-label"><strong>{'General_Website'|translate}</strong></label>
+ {include file="CoreHome/templates/sites_selection.tpl"
+ siteName=$defaultReportSiteName idSite=$idSite showAllSitesItem=false switchSiteOnSelect=false
+ siteSelectorId="js-tracker-website"}
+
+ <br/><br/><br/>
+</div>
+
+<table id="optional-js-tracking-options" class="adminTable" style='width:1024px'>
+<tr>
+ <th>{'General_Options'|translate}</th>
+ <th>{'Mobile_Advanced'|translate} <a href="#" class="section-toggler-link" data-section-id="javascript-advanced-options">({'General_Show_js'|translate})</a></th>
+</tr>
+<tr>
+<td>
+ {* track across all subdomains *}
+ <div class="tracking-option-section">
+ <input type="checkbox" id="javascript-tracking-all-subdomains"/>
+ <label for="javascript-tracking-all-subdomains">{'CoreAdminHome_JSTracking_MergeSubdomains'|translate} <span class='current-site-name'>{$defaultReportSiteName}</span></label>
+
+ <div class="small-form-description">
+ {'CoreAdminHome_JSTracking_MergeSubdomainsDesc'|translate:'x.domain.com':'y.domain.com'}
+ </div>
+ </div>
+
+ {* track across all site aliases *}
+ <div class="tracking-option-section">
+ <input type="checkbox" id="javascript-tracking-all-aliases"/>
+ <label for="javascript-tracking-all-aliases">{'CoreAdminHome_JSTracking_MergeAliases'|translate} <span class='current-site-name'>{$defaultReportSiteName}</span></label>
+
+ <div class="small-form-description">
+ {'CoreAdminHome_JSTracking_MergeAliasesDesc'|translate}
+ </div>
+ </div>
+
+ {* group page titles by site domain *}
+ <div class="tracking-option-section">
+ <input type="checkbox" id="javascript-tracking-group-by-domain"/>
+ <label for="javascript-tracking-group-by-domain">{'CoreAdminHome_JSTracking_GroupPageTitlesByDomain'|translate}</label>
+
+ <div class="small-form-description">
+ {'CoreAdminHome_JSTracking_GroupPageTitlesByDomainDesc'|translate}
+ </div>
+ </div>
+</td>
+<td>
+ <div id="javascript-advanced-options" style="display:none">
+ {* visitor custom variable *}
+ <div class="custom-variable tracking-option-section" id="javascript-tracking-visitor-cv">
+ <input class="section-toggler-link" type="checkbox" id="javascript-tracking-visitor-cv-check" data-section-id="js-visitor-cv-extra"/>
+ <label for="javascript-tracking-visitor-cv-check">{'CoreAdminHome_JSTracking_VisitorCustomVars'|translate}</label>
+
+ <div class="small-form-description">
+ {'CoreAdminHome_JSTracking_VisitorCustomVarsDesc'|translate}
+ </div>
+
+ <table style="display:none" id="js-visitor-cv-extra">
+ <tr>
+ <td><strong>{'General_Name'|translate}</strong></td>
+ <td><input type="textbox" class="custom-variable-name" placeholder="e.g. Type"/></td>
+ <td><strong>{'General_Value'|translate}</strong></td>
+ <td><input type="textbox" class="custom-variable-value" placeholder="e.g. Customer"/></td>
+ </tr>
+ <tr>
+ <td colspan="4" style="text-align:right">
+ <a href="#" class="add-custom-variable">{'General_Add'|translate}</a>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+ {* page view custom variable *}
+ <div class="custom-variable tracking-option-section" id="javascript-tracking-page-cv">
+ <input class="section-toggler-link" type="checkbox" id="javascript-tracking-page-cv-check" data-section-id="js-page-cv-extra"/>
+ <label for="javascript-tracking-page-cv-check">{'CoreAdminHome_JSTracking_PageCustomVars'|translate}</label>
+
+ <div class="small-form-description">
+ {'CoreAdminHome_JSTracking_PageCustomVarsDesc'|translate}
+ </div>
+
+ <table style="display:none" id="js-page-cv-extra">
+ <tr>
+ <td><strong>{'General_Name'|translate}</strong></td>
+ <td><input type="textbox" class="custom-variable-name" placeholder="e.g. Category"/></td>
+ <td><strong>{'General_Value'|translate}</strong></td>
+ <td><input type="textbox" class="custom-variable-value" placeholder="e.g. White Papers"/></td>
+ </tr>
+ <tr>
+ <td colspan="4" style="text-align:right">
+ <a href="#" class="add-custom-variable">{'General_Add'|translate}</a>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+ {* do not track support *}
+ <div class="tracking-option-section">
+ <input type="checkbox" id="javascript-tracking-do-not-track"/>
+ <label for="javascript-tracking-do-not-track">{'CoreAdminHome_JSTracking_EnableDoNotTrack'|translate}</label>
+
+ <div class="small-form-description">
+ {'CoreAdminHome_JSTracking_EnableDoNotTrackDesc'|translate}
+ </div>
+ </div>
+
+ {* custom campaign name/keyword query params *}
+ <div class="tracking-option-section">
+ <input class="section-toggler-link" type="checkbox" id="custom-campaign-query-params-check" data-section-id="js-campaign-query-param-extra"/>
+ <label for="custom-campaign-query-params-check">{'CoreAdminHome_JSTracking_CustomCampaignQueryParam'|translate}</label>
+
+ <table style="display:none" id="js-campaign-query-param-extra">
+ <tr>
+ <td><strong>{'CoreAdminHome_JSTracking_CampaignNameParam'|translate}</strong></td>
+ <td><input type="text" id="custom-campaign-name-query-param"/></td>
+ </tr>
+ <tr>
+ <td><strong>{'CoreAdminHome_JSTracking_CampaignKwdParam'|translate}</strong></td>
+ <td><input type="text" id="custom-campaign-keyword-query-param"/></td>
+ </tr>
+ </table>
+ </div>
+ </div>
+</td>
+</tr>
+</table>
+
+</div>
+
+<div id="javascript-output-section">
+ <h3>{'Installation_JsTag'|translate}</h3>
+ <p class="form-description">{'CoreAdminHome_JSTracking_CodeNote'|translate:"&lt;/body&gt;"}</p>
+ <div id="javascript-text">
+ <textarea> </textarea>
+ </div>
+ <br/>
+</div>
+
+<h2 id="image-tracking-link">{'CoreAdminHome_ImageTracking'|translate}</h2>
+
+<div id="image-tracking-code-options" class="adminTable">
+
+<p>
+ {'CoreAdminHome_ImageTrackingIntro1'|translate:"<em>&lt;noscript&gt;&lt;/noscript&gt;</em>"}
+ <br/><br/>
+ {'CoreAdminHome_ImageTrackingIntro2'|translate:'<a href="http://piwik.org/docs/tracking-api/reference/">':'</a>'}
+</p>
+
+<div>
+ {* website *}
+ <label class="website-label"><strong>{'General_Website'|translate}</strong></label>
+ {include file="CoreHome/templates/sites_selection.tpl"
+ siteName=$defaultReportSiteName idSite=$idSite showAllSitesItem=false switchSiteOnSelect=false
+ siteSelectorId="image-tracker-website"}
+
+ <br/><br/><br/>
+</div>
+
+<table id="image-tracking-section" class="adminTable" style='width:1024px;'>
+<tr>
+ <th>{'General_Options'|translate}</th>
+ <th>{'Mobile_Advanced'|translate} <a href="#" class="section-toggler-link" data-section-id="image-tracker-advanced-options">({'General_Show_js'|translate})</a></th>
+</tr>
+<tr>
+<td>
+ {* action_name *}
+ <div class="tracking-option-section">
+ <label for="image-tracker-action-name">{'Actions_ColumnPageName'|translate}</label>
+ <input type="text" id="image-tracker-action-name"/>
+ </div>
+</td>
+<td>
+ <div id="image-tracker-advanced-options" style="display:none">
+ {* goal *}
+ <div class="goal-picker tracking-option-section">
+ <input class="section-toggler-link" type="checkbox" id="image-tracking-goal-check" data-section-id="image-goal-picker-extra"/>
+ <label for="image-tracking-goal-check">{'CoreAdminHome_TrackAGoal'|translate}</label>
+
+ <div style="display:none" id="image-goal-picker-extra">
+ <select id="image-tracker-goal">
+ <option value="">{'UserCountryMap_None'|translate}</option>
+ </select>
+ <span>{'CoreAdminHome_WithOptionalRevenue'|translate}</span>
+ <span class="currency">{$defaultSiteRevenue}</span>
+ <input type="text" class="revenue" value=""/>
+ </div>
+ </div>
+ </div>
+</td>
+</tr>
+</table>
+
+<div id="image-link-output-section" width="560px">
+ <h3>{'CoreAdminHome_ImageTrackingLink'|translate}</h3><br/><br/>
+ <div id="image-tracking-link">
+ <textarea> </textarea>
+ </div>
+ <br/>
+</div>
+
+</div>
+
+<h2>{'CoreAdminHome_ImportingServerLogs'|translate}</h2>
+
+<p>
+{'CoreAdminHome_ImportingServerLogsDesc'|translate:'<a href="http://piwik.org/log-analytics/" target="_blank">':'</a>'}
+</p>
+
+{include file="CoreAdminHome/templates/footer.tpl"}
+
diff --git a/plugins/CoreHome/templates/autocomplete.js b/plugins/CoreHome/templates/autocomplete.js
index 8285b5fdb4..52523ae054 100644
--- a/plugins/CoreHome/templates/autocomplete.js
+++ b/plugins/CoreHome/templates/autocomplete.js
@@ -5,190 +5,246 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-$('.but').on('click', function(e)
+function switchSite(id, name, showAjaxLoading, idCanBeAll)
{
- if($('#websiteSearch').val() != '')
- $('#websiteSearch').autocomplete('search', $('#websiteSearch').val() + '%%%');
- return false;
-});
-
-function switchSite(id, name, showAjaxLoading)
-{
- $('.sites_autocomplete input').val(id);
- $('.custom_select_main_link').text(name);
- $('.custom_select_main_link').addClass('custom_select_loading');
- broadcast.propagateNewPage('idSite='+id, showAjaxLoading);
+ if (id == 'all'
+ && !idCanBeAll)
+ {
+ broadcast.propagateNewPage('module=MultiSites&action=index');
+ }
+ else
+ {
+ $('.sites_autocomplete input').val(id);
+ $('.custom_select_main_link').text(name);
+ $('.custom_select_main_link').addClass('custom_select_loading');
+ broadcast.propagateNewPage('idSite='+id, showAjaxLoading);
+ }
return false;
}
-// global function that is executed when the user selects a new site.
-// can be overridden to customize behavior (see UsersManager)
-window.autocompleteOnNewSiteSelect = function(siteId, siteName)
-{
- if (siteId == 'all')
- {
- broadcast.propagateNewPage('module=MultiSites&action=index');
- }
- else
- {
- switchSite(siteId, siteName);
- }
-};
-
$(function() {
- if($('#websiteSearch').length == 0)
- {
- return;
- }
-
- $('#websiteSearch').click(function(e)
+
+ var reset = function(selector)
{
- $(this).val('');
- });
- $('#websiteSearch').keyup(function(e)
+ $('.websiteSearch', selector).val('');
+ $('.custom_select_ul_list', selector).show();
+ $(".siteSelect.ui-autocomplete,.reset", selector).hide();
+ };
+
+ // sets up every un-inited site selector widget
+ piwik.initSiteSelectors = function()
{
- if(parseInt($(this).val().length) == 0)
- {
- reset();
- }
- });
- $('#websiteSearch').autocomplete({
- minLength: 1,
- source: '?module=SitesManager&action=getSitesForAutocompleter',
- appendTo: '#custom_select_container',
- select: function(event, ui) {
- if(piwik.idSite == ui.item.id)
+ $('.sites_autocomplete').each(function() {
+ var selector = $(this);
+
+ if (selector.attr('data-inited') == 1)
{
- $("#sitesSelectionSearch .custom_select_block").toggleClass("custom_select_block_show");
+ return;
}
- else
- {
- if(ui.item.id > 0) {
- // set attributes of selected site display (what shows in the box)
- $("#sitesSelectionSearch .custom_select_main_link")
- .attr('siteid', ui.item.id)
- .text(ui.item.name);
- // hide the dropdown
- $("#sitesSelectionSearch .custom_select_block").toggleClass("custom_select_block_show");
- // fire the site selected event
- window.autocompleteOnNewSiteSelect(ui.item.id, ui.item.name);
- } else {
- reset();
+
+ selector.attr('data-inited', 1);
+
+ var websiteSearch = $('.websiteSearch', selector);
+
+ // when the search input is clicked, clear the input
+ websiteSearch.click(function() {
+ $(this).val('');
+ });
+
+ // when a key is released over the search input when empty, reset the selector
+ //
+ websiteSearch.keyup(function(e) {
+ if (e.keyCode == 27)
+ {
+ $('.custom_select_block', selector).removeClass('custom_select_block_show');
+ return false;
}
- }
- return false;
- },
- focus: function(event, ui) {
- $('#websiteSearch').val(ui.item.name);
- return false;
- },
- search: function(event, ui) {
- $("#reset").show();
- $("#sitesSelectionSearch .custom_select_main_link").addClass("custom_select_loading");
- },
- open: function(event, ui) {
- var widthSitesSelection = +$("#sitesSelectionSearch ul").width(); // convert to int
- $("#sitesSelectionSearch .custom_select_main_link").removeClass("custom_select_loading");
- if(widthSitesSelection > $('#max_sitename_width').val())
+
+ if (!$(this).val())
+ {
+ reset(selector);
+ }
+ });
+
+ // setup the autocompleter
+ websiteSearch.autocomplete({
+ minLength: 1,
+ source: '?module=SitesManager&action=getSitesForAutocompleter',
+ appendTo: $('.custom_select_container', selector),
+ select: function(event, ui) {
+ if (piwik.idSite == ui.item.id)
+ {
+ $('.custom_select_block', selector).removeClass('custom_select_block_show');
+ }
+ else
+ {
+ if (ui.item.id > 0)
+ {
+ // set attributes of selected site display (what shows in the box)
+ $('.custom_select_main_link', selector)
+ .attr('siteid', ui.item.id)
+ .text(ui.item.name);
+
+ // hide the dropdown
+ $('.custom_select_block', selector).removeClass('custom_select_block_show');
+
+ // fire the site selected event
+ selector.trigger('piwik:siteSelected', ui.item);
+ }
+ else
+ {
+ reset(selector);
+ }
+ }
+
+ return false;
+ },
+ focus: function(event, ui) {
+ $('.websiteSearch', selector).val(ui.item.name);
+ return false;
+ },
+ search: function(event, ui) {
+ $('.reset', selector).show();
+ $('.custom_select_main_link', selector).addClass('custom_select_loading');
+ },
+ open: function(event, ui) {
+ var widthSitesSelection = +$('.custom_select_ul_list', selector).width();
+
+ $('.custom_select_main_link', selector).removeClass('custom_select_loading');
+
+ var maxSitenameWidth = $('.max_sitename_width', selector);
+ if (widthSitesSelection > maxSitenameWidth.val())
+ {
+ maxSitenameWidth.val(widthSitesSelection);
+ }
+ else
+ {
+ maxSitenameWidth = +maxSitenameWidth.val(); // convert to int
+ }
+
+ $('.custom_select_ul_list', selector).hide();
+
+ // customize jquery-ui's autocomplete positioning
+ var cssToRemove = {float: 'none', position: 'static'};
+ $('.siteSelect.ui-autocomplete', selector)
+ .show().width(widthSitesSelection).css(cssToRemove)
+ .find('li,a').each(function() {
+ $(this).css(cssToRemove);
+ });
+
+ $('.custom_select_block_show', selector).width(widthSitesSelection);
+ }
+ }).data("autocomplete")._renderItem = function (ul, item) {
+ $(ul).addClass('siteSelect');
+
+ var idSiteParam = 'idSite=' + item.id,
+ hash = broadcast.isHashExists() ? broadcast.getHashFromUrl().replace(/idSite=[0-9]+/, idSiteParam) : "",
+ linkUrl = piwikHelper.getCurrentQueryStringWithParametersModified(idSiteParam) + hash,
+ link = $("<a></a>").html(item.label).attr('href', linkUrl),
+ listItem = $('<li></li>');
+
+ listItem.data("item.autocomplete", item)
+ .append(link)
+ .appendTo(ul);
+
+ return listItem;
+ };
+
+ // when the reset button is clicked, reset the site selector
+ $('.reset', selector).click(reset);
+
+ // when mouse button is released on body, check if it is not over the site selector, and if not
+ // close it
+ $('body').on('mouseup', function(e) {
+ var closestSelector = $(e.target).closest('.sites_autocomplete');
+ if (closestSelector != selector)
+ {
+ reset(selector);
+ $('.custom_select_block', selector).removeClass('custom_select_block_show');
+ }
+ });
+
+ // set event handling code for non-jquery-autocomplete parts of widget
+ if ($('li', selector).length > 1)
{
- $('#max_sitename_width').val(widthSitesSelection);
+ // event handler for when site selector is clicked. shows dropdown w/ first X sites
+ $(".custom_select_main_link", selector).click(function() {
+ $(".custom_select_block", selector).addClass("custom_select_block_show");
+ $('.custom_select_ul_list', selector).show();
+ $('.websiteSearch', selector).val('').focus();
+ return false;
+ });
+
+ $('.custom_select_block', selector).on('mouseenter', function() {
+ $('.custom_select_ul_list li a', selector).each(function(){
+ var hash = broadcast.getHashFromUrl();
+ hash = hash ? hash.replace(/idSite=[0-9]+/, 'idSite='+$(this).attr('siteid')) : "";
+
+ var queryString = piwikHelper.getCurrentQueryStringWithParametersModified(
+ 'idSite=' + $(this).attr('siteid'));
+ $(this).attr('href', queryString + hash);
+ });
+ });
+
+ // change selection. fire's site selector's on select event and modifies the attributes
+ // of the selected link
+ $('.custom_select_ul_list li a', selector).each(function() {
+ $(this).click(function (e) {
+ var idsite = $(this).attr('siteid'),
+ name = $(this).text();
+
+ $(".custom_select_main_link", selector)
+ .attr('siteid', idsite)
+ .text(name);
+
+ selector.trigger('piwik:siteSelected', {id: idsite, name: name});
+
+ // close the dropdown
+ $(".custom_select_block", selector).removeClass("custom_select_block_show");
+
+ e.preventDefault();
+ });
+ });
+
+ var inlinePaddingWidth = 22, staticPaddingWidth = 34;
+ if ($(".custom_select_block ul", selector)[0])
+ {
+ var widthSitesSelection = Math.max(
+ $(".custom_select_block ul", selector).width()+inlinePaddingWidth,
+ $(".custom_select_main_link", selector).width()+staticPaddingWidth
+ );
+ $(".custom_select_block", selector).css('width', widthSitesSelection);
+ }
}
else
{
- widthSitesSelection = +$('#max_sitename_width').val(); // convert to int
+ $('.custom_select_main_link', selector).addClass('noselect');
}
- $('.custom_select_ul_list').hide();
+ // handle multi-sites link click (triggers site selected event w/ id=all)
+ $('.custom_select_all', selector).click(function () {
+ $(".custom_select_block", selector).toggleClass("custom_select_block_show");
+
+ selector.trigger('piwik:siteSelected', {id: 'all', name: $('.custom_select_all>a', selector).text()});
+ });
- // customize jquery-ui's autocomplete positioning
- var cssToRemove = {float: 'none', position: 'static'};
- $("#siteSelect.ui-autocomplete")
- .show().width(widthSitesSelection).css(cssToRemove)
- .find('li,a').each(function () {
- $(this).css(cssToRemove);
- });
+ // handle submit button click
+ $('.but', selector).on('click', function(e) {
+ if (websiteSearch.val() != '')
+ {
+ websiteSearch.autocomplete('search', websiteSearch.val() + '%%%');
+ }
+ return false;
+ });
- $(".custom_select_block_show").width(widthSitesSelection);
- }
- }).data("autocomplete")._renderItem = function( ul, item ) {
- $(ul).attr('id', 'siteSelect');
- return $( "<li></li>" )
- .data( "item.autocomplete", item )
- .append( $( "<a></a>" ).html( item.label )
- .attr('href', piwikHelper.getCurrentQueryStringWithParametersModified('idSite='+item.id)
- + (broadcast.isHashExists()
- ? broadcast.getHashFromUrl().replace(/idSite=[0-9]+/, 'idSite='+item.id)
- : ""
- ) ) )
- .appendTo( ul );
+ // if the data-switch-site-on-select attribute is set to 1 on the selector, set
+ // a default handler for piwik:siteSelected that switches the current site
+ if (selector.attr('data-switch-site-on-select') == 1)
+ {
+ selector.bind('piwik:siteSelected', function (e, site) {
+ switchSite(site.id, site.name);
+ });
+ }
+ });
};
-
- $('body').on('mouseup',function(e){
- if(!$(e.target).parents('#sitesSelectionSearch').length && !$(e.target).is('#sitesSelectionSearch') && !$(e.target).parents('#siteSelect.ui-autocomplete').length) {
- reset();
- $('#sitesSelectionSearch .custom_select_block').removeClass('custom_select_block_show');
- }
- });
-
- function reset()
- {
- $('#websiteSearch').val('');
- $('.custom_select_ul_list').show();
- $("#siteSelect.ui-autocomplete").hide();
- $("#reset").hide();
- }
- $("#reset").click(reset);
-
- // set event handling code for non-jquery-autocomplete parts of widget
- if($('.custom_select_ul_list li').length > 1) {
- // event handler for when site selector is clicked. shows dropdown w/ first X sites
- $("#sitesSelectionSearch .custom_select_main_link").click(function(){
- $("#sitesSelectionSearch .custom_select_block").toggleClass("custom_select_block_show");
- $('.custom_select_ul_list').show();
- $('#websiteSearch').val('').focus();
- return false;
- });
- $('#sitesSelectionSearch .custom_select_block').on('mouseenter', function(){
- $('.custom_select_ul_list li a').each(function(){
- var hash = broadcast.getHashFromUrl();
- hash = hash ? hash.replace(/idSite=[0-9]+/, 'idSite='+$(this).attr('siteid')) : "";
-
- var queryString = piwikHelper.getCurrentQueryStringWithParametersModified(
- 'idSite=' + $(this).attr('siteid'));
- $(this).attr('href', queryString + hash);
- });
- });
-
- // change selection. fire's site selector's on select event and modifies the attributes
- // of the selected link
- $('.custom_select_ul_list li a').each(function(){
- $(this).click(function (e) {
- var idsite = $(this).attr('siteid'), name = $(this).text();
- window.autocompleteOnNewSiteSelect(idsite, name);
-
- $("#sitesSelectionSearch .custom_select_main_link")
- .attr('siteid', idsite)
- .text(name);
-
- // close the dropdown
- $("#sitesSelectionSearch .custom_select_block").toggleClass("custom_select_block_show");
-
- e.preventDefault();
- });
- });
-
- var inlinePaddingWidth = 22, staticPaddingWidth = 34;
- if($(".custom_select_block ul")[0]){
- var widthSitesSelection = Math.max($(".custom_select_block ul").width()+inlinePaddingWidth, $(".custom_select_main_link").width()+staticPaddingWidth);
- $(".custom_select_block").css('width', widthSitesSelection);
- }
- } else {
- $('.custom_select_main_link').addClass('noselect');
- }
-
- // handle multi-sites link click
- $('.custom_select_all').click(function () {
- $("#sitesSelectionSearch .custom_select_block").toggleClass("custom_select_block_show");
- window.autocompleteOnNewSiteSelect('all', $('.custom_select_all>a').text());
- });
});
diff --git a/plugins/CoreHome/templates/misc.js b/plugins/CoreHome/templates/misc.js
index ab542b802f..04a21a118b 100755
--- a/plugins/CoreHome/templates/misc.js
+++ b/plugins/CoreHome/templates/misc.js
@@ -56,27 +56,68 @@ $(document).ready(function() {
// section toggler behavior
//
- // when click section toggler link, toggle the visibility of the associated section
- $('body').on('click', '.section-toggler-link', function (e) {
- e.preventDefault();
+ var handleSectionToggle = function (self, showType, doHide)
+ {
+ var sectionId = $(self).attr('data-section-id'),
+ section = $('#' + sectionId),
+ showText = _pk_translate('General_Show_js'),
+ hideText = _pk_translate('General_Hide_js');
- var self = this,
- sectionId = $(self).attr('data-section-id'),
- section = $('#' + sectionId);
+ if (typeof(doHide) == 'undefined')
+ {
+ doHide = section.is(':visible');
+ }
- if (section.is(':visible'))
+ if (doHide)
{
- section.slideUp(function() { $(self).text(_pk_translate('General_Show_js')); });
+ var newText = $(self).text().replace(hideText, showText),
+ afterHide = function() { $(self).text(newText); };
+
+ if (showType == 'slide')
+ {
+ section.slideUp(afterHide);
+ }
+ else if (showType == 'inline')
+ {
+ section.hide();
+ afterHide();
+ }
+ else
+ {
+ section.hide(afterHide);
+ }
}
else
{
- $(self).text(_pk_translate('General_Hide_js'));
- section.slideDown();
+ var newText = $(self).text().replace(showText, hideText);
+ $(self).text(newText);
+
+ if (showType == 'slide')
+ {
+ section.slideDown();
+ }
+ else if (showType == 'inline')
+ {
+ section.css('display', 'inline-block');
+ }
+ else
+ {
+ section.show();
+ }
}
-
+ };
+
+ // when click section toggler link, toggle the visibility of the associated section
+ $('body').on('click', 'a.section-toggler-link', function (e) {
+ e.preventDefault();
+ handleSectionToggle(this, 'slide');
return false;
});
+ $('body').on('change', 'input.section-toggler-link', function (e) {
+ handleSectionToggle(this, 'inline', !$(this).is(':checked'));
+ });
+
//
// reports by dimension list behavior
//
diff --git a/plugins/CoreHome/templates/sites_selection.tpl b/plugins/CoreHome/templates/sites_selection.tpl
index 2e0d224daf..c716bea2fb 100644
--- a/plugins/CoreHome/templates/sites_selection.tpl
+++ b/plugins/CoreHome/templates/sites_selection.tpl
@@ -20,8 +20,9 @@
</a>
</div>
{/capture}
-<div class="sites_autocomplete">
- <div id="sitesSelectionSearch" class="custom_select">
+<div class="sites_autocomplete" {if isset($siteSelectorId)}id="{$siteSelectorId}"{/if}
+ {if !isset($switchSiteOnSelect) || $switchSiteOnSelect eq true}data-switch-site-on-select="1"{/if}>
+ <div class="custom_select">
<a href="#" onclick="return false" class="custom_select_main_link" siteid="{if isset($idSite)}{$idSite}{else}{$sites[0].idsite}{/if}">{if isset($siteName)}{$siteName}{else}{$sites[0].name}{/if}</a>
@@ -29,7 +30,7 @@
{if isset($allWebsitesLinkLocation) && $allWebsitesLinkLocation eq 'top'}
{$sitesSelector_allWebsitesLink}
{/if}
- <div id="custom_select_container">
+ <div class="custom_select_container">
<ul class="custom_select_ul_list" >
{foreach from=$sites item=info}
<li {if (!isset($showSelectedSite) || $showSelectedSite eq false) && $idSite==$info.idsite} style="display: none"{/if}><a href="#" siteid="{$info.idsite}">{$info.name}</a></li>
@@ -40,23 +41,15 @@
{$sitesSelector_allWebsitesLink}
{/if}
<div class="custom_select_search" {if !$show_autocompleter}style="display:none;"{/if}>
- <input type="text" length="15" id="websiteSearch" class="inp"/>
- <input type="hidden" class="max_sitename_width" id="max_sitename_width" value="130" />
+ <input type="text" length="15" class="websiteSearch inp"/>
+ <input type="hidden" class="max_sitename_width" value="130" />
<input type="submit" value="Search" class="but"/>
- <img title="Clear" id="reset" style="position: relative; top: 4px; left: -44px; cursor: pointer; display: none;" src="plugins/CoreHome/templates/images/reset_search.png"/>
+ <img title="Clear" class="reset" style="position: relative; top: 4px; left: -44px; cursor: pointer; display: none;" src="plugins/CoreHome/templates/images/reset_search.png"/>
</div>
</div>
</div>
{if isset($inputName)}<input type="hidden" name="{$inputName}" value="{if isset($idSite)}{$idSite}{else}{$sites[0].idsite}{/if}"/>{/if}
- {if isset($switchSiteOnSelect) && $switchSiteOnSelect eq false}
- <script type="text/javascript">
- {literal}
- // make sure site is not switched an item is selected
- window.autocompleteOnNewSiteSelect = function(id) {
- $('.sites_autocomplete input').val(id);
- };
- {/literal}
- </script>
- {/if}
</div>
-
+<script type="text/javascript">
+ {literal}$(document).ready(function() { piwik.initSiteSelectors(); });{/literal}
+</script>
diff --git a/plugins/UsersManager/templates/UsersManager.js b/plugins/UsersManager/templates/UsersManager.js
index 6948af6f90..66c2cc8001 100644
--- a/plugins/UsersManager/templates/UsersManager.js
+++ b/plugins/UsersManager/templates/UsersManager.js
@@ -234,4 +234,14 @@ $(document).ready( function() {
$('.updateAccess')
.click( bindUpdateAccess );
+
+ // when a site is selected, reload the page w/o showing the ajax loading element
+ $('#usersManagerSiteSelect').bind('piwik:siteSelected', function(e, site) {
+ switchSite(
+ site.id,
+ site.name,
+ false /* do not show main ajax loading animation */,
+ true /* do not go to all websites dash */
+ );
+ });
});
diff --git a/plugins/UsersManager/templates/UsersManager.tpl b/plugins/UsersManager/templates/UsersManager.tpl
index 9034bbcc9c..88ad149c56 100644
--- a/plugins/UsersManager/templates/UsersManager.tpl
+++ b/plugins/UsersManager/templates/UsersManager.tpl
@@ -39,14 +39,8 @@
{/capture}
{include file="CoreHome/templates/sites_selection.tpl"
siteName=$defaultReportSiteName idSite=$idSiteSelected allSitesItemText=$applyAllSitesText
- allWebsitesLinkLocation=top}
+ allWebsitesLinkLocation=top siteSelectorId="usersManagerSiteSelect" switchSiteOnSelect=false}
</section>
- {literal}<script type="text/javascript">
- window.autocompleteOnNewSiteSelect = function(siteId, siteName)
- {
- switchSite(siteId, siteName, false /* do not show main ajax loading animation */);
- };
- </script>{/literal}
</div>
{ajaxErrorDiv}
diff --git a/themes/default/ajaxHelper.js b/themes/default/ajaxHelper.js
index 32c85366de..943590f2c3 100644
--- a/themes/default/ajaxHelper.js
+++ b/themes/default/ajaxHelper.js
@@ -126,6 +126,27 @@ function ajaxHelper() {
break;
}
};
+
+ /**
+ * Gets this helper instance ready to send a bulk request. Each argument to this
+ * function is a single request to use.
+ *
+ * @param {object} ... The requests to send simultaneously.
+ */
+ this.setBulkRequests = function () {
+ var urls = [];
+ for (var i = 0; i != arguments.length; ++i)
+ {
+ urls.push($.param(arguments[i]));
+ }
+
+ this.addParams({
+ module: 'API',
+ method: 'API.getBulkRequest',
+ urls: urls,
+ format: 'json'
+ }, 'post');
+ };
/**
* Sets the callback called after the request finishes
diff --git a/themes/default/common.css b/themes/default/common.css
index 4ecb872a21..fb4af2c3d3 100644
--- a/themes/default/common.css
+++ b/themes/default/common.css
@@ -344,7 +344,7 @@ a {
.custom_select_block_show{ height:auto; overflow:visible;padding-top:5px; }
-#siteSelect a {
+.siteSelect a {
white-space:normal;
text-align:left;
}