Skip to content

Commit

Permalink
Refs #4116, move initElements code to utility function in UIControl.
Browse files Browse the repository at this point in the history
  • Loading branch information
Benaka Moorthi committed Sep 12, 2013
1 parent ac285a1 commit 9479953
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
9 changes: 9 additions & 0 deletions plugins/CoreHome/javascripts/uiControl.js
Expand Up @@ -56,6 +56,15 @@
}
};

UIControl.initElements = function (klass, selector) {
$(selector).each(function () {
if (!$(this).attr('data-inited')) {
var control = new klass(this);
$(this).attr('data-inited', 1);
}
});
};

UIControl.prototype = {

/**
Expand Down
3 changes: 2 additions & 1 deletion plugins/Live/API.php
Expand Up @@ -153,7 +153,8 @@ public function getLastVisitsForVisitor($visitorId, $idSite, $filter_limit = 10,
* @param bool $doNotFetchActions
* @return DataTable
*/
public function getLastVisitsDetails($idSite, $period, $date, $segment = false, $filter_limit = false, $filter_offset = false, $minTimestamp = false, $flat = false, $doNotFetchActions = false)
public function getLastVisitsDetails($idSite, $period = false, $date = false, $segment = false, $filter_limit = false,
$filter_offset = false, $minTimestamp = false, $flat = false, $doNotFetchActions = false)
{
if (empty($filter_limit)) {
$filter_limit = 10;
Expand Down
9 changes: 1 addition & 8 deletions plugins/Live/javascripts/visitorProfile.js
Expand Up @@ -31,14 +31,7 @@
* if the element has not already been initialized.
*/
VisitorProfileControl.initElements = function () {
$('.visitor-profile').each(function () {
if (!$(this).attr('data-inited')) {
var control = new VisitorProfileControl(this);

$(this).data('uiControlObject', control);
$(this).attr('data-inited', 1);
}
});
UIControl.initElements(this, '.visitor-profile');
};

/**
Expand Down
9 changes: 1 addition & 8 deletions plugins/UserCountryMap/javascripts/realtime-map.js
Expand Up @@ -19,14 +19,7 @@
};

RealtimeMap.initElements = function () {
$('.RealTimeMap').each(function () {
if (!$(this).attr('data-inited')) {
var control = new RealtimeMap(this);

$(this).data('uiControlObject', control);
$(this).attr('data-inited', 1);
}
});
UIControl.initElements(this, '.RealTimeMap');
};

$.extend(RealtimeMap.prototype, UIControl.prototype, {
Expand Down
2 changes: 1 addition & 1 deletion plugins/UserCountryMap/templates/realtimeMap.twig
Expand Up @@ -21,4 +21,4 @@
</div>

</div>
<script type="text/javascript">UserCountryMap.RealtimeMap.initElements();</script>
<script type="text/javascript">UserCountryMap.RealtimeMap.initElements();</script>

0 comments on commit 9479953

Please sign in to comment.