From c493abfe0885e8dc9283ebae6254e0d8454f9c68 Mon Sep 17 00:00:00 2001 From: sgiehl <stefan@piwik.org> Date: Wed, 1 May 2013 11:50:43 +0200 Subject: [PATCH] improved jquery id selector usage --- plugins/Annotations/templates/annotations.js | 2 +- .../templates/generalSettings.js | 7 +++--- .../templates/jsTrackingGenerator.js | 18 +++++++-------- .../templates/jsTrackingGenerator.tpl | 6 ++--- plugins/CoreHome/templates/calendar.js | 12 +++++----- plugins/CoreHome/templates/datatable.js | 2 +- plugins/CoreHome/templates/date.js | 4 ++-- plugins/Dashboard/templates/dashboard.js | 22 +++++++++---------- .../Dashboard/templates/dashboardObject.js | 2 +- plugins/Feedback/templates/feedback.js | 2 +- plugins/Feedback/templates/index.tpl | 2 +- plugins/Goals/templates/GoalForm.js | 2 +- plugins/PDFReports/templates/pdf.js | 10 ++++----- .../templates/report_parameters.tpl | 6 ++--- .../templates/privacySettings.js | 8 +++---- .../SegmentEditor/templates/Segmentation.js | 2 +- .../SitesManager/templates/SitesManager.js | 8 +++---- plugins/UserCountry/templates/admin.js | 2 +- plugins/UserCountryMap/js/realtime-map.js | 4 ++-- .../UsersManager/templates/UsersManager.js | 2 +- .../UsersManager/templates/userSettings.js | 6 ++--- 21 files changed, 65 insertions(+), 64 deletions(-) diff --git a/plugins/Annotations/templates/annotations.js b/plugins/Annotations/templates/annotations.js index 941ae4486a..817aade8ac 100755 --- a/plugins/Annotations/templates/annotations.js +++ b/plugins/Annotations/templates/annotations.js @@ -211,7 +211,7 @@ * @return {boolean} */ var isAnnotationStarred = function (annotation) { - return +$('.annotation-star', annotation).attr('data-starred') == 1 ? true : false; + return !!(+$('.annotation-star', annotation).attr('data-starred') == 1); }; /** diff --git a/plugins/CoreAdminHome/templates/generalSettings.js b/plugins/CoreAdminHome/templates/generalSettings.js index 6a493626c7..303e0d4e32 100644 --- a/plugins/CoreAdminHome/templates/generalSettings.js +++ b/plugins/CoreAdminHome/templates/generalSettings.js @@ -123,16 +123,17 @@ $(document).ready(function () { $('#customLogo').change(function () {$("#logoUploadForm").submit()}); // trusted hosts event handling - $('#trustedHostSettings .adminTable').on('click', '.remove-trusted-host', function (e) { + var trustedHostSettings = $('#trustedHostSettings'); + trustedHostSettings.find('.adminTable').on('click', '.remove-trusted-host', function (e) { e.preventDefault(); $(this).parent().parent().remove(); return false; }); - $('#trustedHostSettings .add-trusted-host').click(function (e) { + trustedHostSettings.find('.add-trusted-host').click(function (e) { e.preventDefault(); // append new row to the table - $('#trustedHostSettings tbody').append('<tr>' + $('#trustedHostSettings').find('tbody').append('<tr>' + '<td><input name="trusted_host" type="text" value=""/></td>' + '<td><a href="#" class="remove-trusted-host">x</a></td>' + '</tr>'); diff --git a/plugins/CoreAdminHome/templates/jsTrackingGenerator.js b/plugins/CoreAdminHome/templates/jsTrackingGenerator.js index d1ecd3705f..034d7dbe32 100644 --- a/plugins/CoreAdminHome/templates/jsTrackingGenerator.js +++ b/plugins/CoreAdminHome/templates/jsTrackingGenerator.js @@ -65,7 +65,7 @@ siteUrls = {}, siteCurrencies = {}, allGoals = {}, - noneText = $('#image-tracker-goal>option').text(); + noneText = $('#image-tracker-goal').find('>option').text(); // queries Piwik for needed site info for one site var getSiteData = function (idSite, sectionSelect, callback) { @@ -142,7 +142,7 @@ // function that generates JS code var generateJsCode = function () { // get data - var idSite = $('#js-tracker-website .custom_select_main_link').attr('siteid'), + var idSite = $('#js-tracker-website').find('.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'), @@ -214,13 +214,13 @@ </script>\n\ <!-- End Piwik Code -->'; - $('#javascript-text textarea').val(result) + $('#javascript-text').find('textarea').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'), + var idSite = $('#image-tracker-website').find('.custom_select_main_link').attr('siteid'), path = document.location.pathname, piwikURL = ("https:" == document.location.protocol ? "https://" + piwikHost : "http://" + piwikHost) + path.substring(0, path.lastIndexOf('/')) + '/piwik.php', actionName = $('#image-tracker-action-name').val(), @@ -230,7 +230,7 @@ if ($('#image-tracking-goal-check').is(':checked')) { idGoal = $('#image-tracker-goal').val(); if (idGoal) { - revenue = $('#image-tracker-advanced-options .revenue').val(); + revenue = $('#image-tracker-advanced-options').find('.revenue').val(); } } @@ -256,7 +256,7 @@ <!-- End Piwik -->'; result = result.replace("&", "&", "g"); - $('#image-tracking-link textarea').val(result); + $('#image-tracking-link').find('textarea').val(result); }; // on image link tracker site change, change available goals @@ -328,11 +328,11 @@ }); // initial generation - getSiteData($( - '#js-tracker-website .custom_select_main_link').attr('siteid'), + getSiteData( + $('#js-tracker-website').find('.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'); + var imageTrackerSiteId = $('#image-tracker-website').find('.custom_select_main_link').attr('siteid'); resetGoalSelectItems(imageTrackerSiteId, 'image-tracker-goal'); generateJsCode(); diff --git a/plugins/CoreAdminHome/templates/jsTrackingGenerator.tpl b/plugins/CoreAdminHome/templates/jsTrackingGenerator.tpl index b78d88cbf0..b4ba358e83 100644 --- a/plugins/CoreAdminHome/templates/jsTrackingGenerator.tpl +++ b/plugins/CoreAdminHome/templates/jsTrackingGenerator.tpl @@ -1,5 +1,5 @@ {include file="CoreAdminHome/templates/header.tpl"} -<link rel="stylesheet" href="plugins/CoreAdminHome/templates/jsTrackingGenerator.css"></link> +<link rel="stylesheet" href="plugins/CoreAdminHome/templates/jsTrackingGenerator.css" /> <script type="text/javascript" src="plugins/CoreAdminHome/templates/jsTrackingGenerator.js"></script> <div id="js-tracking-generator-data" @@ -14,7 +14,7 @@ <br/><br/> {'CoreAdminHome_JSTrackingIntro2'|translate} {'CoreAdminHome_JSTrackingIntro3'|translate:'<a href="http://piwik.org/integrate/" target="_blank">':'</a>'} <br/><br/> - {'CoreAdminHome_JSTrackingIntro4'|translate:'<a href="#image-tracking-link">':'</a>'} + {'CoreAdminHome_JSTrackingIntro4'|translate:'<a href="#image-tracking">':'</a>'} <br/><br/> {'CoreAdminHome_JSTrackingIntro5'|translate:'<a target="_blank" href="http://piwik.org/docs/javascript-tracking/">':'</a>'} </p> @@ -174,7 +174,7 @@ <br/> </div> -<h2 id="image-tracking-link">{'CoreAdminHome_ImageTracking'|translate}</h2> +<h2 id="image-tracking">{'CoreAdminHome_ImageTracking'|translate}</h2> <div id="image-tracking-code-options" class="adminTable"> diff --git a/plugins/CoreHome/templates/calendar.js b/plugins/CoreHome/templates/calendar.js index e531e375a9..9952ac281b 100644 --- a/plugins/CoreHome/templates/calendar.js +++ b/plugins/CoreHome/templates/calendar.js @@ -289,8 +289,8 @@ }; var togglePeriodPickers = function (showSingle) { - $('#periodString .period-date').toggle(showSingle); - $('#periodString .period-range').toggle(!showSingle); + $('#periodString').find('.period-date').toggle(showSingle); + $('#periodString').find('.period-range').toggle(!showSingle); $('#calendarRangeApply').toggle(!showSingle); }; @@ -379,13 +379,13 @@ return false; }; - $("#otherPeriods label").on('click', function (e) { + $("#otherPeriods").find("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) { + $("#otherPeriods").find("input").on('click', function (e) { var request_URL = $(e.target).val(), period = broadcast.getValueFromUrl('period', request_URL), lastPeriod = selectedPeriod; @@ -443,7 +443,7 @@ // reset date/period when opening calendar var firstClick = true; - $('#periodString #date').click(function () { + $('#periodString').find('#date').click(function () { if (!firstClick) { datepickerElem.datepicker('setDate', currentDate); $('#period_id_' + piwik.period).click(); @@ -497,7 +497,7 @@ if (!isValidDate(oDateFrom) || !isValidDate(oDateTo) || oDateFrom > oDateTo) { - $('#alert h2').text(_pk_translate('General_InvalidDateRange_js')); + $('#alert').find('h2').text(_pk_translate('General_InvalidDateRange_js')); piwikHelper.modalConfirm('#alert', {}); return false; } diff --git a/plugins/CoreHome/templates/datatable.js b/plugins/CoreHome/templates/datatable.js index 49725bead6..1369b11786 100644 --- a/plugins/CoreHome/templates/datatable.js +++ b/plugins/CoreHome/templates/datatable.js @@ -1366,7 +1366,7 @@ dataTable.prototype = // if this url is also the url of a menu item, better to click that menu item instead of // doing AJAX request var menuItem = null; - $("#root>ul.nav a").each(function () { + $("#root").find(">ul.nav a").each(function () { if ($(this).attr('name') == url) { menuItem = this; return false diff --git a/plugins/CoreHome/templates/date.js b/plugins/CoreHome/templates/date.js index 1c6c5971bd..9e4ca30c72 100644 --- a/plugins/CoreHome/templates/date.js +++ b/plugins/CoreHome/templates/date.js @@ -23,7 +23,7 @@ $(document).ready(function () { } }; - $("#periodString #date") + $("#periodString").find("#date") .hover(function () { $(this).css({ cursor: "pointer"}); }, function () { @@ -32,7 +32,7 @@ $(document).ready(function () { .click(function () { periodWidget.toggle(); if ($("#periodMore").is(":visible")) { - $("#periodMore .ui-state-highlight").removeClass('ui-state-highlight'); + $("#periodMore").find(".ui-state-highlight").removeClass('ui-state-highlight'); } }); diff --git a/plugins/Dashboard/templates/dashboard.js b/plugins/Dashboard/templates/dashboard.js index c1c6996f93..40a3cb04fd 100644 --- a/plugins/Dashboard/templates/dashboard.js +++ b/plugins/Dashboard/templates/dashboard.js @@ -24,7 +24,7 @@ function initDashboard(dashboardId, dashboardLayout) { if (!$('#topBars').length) { $('#dashboardSettings').css({left: 0}); $('#dashboardSettings').after($('#Dashboard')); - $('#Dashboard > ul li a').each(function () {$(this).css({width: this.offestWidth + 30, paddingLeft: 0, paddingRight: 0});}); + $('#Dashboard').find('> ul li a').each(function () {$(this).css({width: this.offestWidth + 30, paddingLeft: 0, paddingRight: 0});}); $('#Dashboard_embeddedIndex_' + dashboardId).addClass('sfHover'); } @@ -36,7 +36,7 @@ function initDashboard(dashboardId, dashboardLayout) { $('#removeDashboardLink').show(); } // fix position - $('#dashboardSettings .widgetpreview-widgetlist').css('paddingTop', $('#dashboardSettings .widgetpreview-categorylist').parent('li').position().top); + $('#dashboardSettings').find('.widgetpreview-widgetlist').css('paddingTop', $('#dashboardSettings').find('.widgetpreview-categorylist').parent('li').position().top); }); $('body').on('mouseup', function (e) { if (!$(e.target).parents('#dashboardSettings').length && !$(e.target).is('#dashboardSettings')) { @@ -56,7 +56,7 @@ function initDashboard(dashboardId, dashboardLayout) { $('#dashboardSettings').widgetPreview({ isWidgetAvailable: function (widgetUniqueId) { - return !$('#dashboardWidgetsArea [widgetId=' + widgetUniqueId + ']').length; + return !$('#dashboardWidgetsArea').find('[widgetId=' + widgetUniqueId + ']').length; }, onSelect: function (widgetUniqueId) { var widget = widgetsHelper.getWidgetObjectFromUniqueId(widgetUniqueId); @@ -66,7 +66,7 @@ function initDashboard(dashboardId, dashboardLayout) { resetOnSelect: true }); - $('#columnPreview>div').each(function () { + $('#columnPreview').find('>div').each(function () { var width = []; $('div', this).each(function () { width.push(this.className.replace(/width-/, '')); @@ -74,8 +74,8 @@ function initDashboard(dashboardId, dashboardLayout) { $(this).attr('layout', width.join('-')); }); - $('#columnPreview>div').on('click', function () { - $('#columnPreview>div').removeClass('choosen'); + $('#columnPreview').find('>div').on('click', function () { + $('#columnPreview').find('>div').removeClass('choosen'); $(this).addClass('choosen'); }); @@ -122,15 +122,15 @@ function renameDashboard() { } function removeDashboard() { - $('#removeDashboardConfirm h2 span').html($('#dashboardWidgetsArea').dashboard('getDashboardName')); + $('#removeDashboardConfirm').find('h2 span').html($('#dashboardWidgetsArea').dashboard('getDashboardName')); piwikHelper.modalConfirm('#removeDashboardConfirm', {yes: function () { $('#dashboardWidgetsArea').dashboard('removeDashboard'); }}); } function showChangeDashboardLayoutDialog() { - $('#columnPreview>div').removeClass('choosen'); - $('#columnPreview>div[layout=' + $('#dashboardWidgetsArea').dashboard('getColumnLayout') + ']').addClass('choosen'); + $('#columnPreview').find('>div').removeClass('choosen'); + $('#columnPreview').find('>div[layout=' + $('#dashboardWidgetsArea').dashboard('getColumnLayout') + ']').addClass('choosen'); piwikHelper.modalConfirm('#changeDashboardLayout', {yes: function () { - $('#dashboardWidgetsArea').dashboard('setColumnLayout', $('#changeDashboardLayout .choosen').attr('layout')); + $('#dashboardWidgetsArea').dashboard('setColumnLayout', $('#changeDashboardLayout').find('.choosen').attr('layout')); }}); } @@ -189,7 +189,7 @@ function copyDashboardToUser() { }, 'post'); ajaxRequest.setCallback( function (id) { - $('#alert h2').text(_pk_translate('Dashboard_DashboardCopied_js')); + $('#alert').find('h2').text(_pk_translate('Dashboard_DashboardCopied_js')); piwikHelper.modalConfirm('#alert', {}); } ); diff --git a/plugins/Dashboard/templates/dashboardObject.js b/plugins/Dashboard/templates/dashboardObject.js index 80d74f3e4d..8ea5037473 100644 --- a/plugins/Dashboard/templates/dashboardObject.js +++ b/plugins/Dashboard/templates/dashboardObject.js @@ -434,7 +434,7 @@ function buildMenu() { var success = function (dashboards) { - var dashboardMenuList = $('#Dashboard > ul'); + var dashboardMenuList = $('#Dashboard').find('> ul'); dashboardMenuList.empty(); if (dashboards.length > 1) { dashboardMenuList.show(); diff --git a/plugins/Feedback/templates/feedback.js b/plugins/Feedback/templates/feedback.js index cbf07b4863..9fa2b1be01 100644 --- a/plugins/Feedback/templates/feedback.js +++ b/plugins/Feedback/templates/feedback.js @@ -10,7 +10,7 @@ $(function () { if (feedback.size()) { var fbDiv = $('<div id="feedback-dialog"></div>').appendTo('body'); - $('a#topmenu-feedback').click(function () { + feedback.click(function () { if (fbDiv.html() == '') { fbDiv.html('<div id="feedback-loading"><img alt="" src="themes/default/images/loading-blue.gif"> ' + _pk_translate('General_Loading_js') + '</div>'); } diff --git a/plugins/Feedback/templates/index.tpl b/plugins/Feedback/templates/index.tpl index adff78c214..fb79427a6a 100644 --- a/plugins/Feedback/templates/index.tpl +++ b/plugins/Feedback/templates/index.tpl @@ -14,7 +14,7 @@ }); $('#feedback-form-submit').click(function () { - var feedback = $('#feedback-form form'); + var feedback = $('#feedback-form').find('form'); $('#feedback-form').hide(); $.post(feedback.attr('action'), feedback.serialize(), function (data) { $('#feedback-sent').show().html(data); diff --git a/plugins/Goals/templates/GoalForm.js b/plugins/Goals/templates/GoalForm.js index fa1d0beceb..354e061978 100644 --- a/plugins/Goals/templates/GoalForm.js +++ b/plugins/Goals/templates/GoalForm.js @@ -155,7 +155,7 @@ function bindListGoalEdit() { var goalId = $(this).attr('id'); var goal = piwik.goals[goalId]; - $('#confirm h2').text(sprintf(_pk_translate('Goals_DeleteGoalConfirm_js'), '"' + goal.name + '"')); + $('#confirm').find('h2').text(sprintf(_pk_translate('Goals_DeleteGoalConfirm_js'), '"' + goal.name + '"')); piwikHelper.modalConfirm('#confirm', {yes: function () { ajaxDeleteGoal(goalId); }}); diff --git a/plugins/PDFReports/templates/pdf.js b/plugins/PDFReports/templates/pdf.js index 75e3ff831b..266c403adf 100644 --- a/plugins/PDFReports/templates/pdf.js +++ b/plugins/PDFReports/templates/pdf.js @@ -30,8 +30,8 @@ function formSetEditReport(idReport) { toggleReportType(report.type); $('#report_description').html(report.description); - $('#report_type option[value=' + report.type + ']').prop('selected', 'selected'); - $('#report_period option[value=' + report.period + ']').prop('selected', 'selected'); + $('#report_type').find('option[value=' + report.type + ']').prop('selected', 'selected'); + $('#report_period').find('option[value=' + report.period + ']').prop('selected', 'selected'); $('#report_hour').val(report.hour); $('[name=report_format].' + report.type + ' option[value=' + report.format + ']').prop('selected', 'selected'); @@ -61,7 +61,7 @@ function getReportAjaxRequest(idReport, defaultApiMethod) { function toggleReportType(reportType) { resetReportParametersFunctions[reportType](); - $('#report_type option').each(function (index, type) { + $('#report_type').find('option').each(function (index, type) { $('.' + $(type).val()).hide(); }); $('.' + reportType).show(); @@ -74,7 +74,7 @@ function initManagePdf() { var apiParameters = getReportAjaxRequest(idReport, 'PDFReports.updateReport'); apiParameters.idReport = idReport; apiParameters.description = $('#report_description').val(); - apiParameters.reportType = $('#report_type option:selected').val(); + apiParameters.reportType = $('#report_type').find('option:selected').val(); apiParameters.reportFormat = $('[name=report_format].' + apiParameters.reportType + ' option:selected').val(); var reports = []; @@ -89,7 +89,7 @@ function initManagePdf() { var ajaxHandler = new ajaxHelper(); ajaxHandler.addParams(apiParameters, 'POST'); - ajaxHandler.addParams({period: $('#report_period option:selected').val()}, 'GET'); + ajaxHandler.addParams({period: $('#report_period').find('option:selected').val()}, 'GET'); ajaxHandler.addParams({hour: $('#report_hour').val()}, 'GET'); ajaxHandler.redirectOnSuccess(); ajaxHandler.setLoadingElement(); diff --git a/plugins/PDFReports/templates/report_parameters.tpl b/plugins/PDFReports/templates/report_parameters.tpl index 9afe1c409c..00b88a20ad 100644 --- a/plugins/PDFReports/templates/report_parameters.tpl +++ b/plugins/PDFReports/templates/report_parameters.tpl @@ -3,7 +3,7 @@ function updateEvolutionGraphParameterVisibility() {ldelim} var evolutionGraphParameterInput = $('.report_evolution_graph'); var nonApplicableDisplayFormats = ['1', '4']; - $.inArray($('#display_format option:selected').val(), nonApplicableDisplayFormats) != -1 ? + $.inArray($('#display_format').find('option:selected').val(), nonApplicableDisplayFormats) != -1 ? evolutionGraphParameterInput.hide() : evolutionGraphParameterInput.show(); {rdelim } @@ -29,7 +29,7 @@ if (reportParameters == null) return; - $('#display_format option[value=' + reportParameters.displayFormat + ']').prop('selected', 'selected'); + $('#display_format').find('option[value=' + reportParameters.displayFormat + ']').prop('selected', 'selected'); updateEvolutionGraphParameterVisibility(); if (reportParameters.emailMe === true) @@ -54,7 +54,7 @@ var parameters = Object(); - parameters.displayFormat = $('#display_format option:selected').val(); + parameters.displayFormat = $('#display_format').find('option:selected').val(); parameters.emailMe = $('#report_email_me').prop('checked'); parameters.evolutionGraph = $('#report_evolution_graph').prop('checked'); diff --git a/plugins/PrivacyManager/templates/privacySettings.js b/plugins/PrivacyManager/templates/privacySettings.js index 75de9b8caa..d420118fdc 100644 --- a/plugins/PrivacyManager/templates/privacySettings.js +++ b/plugins/PrivacyManager/templates/privacySettings.js @@ -95,10 +95,10 @@ $(document).ready(function () { }); // make sure the DB size estimate is reloaded every time a delete logs/reports setting is changed - $('#formDeleteSettings input[type=text]').each(function () { + $('#formDeleteSettings').find('input[type=text]').each(function () { $(this).change(reloadDbStats); }); - $('#formDeleteSettings input[type=checkbox]').each(function () { + $('#formDeleteSettings').find('input[type=checkbox]').each(function () { $(this).click(reloadDbStats); }); @@ -111,7 +111,7 @@ $(document).ready(function () { // hide all confirmation texts, then show the correct one based on what // type of deletion is enabled. - $('#confirmDeleteSettings>h2').each(function () { + $('#confirmDeleteSettings').find('>h2').each(function () { $(this).hide(); }); @@ -145,7 +145,7 @@ $(document).ready(function () { // if any option has been modified, abort purging and instruct user to save first var modified = false; - $('#formDeleteSettings input').each(function () { + $('#formDeleteSettings').find('input').each(function () { if (this.type === 'checkbox' || this.type === 'radio') { modified |= this.defaultChecked !== this.checked; } else { diff --git a/plugins/SegmentEditor/templates/Segmentation.js b/plugins/SegmentEditor/templates/Segmentation.js index d18dc9ee47..c6bb72080e 100644 --- a/plugins/SegmentEditor/templates/Segmentation.js +++ b/plugins/SegmentEditor/templates/Segmentation.js @@ -840,7 +840,7 @@ Segmentation = (function($) { "name": segmentName, "definition": segmentStr, "enabledAllUsers": user, - "idSite": $('#visible_to_website option:selected').attr('value') + "idSite": $('#visible_to_website').find('option:selected').attr('value') }; // determine if save or update should be performed if(segmentId === ""){ diff --git a/plugins/SitesManager/templates/SitesManager.js b/plugins/SitesManager/templates/SitesManager.js index 4d32b283f3..2f3c777927 100644 --- a/plugins/SitesManager/templates/SitesManager.js +++ b/plugins/SitesManager/templates/SitesManager.js @@ -117,8 +117,8 @@ function SitesManager(_timezones, _currencies, _defaultTimezone, _defaultCurrenc } function sendGlobalSettingsAJAX() { - var timezone = $('#defaultTimezone option:selected').val(); - var currency = $('#defaultCurrency option:selected').val(); + var timezone = $('#defaultTimezone').find('option:selected').val(); + var currency = $('#defaultCurrency').find('option:selected').val(); var excludedIps = $('textarea#globalExcludedIps').val(); excludedIps = piwikHelper.getApiFormatTextarea(excludedIps); var excludedQueryParameters = $('textarea#globalExcludedQueryParameters').val(); @@ -199,7 +199,7 @@ function SitesManager(_timezones, _currencies, _defaultTimezone, _defaultCurrenc var nameToDelete = $(this).parent().parent().find('input#siteName').val() || $(this).parent().parent().find('td#siteName').html(); var idsiteToDelete = $(this).parent().parent().find('#idSite').html(); - $('#confirm h2').text(sprintf(_pk_translate('SitesManager_DeleteConfirm_js'), '"' + nameToDelete + '" (idSite = ' + idsiteToDelete + ')')); + $('#confirm').find('h2').text(sprintf(_pk_translate('SitesManager_DeleteConfirm_js'), '"' + nameToDelete + '" (idSite = ' + idsiteToDelete + ')')); piwikHelper.modalConfirm('#confirm', {yes: function () { sendDeleteSiteAJAX(idsiteToDelete); }}); @@ -213,7 +213,7 @@ function SitesManager(_timezones, _currencies, _defaultTimezone, _defaultCurrenc var idRow = $(this).attr('id'); if (alreadyEdited[idRow] == 1) return; if (siteBeingEdited) { - $('#alert h2').text(sprintf(_pk_translate('SitesManager_OnlyOneSiteAtTime_js'), '"' + $("<div/>").html(siteBeingEditedName).text() + '"')); + $('#alert').find('h2').text(sprintf(_pk_translate('SitesManager_OnlyOneSiteAtTime_js'), '"' + $("<div/>").html(siteBeingEditedName).text() + '"')); piwikHelper.modalConfirm('#alert', {}); return; } diff --git a/plugins/UserCountry/templates/admin.js b/plugins/UserCountry/templates/admin.js index 69857b7294..4b7e191076 100755 --- a/plugins/UserCountry/templates/admin.js +++ b/plugins/UserCountry/templates/admin.js @@ -177,7 +177,7 @@ $(document).ready(function () { // setup the auto-updater var ajaxRequest = new ajaxHelper(); ajaxRequest.addParams({ - period: $('#geoip-update-period-cell>input:checked').val() + period: $('#geoip-update-period-cell').find('>input:checked').val() }, 'get'); ajaxRequest.addParams({ module: 'UserCountry', diff --git a/plugins/UserCountryMap/js/realtime-map.js b/plugins/UserCountryMap/js/realtime-map.js index 431b749089..54d5cdfdc3 100644 --- a/plugins/UserCountryMap/js/realtime-map.js +++ b/plugins/UserCountryMap/js/realtime-map.js @@ -215,7 +215,7 @@ * that corresponds to a visit on the map */ function highlightVisit(r) { - $('#visitsLive li#' + r.idVisit + ' .datetime') + $('#visitsLive').find('li#' + r.idVisit + ' .datetime') .css('background', '#E4CD74'); } @@ -224,7 +224,7 @@ * the visit marker on the map */ function unhighlightVisit(r) { - $('#visitsLive li#' + r.idVisit + ' .datetime') + $('#visitsLive').find('li#' + r.idVisit + ' .datetime') .css({ background: '#E4E2D7' }); } diff --git a/plugins/UsersManager/templates/UsersManager.js b/plugins/UsersManager/templates/UsersManager.js index 0db663d7c2..c24cbf73e6 100644 --- a/plugins/UsersManager/templates/UsersManager.js +++ b/plugins/UsersManager/templates/UsersManager.js @@ -196,7 +196,7 @@ $(document).ready(function () { piwikHelper.hideAjaxError(); var idRow = $(this).attr('id'); var loginToDelete = $(this).parent().parent().find('#userLogin').html(); - $('#confirmUserRemove h2').text(sprintf(_pk_translate('UsersManager_DeleteConfirm_js'), '"' + loginToDelete + '"')); + $('#confirmUserRemove').find('h2').text(sprintf(_pk_translate('UsersManager_DeleteConfirm_js'), '"' + loginToDelete + '"')); piwikHelper.modalConfirm('#confirmUserRemove', {yes: function () { sendDeleteUserAJAX(loginToDelete); }}); } ); diff --git a/plugins/UsersManager/templates/userSettings.js b/plugins/UsersManager/templates/userSettings.js index 0bfdf3d8bb..5708ca7a72 100644 --- a/plugins/UsersManager/templates/userSettings.js +++ b/plugins/UsersManager/templates/userSettings.js @@ -23,7 +23,7 @@ function sendUserSettingsAJAX() { var passwordBis = $('#passwordBis').val(); var defaultReport = $('input[name=defaultReport]:checked').val(); if (defaultReport == 1) { - defaultReport = $('#defaultReportSiteSelector .custom_select_main_link').attr('siteid'); + defaultReport = $('#defaultReportSiteSelector').find('.custom_select_main_link').attr('siteid'); } var postParams = {}; postParams.alias = alias; @@ -52,7 +52,7 @@ function sendUserSettingsAJAX() { function sendAnonymousUserSettingsAJAX() { var anonymousDefaultReport = $('input[name=anonymousDefaultReport]:checked').val(); if (anonymousDefaultReport == 1) { - anonymousDefaultReport = $('#anonymousDefaultReportWebsite option:selected').val(); + anonymousDefaultReport = $('#anonymousDefaultReportWebsite').find('option:selected').val(); } var anonymousDefaultDate = $('input[name=anonymousDefaultDate]:checked').val(); @@ -81,7 +81,7 @@ $(document).ready(function () { } }); - $('#userSettingsTable input').keypress(function (e) { + $('#userSettingsTable').find('input').keypress(function (e) { var key = e.keyCode || e.which; if (key == 13) { $('#userSettingsSubmit').click(); -- GitLab