   angular.module('monsart').directive('maPreviewScreen', [ '$rootScope' ,'$window' , '$timeout' ,function($rootScope,$window, $timeout){
            return {
                restrict: 'A',
                
                link: function(scope, elem){
                    var $elem = angular.element(elem);
                    $elem.css({'display' : 'none'});
                    $timeout(function(){
                        $elem.niceScroll({
                            
                            cursoropacitymin: 0.5,
                            background : '#31333e',
                            cursorcolor: "#31333e",
                            cursorwidth: "4px"
                        });
                    },0, false);
                    
                   $timeout(function(){
                        $elem.css({'display' : 'block'});
                        scope.$apply(function(){
                            scope.loading = false;
                        });
                        
                    }, 2000);
                    $window.onresize = function () {
                        
                        scope.$broadcast('screen.changed', $elem.width());
                    };
                    /*scope.on('$destroy', function(){
                        $window.onresize = null;
                    });*/
                    
                }
            }
        }
    ]);