Skip to content

Commit

Permalink
#PS-1727 #time 1h #comment make sure we register to layoutReady only …
Browse files Browse the repository at this point in the history
…once
  • Loading branch information
amirch1 committed Sep 4, 2014
1 parent 5f7a88d commit 7b28ede
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions kWidget/onPagePlugins/omnitureOnPage/resources/omnitureOnPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ kWidget.addReadyCallback( function( playerId ){

// track waiting for scode propagation
_startWaitTime: null,

// flasg to make sure we setup monitor only once
layoutReadyCalled: false,

init: function( player ){
var _this = this;
this.kdp = player;
Expand All @@ -25,18 +27,21 @@ kWidget.addReadyCallback( function( playerId ){
this.kdp.kUnbind( '.' + this.instanceName );
// We bind to event
_this.bindPlayer();

// Check for on-page s-code that already exists
this.bind('layoutReady', function(){
_this.sCodeCheck(function(){
// process any queued events now that sCode is available:
_this.proccessMediaQueue();
_this.proccessNotificationQueue();
// once sCode is ready setup the monitor
_this.setupMonitor();
});
// bind for events as soon as layout is Ready ( proxy events while player checks for sCode )
_this.bindCustomEvents();
if ( !_this.layoutReadyCalled ){
_this.sCodeCheck(function(){
// process any queued events now that sCode is available:
_this.proccessMediaQueue();
_this.proccessNotificationQueue();
// once sCode is ready setup the monitor
_this.setupMonitor();
});
// bind for events as soon as layout is Ready ( proxy events while player checks for sCode )
_this.bindCustomEvents();
_this.layoutReadyCalled = true;
}
});
},
cacheEntryMetadata: function(){
Expand Down Expand Up @@ -179,7 +184,7 @@ kWidget.addReadyCallback( function( playerId ){
*/
setupMonitor: function() {
// Exit if sCode not loaded
if( !this.sCodeLoaded ) {
if( !this.sCodeLoaded) {
return ;
}

Expand Down

0 comments on commit 7b28ede

Please sign in to comment.