diff options
author | benakamoorthi <benaka.moorthi@gmail.com> | 2012-10-03 12:51:50 +0400 |
---|---|---|
committer | benakamoorthi <benaka.moorthi@gmail.com> | 2012-10-03 12:51:50 +0400 |
commit | 22fa19104670ac2e085935958c1080e667d3dff5 (patch) | |
tree | e703cd6b99038dd33a315230047a26a7d75cd312 | |
parent | 57aae75cfc426935fa4d764d2f35a205f2555024 (diff) |
Refs #3184, fix firefox period selector issue when double clicking the selected period and make sure double clicking period selector labels doesn't select the text.
git-svn-id: http://dev.piwik.org/svn/trunk@7092 59fd770c-687e-43c8-a1e3-f5a4ff64c105
-rw-r--r-- | plugins/CoreHome/templates/calendar.js | 44 | ||||
-rw-r--r-- | themes/default/common.css | 3 |
2 files changed, 40 insertions, 7 deletions
diff --git a/plugins/CoreHome/templates/calendar.js b/plugins/CoreHome/templates/calendar.js index 1535793e04..9588577b23 100644 --- a/plugins/CoreHome/templates/calendar.js +++ b/plugins/CoreHome/templates/calendar.js @@ -373,20 +373,50 @@ $(document).ready(function() { } }); + // Hack to get around firefox bug. When double clicking a label in firefox, the 'click' + // event of its associated input will not be fired twice. We want to change the period + // if clicking the select period's label OR input, so we catch the click event on the + // label & the input. + var reloading = false; + var changePeriodOnClick = function(periodInput) + { + if (reloading) // if a click event resulted in reloading, don't reload again + { + return; + } + + var url = periodInput.val(), + period = broadcast.getValueFromUrl('period', url); + + // if clicking on the selected period, change the period but not the date + if (selectedPeriod == period && selectedPeriod != 'range') + { + // only reload if current period is different from selected + if (piwik.period != selectedPeriod && !reloading) + { + reloading = true; + selectedPeriod = period; + updateDate(piwik.currentDateString); + } + return true; + } + + return false; + }; + + $("#otherPeriods label").on('click', function(e) { + var id = $(e.target).attr('for'); + changePeriodOnClick($('#' + id)); + }); + // when non-range period is clicked, change the period & refresh the date picker $("#otherPeriods input").on('click', function(e) { var request_URL = $(e.target).val(), period = broadcast.getValueFromUrl('period', request_URL), lastPeriod = selectedPeriod; - // if clicking on the selected period, change the period but not the date - if (selectedPeriod == period) + if (changePeriodOnClick($(e.target))) { - if (piwik.period != selectedPeriod) // only reload if current period is different from selected - { - selectedPeriod = period; - updateDate(piwik.currentDateString); - } return true; } diff --git a/themes/default/common.css b/themes/default/common.css index aaa248a71c..fdf4c5b3ec 100644 --- a/themes/default/common.css +++ b/themes/default/common.css @@ -157,6 +157,9 @@ a { display:inline-block; padding: 2px 0 3px 0; vertical-align:top; + user-select: none; + -moz-user-select: none; + -webkit-user-select: none; } #periodString label.selected-period-label { text-decoration: underline; |