diff options
-rw-r--r-- | plugins/CoreHome/templates/autocomplete.js | 17 | ||||
-rw-r--r-- | plugins/CoreHome/templates/sites_selection.tpl | 45 | ||||
-rw-r--r-- | plugins/CoreHome/templates/top_bar.tpl | 7 | ||||
-rw-r--r-- | plugins/UsersManager/Controller.php | 9 | ||||
-rw-r--r-- | plugins/UsersManager/templates/userSettings.js | 2 | ||||
-rw-r--r-- | plugins/UsersManager/templates/userSettings.tpl | 13 | ||||
-rw-r--r-- | themes/default/common.css | 21 |
7 files changed, 87 insertions, 27 deletions
diff --git a/plugins/CoreHome/templates/autocomplete.js b/plugins/CoreHome/templates/autocomplete.js index 4f2df91f96..ce10a61e95 100644 --- a/plugins/CoreHome/templates/autocomplete.js +++ b/plugins/CoreHome/templates/autocomplete.js @@ -21,6 +21,13 @@ function switchSite(id, name) 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) +{ + switchSite(siteId, siteName); +}; + $(function() { if($('#websiteSearch').length == 0) { @@ -50,7 +57,14 @@ $(function() { else { if(ui.item.id > 0) { - switchSite(ui.item.id, ui.item.name); + // 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(); } @@ -83,7 +97,6 @@ $(function() { $("#siteSelect.ui-autocomplete").css('left', '-6px'); $("#siteSelect.ui-autocomplete").width(parseInt(widthSitesSelection)); $(".custom_select_block_show").width(parseInt(widthSitesSelection)); - } }).data("autocomplete")._renderItem = function( ul, item ) { $(ul).attr('id', 'siteSelect'); diff --git a/plugins/CoreHome/templates/sites_selection.tpl b/plugins/CoreHome/templates/sites_selection.tpl index 7e25657953..94c60706ea 100644 --- a/plugins/CoreHome/templates/sites_selection.tpl +++ b/plugins/CoreHome/templates/sites_selection.tpl @@ -1,14 +1,13 @@ <div class="sites_autocomplete"> - <label>{'General_Website'|translate}</label> <div id="sitesSelectionSearch" class="custom_select"> - <a href="index.php?module=CoreHome&action=index&idSite={$idSite}&period={$period}&date={$rawDate}" onclick="return false" class="custom_select_main_link">{$siteName}</a> + <a href="index.php?module=CoreHome&action=index&idSite={$idSite}&period={$period}&date={$rawDate}" siteid="{$idSite}" onclick="return false" class="custom_select_main_link">{$siteName}</a> <div class="custom_select_block"> <div id="custom_select_container"> <ul class="custom_select_ul_list" > {foreach from=$sites item=info} - <li {if $idSite==$info.idsite} style="display: none"{/if}><a href="index.php?module=CoreHome&action=index&idSite={$info.idsite}&period={$period}&date={$rawDate}" siteid="{$info.idsite}" onclick="switchSite({$info.idsite}, $(this).text());">{$info.name}</a></li> + <li {if $idSite==$info.idsite} style="display: none"{/if}><a href="index.php?module=CoreHome&action=index&idSite={$info.idsite}&period={$period}&date={$rawDate}" siteid="{$info.idsite}">{$info.name}</a></li> {/foreach} </ul> </div> @@ -18,9 +17,9 @@ </div> <div class="custom_select_search"> - <input type="text" length="15" id="websiteSearch" class="inp"> + <input type="text" length="15" id="websiteSearch" class="inp"/> <input type="hidden" class="max_sitename_width" id="max_sitename_width" value="130" /> - <input type="submit" value="Search" class="but"> + <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"/> </div> </div> @@ -31,22 +30,45 @@ $('.custom_select_search').hide(); {/literal}{/if} {literal} + // 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"); - $('#websiteSearch').focus(); + $('.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(); - $(this).attr('href', piwikHelper.getCurrentQueryStringWithParametersModified('idSite='+$(this).attr('siteid')) + - (hash - ? hash.replace(/idSite=[0-9]+/, 'idSite='+$(this).attr('siteid')) - : "") - ); + 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('href', $(this).attr('href')) + .attr('siteid', idsite) + .text(name); + + // close the dropdown + $("#sitesSelectionSearch .custom_select_block").toggleClass("custom_select_block_show"); + + e.preventDefault(); + }); + }); + var inlinePaddingWidth=22; var staticPaddingWidth=34; if($(".custom_select_block ul")[0]){ @@ -59,4 +81,3 @@ {/literal} </script> </div> - diff --git a/plugins/CoreHome/templates/top_bar.tpl b/plugins/CoreHome/templates/top_bar.tpl index f18c4e7b64..ece94934ea 100644 --- a/plugins/CoreHome/templates/top_bar.tpl +++ b/plugins/CoreHome/templates/top_bar.tpl @@ -24,4 +24,9 @@ </div> -{if $showSitesSelection}{include file="CoreHome/templates/sites_selection.tpl"}{/if} +{if $showSitesSelection} +<div class="top_bar_sites_selector"> + <label>{'General_Website'|translate}</label> + {include file="CoreHome/templates/sites_selection.tpl"} +</div> +{/if} diff --git a/plugins/UsersManager/Controller.php b/plugins/UsersManager/Controller.php index 21f174c119..3ff85f537a 100644 --- a/plugins/UsersManager/Controller.php +++ b/plugins/UsersManager/Controller.php @@ -145,6 +145,15 @@ class Piwik_UsersManager_Controller extends Piwik_Controller_Admin $defaultReport = $this->getDefaultWebsiteId(); } $view->defaultReport = $defaultReport; + + if ($defaultReport == 'MultiSites') + { + $view->defaultReportSiteName = Piwik_Site::getNameFor($this->getDefaultWebsiteId()); + } + else + { + $view->defaultReportSiteName = Piwik_Site::getNameFor($defaultReport); + } $view->defaultDate = $this->getDefaultDateForUser($userLogin); $view->availableDefaultDates = array( diff --git a/plugins/UsersManager/templates/userSettings.js b/plugins/UsersManager/templates/userSettings.js index 46c4fa699a..9d91c0a6c7 100644 --- a/plugins/UsersManager/templates/userSettings.js +++ b/plugins/UsersManager/templates/userSettings.js @@ -25,7 +25,7 @@ function getUserSettingsAJAX() var passwordBis = encodeURIComponent( $('#passwordBis').val() ); var defaultReport = $('input[name=defaultReport]:checked').val(); if(defaultReport == 1) { - defaultReport = $('#defaultReportWebsite option:selected').val(); + defaultReport = $('#sitesSelectionSearch .custom_select_main_link').attr('siteid'); } var request = ''; request += 'module=UsersManager'; diff --git a/plugins/UsersManager/templates/userSettings.tpl b/plugins/UsersManager/templates/userSettings.tpl index 4d3c1ab1bb..5a9730f5e8 100644 --- a/plugins/UsersManager/templates/userSettings.tpl +++ b/plugins/UsersManager/templates/userSettings.tpl @@ -41,11 +41,14 @@ <fieldset> <label><input type="radio" value="MultiSites" name="defaultReport"{if $defaultReport=='MultiSites'} checked="checked"{/if} /> {'General_AllWebsitesDashboard'|translate}</label><br /> <label><input type="radio" value="1" name="defaultReport"{if $defaultReport!='MultiSites'} checked="checked"{/if} /> {'General_DashboardForASpecificWebsite'|translate}</label> - <select id="defaultReportWebsite"> - {if isset($sites)}{foreach from=$sites item=info} - <option value="{$info.idsite}" {if $defaultReport==$info.idsite} selected="selected"{/if}>{$info.name}</option> - {/foreach}{/if} - </select> + {assign var=siteName value="$defaultReportSiteName"} + {include file="CoreHome/templates/sites_selection.tpl"} + {literal} + <script type="text/javascript"> + // make sure nothing happens when an item is selected + window.autocompleteOnNewSiteSelect = function() {}; + </script> + {/literal} </fieldset> </td> </tr> diff --git a/themes/default/common.css b/themes/default/common.css index 8c63dc0b68..396a0a27eb 100644 --- a/themes/default/common.css +++ b/themes/default/common.css @@ -220,21 +220,30 @@ a { } /*sites_autocomplete*/ -.sites_autocomplete{ +.sites_autocomplete{ + position: absolute; + font-size:12px; + display: inline-block; + padding-left: 12px; +} +.top_bar_sites_selector{ position:absolute; top:65px; right:0; +} +.top_bar_sites_selector>label{ + display:inline-block; + padding:7px 0 6px 0; + float:left; font-size:12px; } +.top_bar_sites_selector>.sites_autocomplete{ + position:static; +} .autocompleteMatched { color:#5256BE; font-weight:bold; } -.sites_autocomplete label{ - display:inline-block; - padding:7px 12px 6px 0; - float:left; -} .sites_autocomplete .custom_select{ float:left; |