From e77749ca5db66ef1d28a9150d0296ea403174843 Mon Sep 17 00:00:00 2001 From: sgiehl <stefan@piwik.org> Date: Wed, 14 Aug 2013 14:21:53 +0200 Subject: [PATCH] small jquery selector improvements --- plugins/CoreHome/javascripts/dataTable.js | 10 ++++++-- plugins/CoreHome/javascripts/menu.js | 3 +++ .../SegmentEditor/javascripts/Segmentation.js | 24 +++++++++---------- .../UserCountry/javascripts/userCountry.js | 2 +- plugins/Widgetize/javascripts/widgetize.js | 3 +++ 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/plugins/CoreHome/javascripts/dataTable.js b/plugins/CoreHome/javascripts/dataTable.js index 8c229be1f3..05fa11b55b 100644 --- a/plugins/CoreHome/javascripts/dataTable.js +++ b/plugins/CoreHome/javascripts/dataTable.js @@ -9,7 +9,10 @@ // DataTable //----------------------------------------------------------------------------- -//DataTable constructor +/** + * DataTable + * @constructor + */ function dataTable() { this.param = {}; } @@ -1570,7 +1573,10 @@ dataTable.prototype = actionDataTable.prototype = new dataTable; actionDataTable.prototype.constructor = actionDataTable; -//actionDataTable constructor +/** + * actionDataTable + * @constructor + */ function actionDataTable() { dataTable.call(this); this.parentAttributeParent = ''; diff --git a/plugins/CoreHome/javascripts/menu.js b/plugins/CoreHome/javascripts/menu.js index d83ddb718f..5b6a8d9004 100644 --- a/plugins/CoreHome/javascripts/menu.js +++ b/plugins/CoreHome/javascripts/menu.js @@ -5,6 +5,9 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +/** + * @constructor + */ function menu() { this.param = {}; } diff --git a/plugins/SegmentEditor/javascripts/Segmentation.js b/plugins/SegmentEditor/javascripts/Segmentation.js index 93ec161bb7..d15d082d74 100644 --- a/plugins/SegmentEditor/javascripts/Segmentation.js +++ b/plugins/SegmentEditor/javascripts/Segmentation.js @@ -100,21 +100,21 @@ Segmentation = (function($) { var getAndDiv = function(){ if(typeof andDiv === "undefined"){ - var andDiv = $("#SegmentEditor > div.segment-and").clone(); + var andDiv = $("#SegmentEditor").find("> div.segment-and").clone(); } return andDiv.clone(); }; var getOrDiv = function(){ if(typeof orDiv === "undefined"){ - var orDiv = $("#SegmentEditor > div.segment-or").clone(); + var orDiv = $("#SegmentEditor").find("> div.segment-or").clone(); } return orDiv.clone(); }; var getMockedInputSet = function(){ if(typeof mockedInputSet === "undefined"){ - var mockedInputSet = $("#SegmentEditor div.segment-row-inputs").clone(); + var mockedInputSet = $("#SegmentEditor").find("div.segment-row-inputs").clone(); } return mockedInputSet.clone(); }; @@ -129,7 +129,7 @@ Segmentation = (function($) { var getMockedFormRow = function(){ if(typeof mockedFormRow === "undefined") { - var mockedFormRow = $("#SegmentEditor div.segment-rows").clone(); + var mockedFormRow = $("#SegmentEditor").find("div.segment-rows").clone(); $(mockedFormRow).find(".segment-row").append(getMockedInputSet()).after(getAddOrBlockButtonHtml).after(getOrDiv()); } return mockedFormRow.clone(); @@ -137,7 +137,7 @@ Segmentation = (function($) { var getInitialStateRowsHtml = function(){ if(typeof initialStateRows === "undefined"){ - var content = $("#SegmentEditor div.initial-state-rows").html(); + var content = $("#SegmentEditor").find("div.initial-state-rows").html(); var initialStateRows = $(content).clone(); } return initialStateRows; @@ -199,7 +199,7 @@ Segmentation = (function($) { }; var getListHtml = function() { - var html = $("#SegmentEditor > .listHtml").clone(); + var html = $("#SegmentEditor").find("> .listHtml").clone(); var segment, injClass; var listHtml = '<li data-idsegment="" ' + @@ -239,7 +239,7 @@ Segmentation = (function($) { }; var getFormHtml = function() { - var html = $("#SegmentEditor > .segment-element").clone(); + var html = $("#SegmentEditor").find("> .segment-element").clone(); // set left margin to center form //$("body").append(html); var segmentsDropdown = $(html).find("#available_segments_select"); @@ -485,7 +485,7 @@ Segmentation = (function($) { { if(typeof addNewBlockButton === "undefined") { - var addNewBlockButton = $("#SegmentEditor > div.segment-add-row").clone(); + var addNewBlockButton = $("#SegmentEditor").find("> div.segment-add-row").clone(); } return addNewBlockButton.clone(); @@ -494,7 +494,7 @@ Segmentation = (function($) { var getAddOrBlockButtonHtml = function(){ if(typeof addOrBlockButton === "undefined") { - var addOrBlockButton = $("#SegmentEditor div.segment-add-or").clone(); + var addOrBlockButton = $("#SegmentEditor").find("div.segment-add-or").clone(); } return addOrBlockButton.clone(); }; @@ -959,9 +959,9 @@ Segmentation = (function($) { function toggleLoadingMessage(segmentIsSet) { if (segmentIsSet) { - $('#ajaxLoading .loadingSegment').show(); + $('#ajaxLoading').find('.loadingSegment').show(); } else { - $('#ajaxLoading .loadingSegment').hide(); + $('#ajaxLoading').find('.loadingSegment').hide(); } } @@ -1001,7 +1001,7 @@ $(document).ready( function(){ } var changeSegment = function(segmentDefinition){ - $('#segmentEditorPanel a.close').click(); + $('#segmentEditorPanel').find('a.close').click(); segmentDefinition = cleanupSegmentDefinition(segmentDefinition); segmentDefinition = encodeURIComponent(segmentDefinition); return broadcast.propagateNewPage('segment=' + segmentDefinition, true); diff --git a/plugins/UserCountry/javascripts/userCountry.js b/plugins/UserCountry/javascripts/userCountry.js index bd2c159de0..572dd51aa6 100755 --- a/plugins/UserCountry/javascripts/userCountry.js +++ b/plugins/UserCountry/javascripts/userCountry.js @@ -175,7 +175,7 @@ $(document).ready(function () { // setup the auto-updater var ajaxRequest = new ajaxHelper(); - var periodSelected = $('#geoip-update-period-cell>input:checked').val(); + var periodSelected = $('#geoip-update-period-cell').find('>input:checked').val(); ajaxRequest.addParams({ period: periodSelected }, 'get'); diff --git a/plugins/Widgetize/javascripts/widgetize.js b/plugins/Widgetize/javascripts/widgetize.js index a50dd34630..a630380e5f 100644 --- a/plugins/Widgetize/javascripts/widgetize.js +++ b/plugins/Widgetize/javascripts/widgetize.js @@ -5,6 +5,9 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +/** + * @constructor + */ function widgetize() { var self = this; -- GitLab