@ -312,7 +312,9 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL
options . callbacks = {
options . callbacks = {
onDataUpdated : function ( ) {
onDataUpdated : function ( ) {
widgetTypeInstance . onDataUpdated ( ) ;
if ( displayWidgetInstance ( ) ) {
widgetTypeInstance . onDataUpdated ( ) ;
}
} ,
} ,
onDataUpdateError : function ( subscription , e ) {
onDataUpdateError : function ( subscription , e ) {
handleWidgetException ( e ) ;
handleWidgetException ( e ) ;
@ -849,7 +851,11 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL
if ( ! widgetContext . inited && isReady ( ) ) {
if ( ! widgetContext . inited && isReady ( ) ) {
widgetContext . inited = true ;
widgetContext . inited = true ;
try {
try {
widgetTypeInstance . onInit ( ) ;
if ( displayWidgetInstance ( ) ) {
widgetTypeInstance . onInit ( ) ;
} else {
$scope . loadingData = false ;
}
} catch ( e ) {
} catch ( e ) {
handleWidgetException ( e ) ;
handleWidgetException ( e ) ;
}
}
@ -886,7 +892,9 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL
}
}
cafs [ 'resize' ] = tbRaf ( function ( ) {
cafs [ 'resize' ] = tbRaf ( function ( ) {
try {
try {
widgetTypeInstance . onResize ( ) ;
if ( displayWidgetInstance ( ) ) {
widgetTypeInstance . onResize ( ) ;
}
} catch ( e ) {
} catch ( e ) {
handleWidgetException ( e ) ;
handleWidgetException ( e ) ;
}
}
@ -916,7 +924,9 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL
}
}
cafs [ 'editMode' ] = tbRaf ( function ( ) {
cafs [ 'editMode' ] = tbRaf ( function ( ) {
try {
try {
widgetTypeInstance . onEditModeChanged ( ) ;
if ( displayWidgetInstance ( ) ) {
widgetTypeInstance . onEditModeChanged ( ) ;
}
} catch ( e ) {
} catch ( e ) {
handleWidgetException ( e ) ;
handleWidgetException ( e ) ;
}
}
@ -935,7 +945,9 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL
}
}
cafs [ 'mobileMode' ] = tbRaf ( function ( ) {
cafs [ 'mobileMode' ] = tbRaf ( function ( ) {
try {
try {
widgetTypeInstance . onMobileModeChanged ( ) ;
if ( displayWidgetInstance ( ) ) {
widgetTypeInstance . onMobileModeChanged ( ) ;
}
} catch ( e ) {
} catch ( e ) {
handleWidgetException ( e ) ;
handleWidgetException ( e ) ;
}
}
@ -968,7 +980,21 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL
}
}
}
}
function displayWidgetInstance ( ) {
if ( widget . type !== types . widgetType . static . value ) {
for ( var id in widgetContext . subscriptions ) {
if ( widgetContext . subscriptions [ id ] . isDataResolved ( ) ) {
return true ;
}
}
return false ;
} else {
return true ;
}
}
function onDestroy ( ) {
function onDestroy ( ) {
var shouldDestroyWidgetInstance = displayWidgetInstance ( ) ;
for ( var id in widgetContext . subscriptions ) {
for ( var id in widgetContext . subscriptions ) {
var subscription = widgetContext . subscriptions [ id ] ;
var subscription = widgetContext . subscriptions [ id ] ;
subscription . destroy ( ) ;
subscription . destroy ( ) ;
@ -984,7 +1010,9 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL
}
}
}
}
try {
try {
widgetTypeInstance . onDestroy ( ) ;
if ( shouldDestroyWidgetInstance ) {
widgetTypeInstance . onDestroy ( ) ;
}
} catch ( e ) {
} catch ( e ) {
handleWidgetException ( e ) ;
handleWidgetException ( e ) ;
}
}